Repository navigation
Description
(converting a linear issue created+written by @shykes to GH since it relates to other public GH issues)
Context
The Dagger CLI has powerful "verbs" for executing a pipeline of Zenith functions, then doing something with the result. So far the following verbs exist:
dagger call: generic verb for executing a pipeline, streaming logs, and reporting errorsdagger download: save the result of the pipeline to the local filesystem. Supportsstring,File,Directorydagger up: run the result as a servicedagger shell: execute the result as a container, with an interactive terminal attached
Verbs work by detecting the type of the pipeline result, and deciding what to do based on the type.
Problem
Dagger CLI verbs don't support custom types defined by a module. This forces modules to add unnecessary complexity.
For example, in my docker-compose module:
- To bring up a service, I have to type
dagger shell -m github.com/shykes/daggerverse/docker-clompose example service --name db up- Note the last up. This converts the custom ComposeService to the core Service, which is required for dagger up to work
- This adds verbosity, and feels redundant
- Instead I would like this work: dagger shell -m github.com/shykes/daggerverse/docker-compose example service --name db
- Note the absence of the redundant up at the end
Solution
Implement duck-typing for CLI verbs. Instead of checking for specific core types, check for the required capabilities of those core types: certain required functions and their signatures.
- Core types will continue to work as before, since they match the requirements
- Custom types have a chance be picked up by the verbs, if they implement the right interface
Example:dagger up
My guess is that dagger up requires pipeline results to implement the following interface (graphql notation; from memory, may be not exactly accurate):
start: Bool!ports: [Port!]hostname: String!endpoint
Knowing the interface, I could implement it in my DockerComposeService (probably by passing through to the underlying core service, but not necessarily!).
Related Issues:
- Modules: Support for interfaces #6213 (adds support for duck typing generally across all core+module APIs)
- Simplify CLI commands #6229
Activity
helderco commentedon Jul 5, 2024
Closing because we moved away from this design, to conciliate those verbs in
dagger call.