Log lines about using cached credential
This commit is contained in:
parent
264778113d
commit
09560fd8dc
@ -187,6 +187,7 @@ func runOIDCLogin(cmd *cobra.Command, deps oidcLoginCommandDeps, flags oidcLogin
|
|||||||
if flags.credentialCachePath != "" {
|
if flags.credentialCachePath != "" {
|
||||||
credCache = execcredcache.New(flags.credentialCachePath)
|
credCache = execcredcache.New(flags.credentialCachePath)
|
||||||
if cred := credCache.Get(cacheKey); cred != nil {
|
if cred := credCache.Get(cacheKey); cred != nil {
|
||||||
|
pLogger.Debug("using cached cluster credential.")
|
||||||
return json.NewEncoder(cmd.OutOrStdout()).Encode(cred)
|
return json.NewEncoder(cmd.OutOrStdout()).Encode(cred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,12 +210,14 @@ func runOIDCLogin(cmd *cobra.Command, deps oidcLoginCommandDeps, flags oidcLogin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not complete Concierge credential exchange: %w", err)
|
return fmt.Errorf("could not complete Concierge credential exchange: %w", err)
|
||||||
}
|
}
|
||||||
|
pLogger.Debug("Exchanged token for cluster credential")
|
||||||
} else {
|
} else {
|
||||||
pLogger.Debug("No concierge configured, skipping token credential exchange")
|
pLogger.Debug("No concierge configured, skipping token credential exchange")
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there was a credential cache, save the resulting credential for future use.
|
// If there was a credential cache, save the resulting credential for future use.
|
||||||
if credCache != nil {
|
if credCache != nil {
|
||||||
|
pLogger.Debug("caching cluster credential for future use.")
|
||||||
credCache.Put(cacheKey, cred)
|
credCache.Put(cacheKey, cred)
|
||||||
}
|
}
|
||||||
return json.NewEncoder(cmd.OutOrStdout()).Encode(cred)
|
return json.NewEncoder(cmd.OutOrStdout()).Encode(cred)
|
||||||
|
@ -137,6 +137,7 @@ func runStaticLogin(out io.Writer, deps staticLoginDeps, flags staticLoginParams
|
|||||||
if flags.credentialCachePath != "" {
|
if flags.credentialCachePath != "" {
|
||||||
credCache = execcredcache.New(flags.credentialCachePath)
|
credCache = execcredcache.New(flags.credentialCachePath)
|
||||||
if cred := credCache.Get(cacheKey); cred != nil {
|
if cred := credCache.Get(cacheKey); cred != nil {
|
||||||
|
pLogger.Debug("using cached cluster credential.")
|
||||||
return json.NewEncoder(out).Encode(cred)
|
return json.NewEncoder(out).Encode(cred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,7 @@ func TestLoginStaticCommand(t *testing.T) {
|
|||||||
args: []string{
|
args: []string{
|
||||||
"--token", "test-token",
|
"--token", "test-token",
|
||||||
},
|
},
|
||||||
|
env: map[string]string{"PINNIPED_DEBUG": "true"},
|
||||||
wantStdout: `{"kind":"ExecCredential","apiVersion":"client.authentication.k8s.io/v1beta1","spec":{},"status":{"token":"test-token"}}` + "\n",
|
wantStdout: `{"kind":"ExecCredential","apiVersion":"client.authentication.k8s.io/v1beta1","spec":{},"status":{"token":"test-token"}}` + "\n",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user