mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-03 18:26:59 +00:00
add support for /token subresource in serviceaccount registry
Kubernetes-commit: 8ad1c6655bde4ca8d61c3574980cffce5ee937a5
This commit is contained in:
parent
f09bc8b437
commit
d5f7182e00
@ -32,9 +32,11 @@ go_library(
|
|||||||
"service.go",
|
"service.go",
|
||||||
"service_expansion.go",
|
"service_expansion.go",
|
||||||
"serviceaccount.go",
|
"serviceaccount.go",
|
||||||
|
"serviceaccount_expansion.go",
|
||||||
],
|
],
|
||||||
importpath = "k8s.io/client-go/kubernetes/typed/core/v1",
|
importpath = "k8s.io/client-go/kubernetes/typed/core/v1",
|
||||||
deps = [
|
deps = [
|
||||||
|
"//vendor/k8s.io/api/authentication/v1:go_default_library",
|
||||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||||
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||||
"//vendor/k8s.io/api/policy/v1beta1:go_default_library",
|
"//vendor/k8s.io/api/policy/v1beta1:go_default_library",
|
||||||
|
@ -31,9 +31,11 @@ go_library(
|
|||||||
"fake_service.go",
|
"fake_service.go",
|
||||||
"fake_service_expansion.go",
|
"fake_service_expansion.go",
|
||||||
"fake_serviceaccount.go",
|
"fake_serviceaccount.go",
|
||||||
|
"fake_serviceaccount_expansion.go",
|
||||||
],
|
],
|
||||||
importpath = "k8s.io/client-go/kubernetes/typed/core/v1/fake",
|
importpath = "k8s.io/client-go/kubernetes/typed/core/v1/fake",
|
||||||
deps = [
|
deps = [
|
||||||
|
"//vendor/k8s.io/api/authentication/v1:go_default_library",
|
||||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||||
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||||
"//vendor/k8s.io/api/policy/v1beta1:go_default_library",
|
"//vendor/k8s.io/api/policy/v1beta1:go_default_library",
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2018 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 fake
|
||||||
|
|
||||||
|
import (
|
||||||
|
authenticationv1 "k8s.io/api/authentication/v1"
|
||||||
|
core "k8s.io/client-go/testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *FakeServiceAccounts) CreateToken(name string, tr *authenticationv1.TokenRequest) (*authenticationv1.TokenRequest, error) {
|
||||||
|
obj, err := c.Fake.Invokes(core.NewCreateSubresourceAction(serviceaccountsResource, name, "token", c.ns, tr), &authenticationv1.TokenRequest{})
|
||||||
|
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*authenticationv1.TokenRequest), err
|
||||||
|
}
|
@ -35,5 +35,3 @@ type ReplicationControllerExpansion interface{}
|
|||||||
type ResourceQuotaExpansion interface{}
|
type ResourceQuotaExpansion interface{}
|
||||||
|
|
||||||
type SecretExpansion interface{}
|
type SecretExpansion interface{}
|
||||||
|
|
||||||
type ServiceAccountExpansion interface{}
|
|
||||||
|
41
kubernetes/typed/core/v1/serviceaccount_expansion.go
Normal file
41
kubernetes/typed/core/v1/serviceaccount_expansion.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2018 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 (
|
||||||
|
authenticationv1 "k8s.io/api/authentication/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The ServiceAccountExpansion interface allows manually adding extra methods
|
||||||
|
// to the ServiceAccountInterface.
|
||||||
|
type ServiceAccountExpansion interface {
|
||||||
|
CreateToken(name string, tr *authenticationv1.TokenRequest) (*authenticationv1.TokenRequest, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateToken creates a new token for a serviceaccount.
|
||||||
|
func (c *serviceAccounts) CreateToken(name string, tr *authenticationv1.TokenRequest) (*authenticationv1.TokenRequest, error) {
|
||||||
|
result := &authenticationv1.TokenRequest{}
|
||||||
|
err := c.client.Post().
|
||||||
|
Namespace(c.ns).
|
||||||
|
Resource("serviceaccounts").
|
||||||
|
SubResource("token").
|
||||||
|
Name(name).
|
||||||
|
Body(tr).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return result, err
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user