Skip to content

Commit

Permalink
replace shell command with chainable core api (#6390)
Browse files Browse the repository at this point in the history
This is one part of our efforts to consolidate dagger CLI commands. It
removes `dagger shell` in favor of using a `shell` api chained from the
core `Container` type.

For example, previously you'd do:
`dagger shell my-ctr`

Now you do:
`dagger call my-ctr shell`

This required some adjustments in the core API:
1. `Container` has a new field `withDefaultShell(args: [String!])` that
   can be used to configure the command to use for opening a shell with
   the container
1. `shellEndpoint: String!` on `Container` is replaced with
   `shell(args: [String!]) Terminal!`.
   * If `args` are specified, they override the command to run in the
     container's shell
   * Otherwise, this defaults to the command specified via
     `withDefaultShell`
   * As a fallback, `sh` will be executed

---

Implementation details:

The new `Terminal` type currently only has a field for the existing
websocket endpoint, so same basic idea as before in terms of how its
implemented. However, because its an object now we have more leeway to
easily adjust it in the future if more fields are desired.

This felt like the best solution possible in the short term while keeping
options open in the long-term.

`args` is optional and allows specifying the exact command to run in the
interactive container. If not set, it first defaults to the entrypoint of
the container and falls back to `sh` if those aren't set.

Signed-off-by: Erik Sipsma <erik@dagger.io>
  • Loading branch information
sipsma authored Jan 23, 2024
1 parent e69d3b5 commit 311f78a
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 24 deletions.
6 changes: 6 additions & 0 deletions dag/dag.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 117 additions & 24 deletions dagger.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 311f78a

Please sign in to comment.