-
Notifications
You must be signed in to change notification settings - Fork 46
feat: add --manifest-source flag to run and deploy commands #630
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
base: main
Are you sure you want to change the base?
Changes from all commits
b021d22
a8d89ea
7ab29be
4837889
6ec8dc7
d327435
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,8 @@ package cmdutil | |||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| "github.com/slackapi/slack-cli/internal/shared" | ||||||||||||||||||||||||||
| "github.com/slackapi/slack-cli/internal/slackerror" | ||||||||||||||||||||||||||
| "github.com/slackapi/slack-cli/internal/style" | ||||||||||||||||||||||||||
| "github.com/spf13/cobra" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
@@ -35,6 +37,29 @@ var OrgGrantWorkspaceDescription = func() string { | |||||||||||||||||||||||||
| style.Secondary("(or 'all' for all workspaces in the org)")) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // ManifestSourceFlag values | ||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||
| ManifestSourceProject = "project" | ||||||||||||||||||||||||||
| ManifestSourceRemote = "remote" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
Comment on lines
+41
to
+44
Member
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.
Suggested change
🪬 suggestion(blocking): Earlier suggestion might've hinted at "project" terms but we should match existing configuration options I realize. Perhaps reusing logic from this package instead of validations here? slack-cli/internal/config/manifest.go Lines 20 to 23 in 73dde37
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // ValidateManifestSourceFlag checks that --manifest-source has a valid value if set | ||||||||||||||||||||||||||
| func ValidateManifestSourceFlag(clients *shared.ClientFactory) error { | ||||||||||||||||||||||||||
| v := clients.Config.ManifestSourceFlag | ||||||||||||||||||||||||||
| if v == "" { | ||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if v != ManifestSourceProject && v != ManifestSourceRemote { | ||||||||||||||||||||||||||
| return slackerror.New(slackerror.ErrInvalidFlag). | ||||||||||||||||||||||||||
| WithMessage("Invalid value %q for %s flag", v, style.CommandText("--manifest-source")). | ||||||||||||||||||||||||||
| WithRemediation("Valid values are %s or %s", | ||||||||||||||||||||||||||
| style.Highlight(ManifestSourceProject), | ||||||||||||||||||||||||||
| style.Highlight(ManifestSourceRemote), | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // IsFlagChanged checks if a certain flag has been set in the command | ||||||||||||||||||||||||||
| func IsFlagChanged(cmd *cobra.Command, flag string) bool { | ||||||||||||||||||||||||||
| IsFlagSet := cmd.Flags().Lookup(flag) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,7 @@ type Config struct { | |
| DisableTelemetryFlag bool | ||
| ForceFlag bool | ||
| ForceRemoteFlag bool | ||
| ManifestSourceFlag string | ||
| LogstashHostResolved string | ||
|
Comment on lines
+57
to
58
Member
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. 🧮 suggestion: Let's keep this in alphabetical order! |
||
| NoColor bool | ||
| RuntimeFlag string | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import ( | |
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/slackapi/slack-cli/internal/cmdutil" | ||
| "github.com/slackapi/slack-cli/internal/config" | ||
| "github.com/slackapi/slack-cli/internal/shared" | ||
| "github.com/slackapi/slack-cli/internal/shared/types" | ||
|
|
@@ -77,12 +78,12 @@ func Sync(ctx context.Context, clients *shared.ClientFactory, app types.App, aut | |
|
|
||
| var merged types.AppManifest | ||
| switch { | ||
| case clients.Config.ForceFlag: | ||
| case clients.Config.ManifestSourceFlag == cmdutil.ManifestSourceProject || clients.Config.ForceFlag: | ||
| merged, err = MergeAllFrom(localManifest.AppManifest, remoteManifest.AppManifest, diffs, MergeAllLocal) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| case clients.Config.ForceRemoteFlag: | ||
| case clients.Config.ManifestSourceFlag == cmdutil.ManifestSourceRemote || clients.Config.ForceRemoteFlag: | ||
| merged, err = MergeAllFrom(localManifest.AppManifest, remoteManifest.AppManifest, diffs, MergeAllRemote) | ||
| if err != nil { | ||
| return nil, err | ||
|
|
@@ -91,8 +92,8 @@ func Sync(ctx context.Context, clients *shared.ClientFactory, app types.App, aut | |
| return nil, slackerror.New(slackerror.ErrAppManifestUpdate). | ||
| WithRemediation("Run %s interactively to resolve manifest differences, or pass %s to push the project manifest to app settings or %s to pull app settings to project", | ||
| style.Commandf("manifest sync", false), | ||
| style.CommandText("--force"), | ||
| style.CommandText("--force-remote"), | ||
| style.CommandText("--manifest-source=project / --force"), | ||
| style.CommandText("--manifest-source=remote / --force-remote"), | ||
|
Comment on lines
+95
to
+96
Member
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. 🪓 question: Are we alright to replace the |
||
| ) | ||
| default: | ||
| merged, err = resolveInteractively(ctx, clients, localManifest.AppManifest, remoteManifest.AppManifest, diffs) | ||
|
|
||
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.
🪓 quibble: I'd favor this validation happening with the
switchcase ininternal/manifest/sync.goto avoid duplicate checks in code, although I understand this might error earlier.