@@ -21,6 +21,7 @@ import (
2121 "github.com/jetstack/preflight/pkg/datagatherer/k8s"
2222 "github.com/jetstack/preflight/pkg/datagatherer/local"
2323 "github.com/jetstack/preflight/pkg/kubeconfig"
24+ "github.com/jetstack/preflight/pkg/logs"
2425 "github.com/jetstack/preflight/pkg/version"
2526)
2627
@@ -370,29 +371,33 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
370371
371372 {
372373 var (
373- mode AuthMode
374- reason string
374+ mode AuthMode
375+ reason string
376+ keysAndValues []any
375377 )
376378 switch {
377379 case flags .VenafiCloudMode && flags .CredentialsPath != "" :
378380 mode = VenafiCloudKeypair
379- reason = fmt .Sprintf ("Using the %s auth mode since --venafi-cloud and --credentials-path were specified." , mode )
381+ reason = "--venafi-cloud and --credentials-path were specified"
382+ keysAndValues = []any {"credentialsPath" , flags .CredentialsPath }
380383 case flags .ClientID != "" && flags .PrivateKeyPath != "" :
381384 mode = VenafiCloudKeypair
382- reason = fmt .Sprintf ("Using the %s auth mode since --client-id and --private-key-path were specified." , mode )
385+ reason = "--client-id and --private-key-path were specified"
386+ keysAndValues = []any {"clientID" , flags .ClientID , "privateKeyPath" , flags .PrivateKeyPath }
383387 case flags .ClientID != "" :
384388 return CombinedConfig {}, nil , fmt .Errorf ("if --client-id is specified, --private-key-path must also be specified" )
385389 case flags .PrivateKeyPath != "" :
386390 return CombinedConfig {}, nil , fmt .Errorf ("--private-key-path is specified, --client-id must also be specified" )
387391 case flags .VenConnName != "" :
388392 mode = VenafiCloudVenafiConnection
389- reason = fmt .Sprintf ("Using the %s auth mode since --venafi-connection was specified." , mode )
393+ reason = "--venafi-connection was specified"
394+ keysAndValues = []any {"venConnName" , flags .VenConnName }
390395 case flags .APIToken != "" :
391396 mode = JetstackSecureAPIToken
392- reason = fmt . Sprintf ( "Using the %s auth mode since --api-token was specified." , mode )
397+ reason = " --api-token was specified"
393398 case ! flags .VenafiCloudMode && flags .CredentialsPath != "" :
394399 mode = JetstackSecureOAuth
395- reason = fmt . Sprintf ( "Using the %s auth mode since --credentials-file was specified without --venafi-cloud." , mode )
400+ reason = " --credentials-file was specified without --venafi-cloud"
396401 default :
397402 return CombinedConfig {}, nil , fmt .Errorf ("no auth mode specified. You can use one of four auth modes:\n " +
398403 " - Use (--venafi-cloud with --credentials-file) or (--client-id with --private-key-path) to use the " + string (VenafiCloudKeypair ) + " mode.\n " +
@@ -401,7 +406,8 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
401406 " - Use --api-token if you want to use the " + string (JetstackSecureAPIToken ) + " mode.\n " )
402407 }
403408 res .AuthMode = mode
404- log .Info (reason )
409+ keysAndValues = append (keysAndValues , "mode" , mode , "reason" , reason )
410+ log .V (logs .Debug ).Info ("Authentication mode" , keysAndValues ... )
405411 }
406412
407413 // Validation and defaulting of `server` and the deprecated `endpoint.path`.
0 commit comments