Unset pinniped debug environment variable at end of integration test
Also log when setting the debug log level fails
This commit is contained in:
parent
6a21499ed3
commit
45e4695444
@ -112,7 +112,10 @@ func oidcLoginCommand(deps oidcLoginCommandDeps) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runOIDCLogin(cmd *cobra.Command, deps oidcLoginCommandDeps, flags oidcLoginFlags) error {
|
func runOIDCLogin(cmd *cobra.Command, deps oidcLoginCommandDeps, flags oidcLoginFlags) error {
|
||||||
SetLogLevel()
|
err := SetLogLevel()
|
||||||
|
if err != nil {
|
||||||
|
plog.WarningErr("Received error while setting log level", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the session cache.
|
// Initialize the session cache.
|
||||||
var sessionOptions []filesession.Option
|
var sessionOptions []filesession.Option
|
||||||
@ -261,10 +264,14 @@ func tokenCredential(token *oidctypes.Token) *clientauthv1beta1.ExecCredential {
|
|||||||
return &cred
|
return &cred
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetLogLevel() {
|
func SetLogLevel() error {
|
||||||
if os.Getenv("PINNIPED_DEBUG") == "true" {
|
if os.Getenv("PINNIPED_DEBUG") == "true" {
|
||||||
_ = plog.ValidateAndSetLogLevelGlobally(plog.LevelDebug)
|
err := plog.ValidateAndSetLogLevelGlobally(plog.LevelDebug)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// mustGetConfigDir returns a directory that follows the XDG base directory convention:
|
// mustGetConfigDir returns a directory that follows the XDG base directory convention:
|
||||||
|
@ -84,7 +84,10 @@ func staticLoginCommand(deps staticLoginDeps) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runStaticLogin(out io.Writer, deps staticLoginDeps, flags staticLoginParams) error {
|
func runStaticLogin(out io.Writer, deps staticLoginDeps, flags staticLoginParams) error {
|
||||||
SetLogLevel()
|
err := SetLogLevel()
|
||||||
|
if err != nil {
|
||||||
|
plog.WarningErr("Received error while setting log level", err)
|
||||||
|
}
|
||||||
|
|
||||||
if flags.staticToken == "" && flags.staticTokenEnvName == "" {
|
if flags.staticToken == "" && flags.staticTokenEnvName == "" {
|
||||||
return fmt.Errorf("one of --token or --token-env must be set")
|
return fmt.Errorf("one of --token or --token-env must be set")
|
||||||
|
@ -256,6 +256,8 @@ func TestCLILoginOIDC(t *testing.T) {
|
|||||||
require.Contains(t, cmd4StringOutput, "Found unexpired cached token")
|
require.Contains(t, cmd4StringOutput, "Found unexpired cached token")
|
||||||
require.Contains(t, cmd4StringOutput, "No concierge configured, skipping token credential exchange")
|
require.Contains(t, cmd4StringOutput, "No concierge configured, skipping token credential exchange")
|
||||||
require.Contains(t, cmd4StringOutput, credOutput3.Status.Token)
|
require.Contains(t, cmd4StringOutput, credOutput3.Status.Token)
|
||||||
|
err = os.Unsetenv("PINNIPED_DEBUG")
|
||||||
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPinnipedLoginOIDC(
|
func runPinnipedLoginOIDC(
|
||||||
|
Loading…
Reference in New Issue
Block a user