@@ -97,6 +97,10 @@ type ProvisionStatusFiles struct {
9797}
9898
9999func (a * App ) Run (ctx context.Context , args []string ) int {
100+ if handled := handleInfoCommand (args ); handled {
101+ return 0
102+ }
103+
100104 slog .Info ("aks-node-controller started" , "args" , args )
101105 err := a .run (ctx , args )
102106 exitCode := errToExitCode (err )
@@ -108,6 +112,30 @@ func (a *App) Run(ctx context.Context, args []string) int {
108112 return exitCode
109113}
110114
115+ // handleInfoCommand handles --version, version, --help, and help commands
116+ // without logging noise. Returns true if handled.
117+ func handleInfoCommand (args []string ) bool {
118+ if len (args ) < 2 {
119+ return false
120+ }
121+ switch args [1 ] {
122+ case "--version" , "version" :
123+ _ , _ = fmt .Fprintln (os .Stdout , Version )
124+ return true
125+ case "--help" , "help" :
126+ _ , _ = fmt .Fprintln (os .Stdout , "Usage: aks-node-controller <command> [options]" )
127+ _ , _ = fmt .Fprintln (os .Stdout )
128+ _ , _ = fmt .Fprintln (os .Stdout , "Commands:" )
129+ _ , _ = fmt .Fprintln (os .Stdout , " provision Run node provisioning" )
130+ _ , _ = fmt .Fprintln (os .Stdout , " provision-wait Wait for provisioning to complete" )
131+ _ , _ = fmt .Fprintln (os .Stdout , " version Print the version" )
132+ _ , _ = fmt .Fprintln (os .Stdout , " help Print this help message" )
133+ return true
134+ default :
135+ return false
136+ }
137+ }
138+
111139func (a * App ) run (ctx context.Context , args []string ) error {
112140 command := ""
113141 if len (args ) >= 2 {
@@ -117,12 +145,6 @@ func (a *App) run(ctx context.Context, args []string) error {
117145 return errors .New ("missing command argument" )
118146 }
119147
120- if command == "--version" || command == "version" {
121- //nolint:forbidigo // stdout is part of the interface
122- fmt .Println (Version )
123- return nil
124- }
125-
126148 cmd , ok := getCommandRegistry ()[command ]
127149 if ! ok {
128150 return fmt .Errorf ("unknown command: %s" , command )
0 commit comments