diff --git a/changes/32478-fleetctl-gitops-globs-ignore-dry-run b/changes/32478-fleetctl-gitops-globs-ignore-dry-run new file mode 100644 index 0000000000..6578e5d331 --- /dev/null +++ b/changes/32478-fleetctl-gitops-globs-ignore-dry-run @@ -0,0 +1 @@ +* Added check to gitops command to throw error if positional arguments are detected. \ No newline at end of file diff --git a/cmd/fleetctl/fleetctl/gitops.go b/cmd/fleetctl/fleetctl/gitops.go index 2bad5d55d3..50b529e795 100644 --- a/cmd/fleetctl/fleetctl/gitops.go +++ b/cmd/fleetctl/fleetctl/gitops.go @@ -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)