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
18 changes: 1 addition & 17 deletions cmd/ansible-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,9 @@ func printVersion() {

func main() {
f := &flags.Flags{}
err := f.AddTo(pflag.CommandLine)
if err != nil {
log.Error(err, "Failed to add ansible command line flags")
}
f.AddTo(pflag.CommandLine)
pflag.Parse()
logf.SetLogger(zap.Logger())
warningMsgForDeprecatedFlags()

printVersion()

Expand Down Expand Up @@ -300,15 +296,3 @@ func getAnsibleDebugLog() bool {
}
return val
}

// warningMsgForDeprecatedFlags logs warning messages if deprecated flags are used. Currently,
// "--max-workers" is deprecated. Any value provided using this flags will not be used. Instead
// users are directed to use "--max-concurrent-reconciles".
func warningMsgForDeprecatedFlags() {
if pflag.Lookup("max-workers").Changed {
log.Info("Flag --max-workers has been deprecated, use --max-concurrent-reconciles instead")
if pflag.Lookup("max-concurrent-reconciles").Changed {
log.Info("Ignoring --max-workers since --max-concurrent-reconciles is set")
}
}
}
14 changes: 1 addition & 13 deletions pkg/ansible/flags/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package flags

import (
"fmt"
"runtime"
"time"

Expand All @@ -30,7 +29,6 @@ type Flags struct {
WatchesFile string
InjectOwnerRef bool
MaxConcurrentReconciles int
MaxWorkers int
AnsibleVerbosity int
AnsibleRolesPath string
AnsibleCollectionsPath string
Expand All @@ -40,7 +38,7 @@ const AnsibleRolesPathEnvVar = "ANSIBLE_ROLES_PATH"
const AnsibleCollectionsPathEnvVar = "ANSIBLE_COLLECTIONS_PATH"

// AddTo - Add the ansible operator flags to the the flagset
func (f *Flags) AddTo(flagSet *pflag.FlagSet) error {
func (f *Flags) AddTo(flagSet *pflag.FlagSet) {
flagSet.AddFlagSet(zap.FlagSet())
flagSet.DurationVar(&f.ReconcilePeriod,
"reconcile-period",
Expand All @@ -57,11 +55,6 @@ func (f *Flags) AddTo(flagSet *pflag.FlagSet) error {
true,
"The ansible operator will inject owner references unless this flag is false",
)
flagSet.IntVar(&f.MaxWorkers,
"max-workers",
runtime.NumCPU(),
"Maximum number of workers to use. Overridden by environment variable.",
)
flagSet.IntVar(&f.MaxConcurrentReconciles,
"max-concurrent-reconciles",
runtime.NumCPU(),
Expand All @@ -82,9 +75,4 @@ func (f *Flags) AddTo(flagSet *pflag.FlagSet) error {
"",
"Path to installed Ansible Collections. If set, collections should be located in {{value}}/ansible_collections/. If unset, collections are assumed to be in ~/.ansible/collections or /usr/share/ansible/collections.",
)
err := flagSet.MarkDeprecated("max-workers", "use --max-concurrent-reconciles instead.")
if err != nil {
return fmt.Errorf("flag cannot be deprecated %v", err)
}
return nil
}