@@ -21,6 +21,7 @@ import (
21
21
"github.com/jetstack/preflight/pkg/datagatherer/k8s"
22
22
"github.com/jetstack/preflight/pkg/datagatherer/local"
23
23
"github.com/jetstack/preflight/pkg/kubeconfig"
24
+ "github.com/jetstack/preflight/pkg/logs"
24
25
"github.com/jetstack/preflight/pkg/version"
25
26
)
26
27
@@ -367,29 +368,33 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
367
368
368
369
{
369
370
var (
370
- mode AuthMode
371
- reason string
371
+ mode AuthMode
372
+ reason string
373
+ keysAndValues []any
372
374
)
373
375
switch {
374
376
case flags .VenafiCloudMode && flags .CredentialsPath != "" :
375
377
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 }
377
380
case flags .ClientID != "" && flags .PrivateKeyPath != "" :
378
381
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 }
380
384
case flags .ClientID != "" :
381
385
return CombinedConfig {}, nil , fmt .Errorf ("if --client-id is specified, --private-key-path must also be specified" )
382
386
case flags .PrivateKeyPath != "" :
383
387
return CombinedConfig {}, nil , fmt .Errorf ("--private-key-path is specified, --client-id must also be specified" )
384
388
case flags .VenConnName != "" :
385
389
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 }
387
392
case flags .APIToken != "" :
388
393
mode = JetstackSecureAPIToken
389
- reason = fmt . Sprintf ( "Using the %s auth mode since --api-token was specified." , mode )
394
+ reason = " --api-token was specified"
390
395
case ! flags .VenafiCloudMode && flags .CredentialsPath != "" :
391
396
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"
393
398
default :
394
399
return CombinedConfig {}, nil , fmt .Errorf ("no auth mode specified. You can use one of four auth modes:\n " +
395
400
" - 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)
398
403
" - Use --api-token if you want to use the " + string (JetstackSecureAPIToken ) + " mode.\n " )
399
404
}
400
405
res .AuthMode = mode
401
- log .Info (reason )
406
+ keysAndValues = append (keysAndValues , "mode" , mode , "reason" , reason )
407
+ log .V (logs .Debug ).Info ("Authentication mode" , keysAndValues ... )
402
408
}
403
409
404
410
// Validation and defaulting of `server` and the deprecated `endpoint.path`.
0 commit comments