Skip to content

0.3 CLI design #3347

Closed
Closed

Description

@shykes

Overview

As part of the 0.3 engine release (codename cloak), the dagger CLI needs a redesign to replace the cloak binary used during development.

Task list

This issue is considered complete when consensus is reached on the 0.3 CLI design, and documented in a way that allows unambiguous implementation.

  • Kickstart proposal
  • Bikeshedding in comments
  • Rough consensus
  • Polish
  • Start implementation

Function

The Dagger CLI is a client tool for interacting with the Dagger engine. It can be called from the terminal, a shell script, or a CI runner.

It has (or will have) the following features:

  1. User-friendly GraphQL client, comparable in features to gqurl
  2. Graphql proxy for compatibility with native graphql tools (graphiql)
  3. Auto-install the engine for zero-conf onboarding
  4. Interactive tty attach (for live pipeline debugging)
  5. Login to Dagger Cloud, and other interactions with Dagger Cloud
  6. TBD: management of a dagger project, its pipelines and extensions (possibly by editing one or more config files)
  7. TBD: support for multiple namespaces and engines (possibly by editing one or more config files)
  8. TBD: other development tasks common to all Dagger SDKs

Architecture

graph LR

term["Terminal"]
script["Shell script"]
ci["CI runner"]
cli(("Dagger CLI"))

go["Go SDK"]
python["Pyton SDK"]
nodejs["NodeJS SDK"]

term & script & ci --> cli

engine["Dagger Engine"]
runtime["OCI container runtime"]
cli & go & python & nodejs -..-> engine --> runtime
Loading

Sub-commands

GraphQL client

Subcommand name: query. See options below

Usage:

$ dagger query --help
Open a dagger engine session, and send graphql queries to it

Usage:
  Send API queries to a dagger engine

When no document file, read query from standard input.

Usage:
  dagger query [flags] [operation]

Flags:
      --debug         enable buildkit logs
      --doc string    document query file
  -h, --help          help for query
      --var strings   query variable

Examples:

dagger query <<EOF
{
  container {
    from(address:"hello-world") {
      exec(args:["/hello"]) {
        stdout {
          contents
        }
      }
    }
  }
}
EOF

Global Flags:
      --workdir string   The host workdir loaded into dagger (default ".")

API router Listen command

Subcommand name: listen. See options below

Open a dagger engine session, and forward graphql queries to it.

Usage:
  dagger listen [flags]

Flags:
      --disable-host-read-write   disable host read/write access
  -h, --help                      help for listen
      --listen string             Listen on network address ADDR (default ":8080")

Global Flags:
      --workdir string   The host workdir loaded into dagger (default ".")

Exec wrapper command

Subcommand name: exec. See options below

// In progress

Interactive attach

TBD

Login to Dagger Cloud

TBD

$ dagger login
$ dagger logout

Open questions

  • Should the dagger cmd live in the dagger/dagger repository? @shykes had some observations that it feels strange that the dagger CLI depends on the go SDK from the engine repository. In his head, it makes more sense if the CLI lives in the go-sdk repo instead of the engine one. @aluzzardi he told me he'll bring this to you for discussion.

Activity

  1. added this to the 0.3.0-alpha.1 milestone on Oct 12, 2022
  2. mircubed commented on Oct 13, 2022

    @mircubed
  3. self-assigned this
    on Oct 13, 2022
  4. shykes commented on Oct 13, 2022

    @shykes
    Author
  5. sipsma commented on Oct 13, 2022

    @sipsma
  6. shykes commented on Oct 13, 2022

    @shykes
    Author
  7. shykes commented on Oct 13, 2022

    @shykes
    Author
  8. gerhard commented on Oct 13, 2022

    @gerhard
  9. gerhard commented on Oct 13, 2022

    @gerhard
  10. shykes commented on Oct 13, 2022

    @shykes
    Author
  11. shykes commented on Oct 13, 2022

    @shykes
    Author
  12. gerhard commented on Oct 13, 2022

    @gerhard
  13. gerhard commented on Oct 13, 2022

    @gerhard
  14. shykes commented on Oct 13, 2022

    @shykes
    Author
  15. 11 remaining items

  16. shykes commented on Oct 14, 2022

    @shykes
    Author
  17. shykes commented on Oct 14, 2022

    @shykes
    Author
  18. shykes commented on Oct 14, 2022

    @shykes
    Author
  19. shykes commented on Oct 14, 2022

    @shykes
    Author
  20. shykes commented on Oct 14, 2022

    @shykes
    Author
  21. gerhard commented on Oct 17, 2022

    @gerhard
  22. added
    area/cli
    and removed on Nov 7, 2022
  23. modified the milestones: 0.3.0-alpha.1, on Nov 7, 2022
  24. marcosnils commented on Nov 8, 2022

    @marcosnils
    Contributor

    Additional items to be adressed:

    • How do we plan to handle CLI releases? cc @gerhard

    My initial thought is that CLI SDLC should be able to evolve independently from the engine version while keeping API compatibility with the major version of the Engine. By this I'm suggesting that following the semver convention, the MAJOR version of the engine and the CLI should be kept in sync while the MINOR and PATCH versions could evolve independently.

    Following Go SDK's approach should we use a separate repo and mirror the CLI code to handle releases? Particularly since using github releases in a single repo for both the engine and the CLI might become problematic.


    @shykes now addressing your thoughts:

    It has (or will have) the following features:

    • Should the primary graphql client feature be rooted at the top-level command? Or should it be moved into a sub-command for easier coexistence with other features? And if the latter: what should the sub-command be called? What would the other sub-commands be?

    Only thing that comes to my mind right now is to give the ability to generate shell auto-completion based on the graphQL schema. Similar to what gql (https://github.com/graphql-editor/gql) does. Apart from that I don't why I couldn't be a top-level command.

  25. gerhard commented on Nov 9, 2022

    @gerhard
    Contributor

    @marcosnils I would release both the engine & the CLI in lock-step for now (same version for both). Once both hit 1.0 we should revise. Until then, I foresee unnecessary cycles spent on compatibility discussions & breaking changes. FWIW, this is the same approach that Concourse used, and it worked well from my end-user perspective cc @vito.

    Today we release everything from the same repository (this one). The only exception is the Go SDK since the repo is the package. I propose that we continue with this approach & continue releasing from this repository, otherwise our automation will spread and we will be forced to open multiple PRs, across multiple repositories, for the same changes.

    The other reason for keeping a single repo is that we publish to various destinations: PyPI, NPM, container registries, etc. The tags are there for our convenience - single source of truth - but most of our users should come via their package source, and not via this repository. We get to keep all issues / PRs / discussions in the same place, and reap the benefits of everything in a single place (including docs!).

  26. marcosnils commented on Nov 9, 2022

    @marcosnils
    Contributor

    we just had a quick sync between @aluzzardi and @gerhard and agreed on keeping the CLI and the engine withing the same bundle and release process for the moment since it simplifies the implementation and given the fast release cadence that we will have in the upcoming months, dealing with separate distributions doesn't make sense now.

  27. shykes commented on Nov 9, 2022

    @shykes
    ContributorAuthor

    we just had a quick sync between @aluzzardi and @gerhard and agreed on keeping the CLI and the engine withing the same bundle and release process for the moment since it simplifies the implementation and given the fast release cadence that we will have in the upcoming months, dealing with separate distributions doesn't make sense now.

    Makes sense. From an end-user perspective, it makes sense to make the CLI the "primary". So if you see a release called "0.4.2" on github and look at its contents, the primary thing you should see is the Dagger CLI. Since SDKs are primarily released elsewhere, and the engine can't be used on its own today (and when it is, it will be as a separate OCI image)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/cli

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions