Skip to content

Mock up Zenith CLI - #5420

Closed
vito wants to merge 4 commits into
dagger:mainfrom
vito:zenith-cli
Closed

vito wants to merge 4 commits into
dagger:mainfrom
vito:zenith-cli

Conversation

@vito

@vito vito commented Jul 6, 2023

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Alex Suraci <[email protected]>
Comment thread docs/CLI.md
* `dagger use go` - universe environment
* `dagger use ./go/` - local environment
* `dagger use github.com/vito/progrock@main` - git environment
* `dagger use github.com/vito/progrock/ci@main` - git environment, `./ci` subdirectory

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm being sneaky here with the subpath, since it looks cleaner than ?dir=foo.

I figured we can match go get here, but it turns out that uses a Go-specific <meta> tag these days to figure out the URL. We could respect that, I guess, but it feels like a strange coupling to Go.

Safest heuristic would probably be to do what Go did before 1.4, where it assumes user/repo. (Assuming ChatGPT isn't hallucinating.) Seems like that would cover the 99% case, since even most non-GitHub repos follow that scheme. Would make sense to have some kind of fallback though, like maybe supporting an explicit ?dir= anyway.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would break very easily in GitLab where you can have groups within groups until you reach your repo.

Comment thread docs/CLI.md Outdated
* `dagger test` - alternative
* `dagger test engine`
* `dagger test engine -- -run Services`
* build artifacts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all artifacts are the result of a build (similar to: "not all checks are tests").

@vito vito Jul 11, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree in principle. Do you have an example offhand so I can include it in the doc? I think "build" is probably the most guessable command for the most common case, even if it's overly specific. We could go for dagger export or something, but I don't think a first-time user would guess that. (edit: by "first-time user" I mean "I just cloned this random repo and this is my first time learning about Dagger.")

What do you think of having aliases for discoverability and ergonomics? I could see myself using build when I'm building something even knowing export is the technically correct general name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don’t have any better verb to propose..

Examples of possible artifacts that are produced without building:

  • AI model
  • binary or docker image (if pulling them from a registry)
  • signed source archive
  • minified / formatted / preprocessed source code
  • dataset
  • graphical assets (textures?)

My suggestion would be to not have a verb, and emphasize the nouns instead: dagger artifacts [OPTIONS], dagger checks [OPTIONS]… dagger artifact get ID [OPTIONS]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t mind the idea of aliases for ergonomics at all, by the way.

Comment thread docs/CLI.md
* list available artifacts
* `dagger artifacts`
* extend your environment with another environment
* `dagger use go` - universe environment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use evokes USE in SQL, and similar meaning in other tools. When I see "use" I think "ah this is is about setting a default ".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interested in exploring other options, but I was thinking more along the lines of Rust/Perl/PHP/a few other languages where use is used for loading modules/packages.

I've used it in SQL too, but always felt like that one was the oddball. 😁

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see it from the point of view of the env developer (top hat). But how do we explain it to the env end-user (robin hood hat)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of it from the end user's perspective. They would run dagger use go to bootstrap their Go project, so without touching code they could do something like this:

$ dagger use go
$ dagger test

The default behavior is to merge it into the current environment, which may be initially empty/not exist. There could maybe be an optional namespace argument, which I imagine 🎩 would make use of.

Having said that, there are important details missing here:

  • Where do I specify the base image that provides the go CLI? (Above assumes some sort of default I guess.)
  • How do I go from this to modifying my local environment so that dagger test runs with gotestsum instead? (Assuming the go environment provides it.)
  • If I use an environment but give it a namespace, how do I invoke its entrypoints?
  • Do "merged" environments also merge entrypoints? (Above assumes yes.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. Wouldn't this clash with the concept of environment code and workdir being cleanly separated? That separation implies that a) robin-hood-hat choosing which environment to load in their workdir, and b) top-hat modifying their environment code by adding other environments as extensions, would work very differently since they involve different directories. For example in a), there would be no dagger.json to modify.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, here's where I used to maintain my dev environment (regardless of project): https://gist.github.com/shykes/7bf0704be14a0a9288d7dfe98617c208

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - so I could maintain a single github.com/vito/vito-env and use it for all of my personal projects like Progrock, Bass, and Booklit.

That would help with the too-many-repos problem, but it doesn't fix the fundamental compatibility issue, and it seems like it makes it more likely to come up. Let's say I'm working on Progrock a lot and along the way I've made a ton of improvements and refactors to my environment code, and those changes break Bass and Booklit's usage. Ideally the two don't break on main because they're pinned to a particular version of the environment, but I would still have to deal with that breakage when I bump the environment dependency.

The major benefit of sharing an environment is that I don't have to maintain similar code across all my projects, but I might prefer that pain if there's not much code to begin with. It feels a whole lot like judging when to refactor. Sometimes a bit of duplicate code is better than DRYing everything up because it keeps all the doors open in the future and keeps other things decoupled.

@shykes shykes Jul 11, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be a potential best practice that says something like this:

  • If it defines app-specific dependencies, don't encode it in the environment: use your app's platform-specific package managers instead: package.json, requirements.txt, nix-flakes-something-something, Dockerfile...
  • If it orchestrates how and when to install dependencies, encode it in the environment

In other words, we could use the Dagger/not-dagger boundary to expose a clean app/platform boundary.

So you could still hardcode your app's dependencies in the environment, but it would be considered an anti-pattern. Similarly, you shouldn't encode your app's test suite in the environment - but you should encode the choice of test tooling, etc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a guy wearing the ops hat in a web agency, where you have several projects that share the same framework and deployment strategy, I had it kind of split. Meaning, a lot of duplication in each project for the dev environment (for team members), but a separate repo with config reuse just for deploying into production (privileged). I looked to dagger to help bridge this gap.

Now lets say I have 3 solo projects, each using different languages I'm not fully sure if I want to manage dagger in a separate repo. I wouldn't create a separate repo for each project, just a single one for all, but like @vito says, when I commit to get something done in a project, I prefer to deal with the code and dagger environment in a single repo and there's not much benefit to put in a separate repo if there's no reusability needs.

In addition to that, I want to be able to run from working changes, not necessarily a committed change in a repo, to avoid the "fix deployment" kind of commits.

Having said that, I do think it's powerful to easily support both models. Let's say I have several Django projects.

First, I’d create a general “django” environment with all sorts of conventions. How would I test project “caloura”?

~/projs/caloura$ dagger --env github.com/helderco/ci/django test

To avoid repeating the --env in commands, I can add the static dagger config to this project:

~/projs/caloura$ dagger use github.com/helderco/ci/django
~/projs/caloura$ dagger test

But doing it outside, could also be possible (e.g., repo of project specific environments):

~/projs/infra/caloura$ dagger use github.com/helderco/ci/django
~/projs/infra/caloura$ # "root": "github.com/helderco/caloura"
~/projs/infra/caloura$ dagger test

And to run against working changes:

~/projs/infra/caloura$ dagger --root ~/proj/caloura test

So basically the static file can be a way to set defaults for cli arguments that can be overridden by specifying directly. A bit like a compose.yml file to docker run. As defaults go, the shortest command is to make the project directory the working dir (without a static file in the project).

The changes to my project above are independent from the dagger environment, but that’s not always the case. I’ve always needed to have some project specific configurations. But that could perhaps be encoded either in the project or the separate “infra” repo in a way that the environment code can read it and handle appropriately.

Another issue is that over time, these conventions (e.g., ci/django environment) change, but pinning versions in a dagger.lock prevents breakage.

Note: I wrote this earlier today but now realized I didn’t submit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think the idea of defaulting to external repo but making it easy to define a defaultContext that points to your local repo is a nice+simple way of supporting both models seamlessly.

Yeah, the way I'm thinking about it makes it seamless to support both models.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions Bot closed this Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants