diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 151e933846..44bc502baf 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -108,6 +108,20 @@ ${OPENAPI_PKG}/openapi-gen \ --output-package k8s.io/ingress-gce/pkg/apis/svcneg/v1beta1 \ --go-header-file ${SCRIPT_ROOT}/boilerplate.go.txt +echo "Performing code generation for ClusterSlice CRD" +${CODEGEN_PKG}/generate-groups.sh \ + "deepcopy,client,informer,lister" \ + k8s.io/ingress-gce/pkg/clusterslice/client k8s.io/ingress-gce/pkg/apis \ + "clusterslice:v1" \ + --go-header-file ${SCRIPT_ROOT}/boilerplate.go.txt + +echo "Generating openapi for ClusterSlice v1" +${OPENAPI_PKG}/openapi-gen \ + --output-file-base zz_generated.openapi \ + --input-dirs k8s.io/ingress-gce/pkg/apis/clusterslice/v1 \ + --output-package k8s.io/ingress-gce/pkg/apis/clusterslice/v1 \ + --go-header-file ${SCRIPT_ROOT}/boilerplate.go.txt + echo "Performing code generation for ServiceAttachment CRD" ${CODEGEN_PKG}/generate-groups.sh \ "deepcopy,client,informer,lister" \ diff --git a/pkg/apis/clusterslice/register.go b/pkg/apis/clusterslice/register.go new file mode 100644 index 0000000000..0ebf5184f1 --- /dev/null +++ b/pkg/apis/clusterslice/register.go @@ -0,0 +1,21 @@ +/* +Copyright 2024 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 clusterslice + +import "k8s.io/ingress-gce/pkg/flags" + +var ( + GroupName = flags.F.ClusterSliceAPIGroup +) diff --git a/pkg/apis/clusterslice/v1/doc.go b/pkg/apis/clusterslice/v1/doc.go new file mode 100644 index 0000000000..b5e21d5ae1 --- /dev/null +++ b/pkg/apis/clusterslice/v1/doc.go @@ -0,0 +1,16 @@ +/* +Copyright 2024 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 +// Package v1beta1 is the v1beta1 version of the API. +// +groupName=flags.F.ClusterSliceAPIGroup +package v1 diff --git a/pkg/apis/clusterslice/v1/register.go b/pkg/apis/clusterslice/v1/register.go new file mode 100644 index 0000000000..fa4942e208 --- /dev/null +++ b/pkg/apis/clusterslice/v1/register.go @@ -0,0 +1,50 @@ +/* +Copyright 2020 The Kubernetes Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/ingress-gce/pkg/apis/clusterslice" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: clusterslice.GroupName, Version: "v1"} + +// Kind takes an unqualified kind and returns back 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 = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &ClusterSlice{}, + &ClusterSliceList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/clusterslice/v1/types.go b/pkg/apis/clusterslice/v1/types.go new file mode 100644 index 0000000000..37afb1f840 --- /dev/null +++ b/pkg/apis/clusterslice/v1/types.go @@ -0,0 +1,64 @@ +/* +Copyright 2024 The Kubernetes Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ClusterSlice is the Schema for the ClusterSlice resource in the Multi-Project cluster. +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +// +k8s:openapi-gen=true +type ClusterSlice struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ClusterSliceSpec `json:"spec,omitempty"` + Status ClusterSliceStatus `json:"status,omitempty"` +} + +// ClusterSliceSpec is the spec for a resource +// +k8s:openapi-gen=true +type ClusterSliceSpec struct { + // The ID of the project where the cluster slice is to be created. + ProjectID string `json:"projectID,omitempty"` + // The project number where the cluster slice is to be created. + ProjectNumber int64 `json:"projectNumber,omitempty"` + // The network configuration for the cluster slice. + NetworkConfig *NetworkConfig `json:"networkConfig,omitempty"` +} + +// NetworkConfig specifies the network configuration for the cluster slice. +type NetworkConfig struct { + // The network where the cluster slice is to be created. + Network string `json:"network,omitempty"` + // The default subnetwork where the cluster slice is to be created. + DefaultSubnetwork string `json:"defaultSubnetwork,omitempty"` +} + +// ClusterSliceStatus is the status for a ClusterSlice resource +type ClusterSliceStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// ClusterSliceList is a list of ClusterSlice resources +type ClusterSliceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + Items []ClusterSlice `json:"items"` +} diff --git a/pkg/apis/clusterslice/v1/zz_generated.deepcopy.go b/pkg/apis/clusterslice/v1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..257199840f --- /dev/null +++ b/pkg/apis/clusterslice/v1/zz_generated.deepcopy.go @@ -0,0 +1,140 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2024 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 v1 + +import ( + 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 *ClusterSlice) DeepCopyInto(out *ClusterSlice) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSlice. +func (in *ClusterSlice) DeepCopy() *ClusterSlice { + if in == nil { + return nil + } + out := new(ClusterSlice) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterSlice) 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 *ClusterSliceList) DeepCopyInto(out *ClusterSliceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterSlice, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSliceList. +func (in *ClusterSliceList) DeepCopy() *ClusterSliceList { + if in == nil { + return nil + } + out := new(ClusterSliceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterSliceList) 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 *ClusterSliceSpec) DeepCopyInto(out *ClusterSliceSpec) { + *out = *in + if in.NetworkConfig != nil { + in, out := &in.NetworkConfig, &out.NetworkConfig + *out = new(NetworkConfig) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSliceSpec. +func (in *ClusterSliceSpec) DeepCopy() *ClusterSliceSpec { + if in == nil { + return nil + } + out := new(ClusterSliceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterSliceStatus) DeepCopyInto(out *ClusterSliceStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSliceStatus. +func (in *ClusterSliceStatus) DeepCopy() *ClusterSliceStatus { + if in == nil { + return nil + } + out := new(ClusterSliceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkConfig) DeepCopyInto(out *NetworkConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkConfig. +func (in *NetworkConfig) DeepCopy() *NetworkConfig { + if in == nil { + return nil + } + out := new(NetworkConfig) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/clusterslice/v1/zz_generated.openapi.go b/pkg/apis/clusterslice/v1/zz_generated.openapi.go new file mode 100644 index 0000000000..f45ad394bb --- /dev/null +++ b/pkg/apis/clusterslice/v1/zz_generated.openapi.go @@ -0,0 +1,118 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2024 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 openapi-gen. DO NOT EDIT. + +// This file was autogenerated by openapi-gen. Do not edit it manually! + +package v1 + +import ( + common "k8s.io/kube-openapi/pkg/common" + spec "k8s.io/kube-openapi/pkg/validation/spec" +) + +func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { + return map[string]common.OpenAPIDefinition{ + "k8s.io/ingress-gce/pkg/apis/clusterslice/v1.ClusterSlice": schema_pkg_apis_clusterslice_v1_ClusterSlice(ref), + "k8s.io/ingress-gce/pkg/apis/clusterslice/v1.ClusterSliceSpec": schema_pkg_apis_clusterslice_v1_ClusterSliceSpec(ref), + } +} + +func schema_pkg_apis_clusterslice_v1_ClusterSlice(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ClusterSlice is the Schema for the ClusterSlice resource in the Multi-Project cluster.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/ingress-gce/pkg/apis/clusterslice/v1.ClusterSliceSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/ingress-gce/pkg/apis/clusterslice/v1.ClusterSliceStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "k8s.io/ingress-gce/pkg/apis/clusterslice/v1.ClusterSliceSpec", "k8s.io/ingress-gce/pkg/apis/clusterslice/v1.ClusterSliceStatus"}, + } +} + +func schema_pkg_apis_clusterslice_v1_ClusterSliceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ClusterSliceSpec is the spec for a resource", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "projectID": { + SchemaProps: spec.SchemaProps{ + Description: "The ID of the project where the cluster slice is to be created.", + Type: []string{"string"}, + Format: "", + }, + }, + "projectNumber": { + SchemaProps: spec.SchemaProps{ + Description: "The project number where the cluster slice is to be created.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "networkConfig": { + SchemaProps: spec.SchemaProps{ + Description: "The network configuration for the cluster slice.", + Ref: ref("k8s.io/ingress-gce/pkg/apis/clusterslice/v1.NetworkConfig"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/ingress-gce/pkg/apis/clusterslice/v1.NetworkConfig"}, + } +} diff --git a/pkg/clusterslice/client/clientset/versioned/clientset.go b/pkg/clusterslice/client/clientset/versioned/clientset.go new file mode 100644 index 0000000000..84a166257a --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/clientset.go @@ -0,0 +1,97 @@ +/* +Copyright 2024 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 versioned + +import ( + "fmt" + + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" + flagsv1 "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + FlagsV1() flagsv1.FlagsV1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + flagsV1 *flagsv1.FlagsV1Client +} + +// FlagsV1 retrieves the FlagsV1Client +func (c *Clientset) FlagsV1() flagsv1.FlagsV1Interface { + return c.flagsV1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.flagsV1, err = flagsv1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs Clientset + cs.flagsV1 = flagsv1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.flagsV1 = flagsv1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/clusterslice/client/clientset/versioned/doc.go b/pkg/clusterslice/client/clientset/versioned/doc.go new file mode 100644 index 0000000000..53e388bcd1 --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2024 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 clientset. +package versioned diff --git a/pkg/clusterslice/client/clientset/versioned/fake/clientset_generated.go b/pkg/clusterslice/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 0000000000..87c0a14373 --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,85 @@ +/* +Copyright 2024 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 ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" + clientset "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned" + flagsv1 "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1" + fakeflagsv1 "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) + +// FlagsV1 retrieves the FlagsV1Client +func (c *Clientset) FlagsV1() flagsv1.FlagsV1Interface { + return &fakeflagsv1.FakeFlagsV1{Fake: &c.Fake} +} diff --git a/pkg/clusterslice/client/clientset/versioned/fake/doc.go b/pkg/clusterslice/client/clientset/versioned/fake/doc.go new file mode 100644 index 0000000000..c8342d4bda --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2024 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 fake clientset. +package fake diff --git a/pkg/clusterslice/client/clientset/versioned/fake/register.go b/pkg/clusterslice/client/clientset/versioned/fake/register.go new file mode 100644 index 0000000000..3fb23859d9 --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/fake/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2024 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 ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + flagsv1 "k8s.io/ingress-gce/pkg/apis/clusterslice/v1" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + flagsv1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/pkg/clusterslice/client/clientset/versioned/scheme/doc.go b/pkg/clusterslice/client/clientset/versioned/scheme/doc.go new file mode 100644 index 0000000000..0fe2de9138 --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2024 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 contains the scheme of the automatically generated clientset. +package scheme diff --git a/pkg/clusterslice/client/clientset/versioned/scheme/register.go b/pkg/clusterslice/client/clientset/versioned/scheme/register.go new file mode 100644 index 0000000000..f06a23e7f7 --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/scheme/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2024 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 scheme + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + flagsv1 "k8s.io/ingress-gce/pkg/apis/clusterslice/v1" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + flagsv1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/clusterslice.go b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/clusterslice.go new file mode 100644 index 0000000000..3724ce1b66 --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/clusterslice.go @@ -0,0 +1,178 @@ +/* +Copyright 2024 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 v1 + +import ( + "context" + "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1 "k8s.io/ingress-gce/pkg/apis/clusterslice/v1" + scheme "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned/scheme" +) + +// ClusterSlicesGetter has a method to return a ClusterSliceInterface. +// A group's client should implement this interface. +type ClusterSlicesGetter interface { + ClusterSlices(namespace string) ClusterSliceInterface +} + +// ClusterSliceInterface has methods to work with ClusterSlice resources. +type ClusterSliceInterface interface { + Create(ctx context.Context, clusterSlice *v1.ClusterSlice, opts metav1.CreateOptions) (*v1.ClusterSlice, error) + Update(ctx context.Context, clusterSlice *v1.ClusterSlice, opts metav1.UpdateOptions) (*v1.ClusterSlice, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.ClusterSlice, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.ClusterSliceList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ClusterSlice, err error) + ClusterSliceExpansion +} + +// clusterSlices implements ClusterSliceInterface +type clusterSlices struct { + client rest.Interface + ns string +} + +// newClusterSlices returns a ClusterSlices +func newClusterSlices(c *FlagsV1Client, namespace string) *clusterSlices { + return &clusterSlices{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the clusterSlice, and returns the corresponding clusterSlice object, and an error if there is any. +func (c *clusterSlices) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ClusterSlice, err error) { + result = &v1.ClusterSlice{} + err = c.client.Get(). + Namespace(c.ns). + Resource("clusterslices"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterSlices that match those selectors. +func (c *clusterSlices) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterSliceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ClusterSliceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("clusterslices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterSlices. +func (c *clusterSlices) Watch(ctx context.Context, opts metav1.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("clusterslices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a clusterSlice and creates it. Returns the server's representation of the clusterSlice, and an error, if there is any. +func (c *clusterSlices) Create(ctx context.Context, clusterSlice *v1.ClusterSlice, opts metav1.CreateOptions) (result *v1.ClusterSlice, err error) { + result = &v1.ClusterSlice{} + err = c.client.Post(). + Namespace(c.ns). + Resource("clusterslices"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterSlice). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a clusterSlice and updates it. Returns the server's representation of the clusterSlice, and an error, if there is any. +func (c *clusterSlices) Update(ctx context.Context, clusterSlice *v1.ClusterSlice, opts metav1.UpdateOptions) (result *v1.ClusterSlice, err error) { + result = &v1.ClusterSlice{} + err = c.client.Put(). + Namespace(c.ns). + Resource("clusterslices"). + Name(clusterSlice.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterSlice). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the clusterSlice and deletes it. Returns an error if one occurs. +func (c *clusterSlices) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("clusterslices"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterSlices) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("clusterslices"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched clusterSlice. +func (c *clusterSlices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ClusterSlice, err error) { + result = &v1.ClusterSlice{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("clusterslices"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/clusterslice_client.go b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/clusterslice_client.go new file mode 100644 index 0000000000..6552c0f131 --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/clusterslice_client.go @@ -0,0 +1,89 @@ +/* +Copyright 2024 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 v1 + +import ( + rest "k8s.io/client-go/rest" + v1 "k8s.io/ingress-gce/pkg/apis/clusterslice/v1" + "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned/scheme" +) + +type FlagsV1Interface interface { + RESTClient() rest.Interface + ClusterSlicesGetter +} + +// FlagsV1Client is used to interact with features provided by the flags.F.ClusterSliceAPIGroup group. +type FlagsV1Client struct { + restClient rest.Interface +} + +func (c *FlagsV1Client) ClusterSlices(namespace string) ClusterSliceInterface { + return newClusterSlices(c, namespace) +} + +// NewForConfig creates a new FlagsV1Client for the given config. +func NewForConfig(c *rest.Config) (*FlagsV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &FlagsV1Client{client}, nil +} + +// NewForConfigOrDie creates a new FlagsV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *FlagsV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new FlagsV1Client for the given RESTClient. +func New(c rest.Interface) *FlagsV1Client { + return &FlagsV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.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 *FlagsV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/doc.go b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/doc.go new file mode 100644 index 0000000000..03b25c753e --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2024 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 v1 diff --git a/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake/doc.go b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake/doc.go new file mode 100644 index 0000000000..d9bd9db276 --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2024 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 diff --git a/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake/fake_clusterslice.go b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake/fake_clusterslice.go new file mode 100644 index 0000000000..5c13f3f05f --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake/fake_clusterslice.go @@ -0,0 +1,130 @@ +/* +Copyright 2024 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 ( + "context" + + 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" + clusterslicev1 "k8s.io/ingress-gce/pkg/apis/clusterslice/v1" +) + +// FakeClusterSlices implements ClusterSliceInterface +type FakeClusterSlices struct { + Fake *FakeFlagsV1 + ns string +} + +var clusterslicesResource = schema.GroupVersionResource{Group: "flags.F.ClusterSliceAPIGroup", Version: "v1", Resource: "clusterslices"} + +var clusterslicesKind = schema.GroupVersionKind{Group: "flags.F.ClusterSliceAPIGroup", Version: "v1", Kind: "ClusterSlice"} + +// Get takes name of the clusterSlice, and returns the corresponding clusterSlice object, and an error if there is any. +func (c *FakeClusterSlices) Get(ctx context.Context, name string, options v1.GetOptions) (result *clusterslicev1.ClusterSlice, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(clusterslicesResource, c.ns, name), &clusterslicev1.ClusterSlice{}) + + if obj == nil { + return nil, err + } + return obj.(*clusterslicev1.ClusterSlice), err +} + +// List takes label and field selectors, and returns the list of ClusterSlices that match those selectors. +func (c *FakeClusterSlices) List(ctx context.Context, opts v1.ListOptions) (result *clusterslicev1.ClusterSliceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(clusterslicesResource, clusterslicesKind, c.ns, opts), &clusterslicev1.ClusterSliceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &clusterslicev1.ClusterSliceList{ListMeta: obj.(*clusterslicev1.ClusterSliceList).ListMeta} + for _, item := range obj.(*clusterslicev1.ClusterSliceList).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 clusterSlices. +func (c *FakeClusterSlices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(clusterslicesResource, c.ns, opts)) + +} + +// Create takes the representation of a clusterSlice and creates it. Returns the server's representation of the clusterSlice, and an error, if there is any. +func (c *FakeClusterSlices) Create(ctx context.Context, clusterSlice *clusterslicev1.ClusterSlice, opts v1.CreateOptions) (result *clusterslicev1.ClusterSlice, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(clusterslicesResource, c.ns, clusterSlice), &clusterslicev1.ClusterSlice{}) + + if obj == nil { + return nil, err + } + return obj.(*clusterslicev1.ClusterSlice), err +} + +// Update takes the representation of a clusterSlice and updates it. Returns the server's representation of the clusterSlice, and an error, if there is any. +func (c *FakeClusterSlices) Update(ctx context.Context, clusterSlice *clusterslicev1.ClusterSlice, opts v1.UpdateOptions) (result *clusterslicev1.ClusterSlice, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(clusterslicesResource, c.ns, clusterSlice), &clusterslicev1.ClusterSlice{}) + + if obj == nil { + return nil, err + } + return obj.(*clusterslicev1.ClusterSlice), err +} + +// Delete takes name of the clusterSlice and deletes it. Returns an error if one occurs. +func (c *FakeClusterSlices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(clusterslicesResource, c.ns, name), &clusterslicev1.ClusterSlice{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterSlices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(clusterslicesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &clusterslicev1.ClusterSliceList{}) + return err +} + +// Patch applies the patch and returns the patched clusterSlice. +func (c *FakeClusterSlices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *clusterslicev1.ClusterSlice, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(clusterslicesResource, c.ns, name, pt, data, subresources...), &clusterslicev1.ClusterSlice{}) + + if obj == nil { + return nil, err + } + return obj.(*clusterslicev1.ClusterSlice), err +} diff --git a/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake/fake_clusterslice_client.go b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake/fake_clusterslice_client.go new file mode 100644 index 0000000000..b1c907062c --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/fake/fake_clusterslice_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2024 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1 "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1" +) + +type FakeFlagsV1 struct { + *testing.Fake +} + +func (c *FakeFlagsV1) ClusterSlices(namespace string) v1.ClusterSliceInterface { + return &FakeClusterSlices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeFlagsV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/generated_expansion.go b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/generated_expansion.go new file mode 100644 index 0000000000..87152ef780 --- /dev/null +++ b/pkg/clusterslice/client/clientset/versioned/typed/clusterslice/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2024 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 v1 + +type ClusterSliceExpansion interface{} diff --git a/pkg/clusterslice/client/informers/externalversions/clusterslice/interface.go b/pkg/clusterslice/client/informers/externalversions/clusterslice/interface.go new file mode 100644 index 0000000000..506033156c --- /dev/null +++ b/pkg/clusterslice/client/informers/externalversions/clusterslice/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2024 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 clusterslice + +import ( + v1 "k8s.io/ingress-gce/pkg/clusterslice/client/informers/externalversions/clusterslice/v1" + internalinterfaces "k8s.io/ingress-gce/pkg/clusterslice/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1 provides access to shared informers for resources in V1. + V1() v1.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} +} + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/clusterslice/client/informers/externalversions/clusterslice/v1/clusterslice.go b/pkg/clusterslice/client/informers/externalversions/clusterslice/v1/clusterslice.go new file mode 100644 index 0000000000..73c2a75bbc --- /dev/null +++ b/pkg/clusterslice/client/informers/externalversions/clusterslice/v1/clusterslice.go @@ -0,0 +1,90 @@ +/* +Copyright 2024 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 v1 + +import ( + "context" + time "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + clusterslicev1 "k8s.io/ingress-gce/pkg/apis/clusterslice/v1" + versioned "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned" + internalinterfaces "k8s.io/ingress-gce/pkg/clusterslice/client/informers/externalversions/internalinterfaces" + v1 "k8s.io/ingress-gce/pkg/clusterslice/client/listers/clusterslice/v1" +) + +// ClusterSliceInformer provides access to a shared informer and lister for +// ClusterSlices. +type ClusterSliceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.ClusterSliceLister +} + +type clusterSliceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewClusterSliceInformer constructs a new informer for ClusterSlice 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 NewClusterSliceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterSliceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterSliceInformer constructs a new informer for ClusterSlice 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 NewFilteredClusterSliceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.FlagsV1().ClusterSlices(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.FlagsV1().ClusterSlices(namespace).Watch(context.TODO(), options) + }, + }, + &clusterslicev1.ClusterSlice{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterSliceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterSliceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterSliceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&clusterslicev1.ClusterSlice{}, f.defaultInformer) +} + +func (f *clusterSliceInformer) Lister() v1.ClusterSliceLister { + return v1.NewClusterSliceLister(f.Informer().GetIndexer()) +} diff --git a/pkg/clusterslice/client/informers/externalversions/clusterslice/v1/interface.go b/pkg/clusterslice/client/informers/externalversions/clusterslice/v1/interface.go new file mode 100644 index 0000000000..ccc764fb3d --- /dev/null +++ b/pkg/clusterslice/client/informers/externalversions/clusterslice/v1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2024 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 v1 + +import ( + internalinterfaces "k8s.io/ingress-gce/pkg/clusterslice/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ClusterSlices returns a ClusterSliceInformer. + ClusterSlices() ClusterSliceInformer +} + +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} +} + +// ClusterSlices returns a ClusterSliceInformer. +func (v *version) ClusterSlices() ClusterSliceInformer { + return &clusterSliceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/clusterslice/client/informers/externalversions/factory.go b/pkg/clusterslice/client/informers/externalversions/factory.go new file mode 100644 index 0000000000..e3250cc609 --- /dev/null +++ b/pkg/clusterslice/client/informers/externalversions/factory.go @@ -0,0 +1,180 @@ +/* +Copyright 2024 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 externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + versioned "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned" + clusterslice "k8s.io/ingress-gce/pkg/clusterslice/client/informers/externalversions/clusterslice" + internalinterfaces "k8s.io/ingress-gce/pkg/clusterslice/client/informers/externalversions/internalinterfaces" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Flags() clusterslice.Interface +} + +func (f *sharedInformerFactory) Flags() clusterslice.Interface { + return clusterslice.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/clusterslice/client/informers/externalversions/generic.go b/pkg/clusterslice/client/informers/externalversions/generic.go new file mode 100644 index 0000000000..c8c19e5635 --- /dev/null +++ b/pkg/clusterslice/client/informers/externalversions/generic.go @@ -0,0 +1,62 @@ +/* +Copyright 2024 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 externalversions + +import ( + "fmt" + + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + v1 "k8s.io/ingress-gce/pkg/apis/clusterslice/v1" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=flags.F.ClusterSliceAPIGroup, Version=v1 + case v1.SchemeGroupVersion.WithResource("clusterslices"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Flags().V1().ClusterSlices().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/clusterslice/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/clusterslice/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000000..ef8f82ecef --- /dev/null +++ b/pkg/clusterslice/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,40 @@ +/* +Copyright 2024 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 internalinterfaces + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" + versioned "k8s.io/ingress-gce/pkg/clusterslice/client/clientset/versioned" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/clusterslice/client/listers/clusterslice/v1/clusterslice.go b/pkg/clusterslice/client/listers/clusterslice/v1/clusterslice.go new file mode 100644 index 0000000000..a0ee0b26eb --- /dev/null +++ b/pkg/clusterslice/client/listers/clusterslice/v1/clusterslice.go @@ -0,0 +1,99 @@ +/* +Copyright 2024 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 v1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1 "k8s.io/ingress-gce/pkg/apis/clusterslice/v1" +) + +// ClusterSliceLister helps list ClusterSlices. +// All objects returned here must be treated as read-only. +type ClusterSliceLister interface { + // List lists all ClusterSlices in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.ClusterSlice, err error) + // ClusterSlices returns an object that can list and get ClusterSlices. + ClusterSlices(namespace string) ClusterSliceNamespaceLister + ClusterSliceListerExpansion +} + +// clusterSliceLister implements the ClusterSliceLister interface. +type clusterSliceLister struct { + indexer cache.Indexer +} + +// NewClusterSliceLister returns a new ClusterSliceLister. +func NewClusterSliceLister(indexer cache.Indexer) ClusterSliceLister { + return &clusterSliceLister{indexer: indexer} +} + +// List lists all ClusterSlices in the indexer. +func (s *clusterSliceLister) List(selector labels.Selector) (ret []*v1.ClusterSlice, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ClusterSlice)) + }) + return ret, err +} + +// ClusterSlices returns an object that can list and get ClusterSlices. +func (s *clusterSliceLister) ClusterSlices(namespace string) ClusterSliceNamespaceLister { + return clusterSliceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ClusterSliceNamespaceLister helps list and get ClusterSlices. +// All objects returned here must be treated as read-only. +type ClusterSliceNamespaceLister interface { + // List lists all ClusterSlices in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.ClusterSlice, err error) + // Get retrieves the ClusterSlice from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1.ClusterSlice, error) + ClusterSliceNamespaceListerExpansion +} + +// clusterSliceNamespaceLister implements the ClusterSliceNamespaceLister +// interface. +type clusterSliceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ClusterSlices in the indexer for a given namespace. +func (s clusterSliceNamespaceLister) List(selector labels.Selector) (ret []*v1.ClusterSlice, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ClusterSlice)) + }) + return ret, err +} + +// Get retrieves the ClusterSlice from the indexer for a given namespace and name. +func (s clusterSliceNamespaceLister) Get(name string) (*v1.ClusterSlice, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("clusterslice"), name) + } + return obj.(*v1.ClusterSlice), nil +} diff --git a/pkg/clusterslice/client/listers/clusterslice/v1/expansion_generated.go b/pkg/clusterslice/client/listers/clusterslice/v1/expansion_generated.go new file mode 100644 index 0000000000..f5956d1efc --- /dev/null +++ b/pkg/clusterslice/client/listers/clusterslice/v1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2024 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 v1 + +// ClusterSliceListerExpansion allows custom methods to be added to +// ClusterSliceLister. +type ClusterSliceListerExpansion interface{} + +// ClusterSliceNamespaceListerExpansion allows custom methods to be added to +// ClusterSliceNamespaceLister. +type ClusterSliceNamespaceListerExpansion interface{} diff --git a/pkg/flags/flags.go b/pkg/flags/flags.go index 632032acd1..ddd730e7e2 100644 --- a/pkg/flags/flags.go +++ b/pkg/flags/flags.go @@ -140,6 +140,7 @@ var F = struct { EnableDiscretePortForwarding bool EnableMultiProjectMode bool MultiProjectCRDProjectNameLabel string + ClusterSliceAPIGroup string EnableL4MixedProtocol bool }{ GCERateLimitScale: 1.0, @@ -330,6 +331,7 @@ L7 load balancing. CSV values accepted. Example: -node-port-ranges=80,8080,400-5 flag.BoolVar(&F.EnableMultiProjectMode, "enable-multi-project-mode", false, "Enable running in multi-project mode.") flag.StringVar(&F.MultiProjectCRDProjectNameLabel, "multi-project-crd-project-name-label", "", "The label key for project name of Project in a Project CRD in the Multi-Project cluster.") flag.BoolVar(&F.EnableL4MixedProtocol, "enable-l4-mixed-protocol", false, "Enable support for mixed protocol L4 load balancers.") + flag.StringVar(&F.ClusterSliceAPIGroup, "cluster-slice-api-group", "", "The API group for the ClusterSlice CRD.") } func Validate() { diff --git a/pkg/multiproject/projectcrd/projectcrd.go b/pkg/multiproject/projectcrd/projectcrd.go deleted file mode 100644 index a21990bd85..0000000000 --- a/pkg/multiproject/projectcrd/projectcrd.go +++ /dev/null @@ -1,47 +0,0 @@ -package projectcrd - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/ingress-gce/pkg/flags" -) - -// Project is the Schema for the Project resource in the Multi-Project cluster. -type Project struct { - metav1.TypeMeta - metav1.ObjectMeta - - Spec ProjectSpec - Status ProjectStatus -} - -// ProjectName returns the name of the project which this CRD represents. -func (p *Project) ProjectName() string { - return p.ObjectMeta.Labels[flags.F.MultiProjectCRDProjectNameLabel] -} - -// ProjectList contains a list of Projects. -type ProjectList struct { - metav1.TypeMeta - metav1.ListMeta - Items []Project -} - -// ProjectSpec specifies the desired state of the project in the MT cluster. -type ProjectSpec struct { - // GCP project number where the project is to be created. - ProjectNumber int64 - // Network configuration for the project. - NetworkConfig NetworkConfig -} - -// NetworkConfig specifies the network configuration for the project. -type NetworkConfig struct { - Network string - DefaultSubnetwork string -} - -// ProjectStatus stores the observed state of the project. -type ProjectStatus struct { - // Conditions describe the current state of the Project. - Conditions []metav1.Condition -}