diff --git a/pkg/credentialplugin/reader/reader.go b/pkg/credentialplugin/reader/reader.go index 6ffdfd7f..9ba94f5d 100644 --- a/pkg/credentialplugin/reader/reader.go +++ b/pkg/credentialplugin/reader/reader.go @@ -22,6 +22,8 @@ type Interface interface { type Reader struct{} +// Read parses the environment variable KUBERNETES_EXEC_INFO. +// If the environment variable is not given by kubectl, Read returns a zero value. func (r Reader) Read() (credentialplugin.Input, error) { execInfo := os.Getenv("KUBERNETES_EXEC_INFO") if execInfo == "" { diff --git a/pkg/credentialplugin/types.go b/pkg/credentialplugin/types.go index dd044c54..0b2c7710 100644 --- a/pkg/credentialplugin/types.go +++ b/pkg/credentialplugin/types.go @@ -4,6 +4,7 @@ package credentialplugin import "time" // Input represents an input object of the credential plugin. +// This may be a zero value if the input is not available. type Input struct { ClientAuthenticationAPIVersion string } diff --git a/pkg/credentialplugin/writer/credential_plugin.go b/pkg/credentialplugin/writer/credential_plugin.go index 6ac8c81c..5dd32483 100644 --- a/pkg/credentialplugin/writer/credential_plugin.go +++ b/pkg/credentialplugin/writer/credential_plugin.go @@ -40,7 +40,7 @@ func (w *Writer) Write(out credentialplugin.Output) error { func generateExecCredential(out credentialplugin.Output) (any, error) { switch out.ClientAuthenticationAPIVersion { - // Default to v1beta1 if KUBERNETES_EXEC_INFO is not available + // If the API version is not available, fall back to v1beta1. case clientauthenticationv1beta1.SchemeGroupVersion.String(), "": return &clientauthenticationv1beta1.ExecCredential{ TypeMeta: metav1.TypeMeta{