Skip to content

Commit 0e2f94e

Browse files
Merge pull request #59495 from ericchiang/client-auth-exec
Automatic merge from submit-queue. 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>. client-go: add an exec-based client auth provider Updates kubernetes/enhancements#541 Implements kubernetes/community#1503 Closes kubernetes/kubernetes#57164 ```release-note client-go: alpha support for exec-based credential providers ``` /sig auth /kind feature Kubernetes-commit: cb9d6b51556a1677f262e35e4aded0051c424818
2 parents 5d7eb02 + d22e08f commit 0e2f94e

33 files changed

+2554
-584
lines changed

Godeps/Godeps.json

+580-580
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/clientauthentication/BUILD

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library")
2+
3+
go_library(
4+
name = "go_default_library",
5+
srcs = [
6+
"doc.go",
7+
"register.go",
8+
"types.go",
9+
"zz_generated.deepcopy.go",
10+
],
11+
importpath = "k8s.io/client-go/pkg/apis/clientauthentication",
12+
visibility = ["//visibility:public"],
13+
deps = [
14+
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
15+
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
16+
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
17+
],
18+
)
19+
20+
filegroup(
21+
name = "package-srcs",
22+
srcs = glob(["**"]),
23+
tags = ["automanaged"],
24+
visibility = ["//visibility:private"],
25+
)
26+
27+
filegroup(
28+
name = "all-srcs",
29+
srcs = [
30+
":package-srcs",
31+
"//staging/src/k8s.io/client-go/pkg/apis/clientauthentication/install:all-srcs",
32+
"//staging/src/k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1:all-srcs",
33+
],
34+
tags = ["automanaged"],
35+
visibility = ["//visibility:public"],
36+
)

pkg/apis/clientauthentication/doc.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// +k8s:deepcopy-gen=package
18+
// +groupName=client.authentication.k8s.io
19+
package clientauthentication // import "k8s.io/client-go/pkg/apis/clientauthentication"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
load(
4+
"@io_bazel_rules_go//go:def.bzl",
5+
"go_library",
6+
)
7+
8+
go_library(
9+
name = "go_default_library",
10+
srcs = ["install.go"],
11+
importpath = "k8s.io/client-go/pkg/apis/clientauthentication/install",
12+
deps = [
13+
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
14+
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
15+
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
16+
"//vendor/k8s.io/client-go/pkg/apis/clientauthentication:go_default_library",
17+
"//vendor/k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1:go_default_library",
18+
],
19+
)
20+
21+
filegroup(
22+
name = "package-srcs",
23+
srcs = glob(["**"]),
24+
tags = ["automanaged"],
25+
visibility = ["//visibility:private"],
26+
)
27+
28+
filegroup(
29+
name = "all-srcs",
30+
srcs = [":package-srcs"],
31+
tags = ["automanaged"],
32+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package install installs the experimental API group, making it available as
18+
// an option to all of the API encoding/decoding machinery.
19+
package install
20+
21+
import (
22+
"k8s.io/apimachinery/pkg/apimachinery/announced"
23+
"k8s.io/apimachinery/pkg/apimachinery/registered"
24+
"k8s.io/apimachinery/pkg/runtime"
25+
"k8s.io/client-go/pkg/apis/clientauthentication"
26+
"k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1"
27+
)
28+
29+
// Install registers the API group and adds types to a scheme
30+
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
31+
if err := announced.NewGroupMetaFactory(
32+
&announced.GroupMetaFactoryArgs{
33+
GroupName: clientauthentication.GroupName,
34+
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
35+
AddInternalObjectsToScheme: clientauthentication.AddToScheme,
36+
},
37+
announced.VersionToSchemeFunc{
38+
v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme,
39+
},
40+
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
41+
panic(err)
42+
}
43+
}
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package clientauthentication
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/runtime"
21+
"k8s.io/apimachinery/pkg/runtime/schema"
22+
)
23+
24+
// GroupName is the group name use in this package
25+
const GroupName = "client.authentication.k8s.io"
26+
27+
// SchemeGroupVersion is group version used to register these objects
28+
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
29+
30+
// Kind takes an unqualified kind and returns a Group qualified GroupKind
31+
func Kind(kind string) schema.GroupKind {
32+
return SchemeGroupVersion.WithKind(kind).GroupKind()
33+
}
34+
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
36+
func Resource(resource string) schema.GroupResource {
37+
return SchemeGroupVersion.WithResource(resource).GroupResource()
38+
}
39+
40+
var (
41+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
42+
AddToScheme = SchemeBuilder.AddToScheme
43+
)
44+
45+
func addKnownTypes(scheme *runtime.Scheme) error {
46+
scheme.AddKnownTypes(SchemeGroupVersion,
47+
&ExecCredential{},
48+
)
49+
return nil
50+
}
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package clientauthentication
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
24+
25+
// ExecCredentials is used by exec-based plugins to communicate credentials to
26+
// HTTP transports.
27+
type ExecCredential struct {
28+
metav1.TypeMeta
29+
30+
// Spec holds information passed to the plugin by the transport. This contains
31+
// request and runtime specific information, such as if the session is interactive.
32+
Spec ExecCredentialSpec
33+
34+
// Status is filled in by the plugin and holds the credentials that the transport
35+
// should use to contact the API.
36+
// +optional
37+
Status *ExecCredentialStatus
38+
}
39+
40+
// ExecCredenitalSpec holds request and runtime specific information provided by
41+
// the transport.
42+
type ExecCredentialSpec struct {
43+
// Response is populated when the transport encounters HTTP status codes, such as 401,
44+
// suggesting previous credentials were invalid.
45+
// +optional
46+
Response *Response
47+
48+
// Interactive is true when the transport detects the command is being called from an
49+
// interactive prompt.
50+
// +optional
51+
Interactive bool
52+
}
53+
54+
// ExecCredentialStatus holds credentials for the transport to use.
55+
type ExecCredentialStatus struct {
56+
// ExpirationTimestamp indicates a time when the provided credentials expire.
57+
// +optional
58+
ExpirationTimestamp *metav1.Time
59+
// Token is a bearer token used by the client for request authentication.
60+
Token string
61+
}
62+
63+
// Response defines metadata about a failed request, including HTTP status code and
64+
// response headers.
65+
type Response struct {
66+
// Headers holds HTTP headers returned by the server.
67+
Header map[string][]string
68+
// Code is the HTTP status code returned by the server.
69+
Code int32
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
load(
4+
"@io_bazel_rules_go//go:def.bzl",
5+
"go_library",
6+
)
7+
8+
go_library(
9+
name = "go_default_library",
10+
srcs = [
11+
"doc.go",
12+
"register.go",
13+
"types.go",
14+
"zz_generated.conversion.go",
15+
"zz_generated.deepcopy.go",
16+
"zz_generated.defaults.go",
17+
],
18+
importpath = "k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1",
19+
deps = [
20+
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
21+
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
22+
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
23+
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
24+
"//vendor/k8s.io/client-go/pkg/apis/clientauthentication:go_default_library",
25+
],
26+
)
27+
28+
filegroup(
29+
name = "package-srcs",
30+
srcs = glob(["**"]),
31+
tags = ["automanaged"],
32+
visibility = ["//visibility:private"],
33+
)
34+
35+
filegroup(
36+
name = "all-srcs",
37+
srcs = [":package-srcs"],
38+
tags = ["automanaged"],
39+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// +k8s:deepcopy-gen=package
18+
// +k8s:conversion-gen=k8s.io/client-go/pkg/apis/clientauthentication
19+
// +k8s:openapi-gen=true
20+
// +k8s:defaulter-gen=TypeMeta
21+
22+
// +groupName=client.authentication.k8s.io
23+
package v1alpha1 // import "k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
"k8s.io/apimachinery/pkg/runtime"
22+
"k8s.io/apimachinery/pkg/runtime/schema"
23+
)
24+
25+
// GroupName is the group name use in this package
26+
const GroupName = "client.authentication.k8s.io"
27+
28+
// SchemeGroupVersion is group version used to register these objects
29+
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
30+
31+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
32+
func Resource(resource string) schema.GroupResource {
33+
return SchemeGroupVersion.WithResource(resource).GroupResource()
34+
}
35+
36+
var (
37+
SchemeBuilder runtime.SchemeBuilder
38+
localSchemeBuilder = &SchemeBuilder
39+
AddToScheme = localSchemeBuilder.AddToScheme
40+
)
41+
42+
func init() {
43+
// We only register manually written functions here. The registration of the
44+
// generated functions takes place in the generated files. The separation
45+
// makes the code compile even when the generated files are missing.
46+
localSchemeBuilder.Register(addKnownTypes)
47+
}
48+
49+
func addKnownTypes(scheme *runtime.Scheme) error {
50+
scheme.AddKnownTypes(SchemeGroupVersion,
51+
&ExecCredential{},
52+
)
53+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
54+
return nil
55+
}

0 commit comments

Comments
 (0)