mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
Add argocd app unset command to unset parameter overrides. Bump version to v0.4.5
This commit is contained in:
parent
5a62286127
commit
3acca5095e
2 changed files with 50 additions and 1 deletions
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
|||
0.4.4
|
||||
0.4.5
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ func NewApplicationCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comman
|
|||
command.AddCommand(NewApplicationGetCommand(clientOpts))
|
||||
command.AddCommand(NewApplicationDiffCommand(clientOpts))
|
||||
command.AddCommand(NewApplicationSetCommand(clientOpts))
|
||||
command.AddCommand(NewApplicationUnsetCommand(clientOpts))
|
||||
command.AddCommand(NewApplicationSyncCommand(clientOpts))
|
||||
command.AddCommand(NewApplicationHistoryCommand(clientOpts))
|
||||
command.AddCommand(NewApplicationRollbackCommand(clientOpts))
|
||||
|
|
@ -289,6 +290,54 @@ func addAppFlags(command *cobra.Command, opts *appOptions) {
|
|||
command.Flags().StringArrayVarP(&opts.parameters, "parameter", "p", []string{}, "set a parameter override (e.g. -p guestbook=image=example/guestbook:latest)")
|
||||
}
|
||||
|
||||
// NewApplicationUnsetCommand returns a new instance of an `argocd app unset` command
|
||||
func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
parameters []string
|
||||
)
|
||||
var command = &cobra.Command{
|
||||
Use: "unset APPNAME -p COMPONENT=PARAM",
|
||||
Short: "Unset application parameters",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
if len(args) != 1 || len(parameters) == 0 {
|
||||
c.HelpFunc()(c, args)
|
||||
os.Exit(1)
|
||||
}
|
||||
appName := args[0]
|
||||
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
|
||||
defer util.Close(conn)
|
||||
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName})
|
||||
errors.CheckError(err)
|
||||
|
||||
updated := false
|
||||
for _, paramStr := range parameters {
|
||||
parts := strings.SplitN(paramStr, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
log.Fatalf("Expected parameter of the form: component=param. Received: %s", paramStr)
|
||||
}
|
||||
overrides := app.Spec.Source.ComponentParameterOverrides
|
||||
for i, override := range overrides {
|
||||
if override.Component == parts[0] && override.Name == parts[1] {
|
||||
app.Spec.Source.ComponentParameterOverrides = append(overrides[0:i], overrides[i+1:]...)
|
||||
updated = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !updated {
|
||||
return
|
||||
}
|
||||
_, err = appIf.UpdateSpec(context.Background(), &application.ApplicationSpecRequest{
|
||||
AppName: &app.Name,
|
||||
Spec: app.Spec,
|
||||
})
|
||||
errors.CheckError(err)
|
||||
},
|
||||
}
|
||||
command.Flags().StringArrayVarP(¶meters, "parameter", "p", []string{}, "unset a parameter override (e.g. -p guestbook=image)")
|
||||
return command
|
||||
}
|
||||
|
||||
// NewApplicationDiffCommand returns a new instance of an `argocd app diff` command
|
||||
func NewApplicationDiffCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var command = &cobra.Command{
|
||||
|
|
|
|||
Loading…
Reference in a new issue