@@ -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
@@ -367,29 +368,33 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
367368
368369 {
369370 var (
370- mode AuthMode
371- reason string
371+ mode AuthMode
372+ reason string
373+ keysAndValues []any
372374 )
373375 switch {
374376 case flags .VenafiCloudMode && flags .CredentialsPath != "" :
375377 mode = VenafiCloudKeypair
376- reason = fmt .Sprintf ("Using the %s auth mode since --venafi-cloud and --credentials-path were specified." , mode )
378+ reason = "--venafi-cloud and --credentials-path were specified"
379+ keysAndValues = []any {"credentialsPath" , flags .CredentialsPath }
377380 case flags .ClientID != "" && flags .PrivateKeyPath != "" :
378381 mode = VenafiCloudKeypair
379- reason = fmt .Sprintf ("Using the %s auth mode since --client-id and --private-key-path were specified." , mode )
382+ reason = "--client-id and --private-key-path were specified"
383+ keysAndValues = []any {"clientID" , flags .ClientID , "privateKeyPath" , flags .PrivateKeyPath }
380384 case flags .ClientID != "" :
381385 return CombinedConfig {}, nil , fmt .Errorf ("if --client-id is specified, --private-key-path must also be specified" )
382386 case flags .PrivateKeyPath != "" :
383387 return CombinedConfig {}, nil , fmt .Errorf ("--private-key-path is specified, --client-id must also be specified" )
384388 case flags .VenConnName != "" :
385389 mode = VenafiCloudVenafiConnection
386- reason = fmt .Sprintf ("Using the %s auth mode since --venafi-connection was specified." , mode )
390+ reason = "--venafi-connection was specified"
391+ keysAndValues = []any {"venConnName" , flags .VenConnName }
387392 case flags .APIToken != "" :
388393 mode = JetstackSecureAPIToken
389- reason = fmt . Sprintf ( "Using the %s auth mode since --api-token was specified." , mode )
394+ reason = " --api-token was specified"
390395 case ! flags .VenafiCloudMode && flags .CredentialsPath != "" :
391396 mode = JetstackSecureOAuth
392- reason = fmt . Sprintf ( "Using the %s auth mode since --credentials-file was specified without --venafi-cloud." , mode )
397+ reason = " --credentials-file was specified without --venafi-cloud"
393398 default :
394399 return CombinedConfig {}, nil , fmt .Errorf ("no auth mode specified. You can use one of four auth modes:\n " +
395400 " - Use (--venafi-cloud with --credentials-file) or (--client-id with --private-key-path) to use the " + string (VenafiCloudKeypair ) + " mode.\n " +
@@ -398,7 +403,8 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
398403 " - Use --api-token if you want to use the " + string (JetstackSecureAPIToken ) + " mode.\n " )
399404 }
400405 res .AuthMode = mode
401- log .Info (reason )
406+ keysAndValues = append (keysAndValues , "mode" , mode , "reason" , reason )
407+ log .V (logs .Debug ).Info ("Authentication mode" , keysAndValues ... )
402408 }
403409
404410 // Validation and defaulting of `server` and the deprecated `endpoint.path`.
0 commit comments