Repository navigation
Conversation
b1c342b to
d17d59b
Compare
a27ffca to
8712f50
Compare
| moduleInitCmd.Flags().StringVar(&moduleSourcePath, "source", "", "Source directory used by the installed SDK. Defaults to module root") | ||
| moduleInitCmd.Flags().StringVar(&licenseID, "license", defaultLicense, "License identifier to generate. See https://spdx.org/licenses/") | ||
| moduleInitCmd.Flags().BoolVar(&mergeDeps, "merge", false, "Merge module dependencies with existing project ones") | ||
| moduleInitCmd.Flags().MarkHidden("merge") |
There was a problem hiding this comment.
marking this as hidden as a fallback in case users need to override this behavior. Not entirely sure if we should un-hide it. Thoughts?
There was a problem hiding this comment.
Hm, I'm actually not sure about this option at all. (It's also a bit weird to have a go sdk specific flag right here, if we do want to have it, we probably want to make it a bit more generic or hide it if --sdk=go isn't set).
I think we should probably default to always generating go.mod/go.sum. If the user doesn't want them, they can delete them after, right? As long as we have a test for that, and check it works as expected and gets merged into the root, I think that's fine.
That way, go is like all the other sdks, which manage their own dependencies.
I might be wrong, maybe we do need to keep this option - WDYT @sipsma?
There was a problem hiding this comment.
The feedback about allowing backwards compatibility with a flag came from @shykes https://discord.com/channels/707636530424053791/1003718839739105300/1266140398112346203.
I'd have preferred to avoid it since it makes the implementation cleaner but on the other hand I understand the reason to add it also.
There was a problem hiding this comment.
if we do want to have it, we probably want to make it a bit more generic or hide it if --sdk=go isn't set).
The flag is hidden by default, so users won't know it's there. It's mostly a "safeguard" in case someone is trying to get the current "merge by default" behavior. IMO it's very unlikely to happen, but if it does, we can tell them to use this hidden flag.
There was a problem hiding this comment.
Yeah okay, I guess a flag isn't too bad 🤷♀️ But, we should have a way of explicitly erroring in python/typescript/etc if --merge is set - maybe one day they could be set with merged dependencies, but I don't think that's the behavior today, and I don't think it's configurable (cc @helderco @TomChv).
(Ideally this check should be in the SDK! Not the CLI).
After merging, we should consider either:
- Update Remove deprecated APIs in v0.13.0 #8065 to discuss removing the flag (if we wanna go that route)
- Opening a follow-up issue to implement something similar in python/typescript if we wanna keep this flag around indefinitely
There was a problem hiding this comment.
As long as the flag is hidden, we can wait for someone to ask for it, and if nobody does, we'll just remove it.
b28dc5f to
d71324b
Compare
| if src.Self.WithInitConfig != nil && | ||
| src.Self.WithInitConfig.Merge && | ||
| mod.SDKConfig != SDKGo { | ||
| return fmt.Errorf("merge is only supported for Go SDKs") | ||
| } |
There was a problem hiding this comment.
Not hugely in love with this check being here, ideally we would propagate all the WithInitConfig options into the module SDKs as well, and they would be able to handle them.
However, yeah, it's fine to not do that for now - the plumbing is definitely fiddly 😢 (and maybe actually requires module introspection, separately from codegen, which I'm doing as part of the dag.Self work).
| // will want to have a runtime module that lives in the same Go module as | ||
| // the generated client, which typically lives in the parent directory. | ||
| if mod == nil { | ||
| if mod == nil && (g.Config.Merge == nil || *g.Config.Merge) { |
There was a problem hiding this comment.
Should this not be (g.Config.Merge && *g.Config.Merge)? If g.Config is nil, we should assume merge is false right?
There was a problem hiding this comment.
g.Config can't be nil since it's not a pointer.
Should this not be (g.Config.Merge && *g.Config.Merge)
this doesn't evaluate as g.Config.Merge is *bool
the reason behind this condition is to only perform the block below if mod ==nil AND merge is not set (which dagger init should always set), or it's set to true
There was a problem hiding this comment.
Sorry, I mean - g.Config.Merge == nil shouldn't be assumed to be true? If it's nil, shouldn't it be false? That keeps zero-ish values roughly equivalent.
There was a problem hiding this comment.
If it's
nil, shouldn't it befalse?
Not really since "not set" (g.Config.Merge == nil) doesn't have the same meaning as set to false. That's the main reason for making it a *bool and not passing the flag directly here https://github.com/dagger/dagger/pull/8095/files#diff-fc3b73c833f27945a9663b13ce2651daa11e86389d062a3468e2e038d14d2d6aR66-R68.
I'll add a comment in that line.
There was a problem hiding this comment.
Can we handle this and remove the pointer at that point then? I don't understand why we need to have it be a trinary setting.
The conditions where we use it, g.Config.Merge != nil && !*g.Config.Merge and g.Config.Merge == nil || *g.Config.Merge, are just the inverse of each other (by De Morgan's).
jedevc
left a comment
There was a problem hiding this comment.
Left some comments, but once resolved and tests pass LGTM 🎉
b88607c to
a69b6f9
Compare
This allows setting init configurations to ModuleSource so they can be passed over between the different layers of the codegen. This commit adds a new `merge` config which allows to set if the module dependencies should be merged with the main project upon module initialization. Signed-off-by: Marcos Lilljedahl <[email protected]>
96c5218 to
5f3813a
Compare
Signed-off-by: Marcos Lilljedahl <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
5f3813a to
e2e6583
Compare
Fixes #7527
Signed-off-by: Marcos Lilljedahl [email protected]