mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 16:40:21 +00:00
exec credential provider: InteractiveMode support
The value here is that the exec plugin author can use the kubeconfig to assert how standard input is treated with respect to the exec plugin, e.g., - an exec plugin author can ensure that kubectl fails if it cannot provide standard input to an exec plugin that needs it (Always) - an exec plugin author can ensure that an client-go process will still call an exec plugin that prefers standard input even if standard input is not available (IfAvailable) Signed-off-by: Andrew Keesler <akeesler@vmware.com> Kubernetes-commit: cd83d89ac94c5b61fdd38840098e7223e5af0d34
This commit is contained in:
committed by
Kubernetes Publisher
parent
1bccfc8c60
commit
37ed584bed
84
tools/clientcmd/api/v1/defaults_test.go
Normal file
84
tools/clientcmd/api/v1/defaults_test.go
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestSetDefaults_Config(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
in, wantOut *ExecConfig
|
||||
}{
|
||||
{
|
||||
name: "alpha exec API with empty interactive mode",
|
||||
in: &ExecConfig{APIVersion: "client.authentication.k8s.io/v1alpha1"},
|
||||
wantOut: &ExecConfig{
|
||||
APIVersion: "client.authentication.k8s.io/v1alpha1",
|
||||
InteractiveMode: IfAvailableExecInteractiveMode,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "beta exec API with empty interactive mode",
|
||||
in: &ExecConfig{APIVersion: "client.authentication.k8s.io/v1beta1"},
|
||||
wantOut: &ExecConfig{
|
||||
APIVersion: "client.authentication.k8s.io/v1beta1",
|
||||
InteractiveMode: IfAvailableExecInteractiveMode,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "alpha exec API with set interactive mode",
|
||||
in: &ExecConfig{
|
||||
APIVersion: "client.authentication.k8s.io/v1alpha1",
|
||||
InteractiveMode: NeverExecInteractiveMode,
|
||||
},
|
||||
wantOut: &ExecConfig{
|
||||
APIVersion: "client.authentication.k8s.io/v1alpha1",
|
||||
InteractiveMode: NeverExecInteractiveMode,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "beta exec API with set interactive mode",
|
||||
in: &ExecConfig{
|
||||
APIVersion: "client.authentication.k8s.io/v1beta1",
|
||||
InteractiveMode: NeverExecInteractiveMode,
|
||||
},
|
||||
wantOut: &ExecConfig{
|
||||
APIVersion: "client.authentication.k8s.io/v1beta1",
|
||||
InteractiveMode: NeverExecInteractiveMode,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "v1 exec API with empty interactive mode",
|
||||
in: &ExecConfig{APIVersion: "client.authentication.k8s.io/v1"},
|
||||
wantOut: &ExecConfig{APIVersion: "client.authentication.k8s.io/v1"},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
gotOut := test.in.DeepCopy()
|
||||
SetDefaults_ExecConfig(gotOut)
|
||||
if diff := cmp.Diff(test.wantOut, gotOut); diff != "" {
|
||||
t.Errorf("unexpected defaulting; -want, +got:\n %s", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user