Repository navigation
Don't re-use project go.mod on init. #8095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,8 @@ var ( | |
| developSourcePath string | ||
|
|
||
| force bool | ||
|
|
||
| mergeDeps bool | ||
| ) | ||
|
|
||
| const ( | ||
|
|
@@ -75,6 +77,8 @@ func init() { | |
| moduleInitCmd.Flags().StringVar(&moduleName, "name", "", "Name of the new module (defaults to parent directory name)") | ||
| 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") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 I think we should probably default to always generating 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah okay, I guess a flag isn't too bad 🤷♀️ But, we should have a way of explicitly erroring in python/typescript/etc if (Ideally this check should be in the SDK! Not the CLI). After merging, we should consider either:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
|
|
||
| modulePublishCmd.Flags().BoolVarP(&force, "force", "f", false, "Force publish even if the git repository is not clean") | ||
| modFlag := *moduleFlags.Lookup("mod") | ||
|
|
@@ -162,6 +166,7 @@ If --sdk is specified, the given SDK is installed in the module. You can do this | |
| _, err = modConf.Source. | ||
| WithName(moduleName). | ||
| WithSDK(sdk). | ||
| WithInit(dagger.ModuleSourceWithInitOpts{Merge: mergeDeps}). | ||
| WithSourceSubpath(moduleSourcePath). | ||
| ResolveFromCaller(). | ||
| AsModule(dagger.ModuleSourceAsModuleOpts{EngineVersion: modules.EngineVersionLatest}). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be
(g.Config.Merge && *g.Config.Merge)? Ifg.Configisnil, we should assumemergeisfalseright?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g.Configcan't be nil since it's not a pointer.this doesn't evaluate as
g.Config.Mergeis*boolthe reason behind this condition is to only perform the block below if mod ==nil AND
mergeis not set (which dagger init should always set), or it's set to trueThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I mean -
g.Config.Merge == nilshouldn't be assumed to betrue? If it'snil, shouldn't it befalse? That keeps zero-ish values roughly equivalent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.Mergeandg.Config.Merge == nil || *g.Config.Merge, are just the inverse of each other (by De Morgan's).