mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
update staging
This commit is contained in:
parent
ee6752ef20
commit
af2c52085d
@ -46,7 +46,6 @@ filegroup(
|
|||||||
"//hack:all-srcs",
|
"//hack:all-srcs",
|
||||||
"//pkg:all-srcs",
|
"//pkg:all-srcs",
|
||||||
"//plugin:all-srcs",
|
"//plugin:all-srcs",
|
||||||
"//staging/src/k8s.io/client-go/pkg/util/cert/triple:all-srcs",
|
|
||||||
"//test:all-srcs",
|
"//test:all-srcs",
|
||||||
"//third_party:all-srcs",
|
"//third_party:all-srcs",
|
||||||
"//vendor:all-srcs",
|
"//vendor:all-srcs",
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// defaultRetries is the number of times a resource discovery is repeated if an api group disappears on the fly (e.g. ThirdPartyResources).
|
// defaultRetries is the number of times a resource discovery is repeated if an api group disappears on the fly (e.g. ThirdPartyResources).
|
||||||
@ -42,7 +42,7 @@ const defaultRetries = 2
|
|||||||
// DiscoveryInterface holds the methods that discover server-supported API groups,
|
// DiscoveryInterface holds the methods that discover server-supported API groups,
|
||||||
// versions and resources.
|
// versions and resources.
|
||||||
type DiscoveryInterface interface {
|
type DiscoveryInterface interface {
|
||||||
RESTClient() rest.Interface
|
RESTClient() restclient.Interface
|
||||||
ServerGroupsInterface
|
ServerGroupsInterface
|
||||||
ServerResourcesInterface
|
ServerResourcesInterface
|
||||||
ServerVersionInterface
|
ServerVersionInterface
|
||||||
@ -94,7 +94,7 @@ type SwaggerSchemaInterface interface {
|
|||||||
// DiscoveryClient implements the functions that discover server-supported API groups,
|
// DiscoveryClient implements the functions that discover server-supported API groups,
|
||||||
// versions and resources.
|
// versions and resources.
|
||||||
type DiscoveryClient struct {
|
type DiscoveryClient struct {
|
||||||
restClient rest.Interface
|
restClient restclient.Interface
|
||||||
|
|
||||||
LegacyPrefix string
|
LegacyPrefix string
|
||||||
}
|
}
|
||||||
@ -380,31 +380,31 @@ func withRetries(maxRetries int, f func(failEarly bool) ([]*metav1.APIResourceLi
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDiscoveryDefaults(config *rest.Config) error {
|
func setDiscoveryDefaults(config *restclient.Config) error {
|
||||||
config.APIPath = ""
|
config.APIPath = ""
|
||||||
config.GroupVersion = nil
|
config.GroupVersion = nil
|
||||||
codec := runtime.NoopEncoder{Decoder: api.Codecs.UniversalDecoder()}
|
codec := runtime.NoopEncoder{Decoder: api.Codecs.UniversalDecoder()}
|
||||||
config.NegotiatedSerializer = serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{Serializer: codec})
|
config.NegotiatedSerializer = serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{Serializer: codec})
|
||||||
if len(config.UserAgent) == 0 {
|
if len(config.UserAgent) == 0 {
|
||||||
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
config.UserAgent = restclient.DefaultKubernetesUserAgent()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. This client
|
// NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. This client
|
||||||
// can be used to discover supported resources in the API server.
|
// can be used to discover supported resources in the API server.
|
||||||
func NewDiscoveryClientForConfig(c *rest.Config) (*DiscoveryClient, error) {
|
func NewDiscoveryClientForConfig(c *restclient.Config) (*DiscoveryClient, error) {
|
||||||
config := *c
|
config := *c
|
||||||
if err := setDiscoveryDefaults(&config); err != nil {
|
if err := setDiscoveryDefaults(&config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
client, err := rest.UnversionedRESTClientFor(&config)
|
client, err := restclient.UnversionedRESTClientFor(&config)
|
||||||
return &DiscoveryClient{restClient: client, LegacyPrefix: "/api"}, err
|
return &DiscoveryClient{restClient: client, LegacyPrefix: "/api"}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. If
|
// NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. If
|
||||||
// there is an error, it panics.
|
// there is an error, it panics.
|
||||||
func NewDiscoveryClientForConfigOrDie(c *rest.Config) *DiscoveryClient {
|
func NewDiscoveryClientForConfigOrDie(c *restclient.Config) *DiscoveryClient {
|
||||||
client, err := NewDiscoveryClientForConfig(c)
|
client, err := NewDiscoveryClientForConfig(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -414,7 +414,7 @@ func NewDiscoveryClientForConfigOrDie(c *rest.Config) *DiscoveryClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new DiscoveryClient for the given RESTClient.
|
// New creates a new DiscoveryClient for the given RESTClient.
|
||||||
func NewDiscoveryClient(c rest.Interface) *DiscoveryClient {
|
func NewDiscoveryClient(c restclient.Interface) *DiscoveryClient {
|
||||||
return &DiscoveryClient{restClient: c, LegacyPrefix: "/api"}
|
return &DiscoveryClient{restClient: c, LegacyPrefix: "/api"}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ func stringDoesntExistIn(str string, slice []string) bool {
|
|||||||
|
|
||||||
// RESTClient returns a RESTClient that is used to communicate
|
// RESTClient returns a RESTClient that is used to communicate
|
||||||
// with API server by this client implementation.
|
// with API server by this client implementation.
|
||||||
func (c *DiscoveryClient) RESTClient() rest.Interface {
|
func (c *DiscoveryClient) RESTClient() restclient.Interface {
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetServerVersion(t *testing.T) {
|
func TestGetServerVersion(t *testing.T) {
|
||||||
@ -50,7 +50,7 @@ func TestGetServerVersion(t *testing.T) {
|
|||||||
w.Write(output)
|
w.Write(output)
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
|
|
||||||
got, err := client.ServerVersion()
|
got, err := client.ServerVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -85,7 +85,7 @@ func TestGetServerGroupsWithV1Server(t *testing.T) {
|
|||||||
w.Write(output)
|
w.Write(output)
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
// ServerGroups should not return an error even if server returns error at /api and /apis
|
// ServerGroups should not return an error even if server returns error at /api and /apis
|
||||||
apiGroupList, err := client.ServerGroups()
|
apiGroupList, err := client.ServerGroups()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -103,7 +103,7 @@ func TestGetServerGroupsWithBrokenServer(t *testing.T) {
|
|||||||
w.WriteHeader(statusCode)
|
w.WriteHeader(statusCode)
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
// ServerGroups should not return an error even if server returns Not Found or Forbidden error at all end points
|
// ServerGroups should not return an error even if server returns Not Found or Forbidden error at all end points
|
||||||
apiGroupList, err := client.ServerGroups()
|
apiGroupList, err := client.ServerGroups()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -140,7 +140,7 @@ func TestGetServerResourcesWithV1Server(t *testing.T) {
|
|||||||
w.Write(output)
|
w.Write(output)
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
// ServerResources should not return an error even if server returns error at /api/v1.
|
// ServerResources should not return an error even if server returns error at /api/v1.
|
||||||
serverResources, err := client.ServerResources()
|
serverResources, err := client.ServerResources()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -232,7 +232,7 @@ func TestGetServerResources(t *testing.T) {
|
|||||||
w.Write(output)
|
w.Write(output)
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
got, err := client.ServerResourcesForGroupVersion(test.request)
|
got, err := client.ServerResourcesForGroupVersion(test.request)
|
||||||
if test.expectErr {
|
if test.expectErr {
|
||||||
@ -295,7 +295,7 @@ func TestGetSwaggerSchema(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
got, err := client.SwaggerSchema(v1.SchemeGroupVersion)
|
got, err := client.SwaggerSchema(v1.SchemeGroupVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected encoding error: %v", err)
|
t.Fatalf("unexpected encoding error: %v", err)
|
||||||
@ -314,7 +314,7 @@ func TestGetSwaggerSchemaFail(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
got, err := client.SwaggerSchema(schema.GroupVersion{Group: "api.group", Version: "v4"})
|
got, err := client.SwaggerSchema(schema.GroupVersion{Group: "api.group", Version: "v4"})
|
||||||
if got != nil {
|
if got != nil {
|
||||||
t.Fatalf("unexpected response: %v", got)
|
t.Fatalf("unexpected response: %v", got)
|
||||||
@ -427,7 +427,7 @@ func TestServerPreferredResources(t *testing.T) {
|
|||||||
server := httptest.NewServer(http.HandlerFunc(test.response))
|
server := httptest.NewServer(http.HandlerFunc(test.response))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
resources, err := client.ServerPreferredResources()
|
resources, err := client.ServerPreferredResources()
|
||||||
if test.expectErr != nil {
|
if test.expectErr != nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -540,7 +540,7 @@ func TestServerPreferredResourcesRetries(t *testing.T) {
|
|||||||
server := httptest.NewServer(http.HandlerFunc(response(tc.responseErrors)))
|
server := httptest.NewServer(http.HandlerFunc(response(tc.responseErrors)))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
resources, err := client.ServerPreferredResources()
|
resources, err := client.ServerPreferredResources()
|
||||||
if !tc.expectedError(err) {
|
if !tc.expectedError(err) {
|
||||||
t.Errorf("case %d: unexpected error: %v", i, err)
|
t.Errorf("case %d: unexpected error: %v", i, err)
|
||||||
@ -711,7 +711,7 @@ func TestServerPreferredNamespacedResources(t *testing.T) {
|
|||||||
server := httptest.NewServer(http.HandlerFunc(test.response))
|
server := httptest.NewServer(http.HandlerFunc(test.response))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||||
resources, err := client.ServerPreferredNamespacedResources()
|
resources, err := client.ServerPreferredNamespacedResources()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("[%d] unexpected error: %v", i, err)
|
t.Errorf("[%d] unexpected error: %v", i, err)
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
kubeversion "k8s.io/client-go/pkg/version"
|
kubeversion "k8s.io/client-go/pkg/version"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/testing"
|
"k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -92,6 +92,6 @@ func (c *FakeDiscovery) SwaggerSchema(version schema.GroupVersion) (*swagger.Api
|
|||||||
return &swagger.ApiDeclaration{}, nil
|
return &swagger.ApiDeclaration{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeDiscovery) RESTClient() rest.Interface {
|
func (c *FakeDiscovery) RESTClient() restclient.Interface {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
"k8s.io/client-go/discovery"
|
"k8s.io/client-go/discovery"
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/pkg/api/testapi"
|
"k8s.io/client-go/pkg/api/testapi"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/rest/fake"
|
"k8s.io/client-go/rest/fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -139,8 +139,8 @@ func TestNegotiateVersion(t *testing.T) {
|
|||||||
return &http.Response{StatusCode: test.statusCode, Header: header, Body: objBody(&uapi.APIVersions{Versions: test.serverVersions})}, nil
|
return &http.Response{StatusCode: test.statusCode, Header: header, Body: objBody(&uapi.APIVersions{Versions: test.serverVersions})}, nil
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
c := discovery.NewDiscoveryClientForConfigOrDie(&rest.Config{})
|
c := discovery.NewDiscoveryClientForConfigOrDie(&restclient.Config{})
|
||||||
c.RESTClient().(*rest.RESTClient).Client = fakeClient.Client
|
c.RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
|
||||||
response, err := discovery.NegotiateVersion(c, test.requiredVersion, test.clientVersions)
|
response, err := discovery.NegotiateVersion(c, test.requiredVersion, test.clientVersions)
|
||||||
if err == nil && test.expectErr != nil {
|
if err == nil && test.expectErr != nil {
|
||||||
t.Errorf("expected error, got nil for [%s].", test.name)
|
t.Errorf("expected error, got nil for [%s].", test.name)
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/rest/fake"
|
"k8s.io/client-go/rest/fake"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful/swagger"
|
"github.com/emicklei/go-restful/swagger"
|
||||||
@ -246,7 +246,7 @@ func (c *fakeCachedDiscoveryInterface) Invalidate() {
|
|||||||
c.enabledA = true
|
c.enabledA = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *fakeCachedDiscoveryInterface) RESTClient() rest.Interface {
|
func (c *fakeCachedDiscoveryInterface) RESTClient() restclient.Interface {
|
||||||
return &fake.RESTClient{}
|
return &fake.RESTClient{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,19 +37,19 @@ import (
|
|||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/pkg/util/flowcontrol"
|
"k8s.io/client-go/pkg/util/flowcontrol"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client is a Kubernetes client that allows you to access metadata
|
// Client is a Kubernetes client that allows you to access metadata
|
||||||
// and manipulate metadata of a Kubernetes API group.
|
// and manipulate metadata of a Kubernetes API group.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
cl *rest.RESTClient
|
cl *restclient.RESTClient
|
||||||
parameterCodec runtime.ParameterCodec
|
parameterCodec runtime.ParameterCodec
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient returns a new client based on the passed in config. The
|
// NewClient returns a new client based on the passed in config. The
|
||||||
// codec is ignored, as the dynamic client uses it's own codec.
|
// codec is ignored, as the dynamic client uses it's own codec.
|
||||||
func NewClient(conf *rest.Config) (*Client, error) {
|
func NewClient(conf *restclient.Config) (*Client, error) {
|
||||||
// avoid changing the original config
|
// avoid changing the original config
|
||||||
confCopy := *conf
|
confCopy := *conf
|
||||||
conf = &confCopy
|
conf = &confCopy
|
||||||
@ -66,10 +66,10 @@ func NewClient(conf *rest.Config) (*Client, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(conf.UserAgent) == 0 {
|
if len(conf.UserAgent) == 0 {
|
||||||
conf.UserAgent = rest.DefaultKubernetesUserAgent()
|
conf.UserAgent = restclient.DefaultKubernetesUserAgent()
|
||||||
}
|
}
|
||||||
|
|
||||||
cl, err := rest.RESTClientFor(conf)
|
cl, err := restclient.RESTClientFor(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ func (c *Client) ParameterCodec(parameterCodec runtime.ParameterCodec) *Client {
|
|||||||
// ResourceClient is an API interface to a specific resource under a
|
// ResourceClient is an API interface to a specific resource under a
|
||||||
// dynamic client.
|
// dynamic client.
|
||||||
type ResourceClient struct {
|
type ResourceClient struct {
|
||||||
cl *rest.RESTClient
|
cl *restclient.RESTClient
|
||||||
resource *metav1.APIResource
|
resource *metav1.APIResource
|
||||||
ns string
|
ns string
|
||||||
parameterCodec runtime.ParameterCodec
|
parameterCodec runtime.ParameterCodec
|
||||||
@ -242,8 +242,8 @@ func (dynamicCodec) Encode(obj runtime.Object, w io.Writer) error {
|
|||||||
return unstructured.UnstructuredJSONScheme.Encode(obj, w)
|
return unstructured.UnstructuredJSONScheme.Encode(obj, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContentConfig returns a rest.ContentConfig for dynamic types.
|
// ContentConfig returns a restclient.ContentConfig for dynamic types.
|
||||||
func ContentConfig() rest.ContentConfig {
|
func ContentConfig() restclient.ContentConfig {
|
||||||
var jsonInfo runtime.SerializerInfo
|
var jsonInfo runtime.SerializerInfo
|
||||||
// TODO: api.Codecs here should become "pkg/apis/server/scheme" which is the minimal core you need
|
// TODO: api.Codecs here should become "pkg/apis/server/scheme" which is the minimal core you need
|
||||||
// to talk to a kubernetes server
|
// to talk to a kubernetes server
|
||||||
@ -256,7 +256,7 @@ func ContentConfig() rest.ContentConfig {
|
|||||||
|
|
||||||
jsonInfo.Serializer = dynamicCodec{}
|
jsonInfo.Serializer = dynamicCodec{}
|
||||||
jsonInfo.PrettySerializer = nil
|
jsonInfo.PrettySerializer = nil
|
||||||
return rest.ContentConfig{
|
return restclient.ContentConfig{
|
||||||
AcceptContentTypes: runtime.ContentTypeJSON,
|
AcceptContentTypes: runtime.ContentTypeJSON,
|
||||||
ContentType: runtime.ContentTypeJSON,
|
ContentType: runtime.ContentTypeJSON,
|
||||||
NegotiatedSerializer: serializer.NegotiatedSerializerWrapper(jsonInfo),
|
NegotiatedSerializer: serializer.NegotiatedSerializerWrapper(jsonInfo),
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ClientPool manages a pool of dynamic clients.
|
// ClientPool manages a pool of dynamic clients.
|
||||||
@ -50,7 +50,7 @@ func LegacyAPIPathResolverFunc(kind schema.GroupVersionKind) string {
|
|||||||
// is asked to retrieve. This type is thread safe.
|
// is asked to retrieve. This type is thread safe.
|
||||||
type clientPoolImpl struct {
|
type clientPoolImpl struct {
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
config *rest.Config
|
config *restclient.Config
|
||||||
clients map[schema.GroupVersion]*Client
|
clients map[schema.GroupVersion]*Client
|
||||||
apiPathResolverFunc APIPathResolverFunc
|
apiPathResolverFunc APIPathResolverFunc
|
||||||
mapper meta.RESTMapper
|
mapper meta.RESTMapper
|
||||||
@ -59,7 +59,7 @@ type clientPoolImpl struct {
|
|||||||
// NewClientPool returns a ClientPool from the specified config. It reuses clients for the the same
|
// NewClientPool returns a ClientPool from the specified config. It reuses clients for the the same
|
||||||
// group version. It is expected this type may be wrapped by specific logic that special cases certain
|
// group version. It is expected this type may be wrapped by specific logic that special cases certain
|
||||||
// resources or groups.
|
// resources or groups.
|
||||||
func NewClientPool(config *rest.Config, mapper meta.RESTMapper, apiPathResolverFunc APIPathResolverFunc) ClientPool {
|
func NewClientPool(config *restclient.Config, mapper meta.RESTMapper, apiPathResolverFunc APIPathResolverFunc) ClientPool {
|
||||||
confCopy := *config
|
confCopy := *config
|
||||||
|
|
||||||
return &clientPoolImpl{
|
return &clientPoolImpl{
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
restclientwatch "k8s.io/client-go/rest/watch"
|
restclientwatch "k8s.io/client-go/rest/watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ func getObject(version, kind, name string) *unstructured.Unstructured {
|
|||||||
|
|
||||||
func getClientServer(gv *schema.GroupVersion, h func(http.ResponseWriter, *http.Request)) (*Client, *httptest.Server, error) {
|
func getClientServer(gv *schema.GroupVersion, h func(http.ResponseWriter, *http.Request)) (*Client, *httptest.Server, error) {
|
||||||
srv := httptest.NewServer(http.HandlerFunc(h))
|
srv := httptest.NewServer(http.HandlerFunc(h))
|
||||||
cl, err := NewClient(&rest.Config{
|
cl, err := NewClient(&restclient.Config{
|
||||||
Host: srv.URL,
|
Host: srv.URL,
|
||||||
ContentConfig: rest.ContentConfig{GroupVersion: gv},
|
ContentConfig: restclient.ContentConfig{GroupVersion: gv},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
srv.Close()
|
srv.Close()
|
||||||
|
@ -19,7 +19,7 @@ package fake
|
|||||||
import (
|
import (
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
policy "k8s.io/client-go/pkg/apis/policy/v1beta1"
|
policy "k8s.io/client-go/pkg/apis/policy/v1beta1"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/testing"
|
"k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ func (c *FakePods) Bind(binding *v1.Binding) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakePods) GetLogs(name string, opts *v1.PodLogOptions) *rest.Request {
|
func (c *FakePods) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request {
|
||||||
action := testing.GenericActionImpl{}
|
action := testing.GenericActionImpl{}
|
||||||
action.Verb = "get"
|
action.Verb = "get"
|
||||||
action.Namespace = c.ns
|
action.Namespace = c.ns
|
||||||
@ -43,7 +43,7 @@ func (c *FakePods) GetLogs(name string, opts *v1.PodLogOptions) *rest.Request {
|
|||||||
action.Value = opts
|
action.Value = opts
|
||||||
|
|
||||||
_, _ = c.Fake.Invokes(action, &v1.Pod{})
|
_, _ = c.Fake.Invokes(action, &v1.Pod{})
|
||||||
return &rest.Request{}
|
return &restclient.Request{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakePods) Evict(eviction *policy.Eviction) error {
|
func (c *FakePods) Evict(eviction *policy.Eviction) error {
|
||||||
|
@ -17,10 +17,10 @@ limitations under the License.
|
|||||||
package fake
|
package fake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/testing"
|
"k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *FakeServices) ProxyGet(scheme, name, port, path string, params map[string]string) rest.ResponseWrapper {
|
func (c *FakeServices) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper {
|
||||||
return c.Fake.InvokesProxy(testing.NewProxyGetAction(servicesResource, c.ns, scheme, name, port, path, params))
|
return c.Fake.InvokesProxy(testing.NewProxyGetAction(servicesResource, c.ns, scheme, name, port, path, params))
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ import (
|
|||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
policy "k8s.io/client-go/pkg/apis/policy/v1beta1"
|
policy "k8s.io/client-go/pkg/apis/policy/v1beta1"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The PodExpansion interface allows manually adding extra methods to the PodInterface.
|
// The PodExpansion interface allows manually adding extra methods to the PodInterface.
|
||||||
type PodExpansion interface {
|
type PodExpansion interface {
|
||||||
Bind(binding *v1.Binding) error
|
Bind(binding *v1.Binding) error
|
||||||
Evict(eviction *policy.Eviction) error
|
Evict(eviction *policy.Eviction) error
|
||||||
GetLogs(name string, opts *v1.PodLogOptions) *rest.Request
|
GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
||||||
@ -40,6 +40,6 @@ func (c *pods) Evict(eviction *policy.Eviction) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get constructs a request for getting the logs for a pod
|
// Get constructs a request for getting the logs for a pod
|
||||||
func (c *pods) GetLogs(name string, opts *v1.PodLogOptions) *rest.Request {
|
func (c *pods) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request {
|
||||||
return c.client.Get().Namespace(c.ns).Name(name).Resource("pods").SubResource("log").VersionedParams(opts, api.ParameterCodec)
|
return c.client.Get().Namespace(c.ns).Name(name).Resource("pods").SubResource("log").VersionedParams(opts, api.ParameterCodec)
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,16 @@ package v1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/apimachinery/pkg/util/net"
|
"k8s.io/apimachinery/pkg/util/net"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The ServiceExpansion interface allows manually adding extra methods to the ServiceInterface.
|
// The ServiceExpansion interface allows manually adding extra methods to the ServiceInterface.
|
||||||
type ServiceExpansion interface {
|
type ServiceExpansion interface {
|
||||||
ProxyGet(scheme, name, port, path string, params map[string]string) rest.ResponseWrapper
|
ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProxyGet returns a response of the service by calling it through the proxy.
|
// ProxyGet returns a response of the service by calling it through the proxy.
|
||||||
func (c *services) ProxyGet(scheme, name, port, path string, params map[string]string) rest.ResponseWrapper {
|
func (c *services) ProxyGet(scheme, name, port, path string, params map[string]string) restclient.ResponseWrapper {
|
||||||
request := c.client.Get().
|
request := c.client.Get().
|
||||||
Prefix("proxy").
|
Prefix("proxy").
|
||||||
Namespace(c.ns).
|
Namespace(c.ns).
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1beta1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,batch/v2alpha1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1]
|
|
||||||
|
|
||||||
// This package has the automatically generated typed clients.
|
|
||||||
package v1alpha1
|
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1beta1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,batch/v2alpha1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1]
|
|
||||||
|
|
||||||
// Package fake has the automatically generated clients.
|
|
||||||
package fake
|
|
@ -1,128 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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 (
|
|
||||||
labels "k8s.io/apimachinery/pkg/labels"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
v1alpha1 "k8s.io/client-go/pkg/apis/policy/v1alpha1"
|
|
||||||
testing "k8s.io/client-go/testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FakePodDisruptionBudgets implements PodDisruptionBudgetInterface
|
|
||||||
type FakePodDisruptionBudgets struct {
|
|
||||||
Fake *FakePolicyV1alpha1
|
|
||||||
ns string
|
|
||||||
}
|
|
||||||
|
|
||||||
var poddisruptionbudgetsResource = schema.GroupVersionResource{Group: "policy", Version: "v1alpha1", Resource: "poddisruptionbudgets"}
|
|
||||||
|
|
||||||
func (c *FakePodDisruptionBudgets) Create(podDisruptionBudget *v1alpha1.PodDisruptionBudget) (result *v1alpha1.PodDisruptionBudget, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewCreateAction(poddisruptionbudgetsResource, c.ns, podDisruptionBudget), &v1alpha1.PodDisruptionBudget{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodDisruptionBudget), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakePodDisruptionBudgets) Update(podDisruptionBudget *v1alpha1.PodDisruptionBudget) (result *v1alpha1.PodDisruptionBudget, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewUpdateAction(poddisruptionbudgetsResource, c.ns, podDisruptionBudget), &v1alpha1.PodDisruptionBudget{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodDisruptionBudget), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakePodDisruptionBudgets) UpdateStatus(podDisruptionBudget *v1alpha1.PodDisruptionBudget) (*v1alpha1.PodDisruptionBudget, error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewUpdateSubresourceAction(poddisruptionbudgetsResource, "status", c.ns, podDisruptionBudget), &v1alpha1.PodDisruptionBudget{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodDisruptionBudget), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakePodDisruptionBudgets) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
_, err := c.Fake.
|
|
||||||
Invokes(testing.NewDeleteAction(poddisruptionbudgetsResource, c.ns, name), &v1alpha1.PodDisruptionBudget{})
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakePodDisruptionBudgets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
action := testing.NewDeleteCollectionAction(poddisruptionbudgetsResource, c.ns, listOptions)
|
|
||||||
|
|
||||||
_, err := c.Fake.Invokes(action, &v1alpha1.PodDisruptionBudgetList{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakePodDisruptionBudgets) Get(name string) (result *v1alpha1.PodDisruptionBudget, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewGetAction(poddisruptionbudgetsResource, c.ns, name), &v1alpha1.PodDisruptionBudget{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodDisruptionBudget), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakePodDisruptionBudgets) List(opts v1.ListOptions) (result *v1alpha1.PodDisruptionBudgetList, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewListAction(poddisruptionbudgetsResource, c.ns, opts), &v1alpha1.PodDisruptionBudgetList{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
|
||||||
if label == nil {
|
|
||||||
label = labels.Everything()
|
|
||||||
}
|
|
||||||
list := &v1alpha1.PodDisruptionBudgetList{}
|
|
||||||
for _, item := range obj.(*v1alpha1.PodDisruptionBudgetList).Items {
|
|
||||||
if label.Matches(labels.Set(item.Labels)) {
|
|
||||||
list.Items = append(list.Items, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested podDisruptionBudgets.
|
|
||||||
func (c *FakePodDisruptionBudgets) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
return c.Fake.
|
|
||||||
InvokesWatch(testing.NewWatchAction(poddisruptionbudgetsResource, c.ns, opts))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched podDisruptionBudget.
|
|
||||||
func (c *FakePodDisruptionBudgets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodDisruptionBudget, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewPatchSubresourceAction(poddisruptionbudgetsResource, c.ns, name, data, subresources...), &v1alpha1.PodDisruptionBudget{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodDisruptionBudget), err
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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 (
|
|
||||||
v1alpha1 "k8s.io/client-go/kubernetes/typed/policy/v1alpha1"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
testing "k8s.io/client-go/testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
type FakePolicyV1alpha1 struct {
|
|
||||||
*testing.Fake
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakePolicyV1alpha1) PodDisruptionBudgets(namespace string) v1alpha1.PodDisruptionBudgetInterface {
|
|
||||||
return &FakePodDisruptionBudgets{c, namespace}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RESTClient returns a RESTClient that is used to communicate
|
|
||||||
// with API server by this client implementation.
|
|
||||||
func (c *FakePolicyV1alpha1) RESTClient() rest.Interface {
|
|
||||||
var ret *rest.RESTClient
|
|
||||||
return ret
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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 v1alpha1
|
|
||||||
|
|
||||||
type PodDisruptionBudgetExpansion interface{}
|
|
@ -1,168 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
api "k8s.io/client-go/pkg/api"
|
|
||||||
v1 "k8s.io/client-go/pkg/api/v1"
|
|
||||||
v1alpha1 "k8s.io/client-go/pkg/apis/policy/v1alpha1"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PodDisruptionBudgetsGetter has a method to return a PodDisruptionBudgetInterface.
|
|
||||||
// A group's client should implement this interface.
|
|
||||||
type PodDisruptionBudgetsGetter interface {
|
|
||||||
PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodDisruptionBudgetInterface has methods to work with PodDisruptionBudget resources.
|
|
||||||
type PodDisruptionBudgetInterface interface {
|
|
||||||
Create(*v1alpha1.PodDisruptionBudget) (*v1alpha1.PodDisruptionBudget, error)
|
|
||||||
Update(*v1alpha1.PodDisruptionBudget) (*v1alpha1.PodDisruptionBudget, error)
|
|
||||||
UpdateStatus(*v1alpha1.PodDisruptionBudget) (*v1alpha1.PodDisruptionBudget, error)
|
|
||||||
Delete(name string, options *v1.DeleteOptions) error
|
|
||||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
|
||||||
Get(name string) (*v1alpha1.PodDisruptionBudget, error)
|
|
||||||
List(opts v1.ListOptions) (*v1alpha1.PodDisruptionBudgetList, error)
|
|
||||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
|
||||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodDisruptionBudget, err error)
|
|
||||||
PodDisruptionBudgetExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// podDisruptionBudgets implements PodDisruptionBudgetInterface
|
|
||||||
type podDisruptionBudgets struct {
|
|
||||||
client rest.Interface
|
|
||||||
ns string
|
|
||||||
}
|
|
||||||
|
|
||||||
// newPodDisruptionBudgets returns a PodDisruptionBudgets
|
|
||||||
func newPodDisruptionBudgets(c *PolicyV1alpha1Client, namespace string) *podDisruptionBudgets {
|
|
||||||
return &podDisruptionBudgets{
|
|
||||||
client: c.RESTClient(),
|
|
||||||
ns: namespace,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create takes the representation of a podDisruptionBudget and creates it. Returns the server's representation of the podDisruptionBudget, and an error, if there is any.
|
|
||||||
func (c *podDisruptionBudgets) Create(podDisruptionBudget *v1alpha1.PodDisruptionBudget) (result *v1alpha1.PodDisruptionBudget, err error) {
|
|
||||||
result = &v1alpha1.PodDisruptionBudget{}
|
|
||||||
err = c.client.Post().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("poddisruptionbudgets").
|
|
||||||
Body(podDisruptionBudget).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update takes the representation of a podDisruptionBudget and updates it. Returns the server's representation of the podDisruptionBudget, and an error, if there is any.
|
|
||||||
func (c *podDisruptionBudgets) Update(podDisruptionBudget *v1alpha1.PodDisruptionBudget) (result *v1alpha1.PodDisruptionBudget, err error) {
|
|
||||||
result = &v1alpha1.PodDisruptionBudget{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("poddisruptionbudgets").
|
|
||||||
Name(podDisruptionBudget.Name).
|
|
||||||
Body(podDisruptionBudget).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *podDisruptionBudgets) UpdateStatus(podDisruptionBudget *v1alpha1.PodDisruptionBudget) (result *v1alpha1.PodDisruptionBudget, err error) {
|
|
||||||
result = &v1alpha1.PodDisruptionBudget{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("poddisruptionbudgets").
|
|
||||||
Name(podDisruptionBudget.Name).
|
|
||||||
SubResource("status").
|
|
||||||
Body(podDisruptionBudget).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete takes name of the podDisruptionBudget and deletes it. Returns an error if one occurs.
|
|
||||||
func (c *podDisruptionBudgets) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
return c.client.Delete().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("poddisruptionbudgets").
|
|
||||||
Name(name).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCollection deletes a collection of objects.
|
|
||||||
func (c *podDisruptionBudgets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
return c.client.Delete().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("poddisruptionbudgets").
|
|
||||||
VersionedParams(&listOptions, api.ParameterCodec).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get takes name of the podDisruptionBudget, and returns the corresponding podDisruptionBudget object, and an error if there is any.
|
|
||||||
func (c *podDisruptionBudgets) Get(name string) (result *v1alpha1.PodDisruptionBudget, err error) {
|
|
||||||
result = &v1alpha1.PodDisruptionBudget{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("poddisruptionbudgets").
|
|
||||||
Name(name).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// List takes label and field selectors, and returns the list of PodDisruptionBudgets that match those selectors.
|
|
||||||
func (c *podDisruptionBudgets) List(opts v1.ListOptions) (result *v1alpha1.PodDisruptionBudgetList, err error) {
|
|
||||||
result = &v1alpha1.PodDisruptionBudgetList{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("poddisruptionbudgets").
|
|
||||||
VersionedParams(&opts, api.ParameterCodec).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested podDisruptionBudgets.
|
|
||||||
func (c *podDisruptionBudgets) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
return c.client.Get().
|
|
||||||
Prefix("watch").
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("poddisruptionbudgets").
|
|
||||||
VersionedParams(&opts, api.ParameterCodec).
|
|
||||||
Watch()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched podDisruptionBudget.
|
|
||||||
func (c *podDisruptionBudgets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodDisruptionBudget, err error) {
|
|
||||||
result = &v1alpha1.PodDisruptionBudget{}
|
|
||||||
err = c.client.Patch(pt).
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("poddisruptionbudgets").
|
|
||||||
SubResource(subresources...).
|
|
||||||
Name(name).
|
|
||||||
Body(data).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
fmt "fmt"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
|
||||||
api "k8s.io/client-go/pkg/api"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PolicyV1alpha1Interface interface {
|
|
||||||
RESTClient() rest.Interface
|
|
||||||
PodDisruptionBudgetsGetter
|
|
||||||
}
|
|
||||||
|
|
||||||
// PolicyV1alpha1Client is used to interact with features provided by the k8s.io/kubernetes/pkg/apimachinery/registered.Group group.
|
|
||||||
type PolicyV1alpha1Client struct {
|
|
||||||
restClient rest.Interface
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *PolicyV1alpha1Client) PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface {
|
|
||||||
return newPodDisruptionBudgets(c, namespace)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewForConfig creates a new PolicyV1alpha1Client for the given config.
|
|
||||||
func NewForConfig(c *rest.Config) (*PolicyV1alpha1Client, error) {
|
|
||||||
config := *c
|
|
||||||
if err := setConfigDefaults(&config); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
client, err := rest.RESTClientFor(&config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &PolicyV1alpha1Client{client}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewForConfigOrDie creates a new PolicyV1alpha1Client for the given config and
|
|
||||||
// panics if there is an error in the config.
|
|
||||||
func NewForConfigOrDie(c *rest.Config) *PolicyV1alpha1Client {
|
|
||||||
client, err := NewForConfig(c)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return client
|
|
||||||
}
|
|
||||||
|
|
||||||
// New creates a new PolicyV1alpha1Client for the given RESTClient.
|
|
||||||
func New(c rest.Interface) *PolicyV1alpha1Client {
|
|
||||||
return &PolicyV1alpha1Client{c}
|
|
||||||
}
|
|
||||||
|
|
||||||
func setConfigDefaults(config *rest.Config) error {
|
|
||||||
gv, err := schema.ParseGroupVersion("policy/v1alpha1")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// if policy/v1alpha1 is not enabled, return an error
|
|
||||||
if !api.Registry.IsEnabledVersion(gv) {
|
|
||||||
return fmt.Errorf("policy/v1alpha1 is not enabled")
|
|
||||||
}
|
|
||||||
config.APIPath = "/apis"
|
|
||||||
if config.UserAgent == "" {
|
|
||||||
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
|
||||||
}
|
|
||||||
copyGroupVersion := gv
|
|
||||||
config.GroupVersion = ©GroupVersion
|
|
||||||
|
|
||||||
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RESTClient returns a RESTClient that is used to communicate
|
|
||||||
// with API server by this client implementation.
|
|
||||||
func (c *PolicyV1alpha1Client) RESTClient() rest.Interface {
|
|
||||||
if c == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return c.restClient
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2015 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 path
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NameMayNotBe specifies strings that cannot be used as names specified as path segments (like the REST API or etcd store)
|
|
||||||
var NameMayNotBe = []string{".", ".."}
|
|
||||||
|
|
||||||
// NameMayNotContain specifies substrings that cannot be used in names specified as path segments (like the REST API or etcd store)
|
|
||||||
var NameMayNotContain = []string{"/", "%"}
|
|
||||||
|
|
||||||
// IsValidPathSegmentName validates the name can be safely encoded as a path segment
|
|
||||||
func IsValidPathSegmentName(name string) []string {
|
|
||||||
for _, illegalName := range NameMayNotBe {
|
|
||||||
if name == illegalName {
|
|
||||||
return []string{fmt.Sprintf(`may not be '%s'`, illegalName)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var errors []string
|
|
||||||
for _, illegalContent := range NameMayNotContain {
|
|
||||||
if strings.Contains(name, illegalContent) {
|
|
||||||
errors = append(errors, fmt.Sprintf(`may not contain '%s'`, illegalContent))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return errors
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsValidPathSegmentPrefix validates the name can be used as a prefix for a name which will be encoded as a path segment
|
|
||||||
// It does not check for exact matches with disallowed names, since an arbitrary suffix might make the name valid
|
|
||||||
func IsValidPathSegmentPrefix(name string) []string {
|
|
||||||
var errors []string
|
|
||||||
for _, illegalContent := range NameMayNotContain {
|
|
||||||
if strings.Contains(name, illegalContent) {
|
|
||||||
errors = append(errors, fmt.Sprintf(`may not contain '%s'`, illegalContent))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return errors
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidatePathSegmentName validates the name can be safely encoded as a path segment
|
|
||||||
func ValidatePathSegmentName(name string, prefix bool) []string {
|
|
||||||
if prefix {
|
|
||||||
return IsValidPathSegmentPrefix(name)
|
|
||||||
} else {
|
|
||||||
return IsValidPathSegmentName(name)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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 policy is for any kind of policy object. Suitable examples, even if
|
|
||||||
// they aren't all here, are PodDisruptionBudget, PodSecurityPolicy,
|
|
||||||
// NetworkPolicy, etc.
|
|
||||||
package v1alpha1
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2015 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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GroupName is the group name use in this package
|
|
||||||
const GroupName = "policy"
|
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
|
||||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
|
|
||||||
|
|
||||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
|
||||||
func Resource(resource string) schema.GroupResource {
|
|
||||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
|
||||||
AddToScheme = SchemeBuilder.AddToScheme
|
|
||||||
)
|
|
||||||
|
|
||||||
// Adds the list of known types to api.Scheme.
|
|
||||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
|
||||||
&PodDisruptionBudget{},
|
|
||||||
&PodDisruptionBudgetList{},
|
|
||||||
&Eviction{},
|
|
||||||
&v1.ListOptions{},
|
|
||||||
&v1.DeleteOptions{},
|
|
||||||
&metav1.ExportOptions{},
|
|
||||||
&metav1.GetOptions{},
|
|
||||||
)
|
|
||||||
// Add the watch version that applies
|
|
||||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
|
||||||
"k8s.io/client-go/pkg/util/intstr"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PodDisruptionBudgetSpec is a description of a PodDisruptionBudget.
|
|
||||||
type PodDisruptionBudgetSpec struct {
|
|
||||||
// An eviction is allowed if at least "minAvailable" pods selected by
|
|
||||||
// "selector" will still be available after the eviction, i.e. even in the
|
|
||||||
// absence of the evicted pod. So for example you can prevent all voluntary
|
|
||||||
// evictions by specifying "100%".
|
|
||||||
// +optional
|
|
||||||
MinAvailable intstr.IntOrString `json:"minAvailable,omitempty" protobuf:"bytes,1,opt,name=minAvailable"`
|
|
||||||
|
|
||||||
// Label query over pods whose evictions are managed by the disruption
|
|
||||||
// budget.
|
|
||||||
// +optional
|
|
||||||
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodDisruptionBudgetStatus represents information about the status of a
|
|
||||||
// PodDisruptionBudget. Status may trail the actual state of a system.
|
|
||||||
type PodDisruptionBudgetStatus struct {
|
|
||||||
// Whether or not a disruption is currently allowed.
|
|
||||||
PodDisruptionAllowed bool `json:"disruptionAllowed" protobuf:"varint,1,opt,name=disruptionAllowed"`
|
|
||||||
|
|
||||||
// current number of healthy pods
|
|
||||||
CurrentHealthy int32 `json:"currentHealthy" protobuf:"varint,2,opt,name=currentHealthy"`
|
|
||||||
|
|
||||||
// minimum desired number of healthy pods
|
|
||||||
DesiredHealthy int32 `json:"desiredHealthy" protobuf:"varint,3,opt,name=desiredHealthy"`
|
|
||||||
|
|
||||||
// total number of pods counted by this disruption budget
|
|
||||||
ExpectedPods int32 `json:"expectedPods" protobuf:"varint,4,opt,name=expectedPods"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// +genclient=true
|
|
||||||
|
|
||||||
// PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods
|
|
||||||
type PodDisruptionBudget struct {
|
|
||||||
metav1.TypeMeta `json:",inline"`
|
|
||||||
// +optional
|
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
|
||||||
|
|
||||||
// Specification of the desired behavior of the PodDisruptionBudget.
|
|
||||||
// +optional
|
|
||||||
Spec PodDisruptionBudgetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
|
|
||||||
// Most recently observed status of the PodDisruptionBudget.
|
|
||||||
// +optional
|
|
||||||
Status PodDisruptionBudgetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodDisruptionBudgetList is a collection of PodDisruptionBudgets.
|
|
||||||
type PodDisruptionBudgetList struct {
|
|
||||||
metav1.TypeMeta `json:",inline"`
|
|
||||||
// +optional
|
|
||||||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
|
||||||
Items []PodDisruptionBudget `json:"items" protobuf:"bytes,2,rep,name=items"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Eviction evicts a pod from its node subject to certain policies and safety constraints.
|
|
||||||
// This is a subresource of Pod. A request to cause such an eviction is
|
|
||||||
// created by POSTing to .../pods/<pod name>/eviction.
|
|
||||||
type Eviction struct {
|
|
||||||
metav1.TypeMeta `json:",inline"`
|
|
||||||
|
|
||||||
// ObjectMeta describes the pod that is being evicted.
|
|
||||||
// +optional
|
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
|
||||||
|
|
||||||
// DeleteOptions may be provided
|
|
||||||
// +optional
|
|
||||||
DeleteOptions *v1.DeleteOptions `json:"deleteOptions,omitempty" protobuf:"bytes,2,opt,name=deleteOptions"`
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
licenses(["notice"])
|
|
||||||
|
|
||||||
load("@io_bazel_rules_go//go:def.bzl")
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
@ -32,11 +32,11 @@ import (
|
|||||||
"golang.org/x/oauth2/google"
|
"golang.org/x/oauth2/google"
|
||||||
"k8s.io/apimachinery/pkg/util/yaml"
|
"k8s.io/apimachinery/pkg/util/yaml"
|
||||||
"k8s.io/client-go/pkg/util/jsonpath"
|
"k8s.io/client-go/pkg/util/jsonpath"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if err := rest.RegisterAuthProviderPlugin("gcp", newGCPAuthProvider); err != nil {
|
if err := restclient.RegisterAuthProviderPlugin("gcp", newGCPAuthProvider); err != nil {
|
||||||
glog.Fatalf("Failed to register gcp auth plugin: %v", err)
|
glog.Fatalf("Failed to register gcp auth plugin: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,10 +85,10 @@ func init() {
|
|||||||
//
|
//
|
||||||
type gcpAuthProvider struct {
|
type gcpAuthProvider struct {
|
||||||
tokenSource oauth2.TokenSource
|
tokenSource oauth2.TokenSource
|
||||||
persister rest.AuthProviderConfigPersister
|
persister restclient.AuthProviderConfigPersister
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGCPAuthProvider(_ string, gcpConfig map[string]string, persister rest.AuthProviderConfigPersister) (rest.AuthProvider, error) {
|
func newGCPAuthProvider(_ string, gcpConfig map[string]string, persister restclient.AuthProviderConfigPersister) (restclient.AuthProvider, error) {
|
||||||
cmd, useCmd := gcpConfig["cmd-path"]
|
cmd, useCmd := gcpConfig["cmd-path"]
|
||||||
var ts oauth2.TokenSource
|
var ts oauth2.TokenSource
|
||||||
var err error
|
var err error
|
||||||
@ -121,11 +121,11 @@ type cachedTokenSource struct {
|
|||||||
source oauth2.TokenSource
|
source oauth2.TokenSource
|
||||||
accessToken string
|
accessToken string
|
||||||
expiry time.Time
|
expiry time.Time
|
||||||
persister rest.AuthProviderConfigPersister
|
persister restclient.AuthProviderConfigPersister
|
||||||
cache map[string]string
|
cache map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCachedTokenSource(accessToken, expiry string, persister rest.AuthProviderConfigPersister, ts oauth2.TokenSource, cache map[string]string) (*cachedTokenSource, error) {
|
func newCachedTokenSource(accessToken, expiry string, persister restclient.AuthProviderConfigPersister, ts oauth2.TokenSource, cache map[string]string) (*cachedTokenSource, error) {
|
||||||
var expiryTime time.Time
|
var expiryTime time.Time
|
||||||
if parsedTime, err := time.Parse(time.RFC3339Nano, expiry); err == nil {
|
if parsedTime, err := time.Parse(time.RFC3339Nano, expiry); err == nil {
|
||||||
expiryTime = parsedTime
|
expiryTime = parsedTime
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
"github.com/coreos/go-oidc/oidc"
|
"github.com/coreos/go-oidc/oidc"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -45,7 +45,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if err := rest.RegisterAuthProviderPlugin("oidc", newOIDCAuthProvider); err != nil {
|
if err := restclient.RegisterAuthProviderPlugin("oidc", newOIDCAuthProvider); err != nil {
|
||||||
glog.Fatalf("Failed to register oidc auth plugin: %v", err)
|
glog.Fatalf("Failed to register oidc auth plugin: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ func (c *clientCache) setClient(issuer, clientID, clientSecret string, client *o
|
|||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
func newOIDCAuthProvider(_ string, cfg map[string]string, persister rest.AuthProviderConfigPersister) (rest.AuthProvider, error) {
|
func newOIDCAuthProvider(_ string, cfg map[string]string, persister restclient.AuthProviderConfigPersister) (restclient.AuthProvider, error) {
|
||||||
issuer := cfg[cfgIssuerUrl]
|
issuer := cfg[cfgIssuerUrl]
|
||||||
if issuer == "" {
|
if issuer == "" {
|
||||||
return nil, fmt.Errorf("Must provide %s", cfgIssuerUrl)
|
return nil, fmt.Errorf("Must provide %s", cfgIssuerUrl)
|
||||||
@ -136,14 +136,14 @@ func newOIDCAuthProvider(_ string, cfg map[string]string, persister rest.AuthPro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clientConfig := rest.Config{
|
clientConfig := restclient.Config{
|
||||||
TLSClientConfig: rest.TLSClientConfig{
|
TLSClientConfig: restclient.TLSClientConfig{
|
||||||
CAFile: cfg[cfgCertificateAuthority],
|
CAFile: cfg[cfgCertificateAuthority],
|
||||||
CAData: certAuthData,
|
CAData: certAuthData,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
trans, err := rest.TransportFor(&clientConfig)
|
trans, err := restclient.TransportFor(&clientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ type oidcAuthProvider struct {
|
|||||||
// the RoundTripper only trigger a single refresh request.
|
// the RoundTripper only trigger a single refresh request.
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
cfg map[string]string
|
cfg map[string]string
|
||||||
persister rest.AuthProviderConfigPersister
|
persister restclient.AuthProviderConfigPersister
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *oidcAuthProvider) WrapTransport(rt http.RoundTripper) http.RoundTripper {
|
func (p *oidcAuthProvider) WrapTransport(rt http.RoundTripper) http.RoundTripper {
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/pkg/api/testapi"
|
"k8s.io/client-go/pkg/api/testapi"
|
||||||
"k8s.io/client-go/pkg/util/flowcontrol"
|
"k8s.io/client-go/pkg/util/flowcontrol"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateHTTPClient(roundTripper func(*http.Request) (*http.Response, error)) *http.Client {
|
func CreateHTTPClient(roundTripper func(*http.Request) (*http.Response, error)) *http.Client {
|
||||||
@ -54,27 +54,27 @@ type RESTClient struct {
|
|||||||
Err error
|
Err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RESTClient) Get() *rest.Request {
|
func (c *RESTClient) Get() *restclient.Request {
|
||||||
return c.request("GET")
|
return c.request("GET")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RESTClient) Put() *rest.Request {
|
func (c *RESTClient) Put() *restclient.Request {
|
||||||
return c.request("PUT")
|
return c.request("PUT")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RESTClient) Patch(_ types.PatchType) *rest.Request {
|
func (c *RESTClient) Patch(_ types.PatchType) *restclient.Request {
|
||||||
return c.request("PATCH")
|
return c.request("PATCH")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RESTClient) Post() *rest.Request {
|
func (c *RESTClient) Post() *restclient.Request {
|
||||||
return c.request("POST")
|
return c.request("POST")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RESTClient) Delete() *rest.Request {
|
func (c *RESTClient) Delete() *restclient.Request {
|
||||||
return c.request("DELETE")
|
return c.request("DELETE")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RESTClient) Verb(verb string) *rest.Request {
|
func (c *RESTClient) Verb(verb string) *restclient.Request {
|
||||||
return c.request(verb)
|
return c.request(verb)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +86,8 @@ func (c *RESTClient) GetRateLimiter() flowcontrol.RateLimiter {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RESTClient) request(verb string) *rest.Request {
|
func (c *RESTClient) request(verb string) *restclient.Request {
|
||||||
config := rest.ContentConfig{
|
config := restclient.ContentConfig{
|
||||||
ContentType: runtime.ContentTypeJSON,
|
ContentType: runtime.ContentTypeJSON,
|
||||||
GroupVersion: &api.Registry.GroupOrDie(api.GroupName).GroupVersion,
|
GroupVersion: &api.Registry.GroupOrDie(api.GroupName).GroupVersion,
|
||||||
NegotiatedSerializer: c.NegotiatedSerializer,
|
NegotiatedSerializer: c.NegotiatedSerializer,
|
||||||
@ -104,7 +104,7 @@ func (c *RESTClient) request(verb string) *rest.Request {
|
|||||||
Version: runtime.APIVersionInternal,
|
Version: runtime.APIVersionInternal,
|
||||||
}
|
}
|
||||||
internalVersion.Version = runtime.APIVersionInternal
|
internalVersion.Version = runtime.APIVersionInternal
|
||||||
serializers := rest.Serializers{
|
serializers := restclient.Serializers{
|
||||||
Encoder: ns.EncoderForVersion(info.Serializer, api.Registry.GroupOrDie(api.GroupName).GroupVersion),
|
Encoder: ns.EncoderForVersion(info.Serializer, api.Registry.GroupOrDie(api.GroupName).GroupVersion),
|
||||||
Decoder: ns.DecoderToVersion(info.Serializer, internalVersion),
|
Decoder: ns.DecoderToVersion(info.Serializer, internalVersion),
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ func (c *RESTClient) request(verb string) *rest.Request {
|
|||||||
serializers.StreamingSerializer = info.StreamSerializer.Serializer
|
serializers.StreamingSerializer = info.StreamSerializer.Serializer
|
||||||
serializers.Framer = info.StreamSerializer.Framer
|
serializers.Framer = info.StreamSerializer.Framer
|
||||||
}
|
}
|
||||||
return rest.NewRequest(c, verb, &url.URL{Host: "localhost"}, "", config, serializers, nil, nil)
|
return restclient.NewRequest(c, verb, &url.URL{Host: "localhost"}, "", config, serializers, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RESTClient) Do(req *http.Request) (*http.Response, error) {
|
func (c *RESTClient) Do(req *http.Request) (*http.Response, error) {
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
kubeversion "k8s.io/client-go/pkg/version"
|
kubeversion "k8s.io/client-go/pkg/version"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fake implements client.Interface. Meant to be embedded into a struct to get
|
// Fake implements client.Interface. Meant to be embedded into a struct to get
|
||||||
@ -77,7 +77,7 @@ type ProxyReactor interface {
|
|||||||
Handles(action Action) bool
|
Handles(action Action) bool
|
||||||
// React handles a watch action and returns results. It may choose to
|
// React handles a watch action and returns results. It may choose to
|
||||||
// delegate by indicating handled=false.
|
// delegate by indicating handled=false.
|
||||||
React(action Action) (handled bool, ret rest.ResponseWrapper, err error)
|
React(action Action) (handled bool, ret restclient.ResponseWrapper, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReactionFunc is a function that returns an object or error for a given
|
// ReactionFunc is a function that returns an object or error for a given
|
||||||
@ -95,7 +95,7 @@ type WatchReactionFunc func(action Action) (handled bool, ret watch.Interface, e
|
|||||||
// ProxyReactionFunc is a function that returns a ResponseWrapper interface
|
// ProxyReactionFunc is a function that returns a ResponseWrapper interface
|
||||||
// for a given Action. If "handled" is false, then the test client will
|
// for a given Action. If "handled" is false, then the test client will
|
||||||
// ignore the results and continue to the next ProxyReactionFunc.
|
// ignore the results and continue to the next ProxyReactionFunc.
|
||||||
type ProxyReactionFunc func(action Action) (handled bool, ret rest.ResponseWrapper, err error)
|
type ProxyReactionFunc func(action Action) (handled bool, ret restclient.ResponseWrapper, err error)
|
||||||
|
|
||||||
// AddReactor appends a reactor to the end of the chain.
|
// AddReactor appends a reactor to the end of the chain.
|
||||||
func (c *Fake) AddReactor(verb, resource string, reaction ReactionFunc) {
|
func (c *Fake) AddReactor(verb, resource string, reaction ReactionFunc) {
|
||||||
@ -176,7 +176,7 @@ func (c *Fake) InvokesWatch(action Action) (watch.Interface, error) {
|
|||||||
|
|
||||||
// InvokesProxy records the provided Action and then invokes the ReactionFunc
|
// InvokesProxy records the provided Action and then invokes the ReactionFunc
|
||||||
// that handles the action if one exists.
|
// that handles the action if one exists.
|
||||||
func (c *Fake) InvokesProxy(action Action) rest.ResponseWrapper {
|
func (c *Fake) InvokesProxy(action Action) restclient.ResponseWrapper {
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectTracker keeps track of objects. It is intended to be used to
|
// ObjectTracker keeps track of objects. It is intended to be used to
|
||||||
@ -511,6 +511,6 @@ func (r *SimpleProxyReactor) Handles(action Action) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *SimpleProxyReactor) React(action Action) (bool, rest.ResponseWrapper, error) {
|
func (r *SimpleProxyReactor) React(action Action) (bool, restclient.ResponseWrapper, error) {
|
||||||
return r.Reaction(action)
|
return r.Reaction(action)
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Info holds Kubernetes API authorization config. It is intended
|
// Info holds Kubernetes API authorization config. It is intended
|
||||||
@ -104,8 +104,8 @@ func LoadFromFile(path string) (*Info, error) {
|
|||||||
// MergeWithConfig returns a copy of a client.Config with values from the Info.
|
// MergeWithConfig returns a copy of a client.Config with values from the Info.
|
||||||
// The fields of client.Config with a corresponding field in the Info are set
|
// The fields of client.Config with a corresponding field in the Info are set
|
||||||
// with the value from the Info.
|
// with the value from the Info.
|
||||||
func (info Info) MergeWithConfig(c rest.Config) (rest.Config, error) {
|
func (info Info) MergeWithConfig(c restclient.Config) (restclient.Config, error) {
|
||||||
var config rest.Config = c
|
var config restclient.Config = c
|
||||||
config.Username = info.User
|
config.Username = info.User
|
||||||
config.Password = info.Password
|
config.Password = info.Password
|
||||||
config.CAFile = info.CAFile
|
config.CAFile = info.CAFile
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListerWatcher is any object that knows how to perform an initial list and start a watch on a resource.
|
// ListerWatcher is any object that knows how to perform an initial list and start a watch on a resource.
|
||||||
@ -53,7 +53,7 @@ type ListWatch struct {
|
|||||||
|
|
||||||
// Getter interface knows how to access Get method from RESTClient.
|
// Getter interface knows how to access Get method from RESTClient.
|
||||||
type Getter interface {
|
type Getter interface {
|
||||||
Get() *rest.Request
|
Get() *restclient.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
|
// NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
"github.com/imdario/mergo"
|
"github.com/imdario/mergo"
|
||||||
|
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
clientauth "k8s.io/client-go/tools/auth"
|
clientauth "k8s.io/client-go/tools/auth"
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
)
|
)
|
||||||
@ -58,7 +58,7 @@ type ClientConfig interface {
|
|||||||
// RawConfig returns the merged result of all overrides
|
// RawConfig returns the merged result of all overrides
|
||||||
RawConfig() (clientcmdapi.Config, error)
|
RawConfig() (clientcmdapi.Config, error)
|
||||||
// ClientConfig returns a complete client config
|
// ClientConfig returns a complete client config
|
||||||
ClientConfig() (*rest.Config, error)
|
ClientConfig() (*restclient.Config, error)
|
||||||
// Namespace returns the namespace resulting from the merged
|
// Namespace returns the namespace resulting from the merged
|
||||||
// result of all overrides and a boolean indicating if it was
|
// result of all overrides and a boolean indicating if it was
|
||||||
// overridden
|
// overridden
|
||||||
@ -67,7 +67,7 @@ type ClientConfig interface {
|
|||||||
ConfigAccess() ConfigAccess
|
ConfigAccess() ConfigAccess
|
||||||
}
|
}
|
||||||
|
|
||||||
type PersistAuthProviderConfigForUser func(user string) rest.AuthProviderConfigPersister
|
type PersistAuthProviderConfigForUser func(user string) restclient.AuthProviderConfigPersister
|
||||||
|
|
||||||
type promptedCredentials struct {
|
type promptedCredentials struct {
|
||||||
username string
|
username string
|
||||||
@ -105,7 +105,7 @@ func (config *DirectClientConfig) RawConfig() (clientcmdapi.Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ClientConfig implements ClientConfig
|
// ClientConfig implements ClientConfig
|
||||||
func (config *DirectClientConfig) ClientConfig() (*rest.Config, error) {
|
func (config *DirectClientConfig) ClientConfig() (*restclient.Config, error) {
|
||||||
// check that getAuthInfo, getContext, and getCluster do not return an error.
|
// check that getAuthInfo, getContext, and getCluster do not return an error.
|
||||||
// Do this before checking if the curent config is usable in the event that an
|
// Do this before checking if the curent config is usable in the event that an
|
||||||
// AuthInfo, Context, or Cluster config with user-defined names are not found.
|
// AuthInfo, Context, or Cluster config with user-defined names are not found.
|
||||||
@ -129,7 +129,7 @@ func (config *DirectClientConfig) ClientConfig() (*rest.Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
clientConfig := &rest.Config{}
|
clientConfig := &restclient.Config{}
|
||||||
clientConfig.Host = configClusterInfo.Server
|
clientConfig.Host = configClusterInfo.Server
|
||||||
|
|
||||||
if len(config.overrides.Timeout) > 0 {
|
if len(config.overrides.Timeout) > 0 {
|
||||||
@ -146,17 +146,17 @@ func (config *DirectClientConfig) ClientConfig() (*rest.Config, error) {
|
|||||||
clientConfig.Host = u.String()
|
clientConfig.Host = u.String()
|
||||||
}
|
}
|
||||||
if len(configAuthInfo.Impersonate) > 0 {
|
if len(configAuthInfo.Impersonate) > 0 {
|
||||||
clientConfig.Impersonate = rest.ImpersonationConfig{UserName: configAuthInfo.Impersonate}
|
clientConfig.Impersonate = restclient.ImpersonationConfig{UserName: configAuthInfo.Impersonate}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only try to read the auth information if we are secure
|
// only try to read the auth information if we are secure
|
||||||
if rest.IsConfigTransportTLS(*clientConfig) {
|
if restclient.IsConfigTransportTLS(*clientConfig) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// mergo is a first write wins for map value and a last writing wins for interface values
|
// mergo is a first write wins for map value and a last writing wins for interface values
|
||||||
// NOTE: This behavior changed with https://github.com/imdario/mergo/commit/d304790b2ed594794496464fadd89d2bb266600a.
|
// NOTE: This behavior changed with https://github.com/imdario/mergo/commit/d304790b2ed594794496464fadd89d2bb266600a.
|
||||||
// Our mergo.Merge version is older than this change.
|
// Our mergo.Merge version is older than this change.
|
||||||
var persister rest.AuthProviderConfigPersister
|
var persister restclient.AuthProviderConfigPersister
|
||||||
if config.configAccess != nil {
|
if config.configAccess != nil {
|
||||||
authInfoName, _ := config.getAuthInfoName()
|
authInfoName, _ := config.getAuthInfoName()
|
||||||
persister = PersisterForUser(config.configAccess, authInfoName)
|
persister = PersisterForUser(config.configAccess, authInfoName)
|
||||||
@ -183,11 +183,11 @@ func (config *DirectClientConfig) ClientConfig() (*rest.Config, error) {
|
|||||||
// 1. configClusterInfo (the final result of command line flags and merged .kubeconfig files)
|
// 1. configClusterInfo (the final result of command line flags and merged .kubeconfig files)
|
||||||
// 2. configAuthInfo.auth-path (this file can contain information that conflicts with #1, and we want #1 to win the priority)
|
// 2. configAuthInfo.auth-path (this file can contain information that conflicts with #1, and we want #1 to win the priority)
|
||||||
// 3. load the ~/.kubernetes_auth file as a default
|
// 3. load the ~/.kubernetes_auth file as a default
|
||||||
func getServerIdentificationPartialConfig(configAuthInfo clientcmdapi.AuthInfo, configClusterInfo clientcmdapi.Cluster) (*rest.Config, error) {
|
func getServerIdentificationPartialConfig(configAuthInfo clientcmdapi.AuthInfo, configClusterInfo clientcmdapi.Cluster) (*restclient.Config, error) {
|
||||||
mergedConfig := &rest.Config{}
|
mergedConfig := &restclient.Config{}
|
||||||
|
|
||||||
// configClusterInfo holds the information identify the server provided by .kubeconfig
|
// configClusterInfo holds the information identify the server provided by .kubeconfig
|
||||||
configClientConfig := &rest.Config{}
|
configClientConfig := &restclient.Config{}
|
||||||
configClientConfig.CAFile = configClusterInfo.CertificateAuthority
|
configClientConfig.CAFile = configClusterInfo.CertificateAuthority
|
||||||
configClientConfig.CAData = configClusterInfo.CertificateAuthorityData
|
configClientConfig.CAData = configClusterInfo.CertificateAuthorityData
|
||||||
configClientConfig.Insecure = configClusterInfo.InsecureSkipTLSVerify
|
configClientConfig.Insecure = configClusterInfo.InsecureSkipTLSVerify
|
||||||
@ -203,8 +203,8 @@ func getServerIdentificationPartialConfig(configAuthInfo clientcmdapi.AuthInfo,
|
|||||||
// 2. configAuthInfo.auth-path (this file can contain information that conflicts with #1, and we want #1 to win the priority)
|
// 2. configAuthInfo.auth-path (this file can contain information that conflicts with #1, and we want #1 to win the priority)
|
||||||
// 3. if there is not enough information to idenfity the user, load try the ~/.kubernetes_auth file
|
// 3. if there is not enough information to idenfity the user, load try the ~/.kubernetes_auth file
|
||||||
// 4. if there is not enough information to identify the user, prompt if possible
|
// 4. if there is not enough information to identify the user, prompt if possible
|
||||||
func (config *DirectClientConfig) getUserIdentificationPartialConfig(configAuthInfo clientcmdapi.AuthInfo, fallbackReader io.Reader, persistAuthConfig rest.AuthProviderConfigPersister) (*rest.Config, error) {
|
func (config *DirectClientConfig) getUserIdentificationPartialConfig(configAuthInfo clientcmdapi.AuthInfo, fallbackReader io.Reader, persistAuthConfig restclient.AuthProviderConfigPersister) (*restclient.Config, error) {
|
||||||
mergedConfig := &rest.Config{}
|
mergedConfig := &restclient.Config{}
|
||||||
|
|
||||||
// blindly overwrite existing values based on precedence
|
// blindly overwrite existing values based on precedence
|
||||||
if len(configAuthInfo.Token) > 0 {
|
if len(configAuthInfo.Token) > 0 {
|
||||||
@ -217,7 +217,7 @@ func (config *DirectClientConfig) getUserIdentificationPartialConfig(configAuthI
|
|||||||
mergedConfig.BearerToken = string(tokenBytes)
|
mergedConfig.BearerToken = string(tokenBytes)
|
||||||
}
|
}
|
||||||
if len(configAuthInfo.Impersonate) > 0 {
|
if len(configAuthInfo.Impersonate) > 0 {
|
||||||
mergedConfig.Impersonate = rest.ImpersonationConfig{UserName: configAuthInfo.Impersonate}
|
mergedConfig.Impersonate = restclient.ImpersonationConfig{UserName: configAuthInfo.Impersonate}
|
||||||
}
|
}
|
||||||
if len(configAuthInfo.ClientCertificate) > 0 || len(configAuthInfo.ClientCertificateData) > 0 {
|
if len(configAuthInfo.ClientCertificate) > 0 || len(configAuthInfo.ClientCertificateData) > 0 {
|
||||||
mergedConfig.CertFile = configAuthInfo.ClientCertificate
|
mergedConfig.CertFile = configAuthInfo.ClientCertificate
|
||||||
@ -248,7 +248,7 @@ func (config *DirectClientConfig) getUserIdentificationPartialConfig(configAuthI
|
|||||||
}
|
}
|
||||||
promptedConfig := makeUserIdentificationConfig(*promptedAuthInfo)
|
promptedConfig := makeUserIdentificationConfig(*promptedAuthInfo)
|
||||||
previouslyMergedConfig := mergedConfig
|
previouslyMergedConfig := mergedConfig
|
||||||
mergedConfig = &rest.Config{}
|
mergedConfig = &restclient.Config{}
|
||||||
mergo.Merge(mergedConfig, promptedConfig)
|
mergo.Merge(mergedConfig, promptedConfig)
|
||||||
mergo.Merge(mergedConfig, previouslyMergedConfig)
|
mergo.Merge(mergedConfig, previouslyMergedConfig)
|
||||||
config.promptedCredentials.username = mergedConfig.Username
|
config.promptedCredentials.username = mergedConfig.Username
|
||||||
@ -259,8 +259,8 @@ func (config *DirectClientConfig) getUserIdentificationPartialConfig(configAuthI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// makeUserIdentificationFieldsConfig returns a client.Config capable of being merged using mergo for only user identification information
|
// makeUserIdentificationFieldsConfig returns a client.Config capable of being merged using mergo for only user identification information
|
||||||
func makeUserIdentificationConfig(info clientauth.Info) *rest.Config {
|
func makeUserIdentificationConfig(info clientauth.Info) *restclient.Config {
|
||||||
config := &rest.Config{}
|
config := &restclient.Config{}
|
||||||
config.Username = info.User
|
config.Username = info.User
|
||||||
config.Password = info.Password
|
config.Password = info.Password
|
||||||
config.CertFile = info.CertFile
|
config.CertFile = info.CertFile
|
||||||
@ -270,8 +270,8 @@ func makeUserIdentificationConfig(info clientauth.Info) *rest.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// makeUserIdentificationFieldsConfig returns a client.Config capable of being merged using mergo for only server identification information
|
// makeUserIdentificationFieldsConfig returns a client.Config capable of being merged using mergo for only server identification information
|
||||||
func makeServerIdentificationConfig(info clientauth.Info) rest.Config {
|
func makeServerIdentificationConfig(info clientauth.Info) restclient.Config {
|
||||||
config := rest.Config{}
|
config := restclient.Config{}
|
||||||
config.CAFile = info.CAFile
|
config.CAFile = info.CAFile
|
||||||
if info.Insecure != nil {
|
if info.Insecure != nil {
|
||||||
config.Insecure = *info.Insecure
|
config.Insecure = *info.Insecure
|
||||||
@ -279,7 +279,7 @@ func makeServerIdentificationConfig(info clientauth.Info) rest.Config {
|
|||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
func canIdentifyUser(config rest.Config) bool {
|
func canIdentifyUser(config restclient.Config) bool {
|
||||||
return len(config.Username) > 0 ||
|
return len(config.Username) > 0 ||
|
||||||
(len(config.CertFile) > 0 || len(config.CertData) > 0) ||
|
(len(config.CertFile) > 0 || len(config.CertData) > 0) ||
|
||||||
len(config.BearerToken) > 0 ||
|
len(config.BearerToken) > 0 ||
|
||||||
@ -442,7 +442,7 @@ func (config *DirectClientConfig) getCluster() (clientcmdapi.Cluster, error) {
|
|||||||
// Can take options overrides for flags explicitly provided to the command inside the cluster container.
|
// Can take options overrides for flags explicitly provided to the command inside the cluster container.
|
||||||
type inClusterClientConfig struct {
|
type inClusterClientConfig struct {
|
||||||
overrides *ConfigOverrides
|
overrides *ConfigOverrides
|
||||||
inClusterConfigProvider func() (*rest.Config, error)
|
inClusterConfigProvider func() (*restclient.Config, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ClientConfig = &inClusterClientConfig{}
|
var _ ClientConfig = &inClusterClientConfig{}
|
||||||
@ -451,9 +451,9 @@ func (config *inClusterClientConfig) RawConfig() (clientcmdapi.Config, error) {
|
|||||||
return clientcmdapi.Config{}, fmt.Errorf("inCluster environment config doesn't support multiple clusters")
|
return clientcmdapi.Config{}, fmt.Errorf("inCluster environment config doesn't support multiple clusters")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *inClusterClientConfig) ClientConfig() (*rest.Config, error) {
|
func (config *inClusterClientConfig) ClientConfig() (*restclient.Config, error) {
|
||||||
if config.inClusterConfigProvider == nil {
|
if config.inClusterConfigProvider == nil {
|
||||||
config.inClusterConfigProvider = rest.InClusterConfig
|
config.inClusterConfigProvider = restclient.InClusterConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
icc, err := config.inClusterConfigProvider()
|
icc, err := config.inClusterConfigProvider()
|
||||||
@ -512,10 +512,10 @@ func (config *inClusterClientConfig) Possible() bool {
|
|||||||
// components. Warnings should reflect this usage. If neither masterUrl or kubeconfigPath
|
// components. Warnings should reflect this usage. If neither masterUrl or kubeconfigPath
|
||||||
// are passed in we fallback to inClusterConfig. If inClusterConfig fails, we fallback
|
// are passed in we fallback to inClusterConfig. If inClusterConfig fails, we fallback
|
||||||
// to the default config.
|
// to the default config.
|
||||||
func BuildConfigFromFlags(masterUrl, kubeconfigPath string) (*rest.Config, error) {
|
func BuildConfigFromFlags(masterUrl, kubeconfigPath string) (*restclient.Config, error) {
|
||||||
if kubeconfigPath == "" && masterUrl == "" {
|
if kubeconfigPath == "" && masterUrl == "" {
|
||||||
glog.Warningf("Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work.")
|
glog.Warningf("Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work.")
|
||||||
kubeconfig, err := rest.InClusterConfig()
|
kubeconfig, err := restclient.InClusterConfig()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return kubeconfig, nil
|
return kubeconfig, nil
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ func BuildConfigFromFlags(masterUrl, kubeconfigPath string) (*rest.Config, error
|
|||||||
|
|
||||||
// BuildConfigFromKubeconfigGetter is a helper function that builds configs from a master
|
// BuildConfigFromKubeconfigGetter is a helper function that builds configs from a master
|
||||||
// url and a kubeconfigGetter.
|
// url and a kubeconfigGetter.
|
||||||
func BuildConfigFromKubeconfigGetter(masterUrl string, kubeconfigGetter KubeconfigGetter) (*rest.Config, error) {
|
func BuildConfigFromKubeconfigGetter(masterUrl string, kubeconfigGetter KubeconfigGetter) (*restclient.Config, error) {
|
||||||
// TODO: We do not need a DeferredLoader here. Refactor code and see if we can use DirectClientConfig here.
|
// TODO: We do not need a DeferredLoader here. Refactor code and see if we can use DirectClientConfig here.
|
||||||
cc := NewNonInteractiveDeferredLoadingClientConfig(
|
cc := NewNonInteractiveDeferredLoadingClientConfig(
|
||||||
&ClientConfigGetter{kubeconfigGetter: kubeconfigGetter},
|
&ClientConfigGetter{kubeconfigGetter: kubeconfigGetter},
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/imdario/mergo"
|
"github.com/imdario/mergo"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -448,11 +448,11 @@ func TestInClusterClientConfigPrecedence(t *testing.T) {
|
|||||||
expectedCAFile := "/path/to/ca-from-cluster.crt"
|
expectedCAFile := "/path/to/ca-from-cluster.crt"
|
||||||
|
|
||||||
icc := &inClusterClientConfig{
|
icc := &inClusterClientConfig{
|
||||||
inClusterConfigProvider: func() (*rest.Config, error) {
|
inClusterConfigProvider: func() (*restclient.Config, error) {
|
||||||
return &rest.Config{
|
return &restclient.Config{
|
||||||
Host: expectedServer,
|
Host: expectedServer,
|
||||||
BearerToken: expectedToken,
|
BearerToken: expectedToken,
|
||||||
TLSClientConfig: rest.TLSClientConfig{
|
TLSClientConfig: restclient.TLSClientConfig{
|
||||||
CAFile: expectedCAFile,
|
CAFile: expectedCAFile,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ func ModifyConfig(configAccess ConfigAccess, newConfig clientcmdapi.Config, rela
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func PersisterForUser(configAccess ConfigAccess, user string) rest.AuthProviderConfigPersister {
|
func PersisterForUser(configAccess ConfigAccess, user string) restclient.AuthProviderConfigPersister {
|
||||||
return &persister{configAccess, user}
|
return &persister{configAccess, user}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
"k8s.io/client-go/pkg/util/homedir"
|
"k8s.io/client-go/pkg/util/homedir"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest"
|
clientcmdlatest "k8s.io/client-go/tools/clientcmd/api/latest"
|
||||||
)
|
)
|
||||||
@ -68,7 +68,7 @@ func currentMigrationRules() map[string]string {
|
|||||||
type ClientConfigLoader interface {
|
type ClientConfigLoader interface {
|
||||||
ConfigAccess
|
ConfigAccess
|
||||||
// IsDefaultConfig returns true if the returned config matches the defaults.
|
// IsDefaultConfig returns true if the returned config matches the defaults.
|
||||||
IsDefaultConfig(*rest.Config) bool
|
IsDefaultConfig(*restclient.Config) bool
|
||||||
// Load returns the latest config
|
// Load returns the latest config
|
||||||
Load() (*clientcmdapi.Config, error)
|
Load() (*clientcmdapi.Config, error)
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ func (g *ClientConfigGetter) IsExplicitFile() bool {
|
|||||||
func (g *ClientConfigGetter) GetExplicitFile() string {
|
func (g *ClientConfigGetter) GetExplicitFile() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
func (g *ClientConfigGetter) IsDefaultConfig(config *rest.Config) bool {
|
func (g *ClientConfigGetter) IsDefaultConfig(config *restclient.Config) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ func (rules *ClientConfigLoadingRules) GetExplicitFile() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsDefaultConfig returns true if the provided configuration matches the default
|
// IsDefaultConfig returns true if the provided configuration matches the default
|
||||||
func (rules *ClientConfigLoadingRules) IsDefaultConfig(config *rest.Config) bool {
|
func (rules *ClientConfigLoadingRules) IsDefaultConfig(config *restclient.Config) bool {
|
||||||
if rules.DefaultClientConfig == nil {
|
if rules.DefaultClientConfig == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ func (config *DeferredLoadingClientConfig) RawConfig() (clientcmdapi.Config, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ClientConfig implements ClientConfig
|
// ClientConfig implements ClientConfig
|
||||||
func (config *DeferredLoadingClientConfig) ClientConfig() (*rest.Config, error) {
|
func (config *DeferredLoadingClientConfig) ClientConfig() (*restclient.Config, error) {
|
||||||
mergedClientConfig, err := config.createClientConfig()
|
mergedClientConfig, err := config.createClientConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ func (l *testLoader) Load() (*clientcmdapi.Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type testClientConfig struct {
|
type testClientConfig struct {
|
||||||
config *rest.Config
|
config *restclient.Config
|
||||||
namespace string
|
namespace string
|
||||||
namespaceSpecified bool
|
namespaceSpecified bool
|
||||||
err error
|
err error
|
||||||
@ -47,7 +47,7 @@ type testClientConfig struct {
|
|||||||
func (c *testClientConfig) RawConfig() (clientcmdapi.Config, error) {
|
func (c *testClientConfig) RawConfig() (clientcmdapi.Config, error) {
|
||||||
return clientcmdapi.Config{}, fmt.Errorf("unexpected call")
|
return clientcmdapi.Config{}, fmt.Errorf("unexpected call")
|
||||||
}
|
}
|
||||||
func (c *testClientConfig) ClientConfig() (*rest.Config, error) {
|
func (c *testClientConfig) ClientConfig() (*restclient.Config, error) {
|
||||||
return c.config, c.err
|
return c.config, c.err
|
||||||
}
|
}
|
||||||
func (c *testClientConfig) Namespace() (string, bool, error) {
|
func (c *testClientConfig) Namespace() (string, bool, error) {
|
||||||
@ -95,7 +95,7 @@ func TestInClusterConfig(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
config2 := &rest.Config{Host: "config2"}
|
config2 := &restclient.Config{Host: "config2"}
|
||||||
err1 := fmt.Errorf("unique error")
|
err1 := fmt.Errorf("unique error")
|
||||||
|
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
@ -104,7 +104,7 @@ func TestInClusterConfig(t *testing.T) {
|
|||||||
defaultConfig *DirectClientConfig
|
defaultConfig *DirectClientConfig
|
||||||
|
|
||||||
checkedICC bool
|
checkedICC bool
|
||||||
result *rest.Config
|
result *restclient.Config
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
"in-cluster checked on other error": {
|
"in-cluster checked on other error": {
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/pkg/util/clock"
|
"k8s.io/client-go/pkg/util/clock"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ func recordEvent(sink EventSink, event *v1.Event, patch []byte, updateExistingEv
|
|||||||
// If we can't contact the server, then hold everything while we keep trying.
|
// If we can't contact the server, then hold everything while we keep trying.
|
||||||
// Otherwise, something about the event is malformed and we should abandon it.
|
// Otherwise, something about the event is malformed and we should abandon it.
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
case *rest.RequestConstructionError:
|
case *restclient.RequestConstructionError:
|
||||||
// We will construct the request the same next time, so don't keep trying.
|
// We will construct the request the same next time, so don't keep trying.
|
||||||
glog.Errorf("Unable to construct event '%#v': '%v' (will not retry!)", event, err)
|
glog.Errorf("Unable to construct event '%#v': '%v' (will not retry!)", event, err)
|
||||||
return true
|
return true
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/pkg/util/clock"
|
"k8s.io/client-go/pkg/util/clock"
|
||||||
"k8s.io/client-go/pkg/util/strategicpatch"
|
"k8s.io/client-go/pkg/util/strategicpatch"
|
||||||
"k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testEventSink struct {
|
type testEventSink struct {
|
||||||
@ -387,7 +387,7 @@ func TestWriteEventError(t *testing.T) {
|
|||||||
"giveUp1": {
|
"giveUp1": {
|
||||||
timesToSendError: 1000,
|
timesToSendError: 1000,
|
||||||
attemptsWanted: 1,
|
attemptsWanted: 1,
|
||||||
err: &rest.RequestConstructionError{},
|
err: &restclient.RequestConstructionError{},
|
||||||
},
|
},
|
||||||
"giveUp2": {
|
"giveUp2": {
|
||||||
timesToSendError: 1000,
|
timesToSendError: 1000,
|
||||||
|
66
vendor/BUILD
vendored
66
vendor/BUILD
vendored
@ -11270,48 +11270,6 @@ go_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "k8s.io/client-go/kubernetes/typed/policy/v1alpha1",
|
|
||||||
srcs = [
|
|
||||||
"k8s.io/client-go/kubernetes/typed/policy/v1alpha1/doc.go",
|
|
||||||
"k8s.io/client-go/kubernetes/typed/policy/v1alpha1/generated_expansion.go",
|
|
||||||
"k8s.io/client-go/kubernetes/typed/policy/v1alpha1/poddisruptionbudget.go",
|
|
||||||
"k8s.io/client-go/kubernetes/typed/policy/v1alpha1/policy_client.go",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
deps = [
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/runtime/serializer",
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/types",
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/watch",
|
|
||||||
"//vendor:k8s.io/client-go/pkg/api",
|
|
||||||
"//vendor:k8s.io/client-go/pkg/api/v1",
|
|
||||||
"//vendor:k8s.io/client-go/pkg/apis/policy/v1alpha1",
|
|
||||||
"//vendor:k8s.io/client-go/rest",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "k8s.io/client-go/kubernetes/typed/policy/v1alpha1/fake",
|
|
||||||
srcs = [
|
|
||||||
"k8s.io/client-go/kubernetes/typed/policy/v1alpha1/fake/doc.go",
|
|
||||||
"k8s.io/client-go/kubernetes/typed/policy/v1alpha1/fake/fake_poddisruptionbudget.go",
|
|
||||||
"k8s.io/client-go/kubernetes/typed/policy/v1alpha1/fake/fake_policy_client.go",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
deps = [
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/labels",
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/types",
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/watch",
|
|
||||||
"//vendor:k8s.io/client-go/kubernetes/typed/policy/v1alpha1",
|
|
||||||
"//vendor:k8s.io/client-go/pkg/api/v1",
|
|
||||||
"//vendor:k8s.io/client-go/pkg/apis/policy/v1alpha1",
|
|
||||||
"//vendor:k8s.io/client-go/rest",
|
|
||||||
"//vendor:k8s.io/client-go/testing",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "k8s.io/client-go/kubernetes/typed/policy/v1beta1",
|
name = "k8s.io/client-go/kubernetes/typed/policy/v1beta1",
|
||||||
srcs = [
|
srcs = [
|
||||||
@ -11616,12 +11574,6 @@ go_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "k8s.io/client-go/pkg/api/validation/path",
|
|
||||||
srcs = ["k8s.io/client-go/pkg/api/validation/path/name.go"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "k8s.io/client-go/pkg/apimachinery/announced",
|
name = "k8s.io/client-go/pkg/apimachinery/announced",
|
||||||
srcs = [
|
srcs = [
|
||||||
@ -12299,23 +12251,6 @@ go_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "k8s.io/client-go/pkg/apis/policy/v1alpha1",
|
|
||||||
srcs = [
|
|
||||||
"k8s.io/client-go/pkg/apis/policy/v1alpha1/doc.go",
|
|
||||||
"k8s.io/client-go/pkg/apis/policy/v1alpha1/register.go",
|
|
||||||
"k8s.io/client-go/pkg/apis/policy/v1alpha1/types.go",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
deps = [
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
|
||||||
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
|
|
||||||
"//vendor:k8s.io/client-go/pkg/api/v1",
|
|
||||||
"//vendor:k8s.io/client-go/pkg/util/intstr",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "k8s.io/client-go/pkg/apis/policy/v1beta1",
|
name = "k8s.io/client-go/pkg/apis/policy/v1beta1",
|
||||||
srcs = [
|
srcs = [
|
||||||
@ -12966,7 +12901,6 @@ go_library(
|
|||||||
"//vendor:k8s.io/apimachinery/pkg/watch",
|
"//vendor:k8s.io/apimachinery/pkg/watch",
|
||||||
"//vendor:k8s.io/client-go/pkg/api",
|
"//vendor:k8s.io/client-go/pkg/api",
|
||||||
"//vendor:k8s.io/client-go/pkg/api/v1",
|
"//vendor:k8s.io/client-go/pkg/api/v1",
|
||||||
"//vendor:k8s.io/client-go/pkg/api/validation/path",
|
|
||||||
"//vendor:k8s.io/client-go/pkg/util/cert",
|
"//vendor:k8s.io/client-go/pkg/util/cert",
|
||||||
"//vendor:k8s.io/client-go/pkg/util/flowcontrol",
|
"//vendor:k8s.io/client-go/pkg/util/flowcontrol",
|
||||||
"//vendor:k8s.io/client-go/pkg/version",
|
"//vendor:k8s.io/client-go/pkg/version",
|
||||||
|
Loading…
Reference in New Issue
Block a user