mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-15 14:03:09 +00:00
Merge pull request #56769 from dixudx/forbid_unnamed_context
Automatic merge from submit-queue (batch tested with PRs 57521, 56769). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. forbid unnamed context **What this PR does / why we need it**: forbid unnamed contexts with validation **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #56747 **Special notes for your reviewer**: /assign @sttts @fabianofranz **Release note**: ```release-note forbid unnamed context ``` Kubernetes-commit: a2bce0d74e283654cd6e561faacf5fba7ea29310
This commit is contained in:
commit
1b825e3a78
106
Godeps/Godeps.json
generated
106
Godeps/Godeps.json
generated
@ -488,215 +488,215 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/testing",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
|
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
|
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
|
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
|
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
|
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/fields",
|
"ImportPath": "k8s.io/apimachinery/pkg/fields",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/labels",
|
"ImportPath": "k8s.io/apimachinery/pkg/labels",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/selection",
|
"ImportPath": "k8s.io/apimachinery/pkg/selection",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/types",
|
"ImportPath": "k8s.io/apimachinery/pkg/types",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/version",
|
"ImportPath": "k8s.io/apimachinery/pkg/version",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/watch",
|
"ImportPath": "k8s.io/apimachinery/pkg/watch",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
|
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
|
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
|
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
|
||||||
"Rev": "a463f34d125a31787d2be8b47bcf6370b0cf1bde"
|
"Rev": "91d8586aac31d9086939d077ba556d2c7fb157b4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kube-openapi/pkg/common",
|
"ImportPath": "k8s.io/kube-openapi/pkg/common",
|
||||||
|
@ -253,6 +253,10 @@ func validateAuthInfo(authInfoName string, authInfo clientcmdapi.AuthInfo) []err
|
|||||||
func validateContext(contextName string, context clientcmdapi.Context, config clientcmdapi.Config) []error {
|
func validateContext(contextName string, context clientcmdapi.Context, config clientcmdapi.Config) []error {
|
||||||
validationErrors := make([]error, 0)
|
validationErrors := make([]error, 0)
|
||||||
|
|
||||||
|
if len(contextName) == 0 {
|
||||||
|
validationErrors = append(validationErrors, fmt.Errorf("empty context name for %#v is not allowed", context))
|
||||||
|
}
|
||||||
|
|
||||||
if len(context.AuthInfo) == 0 {
|
if len(context.AuthInfo) == 0 {
|
||||||
validationErrors = append(validationErrors, fmt.Errorf("user was not specified for context %q", contextName))
|
validationErrors = append(validationErrors, fmt.Errorf("user was not specified for context %q", contextName))
|
||||||
} else if _, exists := config.AuthInfos[context.AuthInfo]; !exists {
|
} else if _, exists := config.AuthInfos[context.AuthInfo]; !exists {
|
||||||
|
@ -62,6 +62,7 @@ func TestConfirmUsableBadInfoButOkConfig(t *testing.T) {
|
|||||||
okTest.testConfirmUsable("clean", t)
|
okTest.testConfirmUsable("clean", t)
|
||||||
badValidation.testConfig(t)
|
badValidation.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConfirmUsableBadInfoConfig(t *testing.T) {
|
func TestConfirmUsableBadInfoConfig(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.Clusters["missing ca"] = &clientcmdapi.Cluster{
|
config.Clusters["missing ca"] = &clientcmdapi.Cluster{
|
||||||
@ -83,6 +84,7 @@ func TestConfirmUsableBadInfoConfig(t *testing.T) {
|
|||||||
|
|
||||||
test.testConfirmUsable("first", t)
|
test.testConfirmUsable("first", t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConfirmUsableEmptyConfig(t *testing.T) {
|
func TestConfirmUsableEmptyConfig(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
test := configValidationTest{
|
test := configValidationTest{
|
||||||
@ -92,6 +94,7 @@ func TestConfirmUsableEmptyConfig(t *testing.T) {
|
|||||||
|
|
||||||
test.testConfirmUsable("", t)
|
test.testConfirmUsable("", t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConfirmUsableMissingConfig(t *testing.T) {
|
func TestConfirmUsableMissingConfig(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
test := configValidationTest{
|
test := configValidationTest{
|
||||||
@ -101,6 +104,7 @@ func TestConfirmUsableMissingConfig(t *testing.T) {
|
|||||||
|
|
||||||
test.testConfirmUsable("not-here", t)
|
test.testConfirmUsable("not-here", t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateEmptyConfig(t *testing.T) {
|
func TestValidateEmptyConfig(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
test := configValidationTest{
|
test := configValidationTest{
|
||||||
@ -110,6 +114,7 @@ func TestValidateEmptyConfig(t *testing.T) {
|
|||||||
|
|
||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateMissingCurrentContextConfig(t *testing.T) {
|
func TestValidateMissingCurrentContextConfig(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.CurrentContext = "anything"
|
config.CurrentContext = "anything"
|
||||||
@ -120,6 +125,7 @@ func TestValidateMissingCurrentContextConfig(t *testing.T) {
|
|||||||
|
|
||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIsContextNotFound(t *testing.T) {
|
func TestIsContextNotFound(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.CurrentContext = "anything"
|
config.CurrentContext = "anything"
|
||||||
@ -172,6 +178,7 @@ func TestValidateMissingReferencesConfig(t *testing.T) {
|
|||||||
test.testContext("anything", t)
|
test.testContext("anything", t)
|
||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateEmptyContext(t *testing.T) {
|
func TestValidateEmptyContext(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.CurrentContext = "anything"
|
config.CurrentContext = "anything"
|
||||||
@ -185,6 +192,19 @@ func TestValidateEmptyContext(t *testing.T) {
|
|||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestValidateEmptyContextName(t *testing.T) {
|
||||||
|
config := clientcmdapi.NewConfig()
|
||||||
|
config.CurrentContext = "anything"
|
||||||
|
config.Contexts[""] = &clientcmdapi.Context{Cluster: "missing", AuthInfo: "missing"}
|
||||||
|
test := configValidationTest{
|
||||||
|
config: config,
|
||||||
|
expectedErrorSubstring: []string{"empty context name", "is not allowed"},
|
||||||
|
}
|
||||||
|
|
||||||
|
test.testContext("", t)
|
||||||
|
test.testConfig(t)
|
||||||
|
}
|
||||||
|
|
||||||
func TestValidateEmptyClusterInfo(t *testing.T) {
|
func TestValidateEmptyClusterInfo(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.Clusters["empty"] = clientcmdapi.NewCluster()
|
config.Clusters["empty"] = clientcmdapi.NewCluster()
|
||||||
@ -223,6 +243,7 @@ func TestValidateMissingCAFileClusterInfo(t *testing.T) {
|
|||||||
test.testCluster("missing ca", t)
|
test.testCluster("missing ca", t)
|
||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCleanClusterInfo(t *testing.T) {
|
func TestValidateCleanClusterInfo(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.Clusters["clean"] = &clientcmdapi.Cluster{
|
config.Clusters["clean"] = &clientcmdapi.Cluster{
|
||||||
@ -235,6 +256,7 @@ func TestValidateCleanClusterInfo(t *testing.T) {
|
|||||||
test.testCluster("clean", t)
|
test.testCluster("clean", t)
|
||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCleanWithCAClusterInfo(t *testing.T) {
|
func TestValidateCleanWithCAClusterInfo(t *testing.T) {
|
||||||
tempFile, _ := ioutil.TempFile("", "")
|
tempFile, _ := ioutil.TempFile("", "")
|
||||||
defer os.Remove(tempFile.Name())
|
defer os.Remove(tempFile.Name())
|
||||||
@ -262,6 +284,7 @@ func TestValidateEmptyAuthInfo(t *testing.T) {
|
|||||||
test.testAuthInfo("error", t)
|
test.testAuthInfo("error", t)
|
||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCertFilesNotFoundAuthInfo(t *testing.T) {
|
func TestValidateCertFilesNotFoundAuthInfo(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.AuthInfos["error"] = &clientcmdapi.AuthInfo{
|
config.AuthInfos["error"] = &clientcmdapi.AuthInfo{
|
||||||
@ -276,6 +299,7 @@ func TestValidateCertFilesNotFoundAuthInfo(t *testing.T) {
|
|||||||
test.testAuthInfo("error", t)
|
test.testAuthInfo("error", t)
|
||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCertDataOverridesFiles(t *testing.T) {
|
func TestValidateCertDataOverridesFiles(t *testing.T) {
|
||||||
tempFile, _ := ioutil.TempFile("", "")
|
tempFile, _ := ioutil.TempFile("", "")
|
||||||
defer os.Remove(tempFile.Name())
|
defer os.Remove(tempFile.Name())
|
||||||
@ -295,6 +319,7 @@ func TestValidateCertDataOverridesFiles(t *testing.T) {
|
|||||||
test.testAuthInfo("clean", t)
|
test.testAuthInfo("clean", t)
|
||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCleanCertFilesAuthInfo(t *testing.T) {
|
func TestValidateCleanCertFilesAuthInfo(t *testing.T) {
|
||||||
tempFile, _ := ioutil.TempFile("", "")
|
tempFile, _ := ioutil.TempFile("", "")
|
||||||
defer os.Remove(tempFile.Name())
|
defer os.Remove(tempFile.Name())
|
||||||
@ -311,6 +336,7 @@ func TestValidateCleanCertFilesAuthInfo(t *testing.T) {
|
|||||||
test.testAuthInfo("clean", t)
|
test.testAuthInfo("clean", t)
|
||||||
test.testConfig(t)
|
test.testConfig(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCleanTokenAuthInfo(t *testing.T) {
|
func TestValidateCleanTokenAuthInfo(t *testing.T) {
|
||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
|
config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
|
||||||
@ -363,6 +389,7 @@ func (c configValidationTest) testContext(contextName string, t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c configValidationTest) testConfirmUsable(contextName string, t *testing.T) {
|
func (c configValidationTest) testConfirmUsable(contextName string, t *testing.T) {
|
||||||
err := ConfirmUsable(*c.config, contextName)
|
err := ConfirmUsable(*c.config, contextName)
|
||||||
|
|
||||||
@ -382,6 +409,7 @@ func (c configValidationTest) testConfirmUsable(contextName string, t *testing.T
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c configValidationTest) testConfig(t *testing.T) {
|
func (c configValidationTest) testConfig(t *testing.T) {
|
||||||
err := Validate(*c.config)
|
err := Validate(*c.config)
|
||||||
|
|
||||||
@ -404,6 +432,7 @@ func (c configValidationTest) testConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c configValidationTest) testCluster(clusterName string, t *testing.T) {
|
func (c configValidationTest) testCluster(clusterName string, t *testing.T) {
|
||||||
errs := validateClusterInfo(clusterName, *c.config.Clusters[clusterName])
|
errs := validateClusterInfo(clusterName, *c.config.Clusters[clusterName])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user