mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #80766 from robscott/discovery-api
Adding Discovery API for EndpointSlice
This commit is contained in:
commit
6c9f26ca3a
1267
api/openapi-spec/swagger.json
generated
1267
api/openapi-spec/swagger.json
generated
File diff suppressed because it is too large
Load Diff
@ -60,6 +60,7 @@ tags_values_pkgs = {"openapi-gen": {
|
||||
"staging/src/k8s.io/api/coordination/v1",
|
||||
"staging/src/k8s.io/api/coordination/v1beta1",
|
||||
"staging/src/k8s.io/api/core/v1",
|
||||
"staging/src/k8s.io/api/discovery/v1alpha1",
|
||||
"staging/src/k8s.io/api/events/v1beta1",
|
||||
"staging/src/k8s.io/api/extensions/v1beta1",
|
||||
"staging/src/k8s.io/api/imagepolicy/v1alpha1",
|
||||
@ -141,6 +142,7 @@ tags_pkgs_values = {"openapi-gen": {
|
||||
"false",
|
||||
"true",
|
||||
],
|
||||
"staging/src/k8s.io/api/discovery/v1alpha1": ["true"],
|
||||
"staging/src/k8s.io/api/events/v1beta1": ["true"],
|
||||
"staging/src/k8s.io/api/extensions/v1beta1": ["true"],
|
||||
"staging/src/k8s.io/api/imagepolicy/v1alpha1": ["true"],
|
||||
|
@ -281,6 +281,7 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{
|
||||
{Group: "auditregistration.k8s.io", Version: "v1alpha1"}: {group: 16400, version: 1},
|
||||
{Group: "node.k8s.io", Version: "v1alpha1"}: {group: 16300, version: 1},
|
||||
{Group: "node.k8s.io", Version: "v1beta1"}: {group: 16300, version: 9},
|
||||
{Group: "discovery.k8s.io", Version: "v1alpha1"}: {group: 16200, version: 9},
|
||||
// Append a new group to the end of the list if unsure.
|
||||
// You can use min(existing group)-100 as the initial value for a group.
|
||||
// Version can be set to 9 (to have space around) for a new group.
|
||||
|
@ -32,6 +32,7 @@ pkg/apis/core/v1/helper
|
||||
pkg/apis/core/v1/helper/qos
|
||||
pkg/apis/core/v1/validation
|
||||
pkg/apis/core/validation
|
||||
pkg/apis/discovery/v1alpha1
|
||||
pkg/apis/events/v1beta1
|
||||
pkg/apis/extensions
|
||||
pkg/apis/extensions/v1beta1
|
||||
|
@ -18,6 +18,7 @@
|
||||
"k8s.io/api/coordination/v1": "coordinationv1",
|
||||
"k8s.io/api/coordination/v1beta1": "coordinationv1beta1",
|
||||
"k8s.io/api/core/v1": "v1",
|
||||
"k8s.io/api/discovery/v1alpha1": "discoveryv1alpha1",
|
||||
"k8s.io/api/events/v1beta1": "eventsv1beta1",
|
||||
"k8s.io/api/extensions/v1beta1": "extensionsv1beta1",
|
||||
"k8s.io/api/imagepolicy/v1alpha1": "imagepolicyv1alpha1",
|
||||
|
@ -84,6 +84,7 @@ batch/v2alpha1 \
|
||||
certificates.k8s.io/v1beta1 \
|
||||
coordination.k8s.io/v1beta1 \
|
||||
coordination.k8s.io/v1 \
|
||||
discovery.k8s.io/v1alpha1 \
|
||||
extensions/v1beta1 \
|
||||
events.k8s.io/v1beta1 \
|
||||
imagepolicy.k8s.io/v1alpha1 \
|
||||
|
@ -38,6 +38,7 @@ filegroup(
|
||||
"//pkg/apis/certificates:all-srcs",
|
||||
"//pkg/apis/coordination:all-srcs",
|
||||
"//pkg/apis/core:all-srcs",
|
||||
"//pkg/apis/discovery:all-srcs",
|
||||
"//pkg/apis/events:all-srcs",
|
||||
"//pkg/apis/extensions:all-srcs",
|
||||
"//pkg/apis/imagepolicy:all-srcs",
|
||||
|
@ -33,6 +33,8 @@ go_library(
|
||||
"//pkg/apis/coordination/install:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/core/install:go_default_library",
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//pkg/apis/discovery/install:go_default_library",
|
||||
"//pkg/apis/events:go_default_library",
|
||||
"//pkg/apis/events/install:go_default_library",
|
||||
"//pkg/apis/extensions:go_default_library",
|
||||
|
@ -44,6 +44,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/apis/certificates"
|
||||
"k8s.io/kubernetes/pkg/apis/coordination"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
"k8s.io/kubernetes/pkg/apis/events"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/apis/imagepolicy"
|
||||
@ -67,6 +68,7 @@ import (
|
||||
_ "k8s.io/kubernetes/pkg/apis/certificates/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/coordination/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/discovery/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/events/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/imagepolicy/install"
|
||||
@ -283,6 +285,12 @@ func init() {
|
||||
externalGroupVersion: externalGroupVersion,
|
||||
}
|
||||
}
|
||||
if _, ok := Groups[discovery.GroupName]; !ok {
|
||||
externalGroupVersion := schema.GroupVersion{Group: discovery.GroupName, Version: legacyscheme.Scheme.PrioritizedVersionsForGroup(discovery.GroupName)[0].Version}
|
||||
Groups[discovery.GroupName] = TestGroup{
|
||||
externalGroupVersion: externalGroupVersion,
|
||||
}
|
||||
}
|
||||
|
||||
Default = Groups[api.GroupName]
|
||||
Autoscaling = Groups[autoscaling.GroupName]
|
||||
|
@ -26,6 +26,7 @@ go_library(
|
||||
"//pkg/apis/certificates/fuzzer:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/core/fuzzer:go_default_library",
|
||||
"//pkg/apis/discovery/fuzzer:go_default_library",
|
||||
"//pkg/apis/extensions/fuzzer:go_default_library",
|
||||
"//pkg/apis/networking/fuzzer:go_default_library",
|
||||
"//pkg/apis/policy/fuzzer:go_default_library",
|
||||
|
@ -89,6 +89,8 @@ func TestDefaulting(t *testing.T) {
|
||||
{Group: "batch", Version: "v2alpha1", Kind: "JobTemplate"}: {},
|
||||
{Group: "certificates.k8s.io", Version: "v1beta1", Kind: "CertificateSigningRequest"}: {},
|
||||
{Group: "certificates.k8s.io", Version: "v1beta1", Kind: "CertificateSigningRequestList"}: {},
|
||||
{Group: "discovery.k8s.io", Version: "v1alpha1", Kind: "EndpointSlice"}: {},
|
||||
{Group: "discovery.k8s.io", Version: "v1alpha1", Kind: "EndpointSliceList"}: {},
|
||||
{Group: "kubeadm.k8s.io", Version: "v1alpha1", Kind: "MasterConfiguration"}: {},
|
||||
// This object contains only int fields which currently breaks the defaulting test because
|
||||
// it's pretty stupid. Once we add non integer fields, we should uncomment this.
|
||||
|
@ -37,6 +37,7 @@ import (
|
||||
certificatesfuzzer "k8s.io/kubernetes/pkg/apis/certificates/fuzzer"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
corefuzzer "k8s.io/kubernetes/pkg/apis/core/fuzzer"
|
||||
discoveryfuzzer "k8s.io/kubernetes/pkg/apis/discovery/fuzzer"
|
||||
extensionsfuzzer "k8s.io/kubernetes/pkg/apis/extensions/fuzzer"
|
||||
networkingfuzzer "k8s.io/kubernetes/pkg/apis/networking/fuzzer"
|
||||
policyfuzzer "k8s.io/kubernetes/pkg/apis/policy/fuzzer"
|
||||
@ -107,4 +108,5 @@ var FuzzerFuncs = fuzzer.MergeFuzzerFuncs(
|
||||
networkingfuzzer.Funcs,
|
||||
metafuzzer.Funcs,
|
||||
schedulingfuzzer.Funcs,
|
||||
discoveryfuzzer.Funcs,
|
||||
)
|
||||
|
39
pkg/apis/discovery/BUILD
Normal file
39
pkg/apis/discovery/BUILD
Normal file
@ -0,0 +1,39 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"register.go",
|
||||
"types.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/discovery",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//pkg/apis/discovery/fuzzer:all-srcs",
|
||||
"//pkg/apis/discovery/install:all-srcs",
|
||||
"//pkg/apis/discovery/v1alpha1:all-srcs",
|
||||
"//pkg/apis/discovery/validation:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
20
pkg/apis/discovery/doc.go
Normal file
20
pkg/apis/discovery/doc.go
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright 2019 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.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +groupName=discovery.k8s.io
|
||||
|
||||
package discovery
|
28
pkg/apis/discovery/fuzzer/BUILD
Normal file
28
pkg/apis/discovery/fuzzer/BUILD
Normal file
@ -0,0 +1,28 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["fuzzer.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/discovery/fuzzer",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
52
pkg/apis/discovery/fuzzer/fuzzer.go
Normal file
52
pkg/apis/discovery/fuzzer/fuzzer.go
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2019 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 fuzzer
|
||||
|
||||
import (
|
||||
fuzz "github.com/google/gofuzz"
|
||||
|
||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
)
|
||||
|
||||
// Funcs returns the fuzzer functions for the discovery api group.
|
||||
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
return []interface{}{
|
||||
func(obj *discovery.EndpointSlice, c fuzz.Continue) {
|
||||
c.FuzzNoCustom(obj) // fuzz self without calling this function again
|
||||
|
||||
// match defaults
|
||||
if obj.AddressType == nil {
|
||||
ipAddressType := discovery.AddressTypeIP
|
||||
obj.AddressType = &ipAddressType
|
||||
}
|
||||
|
||||
for i, endpointPort := range obj.Ports {
|
||||
if endpointPort.Name == nil {
|
||||
emptyStr := ""
|
||||
obj.Ports[i].Name = &emptyStr
|
||||
}
|
||||
|
||||
if endpointPort.Protocol == nil {
|
||||
protos := []api.Protocol{api.ProtocolTCP, api.ProtocolUDP, api.ProtocolSCTP}
|
||||
obj.Ports[i].Protocol = &protos[c.Rand.Intn(len(protos))]
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
29
pkg/apis/discovery/install/BUILD
Normal file
29
pkg/apis/discovery/install/BUILD
Normal file
@ -0,0 +1,29 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["install.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/discovery/install",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//pkg/apis/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
38
pkg/apis/discovery/install/install.go
Normal file
38
pkg/apis/discovery/install/install.go
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright 2019 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 install installs the discovery API group, making it available as
|
||||
// an option to all of the API encoding/decoding machinery.
|
||||
package install
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery/v1alpha1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Install(legacyscheme.Scheme)
|
||||
}
|
||||
|
||||
// Install registers the API group and adds types to a scheme
|
||||
func Install(scheme *runtime.Scheme) {
|
||||
utilruntime.Must(discovery.AddToScheme(scheme))
|
||||
utilruntime.Must(v1alpha1.AddToScheme(scheme))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
|
||||
}
|
54
pkg/apis/discovery/register.go
Normal file
54
pkg/apis/discovery/register.go
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright 2019 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 discovery
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// GroupName is the group name used in this package
|
||||
const GroupName = "discovery.k8s.io"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
||||
|
||||
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
||||
func Kind(kind string) schema.GroupKind {
|
||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||
}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
var (
|
||||
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
// AddToScheme is a global function that registers this API group & version to a scheme
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to the given scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&EndpointSlice{},
|
||||
&EndpointSliceList{},
|
||||
)
|
||||
return nil
|
||||
}
|
139
pkg/apis/discovery/types.go
Normal file
139
pkg/apis/discovery/types.go
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
Copyright 2019 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 discovery
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// EndpointSlice represents a subset of the endpoints that implement a service.
|
||||
// For a given service there may be multiple EndpointSlice objects, selected by
|
||||
// labels, which must be joined to produce the full set of endpoints.
|
||||
type EndpointSlice struct {
|
||||
metav1.TypeMeta
|
||||
// Standard object's metadata.
|
||||
// +optional
|
||||
metav1.ObjectMeta
|
||||
// addressType specifies the type of address carried by this EndpointSlice.
|
||||
// All addresses in this slice must be the same type.
|
||||
// +optional
|
||||
AddressType *AddressType
|
||||
// endpoints is a list of unique endpoints in this slice. Each slice may
|
||||
// include a maximum of 1000 endpoints.
|
||||
// +listType=atomic
|
||||
Endpoints []Endpoint
|
||||
// ports specifies the list of network ports exposed by each endpoint in
|
||||
// this slice. Each port must have a unique name. When ports is empty, it
|
||||
// indicates that there are no defined ports. When a port is defined with a
|
||||
// nil port value, it indicates "all ports". Each slice may include a
|
||||
// maximum of 100 ports.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
Ports []EndpointPort
|
||||
}
|
||||
|
||||
// AddressType represents the type of address referred to by an endpoint.
|
||||
type AddressType string
|
||||
|
||||
const (
|
||||
// AddressTypeIP represents an IP Address.
|
||||
AddressTypeIP = AddressType("IP")
|
||||
)
|
||||
|
||||
// Endpoint represents a single logical "backend" implementing a service.
|
||||
type Endpoint struct {
|
||||
// addresses of this endpoint. The contents of this field are interpreted
|
||||
// according to the corresponding EndpointSlice addressType field. This
|
||||
// allows for cases like dual-stack (IPv4 and IPv6) networking. Consumers
|
||||
// (e.g. kube-proxy) must handle different types of addresses in the context
|
||||
// of their own capabilities. This must contain at least one address but no
|
||||
// more than 100.
|
||||
// +listType=set
|
||||
Addresses []string
|
||||
// conditions contains information about the current status of the endpoint.
|
||||
Conditions EndpointConditions
|
||||
// hostname of this endpoint. This field may be used by consumers of
|
||||
// endpoints to distinguish endpoints from each other (e.g. in DNS names).
|
||||
// Multiple endpoints which use the same hostname should be considered
|
||||
// fungible (e.g. multiple A values in DNS). Must pass DNS Label (RFC 1123)
|
||||
// validation.
|
||||
// +optional
|
||||
Hostname *string
|
||||
// targetRef is a reference to a Kubernetes object that represents this
|
||||
// endpoint.
|
||||
// +optional
|
||||
TargetRef *api.ObjectReference
|
||||
// topology contains arbitrary topology information associated with the
|
||||
// endpoint. These key/value pairs must conform with the label format.
|
||||
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
|
||||
// Topology may include a maximum of 16 key/value pairs. This includes, but
|
||||
// is not limited to the following well known keys:
|
||||
// * kubernetes.io/hostname: the value indicates the hostname of the node
|
||||
// where the endpoint is located. This should match the corresponding
|
||||
// node label.
|
||||
// * topology.kubernetes.io/zone: the value indicates the zone where the
|
||||
// endpoint is located. This should match the corresponding node label.
|
||||
// * topology.kubernetes.io/region: the value indicates the region where the
|
||||
// endpoint is located. This should match the corresponding node label.
|
||||
// +optional
|
||||
Topology map[string]string
|
||||
}
|
||||
|
||||
// EndpointConditions represents the current condition of an endpoint.
|
||||
type EndpointConditions struct {
|
||||
// ready indicates that this endpoint is prepared to receive traffic,
|
||||
// according to whatever system is managing the endpoint. A nil value
|
||||
// indicates an unknown state. In most cases consumers should interpret this
|
||||
// unknown state as ready.
|
||||
Ready *bool
|
||||
}
|
||||
|
||||
// EndpointPort represents a Port used by an EndpointSlice.
|
||||
type EndpointPort struct {
|
||||
// The name of this port. All ports in an EndpointSlice must have a unique
|
||||
// name. If the EndpointSlice is dervied from a Kubernetes service, this
|
||||
// corresponds to the Service.ports[].name.
|
||||
// Name must either be an empty string or pass IANA_SVC_NAME validation:
|
||||
// * must be no more than 15 characters long
|
||||
// * may contain only [-a-z0-9]
|
||||
// * must contain at least one letter [a-z]
|
||||
// * it must not start or end with a hyphen, nor contain adjacent hyphens
|
||||
Name *string
|
||||
// The IP protocol for this port.
|
||||
// Must be UDP, TCP, or SCTP.
|
||||
Protocol *api.Protocol
|
||||
// The port number of the endpoint.
|
||||
// If this is not specified, ports are not restricted and must be
|
||||
// interpreted in the context of the specific consumer.
|
||||
Port *int32
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// EndpointSliceList represents a list of endpoint slices.
|
||||
type EndpointSliceList struct {
|
||||
metav1.TypeMeta
|
||||
// Standard list metadata.
|
||||
// +optional
|
||||
metav1.ListMeta
|
||||
// List of endpoint slices
|
||||
// +listType=set
|
||||
Items []EndpointSlice
|
||||
}
|
52
pkg/apis/discovery/v1alpha1/BUILD
Normal file
52
pkg/apis/discovery/v1alpha1/BUILD
Normal file
@ -0,0 +1,52 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"defaults.go",
|
||||
"doc.go",
|
||||
"register.go",
|
||||
"zz_generated.conversion.go",
|
||||
"zz_generated.defaults.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/discovery/v1alpha1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["defaults_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/discovery/install:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//vendor/github.com/google/go-cmp/cmp:go_default_library",
|
||||
"//vendor/k8s.io/utils/pointer:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
49
pkg/apis/discovery/v1alpha1/defaults.go
Normal file
49
pkg/apis/discovery/v1alpha1/defaults.go
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright 2019 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 (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultAddressType = discoveryv1alpha1.AddressTypeIP
|
||||
defaultPortName = ""
|
||||
defaultProtocol = v1.ProtocolTCP
|
||||
)
|
||||
|
||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
return RegisterDefaults(scheme)
|
||||
}
|
||||
|
||||
func SetDefaults_EndpointSlice(obj *discoveryv1alpha1.EndpointSlice) {
|
||||
if obj.AddressType == nil {
|
||||
obj.AddressType = &defaultAddressType
|
||||
}
|
||||
}
|
||||
|
||||
func SetDefaults_EndpointPort(obj *discoveryv1alpha1.EndpointPort) {
|
||||
if obj.Name == nil {
|
||||
obj.Name = &defaultPortName
|
||||
}
|
||||
|
||||
if obj.Protocol == nil {
|
||||
obj.Protocol = &defaultProtocol
|
||||
}
|
||||
}
|
82
pkg/apis/discovery/v1alpha1/defaults_test.go
Normal file
82
pkg/apis/discovery/v1alpha1/defaults_test.go
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
Copyright 2019 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_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
discovery "k8s.io/api/discovery/v1alpha1"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
_ "k8s.io/kubernetes/pkg/apis/discovery/install"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func TestSetDefaultEndpointPort(t *testing.T) {
|
||||
emptyStr := ""
|
||||
fooStr := "foo"
|
||||
protoTCP := v1.ProtocolTCP
|
||||
protoUDP := v1.ProtocolUDP
|
||||
ipAddressType := discovery.AddressTypeIP
|
||||
otherAddressType := discovery.AddressType("other")
|
||||
|
||||
tests := map[string]struct {
|
||||
original *discovery.EndpointSlice
|
||||
expected *discovery.EndpointSlice
|
||||
}{
|
||||
"should set appropriate defaults": {
|
||||
original: &discovery.EndpointSlice{Ports: []discovery.EndpointPort{{
|
||||
Port: utilpointer.Int32Ptr(80),
|
||||
}}},
|
||||
expected: &discovery.EndpointSlice{
|
||||
AddressType: &ipAddressType,
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: &emptyStr,
|
||||
Protocol: &protoTCP,
|
||||
Port: utilpointer.Int32Ptr(80),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"should not overwrite values with defaults when set": {
|
||||
original: &discovery.EndpointSlice{
|
||||
AddressType: &otherAddressType,
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: &fooStr,
|
||||
Protocol: &protoUDP,
|
||||
}},
|
||||
},
|
||||
expected: &discovery.EndpointSlice{
|
||||
AddressType: &otherAddressType,
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: &fooStr,
|
||||
Protocol: &protoUDP,
|
||||
}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
actual := test.original
|
||||
expected := test.expected
|
||||
legacyscheme.Scheme.Default(actual)
|
||||
if !apiequality.Semantic.DeepEqual(actual, expected) {
|
||||
t.Error(cmp.Diff(expected, actual))
|
||||
}
|
||||
}
|
||||
}
|
22
pkg/apis/discovery/v1alpha1/doc.go
Normal file
22
pkg/apis/discovery/v1alpha1/doc.go
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
Copyright 2019 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.
|
||||
*/
|
||||
|
||||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/discovery
|
||||
// +k8s:conversion-gen-external-types=k8s.io/api/discovery/v1alpha1
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/discovery/v1alpha1
|
||||
|
||||
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/discovery/v1alpha1"
|
45
pkg/apis/discovery/v1alpha1/register.go
Normal file
45
pkg/apis/discovery/v1alpha1/register.go
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright 2019 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 (
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// GroupName is the group name used in this package
|
||||
const GroupName = "discovery.k8s.io"
|
||||
|
||||
// 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 (
|
||||
localSchemeBuilder = &discoveryv1alpha1.SchemeBuilder
|
||||
AddToScheme = localSchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
func init() {
|
||||
// We only register manually written functions here. The registration of the
|
||||
// generated functions takes place in the generated files. The separation
|
||||
// makes the code compile even when the generated files are missing.
|
||||
localSchemeBuilder.Register(addDefaultingFuncs)
|
||||
}
|
216
pkg/apis/discovery/v1alpha1/zz_generated.conversion.go
generated
Normal file
216
pkg/apis/discovery/v1alpha1/zz_generated.conversion.go
generated
Normal file
@ -0,0 +1,216 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by conversion-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
unsafe "unsafe"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
v1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
core "k8s.io/kubernetes/pkg/apis/core"
|
||||
discovery "k8s.io/kubernetes/pkg/apis/discovery"
|
||||
)
|
||||
|
||||
func init() {
|
||||
localSchemeBuilder.Register(RegisterConversions)
|
||||
}
|
||||
|
||||
// RegisterConversions adds conversion functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.Endpoint)(nil), (*discovery.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_Endpoint_To_discovery_Endpoint(a.(*v1alpha1.Endpoint), b.(*discovery.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.Endpoint)(nil), (*v1alpha1.Endpoint)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_Endpoint_To_v1alpha1_Endpoint(a.(*discovery.Endpoint), b.(*v1alpha1.Endpoint), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.EndpointConditions)(nil), (*discovery.EndpointConditions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(a.(*v1alpha1.EndpointConditions), b.(*discovery.EndpointConditions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointConditions)(nil), (*v1alpha1.EndpointConditions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(a.(*discovery.EndpointConditions), b.(*v1alpha1.EndpointConditions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.EndpointPort)(nil), (*discovery.EndpointPort)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_EndpointPort_To_discovery_EndpointPort(a.(*v1alpha1.EndpointPort), b.(*discovery.EndpointPort), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointPort)(nil), (*v1alpha1.EndpointPort)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointPort_To_v1alpha1_EndpointPort(a.(*discovery.EndpointPort), b.(*v1alpha1.EndpointPort), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.EndpointSlice)(nil), (*discovery.EndpointSlice)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice(a.(*v1alpha1.EndpointSlice), b.(*discovery.EndpointSlice), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointSlice)(nil), (*v1alpha1.EndpointSlice)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice(a.(*discovery.EndpointSlice), b.(*v1alpha1.EndpointSlice), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.EndpointSliceList)(nil), (*discovery.EndpointSliceList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList(a.(*v1alpha1.EndpointSliceList), b.(*discovery.EndpointSliceList), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*discovery.EndpointSliceList)(nil), (*v1alpha1.EndpointSliceList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList(a.(*discovery.EndpointSliceList), b.(*v1alpha1.EndpointSliceList), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_Endpoint_To_discovery_Endpoint(in *v1alpha1.Endpoint, out *discovery.Endpoint, s conversion.Scope) error {
|
||||
out.Addresses = *(*[]string)(unsafe.Pointer(&in.Addresses))
|
||||
if err := Convert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(&in.Conditions, &out.Conditions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Hostname = (*string)(unsafe.Pointer(in.Hostname))
|
||||
out.TargetRef = (*core.ObjectReference)(unsafe.Pointer(in.TargetRef))
|
||||
out.Topology = *(*map[string]string)(unsafe.Pointer(&in.Topology))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_Endpoint_To_discovery_Endpoint is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_Endpoint_To_discovery_Endpoint(in *v1alpha1.Endpoint, out *discovery.Endpoint, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_Endpoint_To_discovery_Endpoint(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_Endpoint_To_v1alpha1_Endpoint(in *discovery.Endpoint, out *v1alpha1.Endpoint, s conversion.Scope) error {
|
||||
out.Addresses = *(*[]string)(unsafe.Pointer(&in.Addresses))
|
||||
if err := Convert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(&in.Conditions, &out.Conditions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Hostname = (*string)(unsafe.Pointer(in.Hostname))
|
||||
out.TargetRef = (*v1.ObjectReference)(unsafe.Pointer(in.TargetRef))
|
||||
out.Topology = *(*map[string]string)(unsafe.Pointer(&in.Topology))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_Endpoint_To_v1alpha1_Endpoint is an autogenerated conversion function.
|
||||
func Convert_discovery_Endpoint_To_v1alpha1_Endpoint(in *discovery.Endpoint, out *v1alpha1.Endpoint, s conversion.Scope) error {
|
||||
return autoConvert_discovery_Endpoint_To_v1alpha1_Endpoint(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(in *v1alpha1.EndpointConditions, out *discovery.EndpointConditions, s conversion.Scope) error {
|
||||
out.Ready = (*bool)(unsafe.Pointer(in.Ready))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(in *v1alpha1.EndpointConditions, out *discovery.EndpointConditions, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_EndpointConditions_To_discovery_EndpointConditions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(in *discovery.EndpointConditions, out *v1alpha1.EndpointConditions, s conversion.Scope) error {
|
||||
out.Ready = (*bool)(unsafe.Pointer(in.Ready))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(in *discovery.EndpointConditions, out *v1alpha1.EndpointConditions, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointConditions_To_v1alpha1_EndpointConditions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_EndpointPort_To_discovery_EndpointPort(in *v1alpha1.EndpointPort, out *discovery.EndpointPort, s conversion.Scope) error {
|
||||
out.Name = (*string)(unsafe.Pointer(in.Name))
|
||||
out.Protocol = (*core.Protocol)(unsafe.Pointer(in.Protocol))
|
||||
out.Port = (*int32)(unsafe.Pointer(in.Port))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_EndpointPort_To_discovery_EndpointPort is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_EndpointPort_To_discovery_EndpointPort(in *v1alpha1.EndpointPort, out *discovery.EndpointPort, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_EndpointPort_To_discovery_EndpointPort(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointPort_To_v1alpha1_EndpointPort(in *discovery.EndpointPort, out *v1alpha1.EndpointPort, s conversion.Scope) error {
|
||||
out.Name = (*string)(unsafe.Pointer(in.Name))
|
||||
out.Protocol = (*v1.Protocol)(unsafe.Pointer(in.Protocol))
|
||||
out.Port = (*int32)(unsafe.Pointer(in.Port))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointPort_To_v1alpha1_EndpointPort is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointPort_To_v1alpha1_EndpointPort(in *discovery.EndpointPort, out *v1alpha1.EndpointPort, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointPort_To_v1alpha1_EndpointPort(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice(in *v1alpha1.EndpointSlice, out *discovery.EndpointSlice, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.AddressType = (*discovery.AddressType)(unsafe.Pointer(in.AddressType))
|
||||
out.Endpoints = *(*[]discovery.Endpoint)(unsafe.Pointer(&in.Endpoints))
|
||||
out.Ports = *(*[]discovery.EndpointPort)(unsafe.Pointer(&in.Ports))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice(in *v1alpha1.EndpointSlice, out *discovery.EndpointSlice, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_EndpointSlice_To_discovery_EndpointSlice(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice(in *discovery.EndpointSlice, out *v1alpha1.EndpointSlice, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.AddressType = (*v1alpha1.AddressType)(unsafe.Pointer(in.AddressType))
|
||||
out.Endpoints = *(*[]v1alpha1.Endpoint)(unsafe.Pointer(&in.Endpoints))
|
||||
out.Ports = *(*[]v1alpha1.EndpointPort)(unsafe.Pointer(&in.Ports))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice(in *discovery.EndpointSlice, out *v1alpha1.EndpointSlice, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointSlice_To_v1alpha1_EndpointSlice(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList(in *v1alpha1.EndpointSliceList, out *discovery.EndpointSliceList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]discovery.EndpointSlice)(unsafe.Pointer(&in.Items))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList is an autogenerated conversion function.
|
||||
func Convert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList(in *v1alpha1.EndpointSliceList, out *discovery.EndpointSliceList, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_EndpointSliceList_To_discovery_EndpointSliceList(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList(in *discovery.EndpointSliceList, out *v1alpha1.EndpointSliceList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]v1alpha1.EndpointSlice)(unsafe.Pointer(&in.Items))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList is an autogenerated conversion function.
|
||||
func Convert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList(in *discovery.EndpointSliceList, out *v1alpha1.EndpointSliceList, s conversion.Scope) error {
|
||||
return autoConvert_discovery_EndpointSliceList_To_v1alpha1_EndpointSliceList(in, out, s)
|
||||
}
|
50
pkg/apis/discovery/v1alpha1/zz_generated.defaults.go
generated
Normal file
50
pkg/apis/discovery/v1alpha1/zz_generated.defaults.go
generated
Normal file
@ -0,0 +1,50 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// RegisterDefaults adds defaulters functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha1.EndpointSlice{}, func(obj interface{}) { SetObjectDefaults_EndpointSlice(obj.(*v1alpha1.EndpointSlice)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha1.EndpointSliceList{}, func(obj interface{}) { SetObjectDefaults_EndpointSliceList(obj.(*v1alpha1.EndpointSliceList)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_EndpointSlice(in *v1alpha1.EndpointSlice) {
|
||||
SetDefaults_EndpointSlice(in)
|
||||
for i := range in.Ports {
|
||||
a := &in.Ports[i]
|
||||
SetDefaults_EndpointPort(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_EndpointSliceList(in *v1alpha1.EndpointSliceList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_EndpointSlice(a)
|
||||
}
|
||||
}
|
44
pkg/apis/discovery/validation/BUILD
Normal file
44
pkg/apis/discovery/validation/BUILD
Normal file
@ -0,0 +1,44 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["validation.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/discovery/validation",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/core/validation:go_default_library",
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/validation:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/validation:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["validation_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/utils/pointer:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
144
pkg/apis/discovery/validation/validation.go
Normal file
144
pkg/apis/discovery/validation/validation.go
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
Copyright 2019 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 validation
|
||||
|
||||
import (
|
||||
apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation"
|
||||
metavalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
apivalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
)
|
||||
|
||||
var (
|
||||
supportedAddressTypes = sets.NewString(string(discovery.AddressTypeIP))
|
||||
supportedPortProtocols = sets.NewString(string(api.ProtocolTCP), string(api.ProtocolUDP), string(api.ProtocolSCTP))
|
||||
maxTopologyLabels = 16
|
||||
maxAddresses = 100
|
||||
maxPorts = 100
|
||||
maxEndpoints = 1000
|
||||
)
|
||||
|
||||
// ValidateEndpointSlice validates an EndpointSlice.
|
||||
func ValidateEndpointSlice(endpointSlice *discovery.EndpointSlice) field.ErrorList {
|
||||
validateEndpointSliceName := apimachineryvalidation.NameIsDNSSubdomain
|
||||
allErrs := apivalidation.ValidateObjectMeta(&endpointSlice.ObjectMeta, true, validateEndpointSliceName, field.NewPath("metadata"))
|
||||
|
||||
addrType := discovery.AddressType("")
|
||||
if endpointSlice.AddressType == nil {
|
||||
allErrs = append(allErrs, field.Required(field.NewPath("addressType"), ""))
|
||||
} else {
|
||||
addrType = *endpointSlice.AddressType
|
||||
}
|
||||
|
||||
if endpointSlice.AddressType != nil && !supportedAddressTypes.Has(string(*endpointSlice.AddressType)) {
|
||||
allErrs = append(allErrs, field.NotSupported(field.NewPath("addressType"), *endpointSlice.AddressType, supportedAddressTypes.List()))
|
||||
}
|
||||
|
||||
allErrs = append(allErrs, validateEndpoints(endpointSlice.Endpoints, addrType, field.NewPath("endpoints"))...)
|
||||
allErrs = append(allErrs, validatePorts(endpointSlice.Ports, field.NewPath("ports"))...)
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateEndpointSliceUpdate validates an EndpointSlice when it is updated.
|
||||
func ValidateEndpointSliceUpdate(newEndpointSlice, oldEndpointSlice *discovery.EndpointSlice) field.ErrorList {
|
||||
allErrs := ValidateEndpointSlice(newEndpointSlice)
|
||||
|
||||
allErrs = append(allErrs, apivalidation.ValidateImmutableField(*newEndpointSlice.AddressType, *oldEndpointSlice.AddressType, field.NewPath("addressType"))...)
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateEndpoints(endpoints []discovery.Endpoint, addrType discovery.AddressType, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
if len(endpoints) > maxEndpoints {
|
||||
allErrs = append(allErrs, field.TooMany(fldPath, len(endpoints), maxEndpoints))
|
||||
return allErrs
|
||||
}
|
||||
|
||||
for i, endpoint := range endpoints {
|
||||
idxPath := fldPath.Index(i)
|
||||
addressPath := idxPath.Child("addresses")
|
||||
|
||||
if addrType == discovery.AddressTypeIP {
|
||||
if len(endpoint.Addresses) == 0 {
|
||||
allErrs = append(allErrs, field.Required(addressPath, "must contain at least 1 address"))
|
||||
} else if len(endpoint.Addresses) > maxAddresses {
|
||||
allErrs = append(allErrs, field.TooMany(addressPath, len(endpoint.Addresses), maxAddresses))
|
||||
}
|
||||
|
||||
for i, address := range endpoint.Addresses {
|
||||
for _, msg := range validation.IsValidIP(address) {
|
||||
allErrs = append(allErrs, field.Invalid(addressPath.Index(i), address, msg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
topologyPath := idxPath.Child("topology")
|
||||
if len(endpoint.Topology) > maxTopologyLabels {
|
||||
allErrs = append(allErrs, field.TooMany(topologyPath, len(endpoint.Topology), maxTopologyLabels))
|
||||
}
|
||||
allErrs = append(allErrs, metavalidation.ValidateLabels(endpoint.Topology, topologyPath)...)
|
||||
|
||||
if endpoint.Hostname != nil {
|
||||
for _, msg := range validation.IsDNS1123Label(*endpoint.Hostname) {
|
||||
allErrs = append(allErrs, field.Invalid(idxPath.Child("hostname"), *endpoint.Hostname, msg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validatePorts(endpointPorts []discovery.EndpointPort, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
if len(endpointPorts) > maxPorts {
|
||||
allErrs = append(allErrs, field.TooMany(fldPath, len(endpointPorts), maxPorts))
|
||||
return allErrs
|
||||
}
|
||||
|
||||
portNames := sets.String{}
|
||||
for i, endpointPort := range endpointPorts {
|
||||
idxPath := fldPath.Index(i)
|
||||
|
||||
if len(*endpointPort.Name) > 0 {
|
||||
for _, msg := range validation.IsValidPortName(*endpointPort.Name) {
|
||||
allErrs = append(allErrs, field.Invalid(idxPath.Child("name"), endpointPort.Name, msg))
|
||||
}
|
||||
}
|
||||
|
||||
if portNames.Has(*endpointPort.Name) {
|
||||
allErrs = append(allErrs, field.Duplicate(idxPath.Child("name"), endpointPort.Name))
|
||||
} else {
|
||||
portNames.Insert(*endpointPort.Name)
|
||||
}
|
||||
|
||||
if endpointPort.Protocol == nil {
|
||||
allErrs = append(allErrs, field.Required(idxPath.Child("protocol"), ""))
|
||||
} else if !supportedPortProtocols.Has(string(*endpointPort.Protocol)) {
|
||||
allErrs = append(allErrs, field.NotSupported(idxPath.Child("protocol"), *endpointPort.Protocol, supportedPortProtocols.List()))
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
439
pkg/apis/discovery/validation/validation_test.go
Normal file
439
pkg/apis/discovery/validation/validation_test.go
Normal file
@ -0,0 +1,439 @@
|
||||
/*
|
||||
Copyright 2019 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 validation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func TestValidateEndpointSlice(t *testing.T) {
|
||||
standardMeta := metav1.ObjectMeta{
|
||||
Name: "hello",
|
||||
Namespace: "world",
|
||||
}
|
||||
|
||||
testCases := map[string]struct {
|
||||
expectedErrors int
|
||||
endpointSlice *discovery.EndpointSlice
|
||||
}{
|
||||
"good-slice": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(1),
|
||||
Hostname: utilpointer.StringPtr("valid-123"),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"all-protocols": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("tcp"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}, {
|
||||
Name: utilpointer.StringPtr("udp"),
|
||||
Protocol: protocolPtr(api.ProtocolUDP),
|
||||
}, {
|
||||
Name: utilpointer.StringPtr("sctp"),
|
||||
Protocol: protocolPtr(api.ProtocolSCTP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(1),
|
||||
Hostname: utilpointer.StringPtr("valid-123"),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"empty-port-name": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr(""),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}, {
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(1),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"empty-ports-and-endpoints": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{},
|
||||
Endpoints: []discovery.Endpoint{},
|
||||
},
|
||||
},
|
||||
"max-endpoints": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: generatePorts(1),
|
||||
Endpoints: generateEndpoints(maxEndpoints),
|
||||
},
|
||||
},
|
||||
"max-ports": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: generatePorts(maxPorts),
|
||||
},
|
||||
},
|
||||
"max-addresses": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(maxAddresses),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"max-topology-keys": {
|
||||
expectedErrors: 0,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(1),
|
||||
Topology: generateTopology(maxTopologyLabels),
|
||||
}},
|
||||
},
|
||||
},
|
||||
|
||||
// expected failures
|
||||
"duplicate-port-name": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr(""),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}, {
|
||||
Name: utilpointer.StringPtr(""),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{},
|
||||
},
|
||||
},
|
||||
"bad-port-name-caps": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("aCapital"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{},
|
||||
},
|
||||
},
|
||||
"bad-port-name-chars": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("almost_valid"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{},
|
||||
},
|
||||
},
|
||||
"invalid-port-protocol": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.Protocol("foo")),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"too-many-ports": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: generatePorts(maxPorts + 1),
|
||||
},
|
||||
},
|
||||
"too-many-endpoints": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: generatePorts(1),
|
||||
Endpoints: generateEndpoints(maxEndpoints + 1),
|
||||
},
|
||||
},
|
||||
"no-endpoint-addresses": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(0),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"too-many-addresses": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(maxAddresses + 1),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"bad-address-type": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressType("other")),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(1),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"bad-topology-key": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(1),
|
||||
Topology: map[string]string{"--INVALID": "example"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
"too-many-topology-keys": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(1),
|
||||
Topology: generateTopology(maxTopologyLabels + 1),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"bad-hostname": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(1),
|
||||
Hostname: utilpointer.StringPtr("--INVALID"),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"bad-meta": {
|
||||
expectedErrors: 1,
|
||||
endpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "*&^",
|
||||
Namespace: "foo",
|
||||
},
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
}},
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: generateAddresses(1),
|
||||
Hostname: utilpointer.StringPtr("valid-123"),
|
||||
}},
|
||||
},
|
||||
},
|
||||
"empty-everything": {
|
||||
expectedErrors: 3,
|
||||
endpointSlice: &discovery.EndpointSlice{},
|
||||
},
|
||||
}
|
||||
|
||||
for name, testCase := range testCases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
errs := ValidateEndpointSlice(testCase.endpointSlice)
|
||||
if len(errs) != testCase.expectedErrors {
|
||||
t.Errorf("Expected %d errors, got %d errors: %v", testCase.expectedErrors, len(errs), errs)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateEndpointSliceUpdate(t *testing.T) {
|
||||
standardMeta := metav1.ObjectMeta{Name: "es1", Namespace: "test"}
|
||||
|
||||
testCases := map[string]struct {
|
||||
expectedErrors int
|
||||
newEndpointSlice *discovery.EndpointSlice
|
||||
oldEndpointSlice *discovery.EndpointSlice
|
||||
}{
|
||||
"valid and identical slices": {
|
||||
newEndpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
},
|
||||
oldEndpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
},
|
||||
expectedErrors: 0,
|
||||
},
|
||||
"valid and identical slices with different address types": {
|
||||
newEndpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
},
|
||||
oldEndpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressType("other")),
|
||||
},
|
||||
expectedErrors: 1,
|
||||
},
|
||||
"invalid slices with valid address types": {
|
||||
newEndpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr(""),
|
||||
Protocol: protocolPtr(api.Protocol("invalid")),
|
||||
}},
|
||||
},
|
||||
oldEndpointSlice: &discovery.EndpointSlice{
|
||||
ObjectMeta: standardMeta,
|
||||
AddressType: addressTypePtr(discovery.AddressTypeIP),
|
||||
},
|
||||
expectedErrors: 1,
|
||||
},
|
||||
}
|
||||
|
||||
for name, testCase := range testCases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
errs := ValidateEndpointSliceUpdate(testCase.newEndpointSlice, testCase.oldEndpointSlice)
|
||||
if len(errs) != testCase.expectedErrors {
|
||||
t.Errorf("Expected %d errors, got %d errors: %v", testCase.expectedErrors, len(errs), errs)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Test helpers
|
||||
|
||||
func protocolPtr(protocol api.Protocol) *api.Protocol {
|
||||
return &protocol
|
||||
}
|
||||
|
||||
func addressTypePtr(addressType discovery.AddressType) *discovery.AddressType {
|
||||
return &addressType
|
||||
}
|
||||
|
||||
func generatePorts(n int) []discovery.EndpointPort {
|
||||
ports := []discovery.EndpointPort{}
|
||||
for i := 0; i < n; i++ {
|
||||
ports = append(ports, discovery.EndpointPort{
|
||||
Name: utilpointer.StringPtr(fmt.Sprintf("http-%d", i)),
|
||||
Protocol: protocolPtr(api.ProtocolTCP),
|
||||
})
|
||||
}
|
||||
return ports
|
||||
}
|
||||
|
||||
func generateEndpoints(n int) []discovery.Endpoint {
|
||||
endpoints := []discovery.Endpoint{}
|
||||
for i := 0; i < n; i++ {
|
||||
endpoints = append(endpoints, discovery.Endpoint{
|
||||
Addresses: []string{fmt.Sprintf("10.1.2.%d", i%255)},
|
||||
})
|
||||
}
|
||||
return endpoints
|
||||
}
|
||||
|
||||
func generateAddresses(n int) []string {
|
||||
addresses := []string{}
|
||||
for i := 0; i < n; i++ {
|
||||
addresses = append(addresses, fmt.Sprintf("10.1.2.%d", i%255))
|
||||
}
|
||||
return addresses
|
||||
}
|
||||
|
||||
func generateTopology(n int) map[string]string {
|
||||
topology := map[string]string{}
|
||||
for i := 0; i < n; i++ {
|
||||
topology[fmt.Sprintf("topology-%d", i)] = "example"
|
||||
}
|
||||
return topology
|
||||
}
|
195
pkg/apis/discovery/zz_generated.deepcopy.go
generated
Normal file
195
pkg/apis/discovery/zz_generated.deepcopy.go
generated
Normal file
@ -0,0 +1,195 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package discovery
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
core "k8s.io/kubernetes/pkg/apis/core"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Endpoint) DeepCopyInto(out *Endpoint) {
|
||||
*out = *in
|
||||
if in.Addresses != nil {
|
||||
in, out := &in.Addresses, &out.Addresses
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
in.Conditions.DeepCopyInto(&out.Conditions)
|
||||
if in.Hostname != nil {
|
||||
in, out := &in.Hostname, &out.Hostname
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.TargetRef != nil {
|
||||
in, out := &in.TargetRef, &out.TargetRef
|
||||
*out = new(core.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
if in.Topology != nil {
|
||||
in, out := &in.Topology, &out.Topology
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Endpoint.
|
||||
func (in *Endpoint) DeepCopy() *Endpoint {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Endpoint)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *EndpointConditions) DeepCopyInto(out *EndpointConditions) {
|
||||
*out = *in
|
||||
if in.Ready != nil {
|
||||
in, out := &in.Ready, &out.Ready
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointConditions.
|
||||
func (in *EndpointConditions) DeepCopy() *EndpointConditions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(EndpointConditions)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *EndpointPort) DeepCopyInto(out *EndpointPort) {
|
||||
*out = *in
|
||||
if in.Name != nil {
|
||||
in, out := &in.Name, &out.Name
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.Protocol != nil {
|
||||
in, out := &in.Protocol, &out.Protocol
|
||||
*out = new(core.Protocol)
|
||||
**out = **in
|
||||
}
|
||||
if in.Port != nil {
|
||||
in, out := &in.Port, &out.Port
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointPort.
|
||||
func (in *EndpointPort) DeepCopy() *EndpointPort {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(EndpointPort)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *EndpointSlice) DeepCopyInto(out *EndpointSlice) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
if in.AddressType != nil {
|
||||
in, out := &in.AddressType, &out.AddressType
|
||||
*out = new(AddressType)
|
||||
**out = **in
|
||||
}
|
||||
if in.Endpoints != nil {
|
||||
in, out := &in.Endpoints, &out.Endpoints
|
||||
*out = make([]Endpoint, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.Ports != nil {
|
||||
in, out := &in.Ports, &out.Ports
|
||||
*out = make([]EndpointPort, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointSlice.
|
||||
func (in *EndpointSlice) DeepCopy() *EndpointSlice {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(EndpointSlice)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *EndpointSlice) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *EndpointSliceList) DeepCopyInto(out *EndpointSliceList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]EndpointSlice, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointSliceList.
|
||||
func (in *EndpointSliceList) DeepCopy() *EndpointSliceList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(EndpointSliceList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *EndpointSliceList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
@ -26,6 +26,7 @@ go_library(
|
||||
"//pkg/apis/coordination/install:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/core/install:go_default_library",
|
||||
"//pkg/apis/discovery/install:go_default_library",
|
||||
"//pkg/apis/events/install:go_default_library",
|
||||
"//pkg/apis/extensions/install:go_default_library",
|
||||
"//pkg/apis/imagepolicy/install:go_default_library",
|
||||
@ -55,6 +56,7 @@ go_library(
|
||||
"//pkg/registry/core/service/ipallocator:go_default_library",
|
||||
"//pkg/registry/core/service/ipallocator/controller:go_default_library",
|
||||
"//pkg/registry/core/service/portallocator/controller:go_default_library",
|
||||
"//pkg/registry/discovery/rest:go_default_library",
|
||||
"//pkg/registry/events/rest:go_default_library",
|
||||
"//pkg/registry/extensions/rest:go_default_library",
|
||||
"//pkg/registry/networking/rest:go_default_library",
|
||||
@ -88,6 +90,7 @@ go_library(
|
||||
"//staging/src/k8s.io/api/coordination/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/coordination/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/events/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/networking/v1:go_default_library",
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
_ "k8s.io/kubernetes/pkg/apis/certificates/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/coordination/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/discovery/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/events/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/imagepolicy/install"
|
||||
|
@ -44,6 +44,7 @@ import (
|
||||
coordinationapiv1 "k8s.io/api/coordination/v1"
|
||||
coordinationapiv1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
eventsv1beta1 "k8s.io/api/events/v1beta1"
|
||||
extensionsapiv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
networkingapiv1 "k8s.io/api/networking/v1"
|
||||
@ -94,6 +95,7 @@ import (
|
||||
certificatesrest "k8s.io/kubernetes/pkg/registry/certificates/rest"
|
||||
coordinationrest "k8s.io/kubernetes/pkg/registry/coordination/rest"
|
||||
corerest "k8s.io/kubernetes/pkg/registry/core/rest"
|
||||
discoveryrest "k8s.io/kubernetes/pkg/registry/discovery/rest"
|
||||
eventsrest "k8s.io/kubernetes/pkg/registry/events/rest"
|
||||
extensionsrest "k8s.io/kubernetes/pkg/registry/extensions/rest"
|
||||
networkingrest "k8s.io/kubernetes/pkg/registry/networking/rest"
|
||||
@ -349,6 +351,7 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
|
||||
batchrest.RESTStorageProvider{},
|
||||
certificatesrest.RESTStorageProvider{},
|
||||
coordinationrest.RESTStorageProvider{},
|
||||
discoveryrest.StorageProvider{},
|
||||
extensionsrest.RESTStorageProvider{},
|
||||
networkingrest.RESTStorageProvider{},
|
||||
noderest.RESTStorageProvider{},
|
||||
@ -540,6 +543,7 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
|
||||
ret.DisableVersions(
|
||||
auditregistrationv1alpha1.SchemeGroupVersion,
|
||||
batchapiv2alpha1.SchemeGroupVersion,
|
||||
discoveryv1alpha1.SchemeGroupVersion,
|
||||
nodev1alpha1.SchemeGroupVersion,
|
||||
rbacv1alpha1.SchemeGroupVersion,
|
||||
schedulingv1alpha1.SchemeGroupVersion,
|
||||
|
@ -67,6 +67,7 @@ go_library(
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/core/helper:go_default_library",
|
||||
"//pkg/apis/core/install:go_default_library",
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//pkg/apis/events/install:go_default_library",
|
||||
"//pkg/apis/extensions/install:go_default_library",
|
||||
"//pkg/apis/networking:go_default_library",
|
||||
@ -90,6 +91,7 @@ go_library(
|
||||
"//staging/src/k8s.io/api/certificates/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/coordination/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/policy/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/rbac/v1beta1:go_default_library",
|
||||
|
@ -32,6 +32,7 @@ import (
|
||||
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
|
||||
coordinationv1 "k8s.io/api/coordination/v1"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
policyv1beta1 "k8s.io/api/policy/v1beta1"
|
||||
rbacv1beta1 "k8s.io/api/rbac/v1beta1"
|
||||
@ -51,6 +52,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/apis/coordination"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/core/helper"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
"k8s.io/kubernetes/pkg/apis/networking"
|
||||
nodeapi "k8s.io/kubernetes/pkg/apis/node"
|
||||
"k8s.io/kubernetes/pkg/apis/policy"
|
||||
@ -467,6 +469,15 @@ func AddHandlers(h printers.PrintHandler) {
|
||||
}
|
||||
h.TableHandler(volumeAttachmentColumnDefinitions, printVolumeAttachment)
|
||||
h.TableHandler(volumeAttachmentColumnDefinitions, printVolumeAttachmentList)
|
||||
|
||||
endpointSliceColumnDefinitions := []metav1beta1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
|
||||
{Name: "Ports", Type: "string", Description: discoveryv1alpha1.EndpointSlice{}.SwaggerDoc()["ports"]},
|
||||
{Name: "AddressType", Type: "string", Description: discoveryv1alpha1.EndpointSlice{}.SwaggerDoc()["addressType"]},
|
||||
{Name: "Endpoints", Type: "string", Description: discoveryv1alpha1.EndpointSlice{}.SwaggerDoc()["endpoints"]},
|
||||
}
|
||||
h.TableHandler(endpointSliceColumnDefinitions, printEndpointSlice)
|
||||
h.TableHandler(endpointSliceColumnDefinitions, printEndpointSliceList)
|
||||
}
|
||||
|
||||
// Pass ports=nil for all ports.
|
||||
@ -1103,6 +1114,26 @@ func printEndpointsList(list *api.EndpointsList, options printers.GenerateOption
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func printEndpointSlice(obj *discovery.EndpointSlice, options printers.GenerateOptions) ([]metav1beta1.TableRow, error) {
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
row.Cells = append(row.Cells, obj.Name, obj.Ports, obj.AddressType, obj.Endpoints)
|
||||
return []metav1beta1.TableRow{row}, nil
|
||||
}
|
||||
|
||||
func printEndpointSliceList(list *discovery.EndpointSliceList, options printers.GenerateOptions) ([]metav1beta1.TableRow, error) {
|
||||
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
||||
for i := range list.Items {
|
||||
r, err := printEndpointSlice(&list.Items[i], options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rows = append(rows, r...)
|
||||
}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func printNamespace(obj *api.Namespace, options printers.GenerateOptions) ([]metav1beta1.TableRow, error) {
|
||||
row := metav1beta1.TableRow{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
|
@ -69,6 +69,8 @@ filegroup(
|
||||
"//pkg/registry/core/secret:all-srcs",
|
||||
"//pkg/registry/core/service:all-srcs",
|
||||
"//pkg/registry/core/serviceaccount:all-srcs",
|
||||
"//pkg/registry/discovery/endpointslice:all-srcs",
|
||||
"//pkg/registry/discovery/rest:all-srcs",
|
||||
"//pkg/registry/events/event:all-srcs",
|
||||
"//pkg/registry/events/rest:all-srcs",
|
||||
"//pkg/registry/extensions/controller/storage:all-srcs",
|
||||
|
38
pkg/registry/discovery/endpointslice/BUILD
Normal file
38
pkg/registry/discovery/endpointslice/BUILD
Normal file
@ -0,0 +1,38 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"strategy.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/registry/discovery/endpointslice",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//pkg/apis/discovery/validation:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//pkg/registry/discovery/endpointslice/storage:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
17
pkg/registry/discovery/endpointslice/doc.go
Normal file
17
pkg/registry/discovery/endpointslice/doc.go
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
Copyright 2019 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 endpointslice // import "k8s.io/kubernetes/pkg/registry/discovery/endpointslice"
|
29
pkg/registry/discovery/endpointslice/storage/BUILD
Normal file
29
pkg/registry/discovery/endpointslice/storage/BUILD
Normal file
@ -0,0 +1,29 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["storage.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/registry/discovery/endpointslice/storage",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//pkg/registry/discovery/endpointslice:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
51
pkg/registry/discovery/endpointslice/storage/storage.go
Normal file
51
pkg/registry/discovery/endpointslice/storage/storage.go
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright 2019 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 storage
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/registry/generic"
|
||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
"k8s.io/kubernetes/pkg/registry/discovery/endpointslice"
|
||||
)
|
||||
|
||||
// REST implements a RESTStorage for EndpointSlice against etcd
|
||||
type REST struct {
|
||||
*genericregistry.Store
|
||||
}
|
||||
|
||||
// NewREST returns a RESTStorage object that will work against endpoint slices.
|
||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
|
||||
store := &genericregistry.Store{
|
||||
NewFunc: func() runtime.Object { return &discovery.EndpointSlice{} },
|
||||
NewListFunc: func() runtime.Object { return &discovery.EndpointSliceList{} },
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*discovery.EndpointSlice).Name, nil
|
||||
},
|
||||
DefaultQualifiedResource: discovery.Resource("endpointslices"),
|
||||
|
||||
CreateStrategy: endpointslice.Strategy,
|
||||
UpdateStrategy: endpointslice.Strategy,
|
||||
DeleteStrategy: endpointslice.Strategy,
|
||||
}
|
||||
options := &generic.StoreOptions{RESTOptions: optsGetter}
|
||||
if err := store.CompleteWithOptions(options); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &REST{store}, nil
|
||||
}
|
98
pkg/registry/discovery/endpointslice/strategy.go
Normal file
98
pkg/registry/discovery/endpointslice/strategy.go
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
Copyright 2019 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 endpointslice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/apiserver/pkg/storage/names"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery/validation"
|
||||
)
|
||||
|
||||
// endpointSliceStrategy implements verification logic for Replication.
|
||||
type endpointSliceStrategy struct {
|
||||
runtime.ObjectTyper
|
||||
names.NameGenerator
|
||||
}
|
||||
|
||||
// Strategy is the default logic that applies when creating and updating Replication EndpointSlice objects.
|
||||
var Strategy = endpointSliceStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
|
||||
|
||||
// NamespaceScoped returns true because all EndpointSlices need to be within a namespace.
|
||||
func (endpointSliceStrategy) NamespaceScoped() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// PrepareForCreate clears the status of an EndpointSlice before creation.
|
||||
func (endpointSliceStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||
endpointSlice := obj.(*discovery.EndpointSlice)
|
||||
endpointSlice.Generation = 1
|
||||
}
|
||||
|
||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||
func (endpointSliceStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newEPS := obj.(*discovery.EndpointSlice)
|
||||
oldEPS := old.(*discovery.EndpointSlice)
|
||||
|
||||
// Increment generation if anything other than meta changed
|
||||
// This needs to be changed if a status attribute is added to EndpointSlice
|
||||
ogNewMeta := newEPS.ObjectMeta
|
||||
ogOldMeta := oldEPS.ObjectMeta
|
||||
newEPS.ObjectMeta = v1.ObjectMeta{}
|
||||
oldEPS.ObjectMeta = v1.ObjectMeta{}
|
||||
|
||||
if !apiequality.Semantic.DeepEqual(newEPS, oldEPS) {
|
||||
ogNewMeta.Generation = ogOldMeta.Generation + 1
|
||||
}
|
||||
|
||||
newEPS.ObjectMeta = ogNewMeta
|
||||
oldEPS.ObjectMeta = ogOldMeta
|
||||
}
|
||||
|
||||
// Validate validates a new EndpointSlice.
|
||||
func (endpointSliceStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
endpointSlice := obj.(*discovery.EndpointSlice)
|
||||
err := validation.ValidateEndpointSlice(endpointSlice)
|
||||
return err
|
||||
}
|
||||
|
||||
// Canonicalize normalizes the object after validation.
|
||||
func (endpointSliceStrategy) Canonicalize(obj runtime.Object) {
|
||||
}
|
||||
|
||||
// AllowCreateOnUpdate is false for EndpointSlice; this means POST is needed to create one.
|
||||
func (endpointSliceStrategy) AllowCreateOnUpdate() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ValidateUpdate is the default update validation for an end user.
|
||||
func (endpointSliceStrategy) ValidateUpdate(ctx context.Context, new, old runtime.Object) field.ErrorList {
|
||||
newEPS := new.(*discovery.EndpointSlice)
|
||||
oldEPS := old.(*discovery.EndpointSlice)
|
||||
return validation.ValidateEndpointSliceUpdate(newEPS, oldEPS)
|
||||
}
|
||||
|
||||
// AllowUnconditionalUpdate is the default update policy for EndpointSlice objects.
|
||||
func (endpointSliceStrategy) AllowUnconditionalUpdate() bool {
|
||||
return true
|
||||
}
|
32
pkg/registry/discovery/rest/BUILD
Normal file
32
pkg/registry/discovery/rest/BUILD
Normal file
@ -0,0 +1,32 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["storage_discovery.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/registry/discovery/rest",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/discovery:go_default_library",
|
||||
"//pkg/registry/discovery/endpointslice/storage:go_default_library",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/server:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/server/storage:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
65
pkg/registry/discovery/rest/storage_discovery.go
Normal file
65
pkg/registry/discovery/rest/storage_discovery.go
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright 2019 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 rest
|
||||
|
||||
import (
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
"k8s.io/apiserver/pkg/registry/generic"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
genericapiserver "k8s.io/apiserver/pkg/server"
|
||||
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/apis/discovery"
|
||||
endpointslicestorage "k8s.io/kubernetes/pkg/registry/discovery/endpointslice/storage"
|
||||
)
|
||||
|
||||
// StorageProvider is a REST storage provider for discovery.k8s.io.
|
||||
type StorageProvider struct{}
|
||||
|
||||
// NewRESTStorage returns a new storage provider.
|
||||
func (p StorageProvider) NewRESTStorage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (genericapiserver.APIGroupInfo, bool, error) {
|
||||
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(discovery.GroupName, legacyscheme.Scheme, legacyscheme.ParameterCodec, legacyscheme.Codecs)
|
||||
// If you add a version here, be sure to add an entry in `k8s.io/kubernetes/cmd/kube-apiserver/app/aggregator.go with specific priorities.
|
||||
// TODO refactor the plumbing to provide the information in the APIGroupInfo
|
||||
|
||||
if apiResourceConfigSource.VersionEnabled(discoveryv1alpha1.SchemeGroupVersion) {
|
||||
storageMap, err := p.v1alpha1Storage(apiResourceConfigSource, restOptionsGetter)
|
||||
if err != nil {
|
||||
return genericapiserver.APIGroupInfo{}, false, err
|
||||
}
|
||||
apiGroupInfo.VersionedResourcesStorageMap[discoveryv1alpha1.SchemeGroupVersion.Version] = storageMap
|
||||
}
|
||||
|
||||
return apiGroupInfo, true, nil
|
||||
}
|
||||
|
||||
func (p StorageProvider) v1alpha1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (map[string]rest.Storage, error) {
|
||||
storage := map[string]rest.Storage{}
|
||||
|
||||
endpointSliceStorage, err := endpointslicestorage.NewREST(restOptionsGetter)
|
||||
if err != nil {
|
||||
return storage, err
|
||||
}
|
||||
|
||||
storage["endpointslices"] = endpointSliceStorage
|
||||
return storage, err
|
||||
}
|
||||
|
||||
// GroupName is the group name for the storage provider.
|
||||
func (p StorageProvider) GroupName() string {
|
||||
return discoveryv1alpha1.GroupName
|
||||
}
|
@ -86,6 +86,7 @@ filegroup(
|
||||
"//staging/src/k8s.io/api/coordination/v1:all-srcs",
|
||||
"//staging/src/k8s.io/api/coordination/v1beta1:all-srcs",
|
||||
"//staging/src/k8s.io/api/core/v1:all-srcs",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:all-srcs",
|
||||
"//staging/src/k8s.io/api/events/v1beta1:all-srcs",
|
||||
"//staging/src/k8s.io/api/extensions/v1beta1:all-srcs",
|
||||
"//staging/src/k8s.io/api/imagepolicy/v1alpha1:all-srcs",
|
||||
|
38
staging/src/k8s.io/api/discovery/v1alpha1/BUILD
Normal file
38
staging/src/k8s.io/api/discovery/v1alpha1/BUILD
Normal file
@ -0,0 +1,38 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"generated.pb.go",
|
||||
"register.go",
|
||||
"types.go",
|
||||
"types_swagger_doc_generated.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/api/discovery/v1alpha1",
|
||||
importpath = "k8s.io/api/discovery/v1alpha1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/sortkeys:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
22
staging/src/k8s.io/api/discovery/v1alpha1/doc.go
Normal file
22
staging/src/k8s.io/api/discovery/v1alpha1/doc.go
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
Copyright 2019 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.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:protobuf-gen=package
|
||||
// +k8s:openapi-gen=true
|
||||
// +groupName=discovery.k8s.io
|
||||
|
||||
package v1alpha1 // import "k8s.io/api/discovery/v1alpha1"
|
1689
staging/src/k8s.io/api/discovery/v1alpha1/generated.pb.go
generated
Normal file
1689
staging/src/k8s.io/api/discovery/v1alpha1/generated.pb.go
generated
Normal file
File diff suppressed because it is too large
Load Diff
148
staging/src/k8s.io/api/discovery/v1alpha1/generated.proto
Normal file
148
staging/src/k8s.io/api/discovery/v1alpha1/generated.proto
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
Copyright 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 file was autogenerated by go-to-protobuf. Do not edit it manually!
|
||||
|
||||
syntax = 'proto2';
|
||||
|
||||
package k8s.io.api.discovery.v1alpha1;
|
||||
|
||||
import "k8s.io/api/core/v1/generated.proto";
|
||||
import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
|
||||
import "k8s.io/apimachinery/pkg/runtime/generated.proto";
|
||||
import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
|
||||
|
||||
// Package-wide variables from generator "generated".
|
||||
option go_package = "v1alpha1";
|
||||
|
||||
// Endpoint represents a single logical "backend" implementing a service.
|
||||
message Endpoint {
|
||||
// addresses of this endpoint. The contents of this field are interpreted
|
||||
// according to the corresponding EndpointSlice addressType field. This
|
||||
// allows for cases like dual-stack (IPv4 and IPv6) networking. Consumers
|
||||
// (e.g. kube-proxy) must handle different types of addresses in the context
|
||||
// of their own capabilities. This must contain at least one address but no
|
||||
// more than 100.
|
||||
// +listType=set
|
||||
repeated string addresses = 1;
|
||||
|
||||
// conditions contains information about the current status of the endpoint.
|
||||
optional EndpointConditions conditions = 2;
|
||||
|
||||
// hostname of this endpoint. This field may be used by consumers of
|
||||
// endpoints to distinguish endpoints from each other (e.g. in DNS names).
|
||||
// Multiple endpoints which use the same hostname should be considered
|
||||
// fungible (e.g. multiple A values in DNS). Must pass DNS Label (RFC 1123)
|
||||
// validation.
|
||||
// +optional
|
||||
optional string hostname = 3;
|
||||
|
||||
// targetRef is a reference to a Kubernetes object that represents this
|
||||
// endpoint.
|
||||
// +optional
|
||||
optional k8s.io.api.core.v1.ObjectReference targetRef = 4;
|
||||
|
||||
// topology contains arbitrary topology information associated with the
|
||||
// endpoint. These key/value pairs must conform with the label format.
|
||||
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
|
||||
// Topology may include a maximum of 16 key/value pairs. This includes, but
|
||||
// is not limited to the following well known keys:
|
||||
// * kubernetes.io/hostname: the value indicates the hostname of the node
|
||||
// where the endpoint is located. This should match the corresponding
|
||||
// node label.
|
||||
// * topology.kubernetes.io/zone: the value indicates the zone where the
|
||||
// endpoint is located. This should match the corresponding node label.
|
||||
// * topology.kubernetes.io/region: the value indicates the region where the
|
||||
// endpoint is located. This should match the corresponding node label.
|
||||
// +optional
|
||||
map<string, string> topology = 5;
|
||||
}
|
||||
|
||||
// EndpointConditions represents the current condition of an endpoint.
|
||||
message EndpointConditions {
|
||||
// ready indicates that this endpoint is prepared to receive traffic,
|
||||
// according to whatever system is managing the endpoint. A nil value
|
||||
// indicates an unknown state. In most cases consumers should interpret this
|
||||
// unknown state as ready.
|
||||
// +optional
|
||||
optional bool ready = 1;
|
||||
}
|
||||
|
||||
// EndpointPort represents a Port used by an EndpointSlice
|
||||
message EndpointPort {
|
||||
// The name of this port. All ports in an EndpointSlice must have a unique
|
||||
// name. If the EndpointSlice is dervied from a Kubernetes service, this
|
||||
// corresponds to the Service.ports[].name.
|
||||
// Name must either be an empty string or pass IANA_SVC_NAME validation:
|
||||
// * must be no more than 15 characters long
|
||||
// * may contain only [-a-z0-9]
|
||||
// * must contain at least one letter [a-z]
|
||||
// * it must not start or end with a hyphen, nor contain adjacent hyphens
|
||||
// Default is empty string.
|
||||
optional string name = 1;
|
||||
|
||||
// The IP protocol for this port.
|
||||
// Must be UDP, TCP, or SCTP.
|
||||
// Default is TCP.
|
||||
optional string protocol = 2;
|
||||
|
||||
// The port number of the endpoint.
|
||||
// If this is not specified, ports are not restricted and must be
|
||||
// interpreted in the context of the specific consumer.
|
||||
optional int32 port = 3;
|
||||
}
|
||||
|
||||
// EndpointSlice represents a subset of the endpoints that implement a service.
|
||||
// For a given service there may be multiple EndpointSlice objects, selected by
|
||||
// labels, which must be joined to produce the full set of endpoints.
|
||||
message EndpointSlice {
|
||||
// Standard object's metadata.
|
||||
// +optional
|
||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
|
||||
|
||||
// addressType specifies the type of address carried by this EndpointSlice.
|
||||
// All addresses in this slice must be the same type.
|
||||
// Default is IP
|
||||
// +optional
|
||||
optional string addressType = 4;
|
||||
|
||||
// endpoints is a list of unique endpoints in this slice. Each slice may
|
||||
// include a maximum of 1000 endpoints.
|
||||
// +listType=atomic
|
||||
repeated Endpoint endpoints = 2;
|
||||
|
||||
// ports specifies the list of network ports exposed by each endpoint in
|
||||
// this slice. Each port must have a unique name. When ports is empty, it
|
||||
// indicates that there are no defined ports. When a port is defined with a
|
||||
// nil port value, it indicates "all ports". Each slice may include a
|
||||
// maximum of 100 ports.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated EndpointPort ports = 3;
|
||||
}
|
||||
|
||||
// EndpointSliceList represents a list of endpoint slices
|
||||
message EndpointSliceList {
|
||||
// Standard list metadata.
|
||||
// +optional
|
||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
|
||||
|
||||
// List of endpoint slices
|
||||
// +listType=set
|
||||
repeated EndpointSlice items = 2;
|
||||
}
|
||||
|
56
staging/src/k8s.io/api/discovery/v1alpha1/register.go
Normal file
56
staging/src/k8s.io/api/discovery/v1alpha1/register.go
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
Copyright 2019 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"
|
||||
)
|
||||
|
||||
// GroupName is the group name used in this package
|
||||
const GroupName = "discovery.k8s.io"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
|
||||
|
||||
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
||||
func Kind(kind string) schema.GroupKind {
|
||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||
}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
var (
|
||||
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to the given scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&EndpointSlice{},
|
||||
&EndpointSliceList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
144
staging/src/k8s.io/api/discovery/v1alpha1/types.go
Normal file
144
staging/src/k8s.io/api/discovery/v1alpha1/types.go
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
Copyright 2019 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 (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// EndpointSlice represents a subset of the endpoints that implement a service.
|
||||
// For a given service there may be multiple EndpointSlice objects, selected by
|
||||
// labels, which must be joined to produce the full set of endpoints.
|
||||
type EndpointSlice struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard object's metadata.
|
||||
// +optional
|
||||
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||
// addressType specifies the type of address carried by this EndpointSlice.
|
||||
// All addresses in this slice must be the same type.
|
||||
// Default is IP
|
||||
// +optional
|
||||
AddressType *AddressType `json:"addressType" protobuf:"bytes,4,rep,name=addressType"`
|
||||
// endpoints is a list of unique endpoints in this slice. Each slice may
|
||||
// include a maximum of 1000 endpoints.
|
||||
// +listType=atomic
|
||||
Endpoints []Endpoint `json:"endpoints" protobuf:"bytes,2,rep,name=endpoints"`
|
||||
// ports specifies the list of network ports exposed by each endpoint in
|
||||
// this slice. Each port must have a unique name. When ports is empty, it
|
||||
// indicates that there are no defined ports. When a port is defined with a
|
||||
// nil port value, it indicates "all ports". Each slice may include a
|
||||
// maximum of 100 ports.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
Ports []EndpointPort `json:"ports" protobuf:"bytes,3,rep,name=ports"`
|
||||
}
|
||||
|
||||
// AddressType represents the type of address referred to by an endpoint.
|
||||
type AddressType string
|
||||
|
||||
const (
|
||||
// AddressTypeIP represents an IP Address.
|
||||
AddressTypeIP = AddressType("IP")
|
||||
)
|
||||
|
||||
// Endpoint represents a single logical "backend" implementing a service.
|
||||
type Endpoint struct {
|
||||
// addresses of this endpoint. The contents of this field are interpreted
|
||||
// according to the corresponding EndpointSlice addressType field. This
|
||||
// allows for cases like dual-stack (IPv4 and IPv6) networking. Consumers
|
||||
// (e.g. kube-proxy) must handle different types of addresses in the context
|
||||
// of their own capabilities. This must contain at least one address but no
|
||||
// more than 100.
|
||||
// +listType=set
|
||||
Addresses []string `json:"addresses" protobuf:"bytes,1,rep,name=addresses"`
|
||||
// conditions contains information about the current status of the endpoint.
|
||||
Conditions EndpointConditions `json:"conditions,omitempty" protobuf:"bytes,2,opt,name=conditions"`
|
||||
// hostname of this endpoint. This field may be used by consumers of
|
||||
// endpoints to distinguish endpoints from each other (e.g. in DNS names).
|
||||
// Multiple endpoints which use the same hostname should be considered
|
||||
// fungible (e.g. multiple A values in DNS). Must pass DNS Label (RFC 1123)
|
||||
// validation.
|
||||
// +optional
|
||||
Hostname *string `json:"hostname,omitempty" protobuf:"bytes,3,opt,name=hostname"`
|
||||
// targetRef is a reference to a Kubernetes object that represents this
|
||||
// endpoint.
|
||||
// +optional
|
||||
TargetRef *v1.ObjectReference `json:"targetRef,omitempty" protobuf:"bytes,4,opt,name=targetRef"`
|
||||
// topology contains arbitrary topology information associated with the
|
||||
// endpoint. These key/value pairs must conform with the label format.
|
||||
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
|
||||
// Topology may include a maximum of 16 key/value pairs. This includes, but
|
||||
// is not limited to the following well known keys:
|
||||
// * kubernetes.io/hostname: the value indicates the hostname of the node
|
||||
// where the endpoint is located. This should match the corresponding
|
||||
// node label.
|
||||
// * topology.kubernetes.io/zone: the value indicates the zone where the
|
||||
// endpoint is located. This should match the corresponding node label.
|
||||
// * topology.kubernetes.io/region: the value indicates the region where the
|
||||
// endpoint is located. This should match the corresponding node label.
|
||||
// +optional
|
||||
Topology map[string]string `json:"topology,omitempty" protobuf:"bytes,5,opt,name=topology"`
|
||||
}
|
||||
|
||||
// EndpointConditions represents the current condition of an endpoint.
|
||||
type EndpointConditions struct {
|
||||
// ready indicates that this endpoint is prepared to receive traffic,
|
||||
// according to whatever system is managing the endpoint. A nil value
|
||||
// indicates an unknown state. In most cases consumers should interpret this
|
||||
// unknown state as ready.
|
||||
// +optional
|
||||
Ready *bool `json:"ready,omitempty" protobuf:"bytes,1,name=ready"`
|
||||
}
|
||||
|
||||
// EndpointPort represents a Port used by an EndpointSlice
|
||||
type EndpointPort struct {
|
||||
// The name of this port. All ports in an EndpointSlice must have a unique
|
||||
// name. If the EndpointSlice is dervied from a Kubernetes service, this
|
||||
// corresponds to the Service.ports[].name.
|
||||
// Name must either be an empty string or pass IANA_SVC_NAME validation:
|
||||
// * must be no more than 15 characters long
|
||||
// * may contain only [-a-z0-9]
|
||||
// * must contain at least one letter [a-z]
|
||||
// * it must not start or end with a hyphen, nor contain adjacent hyphens
|
||||
// Default is empty string.
|
||||
Name *string `json:"name,omitempty" protobuf:"bytes,1,name=name"`
|
||||
// The IP protocol for this port.
|
||||
// Must be UDP, TCP, or SCTP.
|
||||
// Default is TCP.
|
||||
Protocol *v1.Protocol `json:"protocol,omitempty" protobuf:"bytes,2,name=protocol"`
|
||||
// The port number of the endpoint.
|
||||
// If this is not specified, ports are not restricted and must be
|
||||
// interpreted in the context of the specific consumer.
|
||||
Port *int32 `json:"port,omitempty" protobuf:"bytes,3,opt,name=port"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// EndpointSliceList represents a list of endpoint slices
|
||||
type EndpointSliceList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard list metadata.
|
||||
// +optional
|
||||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||
// List of endpoint slices
|
||||
// +listType=set
|
||||
Items []EndpointSlice `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||
}
|
85
staging/src/k8s.io/api/discovery/v1alpha1/types_swagger_doc_generated.go
generated
Normal file
85
staging/src/k8s.io/api/discovery/v1alpha1/types_swagger_doc_generated.go
generated
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright 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
|
||||
|
||||
// This file contains a collection of methods that can be used from go-restful to
|
||||
// generate Swagger API documentation for its models. Please read this PR for more
|
||||
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
|
||||
//
|
||||
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
|
||||
// they are on one line! For multiple line or blocks that you want to ignore use ---.
|
||||
// Any context after a --- is ignored.
|
||||
//
|
||||
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
|
||||
|
||||
// AUTO-GENERATED FUNCTIONS START HERE. DO NOT EDIT.
|
||||
var map_Endpoint = map[string]string{
|
||||
"": "Endpoint represents a single logical \"backend\" implementing a service.",
|
||||
"addresses": "addresses of this endpoint. The contents of this field are interpreted according to the corresponding EndpointSlice addressType field. This allows for cases like dual-stack (IPv4 and IPv6) networking. Consumers (e.g. kube-proxy) must handle different types of addresses in the context of their own capabilities. This must contain at least one address but no more than 100.",
|
||||
"conditions": "conditions contains information about the current status of the endpoint.",
|
||||
"hostname": "hostname of this endpoint. This field may be used by consumers of endpoints to distinguish endpoints from each other (e.g. in DNS names). Multiple endpoints which use the same hostname should be considered fungible (e.g. multiple A values in DNS). Must pass DNS Label (RFC 1123) validation.",
|
||||
"targetRef": "targetRef is a reference to a Kubernetes object that represents this endpoint.",
|
||||
"topology": "topology contains arbitrary topology information associated with the endpoint. These key/value pairs must conform with the label format. https://kubernetes.io/docs/concepts/overview/working-with-objects/labels Topology may include a maximum of 16 key/value pairs. This includes, but is not limited to the following well known keys: * kubernetes.io/hostname: the value indicates the hostname of the node\n where the endpoint is located. This should match the corresponding\n node label.\n* topology.kubernetes.io/zone: the value indicates the zone where the\n endpoint is located. This should match the corresponding node label.\n* topology.kubernetes.io/region: the value indicates the region where the\n endpoint is located. This should match the corresponding node label.",
|
||||
}
|
||||
|
||||
func (Endpoint) SwaggerDoc() map[string]string {
|
||||
return map_Endpoint
|
||||
}
|
||||
|
||||
var map_EndpointConditions = map[string]string{
|
||||
"": "EndpointConditions represents the current condition of an endpoint.",
|
||||
"ready": "ready indicates that this endpoint is prepared to receive traffic, according to whatever system is managing the endpoint. A nil value indicates an unknown state. In most cases consumers should interpret this unknown state as ready.",
|
||||
}
|
||||
|
||||
func (EndpointConditions) SwaggerDoc() map[string]string {
|
||||
return map_EndpointConditions
|
||||
}
|
||||
|
||||
var map_EndpointPort = map[string]string{
|
||||
"": "EndpointPort represents a Port used by an EndpointSlice",
|
||||
"name": "The name of this port. All ports in an EndpointSlice must have a unique name. If the EndpointSlice is dervied from a Kubernetes service, this corresponds to the Service.ports[].name. Name must either be an empty string or pass IANA_SVC_NAME validation: * must be no more than 15 characters long * may contain only [-a-z0-9] * must contain at least one letter [a-z] * it must not start or end with a hyphen, nor contain adjacent hyphens Default is empty string.",
|
||||
"protocol": "The IP protocol for this port. Must be UDP, TCP, or SCTP. Default is TCP.",
|
||||
"port": "The port number of the endpoint. If this is not specified, ports are not restricted and must be interpreted in the context of the specific consumer.",
|
||||
}
|
||||
|
||||
func (EndpointPort) SwaggerDoc() map[string]string {
|
||||
return map_EndpointPort
|
||||
}
|
||||
|
||||
var map_EndpointSlice = map[string]string{
|
||||
"": "EndpointSlice represents a subset of the endpoints that implement a service. For a given service there may be multiple EndpointSlice objects, selected by labels, which must be joined to produce the full set of endpoints.",
|
||||
"metadata": "Standard object's metadata.",
|
||||
"addressType": "addressType specifies the type of address carried by this EndpointSlice. All addresses in this slice must be the same type. Default is IP",
|
||||
"endpoints": "endpoints is a list of unique endpoints in this slice. Each slice may include a maximum of 1000 endpoints.",
|
||||
"ports": "ports specifies the list of network ports exposed by each endpoint in this slice. Each port must have a unique name. When ports is empty, it indicates that there are no defined ports. When a port is defined with a nil port value, it indicates \"all ports\". Each slice may include a maximum of 100 ports.",
|
||||
}
|
||||
|
||||
func (EndpointSlice) SwaggerDoc() map[string]string {
|
||||
return map_EndpointSlice
|
||||
}
|
||||
|
||||
var map_EndpointSliceList = map[string]string{
|
||||
"": "EndpointSliceList represents a list of endpoint slices",
|
||||
"metadata": "Standard list metadata.",
|
||||
"items": "List of endpoint slices",
|
||||
}
|
||||
|
||||
func (EndpointSliceList) SwaggerDoc() map[string]string {
|
||||
return map_EndpointSliceList
|
||||
}
|
||||
|
||||
// AUTO-GENERATED FUNCTIONS END HERE
|
195
staging/src/k8s.io/api/discovery/v1alpha1/zz_generated.deepcopy.go
generated
Normal file
195
staging/src/k8s.io/api/discovery/v1alpha1/zz_generated.deepcopy.go
generated
Normal file
@ -0,0 +1,195 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Endpoint) DeepCopyInto(out *Endpoint) {
|
||||
*out = *in
|
||||
if in.Addresses != nil {
|
||||
in, out := &in.Addresses, &out.Addresses
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
in.Conditions.DeepCopyInto(&out.Conditions)
|
||||
if in.Hostname != nil {
|
||||
in, out := &in.Hostname, &out.Hostname
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.TargetRef != nil {
|
||||
in, out := &in.TargetRef, &out.TargetRef
|
||||
*out = new(v1.ObjectReference)
|
||||
**out = **in
|
||||
}
|
||||
if in.Topology != nil {
|
||||
in, out := &in.Topology, &out.Topology
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Endpoint.
|
||||
func (in *Endpoint) DeepCopy() *Endpoint {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Endpoint)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *EndpointConditions) DeepCopyInto(out *EndpointConditions) {
|
||||
*out = *in
|
||||
if in.Ready != nil {
|
||||
in, out := &in.Ready, &out.Ready
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointConditions.
|
||||
func (in *EndpointConditions) DeepCopy() *EndpointConditions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(EndpointConditions)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *EndpointPort) DeepCopyInto(out *EndpointPort) {
|
||||
*out = *in
|
||||
if in.Name != nil {
|
||||
in, out := &in.Name, &out.Name
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.Protocol != nil {
|
||||
in, out := &in.Protocol, &out.Protocol
|
||||
*out = new(v1.Protocol)
|
||||
**out = **in
|
||||
}
|
||||
if in.Port != nil {
|
||||
in, out := &in.Port, &out.Port
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointPort.
|
||||
func (in *EndpointPort) DeepCopy() *EndpointPort {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(EndpointPort)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *EndpointSlice) DeepCopyInto(out *EndpointSlice) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
if in.AddressType != nil {
|
||||
in, out := &in.AddressType, &out.AddressType
|
||||
*out = new(AddressType)
|
||||
**out = **in
|
||||
}
|
||||
if in.Endpoints != nil {
|
||||
in, out := &in.Endpoints, &out.Endpoints
|
||||
*out = make([]Endpoint, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.Ports != nil {
|
||||
in, out := &in.Ports, &out.Ports
|
||||
*out = make([]EndpointPort, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointSlice.
|
||||
func (in *EndpointSlice) DeepCopy() *EndpointSlice {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(EndpointSlice)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *EndpointSlice) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *EndpointSliceList) DeepCopyInto(out *EndpointSliceList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]EndpointSlice, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointSliceList.
|
||||
func (in *EndpointSliceList) DeepCopy() *EndpointSliceList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(EndpointSliceList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *EndpointSliceList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
@ -42,6 +42,7 @@ filegroup(
|
||||
"//staging/src/k8s.io/client-go/listers/coordination/v1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/listers/coordination/v1beta1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/listers/core/v1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/listers/discovery/v1alpha1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/listers/events/v1beta1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/listers/extensions/v1beta1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/listers/imagepolicy/v1alpha1:all-srcs",
|
||||
|
@ -26,6 +26,7 @@ go_library(
|
||||
"//staging/src/k8s.io/api/coordination/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/coordination/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/events/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/networking/v1:go_default_library",
|
||||
@ -54,6 +55,7 @@ go_library(
|
||||
"//staging/src/k8s.io/client-go/informers/certificates:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/coordination:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/core:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/discovery:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/events:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/extensions:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
@ -88,6 +90,7 @@ filegroup(
|
||||
"//staging/src/k8s.io/client-go/informers/certificates:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/informers/coordination:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/informers/core:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/informers/discovery:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/informers/events:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/informers/extensions:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/informers/internalinterfaces:all-srcs",
|
||||
|
30
staging/src/k8s.io/client-go/informers/discovery/BUILD
Normal file
30
staging/src/k8s.io/client-go/informers/discovery/BUILD
Normal file
@ -0,0 +1,30 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["interface.go"],
|
||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/informers/discovery",
|
||||
importpath = "k8s.io/client-go/informers/discovery",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//staging/src/k8s.io/client-go/informers/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//staging/src/k8s.io/client-go/informers/discovery/v1alpha1:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package discovery
|
||||
|
||||
import (
|
||||
v1alpha1 "k8s.io/client-go/informers/discovery/v1alpha1"
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
)
|
||||
|
||||
// Interface provides access to each of this group's versions.
|
||||
type Interface interface {
|
||||
// V1alpha1 provides access to shared informers for resources in V1alpha1.
|
||||
V1alpha1() v1alpha1.Interface
|
||||
}
|
||||
|
||||
type group struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
namespace string
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
}
|
||||
|
||||
// New returns a new Interface.
|
||||
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
|
||||
return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
|
||||
}
|
||||
|
||||
// V1alpha1 returns a new v1alpha1.Interface.
|
||||
func (g *group) V1alpha1() v1alpha1.Interface {
|
||||
return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions)
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"endpointslice.go",
|
||||
"interface.go",
|
||||
],
|
||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/informers/discovery/v1alpha1",
|
||||
importpath = "k8s.io/client-go/informers/discovery/v1alpha1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/listers/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
v1alpha1 "k8s.io/client-go/listers/discovery/v1alpha1"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// EndpointSliceInformer provides access to a shared informer and lister for
|
||||
// EndpointSlices.
|
||||
type EndpointSliceInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1alpha1.EndpointSliceLister
|
||||
}
|
||||
|
||||
type endpointSliceInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewEndpointSliceInformer constructs a new informer for EndpointSlice type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewEndpointSliceInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredEndpointSliceInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredEndpointSliceInformer constructs a new informer for EndpointSlice type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewFilteredEndpointSliceInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
||||
return cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.DiscoveryV1alpha1().EndpointSlices(namespace).List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.DiscoveryV1alpha1().EndpointSlices(namespace).Watch(options)
|
||||
},
|
||||
},
|
||||
&discoveryv1alpha1.EndpointSlice{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *endpointSliceInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredEndpointSliceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *endpointSliceInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&discoveryv1alpha1.EndpointSlice{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *endpointSliceInformer) Lister() v1alpha1.EndpointSliceLister {
|
||||
return v1alpha1.NewEndpointSliceLister(f.Informer().GetIndexer())
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
)
|
||||
|
||||
// Interface provides access to all the informers in this group version.
|
||||
type Interface interface {
|
||||
// EndpointSlices returns a EndpointSliceInformer.
|
||||
EndpointSlices() EndpointSliceInformer
|
||||
}
|
||||
|
||||
type version struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
namespace string
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
}
|
||||
|
||||
// New returns a new Interface.
|
||||
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
|
||||
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
|
||||
}
|
||||
|
||||
// EndpointSlices returns a EndpointSliceInformer.
|
||||
func (v *version) EndpointSlices() EndpointSliceInformer {
|
||||
return &endpointSliceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
@ -34,6 +34,7 @@ import (
|
||||
certificates "k8s.io/client-go/informers/certificates"
|
||||
coordination "k8s.io/client-go/informers/coordination"
|
||||
core "k8s.io/client-go/informers/core"
|
||||
discovery "k8s.io/client-go/informers/discovery"
|
||||
events "k8s.io/client-go/informers/events"
|
||||
extensions "k8s.io/client-go/informers/extensions"
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
@ -196,6 +197,7 @@ type SharedInformerFactory interface {
|
||||
Certificates() certificates.Interface
|
||||
Coordination() coordination.Interface
|
||||
Core() core.Interface
|
||||
Discovery() discovery.Interface
|
||||
Events() events.Interface
|
||||
Extensions() extensions.Interface
|
||||
Networking() networking.Interface
|
||||
@ -239,6 +241,10 @@ func (f *sharedInformerFactory) Core() core.Interface {
|
||||
return core.New(f, f.namespace, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *sharedInformerFactory) Discovery() discovery.Interface {
|
||||
return discovery.New(f, f.namespace, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *sharedInformerFactory) Events() events.Interface {
|
||||
return events.New(f, f.namespace, f.tweakListOptions)
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import (
|
||||
coordinationv1 "k8s.io/api/coordination/v1"
|
||||
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
eventsv1beta1 "k8s.io/api/events/v1beta1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
@ -202,6 +203,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
|
||||
case corev1.SchemeGroupVersion.WithResource("serviceaccounts"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1().ServiceAccounts().Informer()}, nil
|
||||
|
||||
// Group=discovery.k8s.io, Version=v1alpha1
|
||||
case discoveryv1alpha1.SchemeGroupVersion.WithResource("endpointslices"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Discovery().V1alpha1().EndpointSlices().Informer()}, nil
|
||||
|
||||
// Group=events.k8s.io, Version=v1beta1
|
||||
case eventsv1beta1.SchemeGroupVersion.WithResource("events"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Events().V1beta1().Events().Informer()}, nil
|
||||
|
@ -32,6 +32,7 @@ go_library(
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/events/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/networking/v1:go_default_library",
|
||||
@ -87,6 +88,7 @@ filegroup(
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1beta1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1alpha1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/events/v1beta1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1:all-srcs",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/networking/v1:all-srcs",
|
||||
|
@ -42,6 +42,7 @@ import (
|
||||
coordinationv1 "k8s.io/client-go/kubernetes/typed/coordination/v1"
|
||||
coordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1"
|
||||
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
discoveryv1alpha1 "k8s.io/client-go/kubernetes/typed/discovery/v1alpha1"
|
||||
eventsv1beta1 "k8s.io/client-go/kubernetes/typed/events/v1beta1"
|
||||
extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
networkingv1 "k8s.io/client-go/kubernetes/typed/networking/v1"
|
||||
@ -85,6 +86,7 @@ type Interface interface {
|
||||
CoordinationV1beta1() coordinationv1beta1.CoordinationV1beta1Interface
|
||||
CoordinationV1() coordinationv1.CoordinationV1Interface
|
||||
CoreV1() corev1.CoreV1Interface
|
||||
DiscoveryV1alpha1() discoveryv1alpha1.DiscoveryV1alpha1Interface
|
||||
EventsV1beta1() eventsv1beta1.EventsV1beta1Interface
|
||||
ExtensionsV1beta1() extensionsv1beta1.ExtensionsV1beta1Interface
|
||||
NetworkingV1() networkingv1.NetworkingV1Interface
|
||||
@ -128,6 +130,7 @@ type Clientset struct {
|
||||
coordinationV1beta1 *coordinationv1beta1.CoordinationV1beta1Client
|
||||
coordinationV1 *coordinationv1.CoordinationV1Client
|
||||
coreV1 *corev1.CoreV1Client
|
||||
discoveryV1alpha1 *discoveryv1alpha1.DiscoveryV1alpha1Client
|
||||
eventsV1beta1 *eventsv1beta1.EventsV1beta1Client
|
||||
extensionsV1beta1 *extensionsv1beta1.ExtensionsV1beta1Client
|
||||
networkingV1 *networkingv1.NetworkingV1Client
|
||||
@ -247,6 +250,11 @@ func (c *Clientset) CoreV1() corev1.CoreV1Interface {
|
||||
return c.coreV1
|
||||
}
|
||||
|
||||
// DiscoveryV1alpha1 retrieves the DiscoveryV1alpha1Client
|
||||
func (c *Clientset) DiscoveryV1alpha1() discoveryv1alpha1.DiscoveryV1alpha1Interface {
|
||||
return c.discoveryV1alpha1
|
||||
}
|
||||
|
||||
// EventsV1beta1 retrieves the EventsV1beta1Client
|
||||
func (c *Clientset) EventsV1beta1() eventsv1beta1.EventsV1beta1Interface {
|
||||
return c.eventsV1beta1
|
||||
@ -433,6 +441,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cs.discoveryV1alpha1, err = discoveryv1alpha1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cs.eventsV1beta1, err = eventsv1beta1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -533,6 +545,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||
cs.coordinationV1beta1 = coordinationv1beta1.NewForConfigOrDie(c)
|
||||
cs.coordinationV1 = coordinationv1.NewForConfigOrDie(c)
|
||||
cs.coreV1 = corev1.NewForConfigOrDie(c)
|
||||
cs.discoveryV1alpha1 = discoveryv1alpha1.NewForConfigOrDie(c)
|
||||
cs.eventsV1beta1 = eventsv1beta1.NewForConfigOrDie(c)
|
||||
cs.extensionsV1beta1 = extensionsv1beta1.NewForConfigOrDie(c)
|
||||
cs.networkingV1 = networkingv1.NewForConfigOrDie(c)
|
||||
@ -578,6 +591,7 @@ func New(c rest.Interface) *Clientset {
|
||||
cs.coordinationV1beta1 = coordinationv1beta1.New(c)
|
||||
cs.coordinationV1 = coordinationv1.New(c)
|
||||
cs.coreV1 = corev1.New(c)
|
||||
cs.discoveryV1alpha1 = discoveryv1alpha1.New(c)
|
||||
cs.eventsV1beta1 = eventsv1beta1.New(c)
|
||||
cs.extensionsV1beta1 = extensionsv1beta1.New(c)
|
||||
cs.networkingV1 = networkingv1.New(c)
|
||||
|
@ -31,6 +31,7 @@ go_library(
|
||||
"//staging/src/k8s.io/api/coordination/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/coordination/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/events/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/networking/v1:go_default_library",
|
||||
@ -97,6 +98,8 @@ go_library(
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1beta1/fake:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1alpha1/fake:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/events/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/events/v1beta1/fake:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1:go_default_library",
|
||||
|
@ -64,6 +64,8 @@ import (
|
||||
fakecoordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1/fake"
|
||||
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
fakecorev1 "k8s.io/client-go/kubernetes/typed/core/v1/fake"
|
||||
discoveryv1alpha1 "k8s.io/client-go/kubernetes/typed/discovery/v1alpha1"
|
||||
fakediscoveryv1alpha1 "k8s.io/client-go/kubernetes/typed/discovery/v1alpha1/fake"
|
||||
eventsv1beta1 "k8s.io/client-go/kubernetes/typed/events/v1beta1"
|
||||
fakeeventsv1beta1 "k8s.io/client-go/kubernetes/typed/events/v1beta1/fake"
|
||||
extensionsv1beta1 "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
|
||||
@ -248,6 +250,11 @@ func (c *Clientset) CoreV1() corev1.CoreV1Interface {
|
||||
return &fakecorev1.FakeCoreV1{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// DiscoveryV1alpha1 retrieves the DiscoveryV1alpha1Client
|
||||
func (c *Clientset) DiscoveryV1alpha1() discoveryv1alpha1.DiscoveryV1alpha1Interface {
|
||||
return &fakediscoveryv1alpha1.FakeDiscoveryV1alpha1{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// EventsV1beta1 retrieves the EventsV1beta1Client
|
||||
func (c *Clientset) EventsV1beta1() eventsv1beta1.EventsV1beta1Interface {
|
||||
return &fakeeventsv1beta1.FakeEventsV1beta1{Fake: &c.Fake}
|
||||
|
@ -39,6 +39,7 @@ import (
|
||||
coordinationv1 "k8s.io/api/coordination/v1"
|
||||
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
eventsv1beta1 "k8s.io/api/events/v1beta1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
@ -87,6 +88,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
coordinationv1beta1.AddToScheme,
|
||||
coordinationv1.AddToScheme,
|
||||
corev1.AddToScheme,
|
||||
discoveryv1alpha1.AddToScheme,
|
||||
eventsv1beta1.AddToScheme,
|
||||
extensionsv1beta1.AddToScheme,
|
||||
networkingv1.AddToScheme,
|
||||
|
@ -30,6 +30,7 @@ go_library(
|
||||
"//staging/src/k8s.io/api/coordination/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/coordination/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/events/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/networking/v1:go_default_library",
|
||||
|
@ -39,6 +39,7 @@ import (
|
||||
coordinationv1 "k8s.io/api/coordination/v1"
|
||||
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
eventsv1beta1 "k8s.io/api/events/v1beta1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
@ -87,6 +88,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
coordinationv1beta1.AddToScheme,
|
||||
coordinationv1.AddToScheme,
|
||||
corev1.AddToScheme,
|
||||
discoveryv1alpha1.AddToScheme,
|
||||
eventsv1beta1.AddToScheme,
|
||||
extensionsv1beta1.AddToScheme,
|
||||
networkingv1.AddToScheme,
|
||||
|
@ -0,0 +1,39 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"discovery_client.go",
|
||||
"doc.go",
|
||||
"endpointslice.go",
|
||||
"generated_expansion.go",
|
||||
],
|
||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/typed/discovery/v1alpha1",
|
||||
importpath = "k8s.io/client-go/kubernetes/typed/discovery/v1alpha1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/scheme:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1alpha1/fake:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type DiscoveryV1alpha1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
EndpointSlicesGetter
|
||||
}
|
||||
|
||||
// DiscoveryV1alpha1Client is used to interact with features provided by the discovery.k8s.io group.
|
||||
type DiscoveryV1alpha1Client struct {
|
||||
restClient rest.Interface
|
||||
}
|
||||
|
||||
func (c *DiscoveryV1alpha1Client) EndpointSlices(namespace string) EndpointSliceInterface {
|
||||
return newEndpointSlices(c, namespace)
|
||||
}
|
||||
|
||||
// NewForConfig creates a new DiscoveryV1alpha1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*DiscoveryV1alpha1Client, error) {
|
||||
config := *c
|
||||
if err := setConfigDefaults(&config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, err := rest.RESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DiscoveryV1alpha1Client{client}, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new DiscoveryV1alpha1Client for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *DiscoveryV1alpha1Client {
|
||||
client, err := NewForConfig(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// New creates a new DiscoveryV1alpha1Client for the given RESTClient.
|
||||
func New(c rest.Interface) *DiscoveryV1alpha1Client {
|
||||
return &DiscoveryV1alpha1Client{c}
|
||||
}
|
||||
|
||||
func setConfigDefaults(config *rest.Config) error {
|
||||
gv := v1alpha1.SchemeGroupVersion
|
||||
config.GroupVersion = &gv
|
||||
config.APIPath = "/apis"
|
||||
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
|
||||
|
||||
if config.UserAgent == "" {
|
||||
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *DiscoveryV1alpha1Client) RESTClient() rest.Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.restClient
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// This package has the automatically generated typed clients.
|
||||
package v1alpha1
|
@ -0,0 +1,174 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
v1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
// EndpointSlicesGetter has a method to return a EndpointSliceInterface.
|
||||
// A group's client should implement this interface.
|
||||
type EndpointSlicesGetter interface {
|
||||
EndpointSlices(namespace string) EndpointSliceInterface
|
||||
}
|
||||
|
||||
// EndpointSliceInterface has methods to work with EndpointSlice resources.
|
||||
type EndpointSliceInterface interface {
|
||||
Create(*v1alpha1.EndpointSlice) (*v1alpha1.EndpointSlice, error)
|
||||
Update(*v1alpha1.EndpointSlice) (*v1alpha1.EndpointSlice, error)
|
||||
Delete(name string, options *v1.DeleteOptions) error
|
||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
||||
Get(name string, options v1.GetOptions) (*v1alpha1.EndpointSlice, error)
|
||||
List(opts v1.ListOptions) (*v1alpha1.EndpointSliceList, error)
|
||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.EndpointSlice, err error)
|
||||
EndpointSliceExpansion
|
||||
}
|
||||
|
||||
// endpointSlices implements EndpointSliceInterface
|
||||
type endpointSlices struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
}
|
||||
|
||||
// newEndpointSlices returns a EndpointSlices
|
||||
func newEndpointSlices(c *DiscoveryV1alpha1Client, namespace string) *endpointSlices {
|
||||
return &endpointSlices{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the endpointSlice, and returns the corresponding endpointSlice object, and an error if there is any.
|
||||
func (c *endpointSlices) Get(name string, options v1.GetOptions) (result *v1alpha1.EndpointSlice, err error) {
|
||||
result = &v1alpha1.EndpointSlice{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("endpointslices").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of EndpointSlices that match those selectors.
|
||||
func (c *endpointSlices) List(opts v1.ListOptions) (result *v1alpha1.EndpointSliceList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1alpha1.EndpointSliceList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("endpointslices").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested endpointSlices.
|
||||
func (c *endpointSlices) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("endpointslices").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Create takes the representation of a endpointSlice and creates it. Returns the server's representation of the endpointSlice, and an error, if there is any.
|
||||
func (c *endpointSlices) Create(endpointSlice *v1alpha1.EndpointSlice) (result *v1alpha1.EndpointSlice, err error) {
|
||||
result = &v1alpha1.EndpointSlice{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("endpointslices").
|
||||
Body(endpointSlice).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a endpointSlice and updates it. Returns the server's representation of the endpointSlice, and an error, if there is any.
|
||||
func (c *endpointSlices) Update(endpointSlice *v1alpha1.EndpointSlice) (result *v1alpha1.EndpointSlice, err error) {
|
||||
result = &v1alpha1.EndpointSlice{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("endpointslices").
|
||||
Name(endpointSlice.Name).
|
||||
Body(endpointSlice).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the endpointSlice and deletes it. Returns an error if one occurs.
|
||||
func (c *endpointSlices) Delete(name string, options *v1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("endpointslices").
|
||||
Name(name).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *endpointSlices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOptions.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("endpointslices").
|
||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched endpointSlice.
|
||||
func (c *endpointSlices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.EndpointSlice, err error) {
|
||||
result = &v1alpha1.EndpointSlice{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("endpointslices").
|
||||
SubResource(subresources...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"fake_discovery_client.go",
|
||||
"fake_endpointslice.go",
|
||||
],
|
||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/typed/discovery/v1alpha1/fake",
|
||||
importpath = "k8s.io/client-go/kubernetes/typed/discovery/v1alpha1/fake",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/testing:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
// Package fake has the automatically generated clients.
|
||||
package fake
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
v1alpha1 "k8s.io/client-go/kubernetes/typed/discovery/v1alpha1"
|
||||
rest "k8s.io/client-go/rest"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
type FakeDiscoveryV1alpha1 struct {
|
||||
*testing.Fake
|
||||
}
|
||||
|
||||
func (c *FakeDiscoveryV1alpha1) EndpointSlices(namespace string) v1alpha1.EndpointSliceInterface {
|
||||
return &FakeEndpointSlices{c, namespace}
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakeDiscoveryV1alpha1) RESTClient() rest.Interface {
|
||||
var ret *rest.RESTClient
|
||||
return ret
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
v1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
labels "k8s.io/apimachinery/pkg/labels"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
// FakeEndpointSlices implements EndpointSliceInterface
|
||||
type FakeEndpointSlices struct {
|
||||
Fake *FakeDiscoveryV1alpha1
|
||||
ns string
|
||||
}
|
||||
|
||||
var endpointslicesResource = schema.GroupVersionResource{Group: "discovery.k8s.io", Version: "v1alpha1", Resource: "endpointslices"}
|
||||
|
||||
var endpointslicesKind = schema.GroupVersionKind{Group: "discovery.k8s.io", Version: "v1alpha1", Kind: "EndpointSlice"}
|
||||
|
||||
// Get takes name of the endpointSlice, and returns the corresponding endpointSlice object, and an error if there is any.
|
||||
func (c *FakeEndpointSlices) Get(name string, options v1.GetOptions) (result *v1alpha1.EndpointSlice, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(endpointslicesResource, c.ns, name), &v1alpha1.EndpointSlice{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.EndpointSlice), err
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of EndpointSlices that match those selectors.
|
||||
func (c *FakeEndpointSlices) List(opts v1.ListOptions) (result *v1alpha1.EndpointSliceList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(endpointslicesResource, endpointslicesKind, c.ns, opts), &v1alpha1.EndpointSliceList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1alpha1.EndpointSliceList{ListMeta: obj.(*v1alpha1.EndpointSliceList).ListMeta}
|
||||
for _, item := range obj.(*v1alpha1.EndpointSliceList).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 endpointSlices.
|
||||
func (c *FakeEndpointSlices) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(endpointslicesResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Create takes the representation of a endpointSlice and creates it. Returns the server's representation of the endpointSlice, and an error, if there is any.
|
||||
func (c *FakeEndpointSlices) Create(endpointSlice *v1alpha1.EndpointSlice) (result *v1alpha1.EndpointSlice, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(endpointslicesResource, c.ns, endpointSlice), &v1alpha1.EndpointSlice{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.EndpointSlice), err
|
||||
}
|
||||
|
||||
// Update takes the representation of a endpointSlice and updates it. Returns the server's representation of the endpointSlice, and an error, if there is any.
|
||||
func (c *FakeEndpointSlices) Update(endpointSlice *v1alpha1.EndpointSlice) (result *v1alpha1.EndpointSlice, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(endpointslicesResource, c.ns, endpointSlice), &v1alpha1.EndpointSlice{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.EndpointSlice), err
|
||||
}
|
||||
|
||||
// Delete takes name of the endpointSlice and deletes it. Returns an error if one occurs.
|
||||
func (c *FakeEndpointSlices) Delete(name string, options *v1.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(endpointslicesResource, c.ns, name), &v1alpha1.EndpointSlice{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *FakeEndpointSlices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(endpointslicesResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1alpha1.EndpointSliceList{})
|
||||
return err
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched endpointSlice.
|
||||
func (c *FakeEndpointSlices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.EndpointSlice, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(endpointslicesResource, c.ns, name, pt, data, subresources...), &v1alpha1.EndpointSlice{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.EndpointSlice), err
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
type EndpointSliceExpansion interface{}
|
@ -0,0 +1,32 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"endpointslice.go",
|
||||
"expansion_generated.go",
|
||||
],
|
||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/listers/discovery/v1alpha1",
|
||||
importpath = "k8s.io/client-go/listers/discovery/v1alpha1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// EndpointSliceLister helps list EndpointSlices.
|
||||
type EndpointSliceLister interface {
|
||||
// List lists all EndpointSlices in the indexer.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.EndpointSlice, err error)
|
||||
// EndpointSlices returns an object that can list and get EndpointSlices.
|
||||
EndpointSlices(namespace string) EndpointSliceNamespaceLister
|
||||
EndpointSliceListerExpansion
|
||||
}
|
||||
|
||||
// endpointSliceLister implements the EndpointSliceLister interface.
|
||||
type endpointSliceLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewEndpointSliceLister returns a new EndpointSliceLister.
|
||||
func NewEndpointSliceLister(indexer cache.Indexer) EndpointSliceLister {
|
||||
return &endpointSliceLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all EndpointSlices in the indexer.
|
||||
func (s *endpointSliceLister) List(selector labels.Selector) (ret []*v1alpha1.EndpointSlice, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.EndpointSlice))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// EndpointSlices returns an object that can list and get EndpointSlices.
|
||||
func (s *endpointSliceLister) EndpointSlices(namespace string) EndpointSliceNamespaceLister {
|
||||
return endpointSliceNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
}
|
||||
|
||||
// EndpointSliceNamespaceLister helps list and get EndpointSlices.
|
||||
type EndpointSliceNamespaceLister interface {
|
||||
// List lists all EndpointSlices in the indexer for a given namespace.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.EndpointSlice, err error)
|
||||
// Get retrieves the EndpointSlice from the indexer for a given namespace and name.
|
||||
Get(name string) (*v1alpha1.EndpointSlice, error)
|
||||
EndpointSliceNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// endpointSliceNamespaceLister implements the EndpointSliceNamespaceLister
|
||||
// interface.
|
||||
type endpointSliceNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all EndpointSlices in the indexer for a given namespace.
|
||||
func (s endpointSliceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.EndpointSlice, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.EndpointSlice))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the EndpointSlice from the indexer for a given namespace and name.
|
||||
func (s endpointSliceNamespaceLister) Get(name string) (*v1alpha1.EndpointSlice, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1alpha1.Resource("endpointslice"), name)
|
||||
}
|
||||
return obj.(*v1alpha1.EndpointSlice), nil
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
*/
|
||||
|
||||
// Code generated by lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
// EndpointSliceListerExpansion allows custom methods to be added to
|
||||
// EndpointSliceLister.
|
||||
type EndpointSliceListerExpansion interface{}
|
||||
|
||||
// EndpointSliceNamespaceListerExpansion allows custom methods to be added to
|
||||
// EndpointSliceNamespaceLister.
|
||||
type EndpointSliceNamespaceListerExpansion interface{}
|
@ -33,6 +33,7 @@ go_test(
|
||||
"//staging/src/k8s.io/api/auditregistration/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/batch/v2alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/discovery/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/node/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/rbac/v1alpha1:go_default_library",
|
||||
|
@ -1390,6 +1390,9 @@ func getStubObj(gvr schema.GroupVersionResource, resource metav1.APIResource) (*
|
||||
|
||||
func createOrGetResource(client dynamic.Interface, gvr schema.GroupVersionResource, resource metav1.APIResource) (*unstructured.Unstructured, error) {
|
||||
stubObj, err := getStubObj(gvr, resource)
|
||||
if gvr.Group == "discovery.k8s.io" {
|
||||
fmt.Printf("stubObj =====> %v\n", stubObj)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import (
|
||||
appsv1beta2 "k8s.io/api/apps/v1beta2"
|
||||
auditregv1alpha1 "k8s.io/api/auditregistration/v1alpha1"
|
||||
batchv2alpha1 "k8s.io/api/batch/v2alpha1"
|
||||
discoveryv1alpha1 "k8s.io/api/discovery/v1alpha1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
nodev1alpha1 "k8s.io/api/node/v1alpha1"
|
||||
rbacv1alpha1 "k8s.io/api/rbac/v1alpha1"
|
||||
@ -145,6 +146,7 @@ func TestServerSidePrint(t *testing.T) {
|
||||
[]schema.GroupVersion{
|
||||
auditregv1alpha1.SchemeGroupVersion,
|
||||
batchv2alpha1.SchemeGroupVersion,
|
||||
discoveryv1alpha1.SchemeGroupVersion,
|
||||
rbacv1alpha1.SchemeGroupVersion,
|
||||
settingsv1alpha1.SchemeGroupVersion,
|
||||
schedulerapi.SchemeGroupVersion,
|
||||
|
@ -237,6 +237,13 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
|
||||
},
|
||||
// --
|
||||
|
||||
// k8s.io/kubernetes/pkg/apis/discovery/v1alpha1
|
||||
gvr("discovery.k8s.io", "v1alpha1", "endpointslices"): {
|
||||
Stub: `{"metadata": {"name": "slice1"}, "protocol": "TCP", "ports": [], "endpoints": []}`,
|
||||
ExpectedEtcdPath: "/registry/endpointslices/" + namespace + "/slice1",
|
||||
},
|
||||
// --
|
||||
|
||||
// k8s.io/kubernetes/pkg/apis/events/v1beta1
|
||||
gvr("events.k8s.io", "v1beta1", "events"): {
|
||||
Stub: `{"metadata": {"name": "event2"}, "regarding": {"namespace": "` + namespace + `"}, "note": "some data here", "eventTime": "2017-08-09T15:04:05.000000Z", "reportingInstance": "node-xyz", "reportingController": "k8s.io/my-controller", "action": "DidNothing", "reason": "Laziness"}`,
|
||||
|
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
@ -1127,6 +1127,7 @@ k8s.io/api/certificates/v1beta1
|
||||
k8s.io/api/coordination/v1
|
||||
k8s.io/api/coordination/v1beta1
|
||||
k8s.io/api/core/v1
|
||||
k8s.io/api/discovery/v1alpha1
|
||||
k8s.io/api/events/v1beta1
|
||||
k8s.io/api/extensions/v1beta1
|
||||
k8s.io/api/imagepolicy/v1alpha1
|
||||
@ -1432,6 +1433,8 @@ k8s.io/client-go/informers/coordination/v1
|
||||
k8s.io/client-go/informers/coordination/v1beta1
|
||||
k8s.io/client-go/informers/core
|
||||
k8s.io/client-go/informers/core/v1
|
||||
k8s.io/client-go/informers/discovery
|
||||
k8s.io/client-go/informers/discovery/v1alpha1
|
||||
k8s.io/client-go/informers/events
|
||||
k8s.io/client-go/informers/events/v1beta1
|
||||
k8s.io/client-go/informers/extensions
|
||||
@ -1502,6 +1505,8 @@ k8s.io/client-go/kubernetes/typed/coordination/v1beta1
|
||||
k8s.io/client-go/kubernetes/typed/coordination/v1beta1/fake
|
||||
k8s.io/client-go/kubernetes/typed/core/v1
|
||||
k8s.io/client-go/kubernetes/typed/core/v1/fake
|
||||
k8s.io/client-go/kubernetes/typed/discovery/v1alpha1
|
||||
k8s.io/client-go/kubernetes/typed/discovery/v1alpha1/fake
|
||||
k8s.io/client-go/kubernetes/typed/events/v1beta1
|
||||
k8s.io/client-go/kubernetes/typed/events/v1beta1/fake
|
||||
k8s.io/client-go/kubernetes/typed/extensions/v1beta1
|
||||
@ -1552,6 +1557,7 @@ k8s.io/client-go/listers/certificates/v1beta1
|
||||
k8s.io/client-go/listers/coordination/v1
|
||||
k8s.io/client-go/listers/coordination/v1beta1
|
||||
k8s.io/client-go/listers/core/v1
|
||||
k8s.io/client-go/listers/discovery/v1alpha1
|
||||
k8s.io/client-go/listers/events/v1beta1
|
||||
k8s.io/client-go/listers/extensions/v1beta1
|
||||
k8s.io/client-go/listers/networking/v1
|
||||
|
Loading…
Reference in New Issue
Block a user