Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.
if appOpts.destNamespace != "" {
app.Spec.Destination.Namespace = appOpts.destNamespace
}
if appOpts.namePrefix != "" {
app.Spec.Source.NamePrefix = appOpts.namePrefix
}
setParameterOverrides(&app, appOpts.parameters)
if len(appOpts.valuesFiles) > 0 {
app.Spec.Source.ValuesFiles = appOpts.valuesFiles
Expand Down Expand Up @@ -194,6 +197,9 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
if len(app.Spec.Source.ValuesFiles) > 0 {
fmt.Printf(printOpFmtStr, "Helm Values:", strings.Join(app.Spec.Source.ValuesFiles, ","))
}
if len(app.Spec.Source.NamePrefix) > 0 {
fmt.Printf(printOpFmtStr, "Name Prefix:", app.Spec.Source.NamePrefix)
}
var syncPolicy string
if app.Spec.SyncPolicy != nil && app.Spec.SyncPolicy.Automated != nil {
syncPolicy = "Automated"
Expand Down Expand Up @@ -335,6 +341,8 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
app.Spec.Destination.Namespace = appOpts.destNamespace
case "project":
app.Spec.Project = appOpts.project
case "name-prefix":
app.Spec.Source.NamePrefix = appOpts.namePrefix
case "sync-policy":
switch appOpts.syncPolicy {
case "automated":
Expand Down Expand Up @@ -400,6 +408,7 @@ type appOptions struct {
project string
syncPolicy string
autoPrune bool
namePrefix string
}

func addAppFlags(command *cobra.Command, opts *appOptions) {
Expand All @@ -414,19 +423,21 @@ func addAppFlags(command *cobra.Command, opts *appOptions) {
command.Flags().StringVar(&opts.project, "project", "", "Application project name")
command.Flags().StringVar(&opts.syncPolicy, "sync-policy", "", "Set the sync policy (one of: automated, none)")
command.Flags().BoolVar(&opts.autoPrune, "auto-prune", false, "Set automatic pruning when sync is automated")
command.Flags().StringVar(&opts.namePrefix, "name-prefix", "", "Set a prefix to add to resource names for kustomize and helm app")
}

// NewApplicationUnsetCommand returns a new instance of an `argocd app unset` command
func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
parameters []string
valuesFiles []string
namePrefix bool
)
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 && len(valuesFiles) == 0) {
if len(args) != 1 || (len(parameters) == 0 && len(valuesFiles) == 0 && !namePrefix) {
c.HelpFunc()(c, args)
os.Exit(1)
}
Expand Down Expand Up @@ -472,6 +483,10 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
}
}
}
if namePrefix {
app.Spec.Source.NamePrefix = ""
updated = true
}

if !updated {
return
Expand All @@ -485,6 +500,8 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
}
command.Flags().StringArrayVarP(&parameters, "parameter", "p", []string{}, "unset a parameter override (e.g. -p guestbook=image)")
command.Flags().StringArrayVar(&valuesFiles, "values", []string{}, "unset one or more helm values files")
command.Flags().BoolVar(&namePrefix, "name-prefix", false, "Unset the name prefix")

return command
}

Expand Down
1 change: 1 addition & 0 deletions controller/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (s *appStateManager) getTargetObjs(app *v1alpha1.Application, revision stri
AppLabel: app.Name,
ValueFiles: app.Spec.Source.ValuesFiles,
Namespace: app.Spec.Destination.Namespace,
NamePrefix: app.Spec.Source.NamePrefix,
})
if err != nil {
return nil, nil, err
Expand Down
Loading