Do not allow positional arguments when running gitops (#32780)

For #32478

Added check to gitops command to throw error if positional arguments are
detected.
This commit is contained in:
Juan Fernandez
2025-09-11 14:42:56 -04:00
committed by GitHub
parent f576bd8863
commit 43bbb4686a
2 changed files with 9 additions and 3 deletions
@@ -0,0 +1 @@
* Added check to gitops command to throw error if positional arguments are detected.
+8 -3
View File
@@ -60,6 +60,14 @@ func gitopsCommand() *cli.Command {
debugFlag(),
},
Action: func(c *cli.Context) error {
logf := func(format string, a ...interface{}) {
_, _ = fmt.Fprintf(c.App.Writer, format, a...)
}
if len(c.Args().Slice()) != 0 {
return errors.New("No positional arguments are allowed. To load multiple config files, use one -f flag per file.")
}
totalFilenames := len(flFilenames.Value())
if totalFilenames == 0 {
return errors.New("-f must be specified")
@@ -85,9 +93,6 @@ func gitopsCommand() *cli.Command {
if appConfig.License == nil {
return errors.New("no license struct found in app config")
}
logf := func(format string, a ...interface{}) {
_, _ = fmt.Fprintf(c.App.Writer, format, a...)
}
// We need the controls from no-team.yml to apply them when applying the global app config.
noTeamControls, noTeamPresent, err := extractControlsForNoTeam(flFilenames, appConfig)