Repository navigation
dagger.json - #3281
dagger.json#3281
Conversation
👷 Deploy request for cloak-docs pending review.Visit the deploys page to approve it
|
|
/cc @jpadams @kpenfound This is the WIP cloak.yaml --> dagger.json PR.
|
This comment was marked as duplicate.
This comment was marked as duplicate.
|
Overall looks good. Open questions on format, CLI, and other nitpickery: Format: "netlify": {
"location": "git",
"params": {
"remote": "https://github.com/sipsma/foo",
"ref": "bar",
"path": "path/to/netlify/dagger.json"
}
}Brainstorming here, but how would we feel like encoding this as a string and "restructuring" later rather than storing the structure? Example from package.json https://docs.npmjs.com/cli/v8/configuring-npm/package-json#dependencies {
"name": "baz",
"dependencies": {
"bar": "file:../foo/bar"
}
}They support git URLs (with Similar to what Same feedback about the CLI: rather than === If remaining with the current structured approach, one nitpick === Rather than a type Extension struct {
Git *GitParams `json:"git,omitempty"`
Local *LocalParams `json:"local,omitempty"`
}That way this: {
"netlify": {
"location": "git",
"params": {
"remote": "https://github.com/sipsma/foo",
"ref": "bar",
"path": "path/to/netlify/dagger.json"
}
}
}could be written as: {
"netlify": {
"git": {
"remote": "https://github.com/sipsma/foo",
"ref": "bar",
"path": "path/to/netlify/dagger.json"
}
}
}(yeah the Go code would less nice since we'd need to switch over all the pointers and check which is not |
|
@aluzzardi I’d say if it’s good enough for package.json, it’s good enough for us :) (for the parts that are actually semantically equivalent in both files of course) |
I think we should definitely support that for the CLI interface (independently came up in this comment) but what's the advantage of doing that in the json file? The json config is meant to be human readable but not optimized for human writing (CLI should be main interface), which is where our approach deviates from package.json. Having structured data in a string in json seems more complicated than just using the structure of json directly. It also makes it more complicated to parse information out (have deser json and then deser strings inside it). But again, all for supporting that on the CLI interface level. I do think the |
ba7bf09 to
10ddc51
Compare
|
@aluzzardi know there's many other priorities and this one is now lower, but updated from your comments:
Also, I ended up including a fix to make dagger.json optional here since otherwise there's tons of useless configs all over. So if you have a spare min to look again, appreciate it. If it's feasible to merge this before I go on PTO next week that would be ideal since otherwise it's going to go stale. |
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Related: #3016
Follow-ups
TODO
{"local": "path/to/local"}is weird, made sense in yaml but not json, worth a quick re-assessmentFormat
Example w/ an SDK
{ "name": "myproject", "extensions": { "alpine": { "local": { "path": "examples/alpine/dagger.json" } }, "netlify": { "git": { "remote": "https://github.com/sipsma/foo", "ref": "bar", "path": "path/to/netlify/dagger.json" } } }, "sdk": "go" }One important part of the format is that
extensionsis keyed by the extension name (whereas previously in the yaml you just provided a list of locations). This is a good thing I think: it reflects the fact that extensions are currently identified uniquely in the router by their name alone and there thus can only be one with a given name at a time.Other than that, I am not a huge fan of the weird
"location"and"params"keys; it exists mostly because it was a convenient format to achieve some semblance of polymorphism in the go code for parsing all this while still using static types to the extent possible. Happy to adjust it if needed.sdk field
"sdk"is an optional field. The behavior of loading a project will change depending on whether it is present or not:dagger.jsonwill be presented the merged API of the extensions defined indagger.json.This is the only relatively clean way I found in the short term to achieve the behavior described here (and that was present previously due to distinction between dependencies and extensions) while staying logically consistent.
Note that there's a huge caveat to all of the above: until this issue has been fixed, none of the above matters because there is only a single global schema. The code has been written such that the above behavior should appear once we've addressed that issue though, so it's extremely important we are all on the same page about it rather than surprised later.
Let me know if this makes sense, it's very subtle, I can provide a full concrete example if helpful.
Loading Behavior
dagger.jsoncan only be used for one extension now. No more scripts field eitherCLI interface
Threw together a very basic CLI interface. Happy to adjust and clean this up, but want to get initial feedback before too much work.
dagger projectDumps the current json (can support more formats in future)
dagger project initdagger project init --name foobar --sdk godagger.jsonin your cwdsdkis optionaldagger project addlocal:
dagger project add local --path path/to/dagger.jsongit:
dagger project add git --remote https://github.com/sipsma/foo --ref bar --path path/to/dagger.jsondagger.jsonspecified (in the case of git this requires use of the engine and project API, which is pretty convenient)dagger project rmdagger project rm --name netlify--nameshould probably just a positional arg, it's a flag for consistency atm but writing this now that seems silly. Will update