diff --git a/cmd/osm-bootstrap/crds/config_meshconfig.yaml b/cmd/osm-bootstrap/crds/config_meshconfig.yaml index a1fa556c15..b57916cb57 100644 --- a/cmd/osm-bootstrap/crds/config_meshconfig.yaml +++ b/cmd/osm-bootstrap/crds/config_meshconfig.yaml @@ -31,9 +31,253 @@ spec: singular: meshconfig plural: meshconfigs versions: - - name: v1alpha2 + - name: v1alpha3 served: true storage: true + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + sidecar: + description: Configuration for Envoy sidecar + type: object + properties: + enablePrivilegedInitContainer: + description: Enables privileged init containers for pods in mesh. When false, init containers only have NET_ADMIN. + type: boolean + logLevel: + description: Sets the logging verbosity of Envoy proxy sidecar, only applicable to newly created pods joining the mesh. + type: string + enum: + - trace + - debug + - info + - warning + - warn + - error + - critical + - off + maxDataPlaneConnections: + description: Max allowed data plane sidecar connections + type: integer + envoyImage: + description: Image for the Envoy sidecar + type: string + envoyWindowsImage: + description: Image for the Envoy sidecar on Windows workers + type: string + initContainerImage: + description: Image for the init container + type: string + resources: + type: object + properties: + limits: + description: "Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/" + type: object + additionalProperties: true + requests: + description: "Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/" + type: object + additionalProperties: true + configResyncInterval: + description: Resync interval for regular proxy broadcast updates + type: string + tlsMinProtocolVersion: + description: The minimum TLS protocol version that the sidecar supports. Valid TLS protocol versions are TLS_AUTO, TLSv1_0, TLSv1_1, TLSv1_2 and TLSv1_3. + type: string + enum: + - TLS_AUTO + - TLSv1_0 + - TLSv1_1 + - TLSv1_2 + - TLSv1_3 + default: TLSv1_2 + tlsMaxProtocolVersion: + description: The maximum TLS protocol version that the sidecar supports. Valid TLS protocol versions are TLS_AUTO, TLSv1_0, TLSv1_1, TLSv1_2 and TLSv1_3. + type: string + enum: + - TLS_AUTO + - TLSv1_0 + - TLSv1_1 + - TLSv1_2 + - TLSv1_3 + default: TLSv1_3 + cipherSuites: + description: A list of ciphers that listener supports when negotiating TLS 1.0-1.2. This setting has no effect when negotiating TLS 1.3. For valid cipher names, see the latest OpenSSL ciphers manual page. E.g. https://www.openssl.org/docs/man1.1.1/apps/ciphers.html. + type: array + items: + type: string + ecdhCurves: + description: A list of ECDH curves that TLS connection supports. If not specified, the curves are [X25519, P-256] for non-FIPS build and P-256 for builds using BoringSSL FIPS. + type: array + items: + type: string + localProxyMode: + description: Sets the destination ip address the envoy proxy will use when connecting to the backend application. Acceptable values are [Localhost, PodIP]. The default value is Localhost + type: string + enum: + - Localhost + - PodIP + default: Localhost + traffic: + description: Configuration for traffic management + type: object + properties: + enableEgress: + description: Enables egress in the mesh + type: boolean + outboundIPRangeExclusionList: + description: Global list of IP address ranges to exclude from outbound traffic interception by the sidecar proxy. + type: array + items: + type: string + pattern: ((?:\d{1,3}\.){3}\d{1,3})\/(\d{1,2})$ + outboundIPRangeInclusionList: + description: Global list of IP address ranges to include for outbound traffic interception by the sidecar proxy. + type: array + items: + type: string + pattern: ((?:\d{1,3}\.){3}\d{1,3})\/(\d{1,2})$ + outboundPortExclusionList: + description: Global list of ports to exclude from outbound traffic interception by the sidecar proxy. + type: array + items: + type: integer + minimum: 1 + maximum: 65535 + inboundPortExclusionList: + description: Global list of ports to exclude from inbound traffic interception by the sidecar proxy. + type: array + items: + type: integer + minimum: 1 + maximum: 65535 + enablePermissiveTrafficPolicyMode: + description: True for allowing traffic to flow between client and service pods within the mesh without SMI traffic policies, i.e. no traffic policy enforcement in the mesh. If set to false, enables deny-all traffic policy in mesh i.e. an SMI Traffic Target is necessary for services to communicate. + type: boolean + inboundExternalAuthorization: + description: Configures external authorization for inbound and ingress connections. + type: object + properties: + enable: + description: Enables/disables the inbound external authorization policy if present. + type: boolean + address: + description: Target destination endpoint that will handle external authorization. + type: string + port: + description: Remote destination port for the external authorization endpoint. + type: integer + minimum: 1 + maximum: 65535 + statPrefix: + description: String prefix for inbound external authorization related metrics. + type: string + default: "inboundExtAuthz" + timeout: + description: Defines the timeout to consider for the remote endpoint to reply in time. + type: string + default: "1s" + failureModeAllow: + description: Allows specifying if traffic should succeed or fail if the external authorization endpoint fails to respond. + type: boolean + observability: + description: Configuration for observing the service mesh, including metrics, logs, tracing etc,. + type: object + properties: + osmLogLevel: + description: Allows setting OSM control plane log level at runtime + type: string + enableDebugServer: + description: Enables a debug endpoint on the osm-controller pod to list information regarding the mesh such as proxy connections, certificates, and SMI policies. + type: boolean + tracing: + description: Configuration for distributed tracing + type: object + properties: + enable: + description: Enables Jaeger tracing for the mesh. + type: boolean + port: + description: Port on which tracing is enabled. + type: integer + address: + description: Address of Jaeger tracing deployment, if tracing is enabled. + type: string + endpoint: + description: Endpoint for tracing data, if tracing is enabled. + type: string + certificate: + description: Configuration for certificate management + type: object + required: + - serviceCertValidityDuration + - certKeyBitSize + properties: + serviceCertValidityDuration: + description: Sets the service certificate validity duration, represented as a sequence of decimal numbers each with optional fraction and a unit suffix. + type: string + certKeyBitSize: + description: Sets the certificate key bit size for data plane certificates. + type: integer + ingressGateway: + description: Configuration for the ingress gateway's certificate + type: object + required: + - subjectAltNames + - validityDuration + - secret + properties: + subjectAltNames: + description: Subject Alternative Names secured by the certificate + type: array + items: + type: string + minItems: 1 + validityDuration: + description: Certificate validity duration, represented as a sequence of decimal numbers each with optional fraction and a unit suffix + type: string + secret: + description: Secret reference to store the certificate in + type: object + required: + - name + - namespace + properties: + name: + description: Name of the secret + type: string + namespace: + description: Namespace of the secret + type: string + featureFlags: + description: OSM feature flags + type: object + properties: + enableWASMStats: + type: boolean + enableEgressPolicy: + type: boolean + enableMulticlusterMode: + type: boolean + enableSnapshotCacheMode: + type: boolean + enableAsyncProxyServiceMapping: + type: boolean + enableIngressBackendPolicy: + type: boolean + enableEnvoyActiveHealthChecks: + type: boolean + enableRetryPolicy: + type: boolean + - name: v1alpha2 + served: true + storage: false + deprecated: true schema: openAPIV3Schema: type: object diff --git a/cmd/osm-bootstrap/osm-bootstrap.go b/cmd/osm-bootstrap/osm-bootstrap.go index 8a059097e2..f44376eca5 100644 --- a/cmd/osm-bootstrap/osm-bootstrap.go +++ b/cmd/osm-bootstrap/osm-bootstrap.go @@ -317,7 +317,7 @@ func buildDefaultMeshConfig(presetMeshConfigMap *corev1.ConfigMap) *configv1alph return &configv1alpha2.MeshConfig{ TypeMeta: metav1.TypeMeta{ Kind: "MeshConfig", - APIVersion: "config.openservicemesh.io/configv1alpha2", + APIVersion: "config.openservicemesh.io/configv1alpha3", }, ObjectMeta: metav1.ObjectMeta{ Name: meshConfigName, diff --git a/codegen/gen-crd-client.sh b/codegen/gen-crd-client.sh index bcc0252b59..b2977fb5d7 100755 --- a/codegen/gen-crd-client.sh +++ b/codegen/gen-crd-client.sh @@ -72,7 +72,7 @@ function generate_client() { } echo "##### Generating config.openservicemesh.io client ######" -generate_client "config" "v1alpha1,v1alpha2" +generate_client "config" "v1alpha1,v1alpha2,v1alpha3" echo "##### Generating policy.openservicemesh.io client ######" generate_client "policy" "v1alpha1" diff --git a/pkg/apis/config/v1alpha3/doc.go b/pkg/apis/config/v1alpha3/doc.go new file mode 100644 index 0000000000..d4cc4cec0d --- /dev/null +++ b/pkg/apis/config/v1alpha3/doc.go @@ -0,0 +1,5 @@ +// +k8s:deepcopy-gen=package,register +// +groupName=config.openservicemesh.io + +// Package v1alpha3 is the v1alpha3 version of the API. +package v1alpha3 diff --git a/pkg/apis/config/v1alpha3/mesh_config.go b/pkg/apis/config/v1alpha3/mesh_config.go new file mode 100644 index 0000000000..be575c1124 --- /dev/null +++ b/pkg/apis/config/v1alpha3/mesh_config.go @@ -0,0 +1,232 @@ +package v1alpha3 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// LocalProxyMode is a type alias representing the way the envoy sidecar proxies to the main application +type LocalProxyMode string + +const ( + // LocalProxyModeLocalhost indicates the the sidecar should communicate with the main application over localhost + LocalProxyModeLocalhost LocalProxyMode = "Localhost" + // LocalProxyModePodIP indicates that the sidecar should communicate with the main application via the pod ip + LocalProxyModePodIP LocalProxyMode = "PodIP" +) + +// MeshConfig is the type used to represent the mesh configuration. +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type MeshConfig struct { + // Object's type metadata. + metav1.TypeMeta `json:",inline" yaml:",inline"` + + // Object's metadata. + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"` + + // Spec is the MeshConfig specification. + // +optional + Spec MeshConfigSpec `json:"spec,omitempty" yaml:"spec,omitempty"` +} + +// MeshConfigSpec is the spec for OSM's configuration. +type MeshConfigSpec struct { + // Sidecar defines the configurations of the proxy sidecar in a mesh. + Sidecar SidecarSpec `json:"sidecar,omitempty"` + + // Traffic defines the traffic management configurations for a mesh instance. + Traffic TrafficSpec `json:"traffic,omitempty"` + + // Observalility defines the observability configurations for a mesh instance. + Observability ObservabilitySpec `json:"observability,omitempty"` + + // Certificate defines the certificate management configurations for a mesh instance. + Certificate CertificateSpec `json:"certificate,omitempty"` + + // FeatureFlags defines the feature flags for a mesh instance. + FeatureFlags FeatureFlags `json:"featureFlags,omitempty"` +} + +// SidecarSpec is the type used to represent the specifications for the proxy sidecar. +type SidecarSpec struct { + // EnablePrivilegedInitContainer defines a boolean indicating whether the init container for a meshed pod should run as privileged. + EnablePrivilegedInitContainer bool `json:"enablePrivilegedInitContainer"` + + // LogLevel defines the logging level for the sidecar's logs. Non developers should generally never set this value. In production environments the LogLevel should be set to error. + LogLevel string `json:"logLevel,omitempty"` + + // EnvoyImage defines the container image used for the Envoy proxy sidecar. + EnvoyImage string `json:"envoyImage,omitempty"` + + // EnvoyWindowsImage defines the windows container image used for the Envoy proxy sidecar. + EnvoyWindowsImage string `json:"envoyWindowsImage,omitempty"` + + // InitContainerImage defines the container image used for the init container injected to meshed pods. + InitContainerImage string `json:"initContainerImage,omitempty"` + + // MaxDataPlaneConnections defines the maximum allowed data plane connections from a proxy sidecar to the OSM controller. + MaxDataPlaneConnections int `json:"maxDataPlaneConnections,omitempty"` + + // ConfigResyncInterval defines the resync interval for regular proxy broadcast updates. + ConfigResyncInterval string `json:"configResyncInterval,omitempty"` + + // Resources defines the compute resources for the sidecar. + Resources corev1.ResourceRequirements `json:"resources,omitempty"` + + // TLSMinProtocolVersion defines the minimum TLS protocol version that the sidecar supports. Valid TLS protocol versions are TLS_AUTO, TLSv1_0, TLSv1_1, TLSv1_2 and TLSv1_3. + TLSMinProtocolVersion string `json:"tlsMinProtocolVersion,omitempty"` + + // TLSMaxProtocolVersion defines the maximum TLS protocol version that the sidecar supports. Valid TLS protocol versions are TLS_AUTO, TLSv1_0, TLSv1_1, TLSv1_2 and TLSv1_3. + TLSMaxProtocolVersion string `json:"tlsMaxProtocolVersion,omitempty"` + + // CipherSuites defines a list of ciphers that listener supports when negotiating TLS 1.0-1.2. This setting has no effect when negotiating TLS 1.3. For valid cipher names, see the latest OpenSSL ciphers manual page. E.g. https://www.openssl.org/docs/man1.1.1/apps/ciphers.html. + CipherSuites []string `json:"cipherSuites,omitempty"` + + // ECDHCurves defines a list of ECDH curves that TLS connection supports. If not specified, the curves are [X25519, P-256] for non-FIPS build and P-256 for builds using BoringSSL FIPS. + ECDHCurves []string `json:"ecdhCurves,omitempty"` + + // LocalProxyMode defines the network interface the envoy proxy will use to send traffic to the backend service application. Acceptable values are [`Localhost`, `PodIP`]. The default is `Localhost` + LocalProxyMode LocalProxyMode `json:"localProxyMode,omitempty"` +} + +// TrafficSpec is the type used to represent OSM's traffic management configuration. +type TrafficSpec struct { + // EnableEgress defines a boolean indicating if mesh-wide Egress is enabled. + EnableEgress bool `json:"enableEgress"` + + // OutboundIPRangeExclusionList defines a global list of IP address ranges to exclude from outbound traffic interception by the sidecar proxy. + OutboundIPRangeExclusionList []string `json:"outboundIPRangeExclusionList"` + + // OutboundIPRangeInclusionList defines a global list of IP address ranges to include for outbound traffic interception by the sidecar proxy. + // IP addresses outside this range will be excluded from outbound traffic interception by the sidecar proxy. + OutboundIPRangeInclusionList []string `json:"outboundIPRangeInclusionList"` + + // OutboundPortExclusionList defines a global list of ports to exclude from outbound traffic interception by the sidecar proxy. + OutboundPortExclusionList []int `json:"outboundPortExclusionList"` + + // InboundPortExclusionList defines a global list of ports to exclude from inbound traffic interception by the sidecar proxy. + InboundPortExclusionList []int `json:"inboundPortExclusionList"` + + // EnablePermissiveTrafficPolicyMode defines a boolean indicating if permissive traffic policy mode is enabled mesh-wide. + EnablePermissiveTrafficPolicyMode bool `json:"enablePermissiveTrafficPolicyMode"` + + // InboundExternalAuthorization defines a ruleset that, if enabled, will configure a remote external authorization endpoint + // for all inbound and ingress traffic in the mesh. + InboundExternalAuthorization ExternalAuthzSpec `json:"inboundExternalAuthorization,omitempty"` +} + +// ObservabilitySpec is the type to represent OSM's observability configurations. +type ObservabilitySpec struct { + // OSMLogLevel defines the log level for OSM control plane logs. + OSMLogLevel string `json:"osmLogLevel,omitempty"` + + // EnableDebugServer defines if the debug endpoint on the OSM controller pod is enabled. + EnableDebugServer bool `json:"enableDebugServer"` + + // Tracing defines OSM's tracing configuration. + Tracing TracingSpec `json:"tracing,omitempty"` +} + +// TracingSpec is the type to represent OSM's tracing configuration. +type TracingSpec struct { + // Enable defines a boolean indicating if the sidecars are enabled for tracing. + Enable bool `json:"enable"` + + // Port defines the tracing collector's port. + Port int16 `json:"port,omitempty"` + + // Address defines the tracing collectio's hostname. + Address string `json:"address,omitempty"` + + // Endpoint defines the API endpoint for tracing requests sent to the collector. + Endpoint string `json:"endpoint,omitempty"` +} + +// ExternalAuthzSpec is a type to represent external authorization configuration. +type ExternalAuthzSpec struct { + // Enable defines a boolean indicating if the external authorization policy is to be enabled. + Enable bool `json:"enable"` + + // Address defines the remote address of the external authorization endpoint. + Address string `json:"address,omitempty"` + + // Port defines the destination port of the remote external authorization endpoint. + Port uint16 `json:"port,omitempty"` + + // StatPrefix defines a prefix for the stats sink for this external authorization policy. + StatPrefix string `json:"statPrefix,omitempty"` + + // Timeout defines the timeout in which a response from the external authorization endpoint. + // is expected to execute. + Timeout string `json:"timeout,omitempty"` + + // FailureModeAllow defines a boolean indicating if traffic should be allowed on a failure to get a + // response against the external authorization endpoint. + FailureModeAllow bool `json:"failureModeAllow"` +} + +// CertificateSpec is the type to reperesent OSM's certificate management configuration. +type CertificateSpec struct { + // ServiceCertValidityDuration defines the service certificate validity duration. + ServiceCertValidityDuration string `json:"serviceCertValidityDuration,omitempty"` + + // CertKeyBitSize defines the certicate key bit size. + CertKeyBitSize int `json:"certKeyBitSize,omitempty"` + + // IngressGateway defines the certificate specification for an ingress gateway. + // +optional + IngressGateway *IngressGatewayCertSpec `json:"ingressGateway,omitempty"` +} + +// IngressGatewayCertSpec is the type to represent the certificate specification for an ingress gateway. +type IngressGatewayCertSpec struct { + // SubjectAltNames defines the Subject Alternative Names (domain names and IP addresses) secured by the certificate. + SubjectAltNames []string `json:"subjectAltNames"` + + // ValidityDuration defines the validity duration of the certificate. + ValidityDuration string `json:"validityDuration"` + + // Secret defines the secret in which the certificate is stored. + Secret corev1.SecretReference `json:"secret"` +} + +// MeshConfigList lists the MeshConfig objects. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type MeshConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []MeshConfig `json:"items"` +} + +// FeatureFlags is a type to represent OSM's feature flags. +type FeatureFlags struct { + // EnableWASMStats defines if WASM Stats are enabled. + EnableWASMStats bool `json:"enableWASMStats"` + + // EnableEgressPolicy defines if OSM's Egress policy is enabled. + EnableEgressPolicy bool `json:"enableEgressPolicy"` + + // EnableMulticlusterMode defines if Multicluster mode is enabled. + EnableMulticlusterMode bool `json:"enableMulticlusterMode"` + + // EnableSnapshotCacheMode defines if XDS server starts with snapshot cache. + EnableSnapshotCacheMode bool `json:"enableSnapshotCacheMode"` + + //EnableAsyncProxyServiceMapping defines if OSM will map proxies to services asynchronously. + EnableAsyncProxyServiceMapping bool `json:"enableAsyncProxyServiceMapping"` + + // EnableIngressBackendPolicy defines if OSM will use the IngressBackend API to allow ingress traffic to + // service mesh backends. + EnableIngressBackendPolicy bool `json:"enableIngressBackendPolicy"` + + // EnableEnvoyActiveHealthChecks defines if OSM will Envoy active health + // checks between services allowed to communicate. + EnableEnvoyActiveHealthChecks bool `json:"enableEnvoyActiveHealthChecks"` + + // EnableRetryPolicy defines if retry policy is enabled. + EnableRetryPolicy bool `json:"enableRetryPolicy"` +} diff --git a/pkg/apis/config/v1alpha3/multi_cluster_service.go b/pkg/apis/config/v1alpha3/multi_cluster_service.go new file mode 100644 index 0000000000..597e24ca8b --- /dev/null +++ b/pkg/apis/config/v1alpha3/multi_cluster_service.go @@ -0,0 +1,73 @@ +package v1alpha3 + +import ( + "fmt" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// MultiClusterService is the type used to represent the multicluster configuration. +// MultiClusterService name needs to match the name of the service backing the pods in each cluster. +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type MultiClusterService struct { + // Object's type metadata. + metav1.TypeMeta `json:",inline" yaml:",inline"` + + // Object's metadata. + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"` + + // Spec is the MultiClusterService specification. + Spec MultiClusterServiceSpec `json:"spec,omitempty" yaml:"spec,omitempty"` +} + +func (mcs MultiClusterService) String() string { + return fmt.Sprintf("%s/%s with SA=%s", mcs.Namespace, mcs.Name, mcs.Spec.ServiceAccount) +} + +// MultiClusterServiceSpec is the type used to represent the multicluster service specification. +type MultiClusterServiceSpec struct { + // ClusterSpec defines the configuration of other clusters + Clusters []ClusterSpec `json:"clusters,omitempty"` + + // ServiceAccount represents the service account of the multicluster service. + ServiceAccount string `json:"serviceAccount,omitempty"` + + // Ports is the list of ports exported by this service. + Ports []PortSpec `json:"ports,omitempty"` +} + +// ClusterSpec is the type used to represent a remote cluster in multicluster scenarios. +type ClusterSpec struct { + + // Address defines the remote IP address of the gateway + Address string `json:"address,omitempty"` + + // Name defines the name of the remote cluster. + Name string `json:"name,omitempty"` + + // Weight defines the load balancing weight of the remote cluster + Weight int `json:"weight,omitempty"` + + // Priority defines the priority of the remote cluster in locality based load balancing + Priority int `json:"priority,omitempty"` +} + +// PortSpec contains information on service's port. +type PortSpec struct { + // The port that will be exposed by this service. + Port uint32 + // Protocol is The IP protocol for this port. Supports "TCP", "UDP", and "SCTP". Default is TCP. + Protocol string +} + +// MultiClusterServiceList defines the list of MultiClusterService objects. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type MultiClusterServiceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []MultiClusterService `json:"items"` +} diff --git a/pkg/apis/config/v1alpha3/register.go b/pkg/apis/config/v1alpha3/register.go new file mode 100644 index 0000000000..539ffb766b --- /dev/null +++ b/pkg/apis/config/v1alpha3/register.go @@ -0,0 +1,51 @@ +// +k8s:deepcopy-gen=package,register +// +groupName=config.openservicemesh.io + +// Package v1alpha3 contains API Schema definitions for the config.openservicemesh.io v1alpha3 API group +package v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + // SchemeGroupVersion is group version used to register MeshConfig + SchemeGroupVersion = schema.GroupVersion{ + Group: "config.openservicemesh.io", + Version: "v1alpha3", + } + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme adds all Resources to the Scheme + AddToScheme = SchemeBuilder.AddToScheme +) + +// 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() +} + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &MeshConfig{}, + &MeshConfigList{}, + &MultiClusterService{}, + &MultiClusterServiceList{}, + ) + + metav1.AddToGroupVersion( + scheme, + SchemeGroupVersion, + ) + return nil +} diff --git a/pkg/apis/config/v1alpha3/zz_generated.deepcopy.go b/pkg/apis/config/v1alpha3/zz_generated.deepcopy.go new file mode 100644 index 0000000000..8bc35774d6 --- /dev/null +++ b/pkg/apis/config/v1alpha3/zz_generated.deepcopy.go @@ -0,0 +1,394 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +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 v1alpha3 + +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 *CertificateSpec) DeepCopyInto(out *CertificateSpec) { + *out = *in + if in.IngressGateway != nil { + in, out := &in.IngressGateway, &out.IngressGateway + *out = new(IngressGatewayCertSpec) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateSpec. +func (in *CertificateSpec) DeepCopy() *CertificateSpec { + if in == nil { + return nil + } + out := new(CertificateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSpec. +func (in *ClusterSpec) DeepCopy() *ClusterSpec { + if in == nil { + return nil + } + out := new(ClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExternalAuthzSpec) DeepCopyInto(out *ExternalAuthzSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalAuthzSpec. +func (in *ExternalAuthzSpec) DeepCopy() *ExternalAuthzSpec { + if in == nil { + return nil + } + out := new(ExternalAuthzSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FeatureFlags) DeepCopyInto(out *FeatureFlags) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeatureFlags. +func (in *FeatureFlags) DeepCopy() *FeatureFlags { + if in == nil { + return nil + } + out := new(FeatureFlags) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressGatewayCertSpec) DeepCopyInto(out *IngressGatewayCertSpec) { + *out = *in + if in.SubjectAltNames != nil { + in, out := &in.SubjectAltNames, &out.SubjectAltNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + out.Secret = in.Secret + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressGatewayCertSpec. +func (in *IngressGatewayCertSpec) DeepCopy() *IngressGatewayCertSpec { + if in == nil { + return nil + } + out := new(IngressGatewayCertSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MeshConfig) DeepCopyInto(out *MeshConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MeshConfig. +func (in *MeshConfig) DeepCopy() *MeshConfig { + if in == nil { + return nil + } + out := new(MeshConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MeshConfig) 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 *MeshConfigList) DeepCopyInto(out *MeshConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]MeshConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MeshConfigList. +func (in *MeshConfigList) DeepCopy() *MeshConfigList { + if in == nil { + return nil + } + out := new(MeshConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MeshConfigList) 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 *MeshConfigSpec) DeepCopyInto(out *MeshConfigSpec) { + *out = *in + in.Sidecar.DeepCopyInto(&out.Sidecar) + in.Traffic.DeepCopyInto(&out.Traffic) + out.Observability = in.Observability + in.Certificate.DeepCopyInto(&out.Certificate) + out.FeatureFlags = in.FeatureFlags + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MeshConfigSpec. +func (in *MeshConfigSpec) DeepCopy() *MeshConfigSpec { + if in == nil { + return nil + } + out := new(MeshConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MultiClusterService) DeepCopyInto(out *MultiClusterService) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiClusterService. +func (in *MultiClusterService) DeepCopy() *MultiClusterService { + if in == nil { + return nil + } + out := new(MultiClusterService) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MultiClusterService) 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 *MultiClusterServiceList) DeepCopyInto(out *MultiClusterServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]MultiClusterService, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiClusterServiceList. +func (in *MultiClusterServiceList) DeepCopy() *MultiClusterServiceList { + if in == nil { + return nil + } + out := new(MultiClusterServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MultiClusterServiceList) 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 *MultiClusterServiceSpec) DeepCopyInto(out *MultiClusterServiceSpec) { + *out = *in + if in.Clusters != nil { + in, out := &in.Clusters, &out.Clusters + *out = make([]ClusterSpec, len(*in)) + copy(*out, *in) + } + if in.Ports != nil { + in, out := &in.Ports, &out.Ports + *out = make([]PortSpec, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiClusterServiceSpec. +func (in *MultiClusterServiceSpec) DeepCopy() *MultiClusterServiceSpec { + if in == nil { + return nil + } + out := new(MultiClusterServiceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ObservabilitySpec) DeepCopyInto(out *ObservabilitySpec) { + *out = *in + out.Tracing = in.Tracing + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObservabilitySpec. +func (in *ObservabilitySpec) DeepCopy() *ObservabilitySpec { + if in == nil { + return nil + } + out := new(ObservabilitySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PortSpec) DeepCopyInto(out *PortSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortSpec. +func (in *PortSpec) DeepCopy() *PortSpec { + if in == nil { + return nil + } + out := new(PortSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SidecarSpec) DeepCopyInto(out *SidecarSpec) { + *out = *in + in.Resources.DeepCopyInto(&out.Resources) + if in.CipherSuites != nil { + in, out := &in.CipherSuites, &out.CipherSuites + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ECDHCurves != nil { + in, out := &in.ECDHCurves, &out.ECDHCurves + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SidecarSpec. +func (in *SidecarSpec) DeepCopy() *SidecarSpec { + if in == nil { + return nil + } + out := new(SidecarSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TracingSpec) DeepCopyInto(out *TracingSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TracingSpec. +func (in *TracingSpec) DeepCopy() *TracingSpec { + if in == nil { + return nil + } + out := new(TracingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TrafficSpec) DeepCopyInto(out *TrafficSpec) { + *out = *in + if in.OutboundIPRangeExclusionList != nil { + in, out := &in.OutboundIPRangeExclusionList, &out.OutboundIPRangeExclusionList + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.OutboundIPRangeInclusionList != nil { + in, out := &in.OutboundIPRangeInclusionList, &out.OutboundIPRangeInclusionList + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.OutboundPortExclusionList != nil { + in, out := &in.OutboundPortExclusionList, &out.OutboundPortExclusionList + *out = make([]int, len(*in)) + copy(*out, *in) + } + if in.InboundPortExclusionList != nil { + in, out := &in.InboundPortExclusionList, &out.InboundPortExclusionList + *out = make([]int, len(*in)) + copy(*out, *in) + } + out.InboundExternalAuthorization = in.InboundExternalAuthorization + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficSpec. +func (in *TrafficSpec) DeepCopy() *TrafficSpec { + if in == nil { + return nil + } + out := new(TrafficSpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/crdconversion/config_meshconfig_conversion.go b/pkg/crdconversion/config_meshconfig_conversion.go index f39373e275..2d5eef376c 100644 --- a/pkg/crdconversion/config_meshconfig_conversion.go +++ b/pkg/crdconversion/config_meshconfig_conversion.go @@ -5,6 +5,10 @@ import ( "github.com/pkg/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + + configv1alpha1 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha1" + configv1alpha2 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha2" + configv1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" ) // serveMeshConfigConversion servers endpoint for the converter defined as convertMeshConfig function. @@ -24,20 +28,27 @@ func convertMeshConfig(obj *unstructured.Unstructured, toVersion string) (*unstr log.Debug().Msgf("MeshConfig conversion request: from-version=%s, to-version=%s", fromVersion, toVersion) switch fromVersion { - case "config.openservicemesh.io/v1alpha1": + case configv1alpha1.SchemeGroupVersion.String(): switch toVersion { - case "config.openservicemesh.io/v1alpha2": + case configv1alpha2.SchemeGroupVersion.String(): log.Debug().Msgf("Converting MeshConfig v1alpha1 -> v1alpha2") // v1alpha2 is backward compatible with v1alpha1, so no conversion is // necessary at this moment. - + case configv1alpha3.SchemeGroupVersion.String(): + log.Debug().Msgf("Converting MeshConfig v1alpha1 -> v1alpha3") + // v1alpha3 is backward compatible with v1alpha1, so no conversion is + // necessary at this moment. default: return nil, errors.Errorf("Unexpected conversion to-version for MeshConfig resource: %s", toVersion) } - case "config.openservicemesh.io/v1alpha2": + case configv1alpha2.SchemeGroupVersion.String(): switch toVersion { - case "config.openservicemesh.io/v1alpha1": + case configv1alpha3.SchemeGroupVersion.String(): + log.Debug().Msgf("Converting MeshConfig v1alpha2 -> v1alpha3") + // v1alpha3 is backward compatible with v1alpha2, so no conversion is + // necessary at this moment. + case configv1alpha1.SchemeGroupVersion.String(): log.Debug().Msgf("Converting MeshConfig v1alpha2 -> v1alpha1") // Remove spec.traffic.outboundIPRangeInclusionList field not supported in v1alpha1 unsupportedFields := [][]string{ @@ -58,6 +69,43 @@ func convertMeshConfig(obj *unstructured.Unstructured, toVersion string) (*unstr return nil, errors.Errorf("Unexpected conversion to-version for MeshConfig resource: %s", toVersion) } + case configv1alpha3.SchemeGroupVersion.String(): + switch toVersion { + case configv1alpha2.SchemeGroupVersion.String(): + log.Debug().Msgf("Converting MeshConfig v1alpha3 -> v1alpha2") + // Remove spec.sidecar.localProxyMode field not supported in v1alpha2 + unsupportedFields := [][]string{ + {"spec", "sidecar", "localProxyMode"}, + } + + for _, unsupportedField := range unsupportedFields { + _, found, err := unstructured.NestedSlice(convertedObject.Object, unsupportedField...) + if found && err == nil { + unstructured.RemoveNestedField(convertedObject.Object, unsupportedField...) + } + } + case configv1alpha1.SchemeGroupVersion.String(): + log.Debug().Msgf("Converting MeshConfig v1alpha3 -> v1alpha1") + // Remove spec.sidecar.localProxyMode field not supported in v1alpha1 + // as well as other v1alpha2 fields not supported in v1alpha1 + unsupportedFields := [][]string{ + {"spec", "traffic", "outboundIPRangeInclusionList"}, + {"spec", "sidecar", "tlsMinProtocolVersion"}, + {"spec", "sidecar", "tlsMaxProtocolVersion"}, + {"spec", "sidecar", "cipherSuites"}, + {"spec", "sidecar", "ecdhCurves"}, + {"spec", "sidecar", "localProxyMode"}, + } + + for _, unsupportedField := range unsupportedFields { + _, found, err := unstructured.NestedSlice(convertedObject.Object, unsupportedField...) + if found && err == nil { + unstructured.RemoveNestedField(convertedObject.Object, unsupportedField...) + } + } + default: + return nil, errors.Errorf("Unexpected conversion to-version for MeshConfig resource: %s", toVersion) + } default: return nil, errors.Errorf("Unexpected conversion from-version for MeshConfig resource: %s", fromVersion) } diff --git a/pkg/crdconversion/config_meshconfig_conversion_test.go b/pkg/crdconversion/config_meshconfig_conversion_test.go index 0e442c16bf..63f3d7387d 100644 --- a/pkg/crdconversion/config_meshconfig_conversion_test.go +++ b/pkg/crdconversion/config_meshconfig_conversion_test.go @@ -10,6 +10,7 @@ import ( configv1alpha1 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha1" configv1alpha2 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha2" + configv1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" ) func TestConvertMeshConfig(t *testing.T) { @@ -19,6 +20,79 @@ func TestConvertMeshConfig(t *testing.T) { toVersion string verifyFn func(*assert.Assertions, *unstructured.Unstructured, error) }{ + { + name: "v1alpha3 -> v1alpha2 should remove additional field", + request: &configv1alpha3.MeshConfig{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "config.openservicemesh.io/v1alpha3", + Kind: "MeshConfig", + }, + Spec: configv1alpha3.MeshConfigSpec{ + Traffic: configv1alpha3.TrafficSpec{ + OutboundIPRangeInclusionList: []string{"1.1.1.1/32"}, + }, + Sidecar: configv1alpha3.SidecarSpec{ + TLSMinProtocolVersion: "TLSv1_2", + TLSMaxProtocolVersion: "TLSv1_3", + CipherSuites: []string{"SomeCipherSuite"}, + ECDHCurves: []string{"SomeECDHCurve"}, + LocalProxyMode: configv1alpha3.LocalProxyModePodIP, + }, + }, + }, + toVersion: "config.openservicemesh.io/v1alpha2", + verifyFn: func(a *assert.Assertions, converted *unstructured.Unstructured, err error) { + a.NoError(err) + + unsupportedFields := [][]string{ + {"spec", "sidecar", "localProxyMode"}, + } + + for _, unsupportedField := range unsupportedFields { + _, found, _ := unstructured.NestedSlice(converted.Object, unsupportedField...) + a.False(found) + } + }, + }, + { + name: "v1alpha3 -> v1alpha1 should remove additional field", + request: &configv1alpha3.MeshConfig{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "config.openservicemesh.io/v1alpha3", + Kind: "MeshConfig", + }, + Spec: configv1alpha3.MeshConfigSpec{ + Traffic: configv1alpha3.TrafficSpec{ + OutboundIPRangeInclusionList: []string{"1.1.1.1/32"}, + }, + Sidecar: configv1alpha3.SidecarSpec{ + TLSMinProtocolVersion: "TLSv1_2", + TLSMaxProtocolVersion: "TLSv1_3", + CipherSuites: []string{"SomeCipherSuite"}, + ECDHCurves: []string{"SomeECDHCurve"}, + LocalProxyMode: configv1alpha3.LocalProxyModePodIP, + }, + }, + }, + toVersion: "config.openservicemesh.io/v1alpha1", + verifyFn: func(a *assert.Assertions, converted *unstructured.Unstructured, err error) { + a.NoError(err) + + unsupportedFields := [][]string{ + {"spec", "traffic", "outboundIPRangeInclusionList"}, + {"spec", "sidecar", "tlsMinProtocolVersion"}, + {"spec", "sidecar", "tlsMaxProtocolVersion"}, + {"spec", "sidecar", "cipherSuites"}, + {"spec", "sidecar", "ecdhCurves"}, + {"spec", "sidecar", "localProxyMode"}, + } + + for _, unsupportedField := range unsupportedFields { + _, found, _ := unstructured.NestedSlice(converted.Object, unsupportedField...) + a.False(found) + } + }, + }, { name: "v1alpha2 -> v1alpha1 should remove additional field", request: &configv1alpha2.MeshConfig{ @@ -70,6 +144,34 @@ func TestConvertMeshConfig(t *testing.T) { a.NoError(err) }, }, + { + name: "v1alpha1 -> v1alpha3", + request: &configv1alpha1.MeshConfig{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "config.openservicemesh.io/v1alpha1", + Kind: "MeshConfig", + }, + Spec: configv1alpha1.MeshConfigSpec{}, + }, + toVersion: "config.openservicemesh.io/v1alpha3", + verifyFn: func(a *assert.Assertions, converted *unstructured.Unstructured, err error) { + a.NoError(err) + }, + }, + { + name: "v1alpha2 -> v1alpha3", + request: &configv1alpha2.MeshConfig{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "config.openservicemesh.io/v1alpha2", + Kind: "MeshConfig", + }, + Spec: configv1alpha2.MeshConfigSpec{}, + }, + toVersion: "config.openservicemesh.io/v1alpha3", + verifyFn: func(a *assert.Assertions, converted *unstructured.Unstructured, err error) { + a.NoError(err) + }, + }, } for _, tc := range testCases { diff --git a/pkg/gen/client/config/clientset/versioned/clientset.go b/pkg/gen/client/config/clientset/versioned/clientset.go index 380498f9ef..f946c982f3 100644 --- a/pkg/gen/client/config/clientset/versioned/clientset.go +++ b/pkg/gen/client/config/clientset/versioned/clientset.go @@ -20,6 +20,7 @@ import ( configv1alpha1 "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha1" configv1alpha2 "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha2" + configv1alpha3 "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -29,6 +30,7 @@ type Interface interface { Discovery() discovery.DiscoveryInterface ConfigV1alpha1() configv1alpha1.ConfigV1alpha1Interface ConfigV1alpha2() configv1alpha2.ConfigV1alpha2Interface + ConfigV1alpha3() configv1alpha3.ConfigV1alpha3Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -37,6 +39,7 @@ type Clientset struct { *discovery.DiscoveryClient configV1alpha1 *configv1alpha1.ConfigV1alpha1Client configV1alpha2 *configv1alpha2.ConfigV1alpha2Client + configV1alpha3 *configv1alpha3.ConfigV1alpha3Client } // ConfigV1alpha1 retrieves the ConfigV1alpha1Client @@ -49,6 +52,11 @@ func (c *Clientset) ConfigV1alpha2() configv1alpha2.ConfigV1alpha2Interface { return c.configV1alpha2 } +// ConfigV1alpha3 retrieves the ConfigV1alpha3Client +func (c *Clientset) ConfigV1alpha3() configv1alpha3.ConfigV1alpha3Interface { + return c.configV1alpha3 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -78,6 +86,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.configV1alpha3, err = configv1alpha3.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -92,6 +104,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.configV1alpha1 = configv1alpha1.NewForConfigOrDie(c) cs.configV1alpha2 = configv1alpha2.NewForConfigOrDie(c) + cs.configV1alpha3 = configv1alpha3.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -102,6 +115,7 @@ func New(c rest.Interface) *Clientset { var cs Clientset cs.configV1alpha1 = configv1alpha1.New(c) cs.configV1alpha2 = configv1alpha2.New(c) + cs.configV1alpha3 = configv1alpha3.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/gen/client/config/clientset/versioned/fake/clientset_generated.go b/pkg/gen/client/config/clientset/versioned/fake/clientset_generated.go index ee226334d2..959a8a7998 100644 --- a/pkg/gen/client/config/clientset/versioned/fake/clientset_generated.go +++ b/pkg/gen/client/config/clientset/versioned/fake/clientset_generated.go @@ -21,6 +21,8 @@ import ( fakeconfigv1alpha1 "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha1/fake" configv1alpha2 "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha2" fakeconfigv1alpha2 "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha2/fake" + configv1alpha3 "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3" + fakeconfigv1alpha3 "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -87,3 +89,8 @@ func (c *Clientset) ConfigV1alpha1() configv1alpha1.ConfigV1alpha1Interface { func (c *Clientset) ConfigV1alpha2() configv1alpha2.ConfigV1alpha2Interface { return &fakeconfigv1alpha2.FakeConfigV1alpha2{Fake: &c.Fake} } + +// ConfigV1alpha3 retrieves the ConfigV1alpha3Client +func (c *Clientset) ConfigV1alpha3() configv1alpha3.ConfigV1alpha3Interface { + return &fakeconfigv1alpha3.FakeConfigV1alpha3{Fake: &c.Fake} +} diff --git a/pkg/gen/client/config/clientset/versioned/fake/register.go b/pkg/gen/client/config/clientset/versioned/fake/register.go index eb29f255d8..efdee6ab65 100644 --- a/pkg/gen/client/config/clientset/versioned/fake/register.go +++ b/pkg/gen/client/config/clientset/versioned/fake/register.go @@ -18,6 +18,7 @@ package fake import ( configv1alpha1 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha1" configv1alpha2 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha2" + configv1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,6 +32,7 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ configv1alpha1.AddToScheme, configv1alpha2.AddToScheme, + configv1alpha3.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/gen/client/config/clientset/versioned/scheme/register.go b/pkg/gen/client/config/clientset/versioned/scheme/register.go index f35d076326..228151598f 100644 --- a/pkg/gen/client/config/clientset/versioned/scheme/register.go +++ b/pkg/gen/client/config/clientset/versioned/scheme/register.go @@ -18,6 +18,7 @@ package scheme import ( configv1alpha1 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha1" configv1alpha2 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha2" + configv1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,6 +32,7 @@ var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ configv1alpha1.AddToScheme, configv1alpha2.AddToScheme, + configv1alpha3.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/config_client.go b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/config_client.go new file mode 100644 index 0000000000..ae2bfe00f0 --- /dev/null +++ b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/config_client.go @@ -0,0 +1,91 @@ +/* +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 v1alpha3 + +import ( + v1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" + "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type ConfigV1alpha3Interface interface { + RESTClient() rest.Interface + MeshConfigsGetter + MultiClusterServicesGetter +} + +// ConfigV1alpha3Client is used to interact with features provided by the config.openservicemesh.io group. +type ConfigV1alpha3Client struct { + restClient rest.Interface +} + +func (c *ConfigV1alpha3Client) MeshConfigs(namespace string) MeshConfigInterface { + return newMeshConfigs(c, namespace) +} + +func (c *ConfigV1alpha3Client) MultiClusterServices(namespace string) MultiClusterServiceInterface { + return newMultiClusterServices(c, namespace) +} + +// NewForConfig creates a new ConfigV1alpha3Client for the given config. +func NewForConfig(c *rest.Config) (*ConfigV1alpha3Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ConfigV1alpha3Client{client}, nil +} + +// NewForConfigOrDie creates a new ConfigV1alpha3Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ConfigV1alpha3Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ConfigV1alpha3Client for the given RESTClient. +func New(c rest.Interface) *ConfigV1alpha3Client { + return &ConfigV1alpha3Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha3.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 *ConfigV1alpha3Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/doc.go b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/doc.go new file mode 100644 index 0000000000..958a357d1d --- /dev/null +++ b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/doc.go @@ -0,0 +1,17 @@ +/* +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 v1alpha3 diff --git a/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/doc.go b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/doc.go new file mode 100644 index 0000000000..b8b5e2568b --- /dev/null +++ b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/doc.go @@ -0,0 +1,17 @@ +/* +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/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/fake_config_client.go b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/fake_config_client.go new file mode 100644 index 0000000000..8bd3f29e43 --- /dev/null +++ b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/fake_config_client.go @@ -0,0 +1,41 @@ +/* +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 ( + v1alpha3 "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeConfigV1alpha3 struct { + *testing.Fake +} + +func (c *FakeConfigV1alpha3) MeshConfigs(namespace string) v1alpha3.MeshConfigInterface { + return &FakeMeshConfigs{c, namespace} +} + +func (c *FakeConfigV1alpha3) MultiClusterServices(namespace string) v1alpha3.MultiClusterServiceInterface { + return &FakeMultiClusterServices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeConfigV1alpha3) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/fake_meshconfig.go b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/fake_meshconfig.go new file mode 100644 index 0000000000..afa7c7cb68 --- /dev/null +++ b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/fake_meshconfig.go @@ -0,0 +1,127 @@ +/* +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" + + v1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" + 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" +) + +// FakeMeshConfigs implements MeshConfigInterface +type FakeMeshConfigs struct { + Fake *FakeConfigV1alpha3 + ns string +} + +var meshconfigsResource = schema.GroupVersionResource{Group: "config.openservicemesh.io", Version: "v1alpha3", Resource: "meshconfigs"} + +var meshconfigsKind = schema.GroupVersionKind{Group: "config.openservicemesh.io", Version: "v1alpha3", Kind: "MeshConfig"} + +// Get takes name of the meshConfig, and returns the corresponding meshConfig object, and an error if there is any. +func (c *FakeMeshConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.MeshConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(meshconfigsResource, c.ns, name), &v1alpha3.MeshConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.MeshConfig), err +} + +// List takes label and field selectors, and returns the list of MeshConfigs that match those selectors. +func (c *FakeMeshConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.MeshConfigList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(meshconfigsResource, meshconfigsKind, c.ns, opts), &v1alpha3.MeshConfigList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha3.MeshConfigList{ListMeta: obj.(*v1alpha3.MeshConfigList).ListMeta} + for _, item := range obj.(*v1alpha3.MeshConfigList).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 meshConfigs. +func (c *FakeMeshConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(meshconfigsResource, c.ns, opts)) + +} + +// Create takes the representation of a meshConfig and creates it. Returns the server's representation of the meshConfig, and an error, if there is any. +func (c *FakeMeshConfigs) Create(ctx context.Context, meshConfig *v1alpha3.MeshConfig, opts v1.CreateOptions) (result *v1alpha3.MeshConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(meshconfigsResource, c.ns, meshConfig), &v1alpha3.MeshConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.MeshConfig), err +} + +// Update takes the representation of a meshConfig and updates it. Returns the server's representation of the meshConfig, and an error, if there is any. +func (c *FakeMeshConfigs) Update(ctx context.Context, meshConfig *v1alpha3.MeshConfig, opts v1.UpdateOptions) (result *v1alpha3.MeshConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(meshconfigsResource, c.ns, meshConfig), &v1alpha3.MeshConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.MeshConfig), err +} + +// Delete takes name of the meshConfig and deletes it. Returns an error if one occurs. +func (c *FakeMeshConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(meshconfigsResource, c.ns, name), &v1alpha3.MeshConfig{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeMeshConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(meshconfigsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha3.MeshConfigList{}) + return err +} + +// Patch applies the patch and returns the patched meshConfig. +func (c *FakeMeshConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.MeshConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(meshconfigsResource, c.ns, name, pt, data, subresources...), &v1alpha3.MeshConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.MeshConfig), err +} diff --git a/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/fake_multiclusterservice.go b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/fake_multiclusterservice.go new file mode 100644 index 0000000000..53a2df0e72 --- /dev/null +++ b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/fake/fake_multiclusterservice.go @@ -0,0 +1,127 @@ +/* +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" + + v1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" + 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" +) + +// FakeMultiClusterServices implements MultiClusterServiceInterface +type FakeMultiClusterServices struct { + Fake *FakeConfigV1alpha3 + ns string +} + +var multiclusterservicesResource = schema.GroupVersionResource{Group: "config.openservicemesh.io", Version: "v1alpha3", Resource: "multiclusterservices"} + +var multiclusterservicesKind = schema.GroupVersionKind{Group: "config.openservicemesh.io", Version: "v1alpha3", Kind: "MultiClusterService"} + +// Get takes name of the multiClusterService, and returns the corresponding multiClusterService object, and an error if there is any. +func (c *FakeMultiClusterServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.MultiClusterService, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(multiclusterservicesResource, c.ns, name), &v1alpha3.MultiClusterService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.MultiClusterService), err +} + +// List takes label and field selectors, and returns the list of MultiClusterServices that match those selectors. +func (c *FakeMultiClusterServices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.MultiClusterServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(multiclusterservicesResource, multiclusterservicesKind, c.ns, opts), &v1alpha3.MultiClusterServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha3.MultiClusterServiceList{ListMeta: obj.(*v1alpha3.MultiClusterServiceList).ListMeta} + for _, item := range obj.(*v1alpha3.MultiClusterServiceList).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 multiClusterServices. +func (c *FakeMultiClusterServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(multiclusterservicesResource, c.ns, opts)) + +} + +// Create takes the representation of a multiClusterService and creates it. Returns the server's representation of the multiClusterService, and an error, if there is any. +func (c *FakeMultiClusterServices) Create(ctx context.Context, multiClusterService *v1alpha3.MultiClusterService, opts v1.CreateOptions) (result *v1alpha3.MultiClusterService, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(multiclusterservicesResource, c.ns, multiClusterService), &v1alpha3.MultiClusterService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.MultiClusterService), err +} + +// Update takes the representation of a multiClusterService and updates it. Returns the server's representation of the multiClusterService, and an error, if there is any. +func (c *FakeMultiClusterServices) Update(ctx context.Context, multiClusterService *v1alpha3.MultiClusterService, opts v1.UpdateOptions) (result *v1alpha3.MultiClusterService, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(multiclusterservicesResource, c.ns, multiClusterService), &v1alpha3.MultiClusterService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.MultiClusterService), err +} + +// Delete takes name of the multiClusterService and deletes it. Returns an error if one occurs. +func (c *FakeMultiClusterServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(multiclusterservicesResource, c.ns, name), &v1alpha3.MultiClusterService{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeMultiClusterServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(multiclusterservicesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha3.MultiClusterServiceList{}) + return err +} + +// Patch applies the patch and returns the patched multiClusterService. +func (c *FakeMultiClusterServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.MultiClusterService, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(multiclusterservicesResource, c.ns, name, pt, data, subresources...), &v1alpha3.MultiClusterService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.MultiClusterService), err +} diff --git a/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/generated_expansion.go b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/generated_expansion.go new file mode 100644 index 0000000000..f89a6bf333 --- /dev/null +++ b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/generated_expansion.go @@ -0,0 +1,20 @@ +/* +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 v1alpha3 + +type MeshConfigExpansion interface{} + +type MultiClusterServiceExpansion interface{} diff --git a/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/meshconfig.go b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/meshconfig.go new file mode 100644 index 0000000000..5da687e16d --- /dev/null +++ b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/meshconfig.go @@ -0,0 +1,175 @@ +/* +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 v1alpha3 + +import ( + "context" + "time" + + v1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" + scheme "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/scheme" + v1 "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" +) + +// MeshConfigsGetter has a method to return a MeshConfigInterface. +// A group's client should implement this interface. +type MeshConfigsGetter interface { + MeshConfigs(namespace string) MeshConfigInterface +} + +// MeshConfigInterface has methods to work with MeshConfig resources. +type MeshConfigInterface interface { + Create(ctx context.Context, meshConfig *v1alpha3.MeshConfig, opts v1.CreateOptions) (*v1alpha3.MeshConfig, error) + Update(ctx context.Context, meshConfig *v1alpha3.MeshConfig, opts v1.UpdateOptions) (*v1alpha3.MeshConfig, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha3.MeshConfig, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha3.MeshConfigList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.MeshConfig, err error) + MeshConfigExpansion +} + +// meshConfigs implements MeshConfigInterface +type meshConfigs struct { + client rest.Interface + ns string +} + +// newMeshConfigs returns a MeshConfigs +func newMeshConfigs(c *ConfigV1alpha3Client, namespace string) *meshConfigs { + return &meshConfigs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the meshConfig, and returns the corresponding meshConfig object, and an error if there is any. +func (c *meshConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.MeshConfig, err error) { + result = &v1alpha3.MeshConfig{} + err = c.client.Get(). + Namespace(c.ns). + Resource("meshconfigs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of MeshConfigs that match those selectors. +func (c *meshConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.MeshConfigList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha3.MeshConfigList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("meshconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested meshConfigs. +func (c *meshConfigs) Watch(ctx context.Context, 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("meshconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a meshConfig and creates it. Returns the server's representation of the meshConfig, and an error, if there is any. +func (c *meshConfigs) Create(ctx context.Context, meshConfig *v1alpha3.MeshConfig, opts v1.CreateOptions) (result *v1alpha3.MeshConfig, err error) { + result = &v1alpha3.MeshConfig{} + err = c.client.Post(). + Namespace(c.ns). + Resource("meshconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(meshConfig). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a meshConfig and updates it. Returns the server's representation of the meshConfig, and an error, if there is any. +func (c *meshConfigs) Update(ctx context.Context, meshConfig *v1alpha3.MeshConfig, opts v1.UpdateOptions) (result *v1alpha3.MeshConfig, err error) { + result = &v1alpha3.MeshConfig{} + err = c.client.Put(). + Namespace(c.ns). + Resource("meshconfigs"). + Name(meshConfig.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(meshConfig). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the meshConfig and deletes it. Returns an error if one occurs. +func (c *meshConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("meshconfigs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *meshConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.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("meshconfigs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched meshConfig. +func (c *meshConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.MeshConfig, err error) { + result = &v1alpha3.MeshConfig{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("meshconfigs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/multiclusterservice.go b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/multiclusterservice.go new file mode 100644 index 0000000000..86a859a072 --- /dev/null +++ b/pkg/gen/client/config/clientset/versioned/typed/config/v1alpha3/multiclusterservice.go @@ -0,0 +1,175 @@ +/* +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 v1alpha3 + +import ( + "context" + "time" + + v1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" + scheme "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned/scheme" + v1 "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" +) + +// MultiClusterServicesGetter has a method to return a MultiClusterServiceInterface. +// A group's client should implement this interface. +type MultiClusterServicesGetter interface { + MultiClusterServices(namespace string) MultiClusterServiceInterface +} + +// MultiClusterServiceInterface has methods to work with MultiClusterService resources. +type MultiClusterServiceInterface interface { + Create(ctx context.Context, multiClusterService *v1alpha3.MultiClusterService, opts v1.CreateOptions) (*v1alpha3.MultiClusterService, error) + Update(ctx context.Context, multiClusterService *v1alpha3.MultiClusterService, opts v1.UpdateOptions) (*v1alpha3.MultiClusterService, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha3.MultiClusterService, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha3.MultiClusterServiceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.MultiClusterService, err error) + MultiClusterServiceExpansion +} + +// multiClusterServices implements MultiClusterServiceInterface +type multiClusterServices struct { + client rest.Interface + ns string +} + +// newMultiClusterServices returns a MultiClusterServices +func newMultiClusterServices(c *ConfigV1alpha3Client, namespace string) *multiClusterServices { + return &multiClusterServices{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the multiClusterService, and returns the corresponding multiClusterService object, and an error if there is any. +func (c *multiClusterServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.MultiClusterService, err error) { + result = &v1alpha3.MultiClusterService{} + err = c.client.Get(). + Namespace(c.ns). + Resource("multiclusterservices"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of MultiClusterServices that match those selectors. +func (c *multiClusterServices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.MultiClusterServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha3.MultiClusterServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("multiclusterservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested multiClusterServices. +func (c *multiClusterServices) Watch(ctx context.Context, 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("multiclusterservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a multiClusterService and creates it. Returns the server's representation of the multiClusterService, and an error, if there is any. +func (c *multiClusterServices) Create(ctx context.Context, multiClusterService *v1alpha3.MultiClusterService, opts v1.CreateOptions) (result *v1alpha3.MultiClusterService, err error) { + result = &v1alpha3.MultiClusterService{} + err = c.client.Post(). + Namespace(c.ns). + Resource("multiclusterservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(multiClusterService). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a multiClusterService and updates it. Returns the server's representation of the multiClusterService, and an error, if there is any. +func (c *multiClusterServices) Update(ctx context.Context, multiClusterService *v1alpha3.MultiClusterService, opts v1.UpdateOptions) (result *v1alpha3.MultiClusterService, err error) { + result = &v1alpha3.MultiClusterService{} + err = c.client.Put(). + Namespace(c.ns). + Resource("multiclusterservices"). + Name(multiClusterService.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(multiClusterService). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the multiClusterService and deletes it. Returns an error if one occurs. +func (c *multiClusterServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("multiclusterservices"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *multiClusterServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.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("multiclusterservices"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched multiClusterService. +func (c *multiClusterServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.MultiClusterService, err error) { + result = &v1alpha3.MultiClusterService{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("multiclusterservices"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/gen/client/config/informers/externalversions/config/interface.go b/pkg/gen/client/config/informers/externalversions/config/interface.go index cdc65f762f..90c1d70019 100644 --- a/pkg/gen/client/config/informers/externalversions/config/interface.go +++ b/pkg/gen/client/config/informers/externalversions/config/interface.go @@ -18,6 +18,7 @@ package config import ( v1alpha1 "github.com/openservicemesh/osm/pkg/gen/client/config/informers/externalversions/config/v1alpha1" v1alpha2 "github.com/openservicemesh/osm/pkg/gen/client/config/informers/externalversions/config/v1alpha2" + v1alpha3 "github.com/openservicemesh/osm/pkg/gen/client/config/informers/externalversions/config/v1alpha3" internalinterfaces "github.com/openservicemesh/osm/pkg/gen/client/config/informers/externalversions/internalinterfaces" ) @@ -27,6 +28,8 @@ type Interface interface { V1alpha1() v1alpha1.Interface // V1alpha2 provides access to shared informers for resources in V1alpha2. V1alpha2() v1alpha2.Interface + // V1alpha3 provides access to shared informers for resources in V1alpha3. + V1alpha3() v1alpha3.Interface } type group struct { @@ -49,3 +52,8 @@ func (g *group) V1alpha1() v1alpha1.Interface { func (g *group) V1alpha2() v1alpha2.Interface { return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1alpha3 returns a new v1alpha3.Interface. +func (g *group) V1alpha3() v1alpha3.Interface { + return v1alpha3.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/gen/client/config/informers/externalversions/config/v1alpha3/interface.go b/pkg/gen/client/config/informers/externalversions/config/v1alpha3/interface.go new file mode 100644 index 0000000000..348fdd1dfd --- /dev/null +++ b/pkg/gen/client/config/informers/externalversions/config/v1alpha3/interface.go @@ -0,0 +1,49 @@ +/* +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 v1alpha3 + +import ( + internalinterfaces "github.com/openservicemesh/osm/pkg/gen/client/config/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // MeshConfigs returns a MeshConfigInformer. + MeshConfigs() MeshConfigInformer + // MultiClusterServices returns a MultiClusterServiceInformer. + MultiClusterServices() MultiClusterServiceInformer +} + +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} +} + +// MeshConfigs returns a MeshConfigInformer. +func (v *version) MeshConfigs() MeshConfigInformer { + return &meshConfigInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// MultiClusterServices returns a MultiClusterServiceInformer. +func (v *version) MultiClusterServices() MultiClusterServiceInformer { + return &multiClusterServiceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/gen/client/config/informers/externalversions/config/v1alpha3/meshconfig.go b/pkg/gen/client/config/informers/externalversions/config/v1alpha3/meshconfig.go new file mode 100644 index 0000000000..f985d86f2c --- /dev/null +++ b/pkg/gen/client/config/informers/externalversions/config/v1alpha3/meshconfig.go @@ -0,0 +1,87 @@ +/* +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 v1alpha3 + +import ( + "context" + time "time" + + configv1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" + versioned "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned" + internalinterfaces "github.com/openservicemesh/osm/pkg/gen/client/config/informers/externalversions/internalinterfaces" + v1alpha3 "github.com/openservicemesh/osm/pkg/gen/client/config/listers/config/v1alpha3" + v1 "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" +) + +// MeshConfigInformer provides access to a shared informer and lister for +// MeshConfigs. +type MeshConfigInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha3.MeshConfigLister +} + +type meshConfigInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewMeshConfigInformer constructs a new informer for MeshConfig 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 NewMeshConfigInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredMeshConfigInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredMeshConfigInformer constructs a new informer for MeshConfig 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 NewFilteredMeshConfigInformer(client versioned.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.ConfigV1alpha3().MeshConfigs(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ConfigV1alpha3().MeshConfigs(namespace).Watch(context.TODO(), options) + }, + }, + &configv1alpha3.MeshConfig{}, + resyncPeriod, + indexers, + ) +} + +func (f *meshConfigInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredMeshConfigInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *meshConfigInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&configv1alpha3.MeshConfig{}, f.defaultInformer) +} + +func (f *meshConfigInformer) Lister() v1alpha3.MeshConfigLister { + return v1alpha3.NewMeshConfigLister(f.Informer().GetIndexer()) +} diff --git a/pkg/gen/client/config/informers/externalversions/config/v1alpha3/multiclusterservice.go b/pkg/gen/client/config/informers/externalversions/config/v1alpha3/multiclusterservice.go new file mode 100644 index 0000000000..c180401d0c --- /dev/null +++ b/pkg/gen/client/config/informers/externalversions/config/v1alpha3/multiclusterservice.go @@ -0,0 +1,87 @@ +/* +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 v1alpha3 + +import ( + "context" + time "time" + + configv1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" + versioned "github.com/openservicemesh/osm/pkg/gen/client/config/clientset/versioned" + internalinterfaces "github.com/openservicemesh/osm/pkg/gen/client/config/informers/externalversions/internalinterfaces" + v1alpha3 "github.com/openservicemesh/osm/pkg/gen/client/config/listers/config/v1alpha3" + v1 "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" +) + +// MultiClusterServiceInformer provides access to a shared informer and lister for +// MultiClusterServices. +type MultiClusterServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha3.MultiClusterServiceLister +} + +type multiClusterServiceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewMultiClusterServiceInformer constructs a new informer for MultiClusterService 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 NewMultiClusterServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredMultiClusterServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredMultiClusterServiceInformer constructs a new informer for MultiClusterService 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 NewFilteredMultiClusterServiceInformer(client versioned.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.ConfigV1alpha3().MultiClusterServices(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ConfigV1alpha3().MultiClusterServices(namespace).Watch(context.TODO(), options) + }, + }, + &configv1alpha3.MultiClusterService{}, + resyncPeriod, + indexers, + ) +} + +func (f *multiClusterServiceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredMultiClusterServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *multiClusterServiceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&configv1alpha3.MultiClusterService{}, f.defaultInformer) +} + +func (f *multiClusterServiceInformer) Lister() v1alpha3.MultiClusterServiceLister { + return v1alpha3.NewMultiClusterServiceLister(f.Informer().GetIndexer()) +} diff --git a/pkg/gen/client/config/informers/externalversions/generic.go b/pkg/gen/client/config/informers/externalversions/generic.go index 5e945ff55b..3184e1c5d7 100644 --- a/pkg/gen/client/config/informers/externalversions/generic.go +++ b/pkg/gen/client/config/informers/externalversions/generic.go @@ -20,6 +20,7 @@ import ( v1alpha1 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha1" v1alpha2 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha2" + v1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -62,6 +63,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha2.SchemeGroupVersion.WithResource("multiclusterservices"): return &genericInformer{resource: resource.GroupResource(), informer: f.Config().V1alpha2().MultiClusterServices().Informer()}, nil + // Group=config.openservicemesh.io, Version=v1alpha3 + case v1alpha3.SchemeGroupVersion.WithResource("meshconfigs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Config().V1alpha3().MeshConfigs().Informer()}, nil + case v1alpha3.SchemeGroupVersion.WithResource("multiclusterservices"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Config().V1alpha3().MultiClusterServices().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/gen/client/config/listers/config/v1alpha3/expansion_generated.go b/pkg/gen/client/config/listers/config/v1alpha3/expansion_generated.go new file mode 100644 index 0000000000..1e3f926f70 --- /dev/null +++ b/pkg/gen/client/config/listers/config/v1alpha3/expansion_generated.go @@ -0,0 +1,32 @@ +/* +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 v1alpha3 + +// MeshConfigListerExpansion allows custom methods to be added to +// MeshConfigLister. +type MeshConfigListerExpansion interface{} + +// MeshConfigNamespaceListerExpansion allows custom methods to be added to +// MeshConfigNamespaceLister. +type MeshConfigNamespaceListerExpansion interface{} + +// MultiClusterServiceListerExpansion allows custom methods to be added to +// MultiClusterServiceLister. +type MultiClusterServiceListerExpansion interface{} + +// MultiClusterServiceNamespaceListerExpansion allows custom methods to be added to +// MultiClusterServiceNamespaceLister. +type MultiClusterServiceNamespaceListerExpansion interface{} diff --git a/pkg/gen/client/config/listers/config/v1alpha3/meshconfig.go b/pkg/gen/client/config/listers/config/v1alpha3/meshconfig.go new file mode 100644 index 0000000000..ed674a7f6d --- /dev/null +++ b/pkg/gen/client/config/listers/config/v1alpha3/meshconfig.go @@ -0,0 +1,96 @@ +/* +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 v1alpha3 + +import ( + v1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// MeshConfigLister helps list MeshConfigs. +// All objects returned here must be treated as read-only. +type MeshConfigLister interface { + // List lists all MeshConfigs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha3.MeshConfig, err error) + // MeshConfigs returns an object that can list and get MeshConfigs. + MeshConfigs(namespace string) MeshConfigNamespaceLister + MeshConfigListerExpansion +} + +// meshConfigLister implements the MeshConfigLister interface. +type meshConfigLister struct { + indexer cache.Indexer +} + +// NewMeshConfigLister returns a new MeshConfigLister. +func NewMeshConfigLister(indexer cache.Indexer) MeshConfigLister { + return &meshConfigLister{indexer: indexer} +} + +// List lists all MeshConfigs in the indexer. +func (s *meshConfigLister) List(selector labels.Selector) (ret []*v1alpha3.MeshConfig, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.MeshConfig)) + }) + return ret, err +} + +// MeshConfigs returns an object that can list and get MeshConfigs. +func (s *meshConfigLister) MeshConfigs(namespace string) MeshConfigNamespaceLister { + return meshConfigNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MeshConfigNamespaceLister helps list and get MeshConfigs. +// All objects returned here must be treated as read-only. +type MeshConfigNamespaceLister interface { + // List lists all MeshConfigs in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha3.MeshConfig, err error) + // Get retrieves the MeshConfig from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha3.MeshConfig, error) + MeshConfigNamespaceListerExpansion +} + +// meshConfigNamespaceLister implements the MeshConfigNamespaceLister +// interface. +type meshConfigNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all MeshConfigs in the indexer for a given namespace. +func (s meshConfigNamespaceLister) List(selector labels.Selector) (ret []*v1alpha3.MeshConfig, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.MeshConfig)) + }) + return ret, err +} + +// Get retrieves the MeshConfig from the indexer for a given namespace and name. +func (s meshConfigNamespaceLister) Get(name string) (*v1alpha3.MeshConfig, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha3.Resource("meshconfig"), name) + } + return obj.(*v1alpha3.MeshConfig), nil +} diff --git a/pkg/gen/client/config/listers/config/v1alpha3/multiclusterservice.go b/pkg/gen/client/config/listers/config/v1alpha3/multiclusterservice.go new file mode 100644 index 0000000000..816f2e472f --- /dev/null +++ b/pkg/gen/client/config/listers/config/v1alpha3/multiclusterservice.go @@ -0,0 +1,96 @@ +/* +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 v1alpha3 + +import ( + v1alpha3 "github.com/openservicemesh/osm/pkg/apis/config/v1alpha3" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// MultiClusterServiceLister helps list MultiClusterServices. +// All objects returned here must be treated as read-only. +type MultiClusterServiceLister interface { + // List lists all MultiClusterServices in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha3.MultiClusterService, err error) + // MultiClusterServices returns an object that can list and get MultiClusterServices. + MultiClusterServices(namespace string) MultiClusterServiceNamespaceLister + MultiClusterServiceListerExpansion +} + +// multiClusterServiceLister implements the MultiClusterServiceLister interface. +type multiClusterServiceLister struct { + indexer cache.Indexer +} + +// NewMultiClusterServiceLister returns a new MultiClusterServiceLister. +func NewMultiClusterServiceLister(indexer cache.Indexer) MultiClusterServiceLister { + return &multiClusterServiceLister{indexer: indexer} +} + +// List lists all MultiClusterServices in the indexer. +func (s *multiClusterServiceLister) List(selector labels.Selector) (ret []*v1alpha3.MultiClusterService, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.MultiClusterService)) + }) + return ret, err +} + +// MultiClusterServices returns an object that can list and get MultiClusterServices. +func (s *multiClusterServiceLister) MultiClusterServices(namespace string) MultiClusterServiceNamespaceLister { + return multiClusterServiceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MultiClusterServiceNamespaceLister helps list and get MultiClusterServices. +// All objects returned here must be treated as read-only. +type MultiClusterServiceNamespaceLister interface { + // List lists all MultiClusterServices in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha3.MultiClusterService, err error) + // Get retrieves the MultiClusterService from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha3.MultiClusterService, error) + MultiClusterServiceNamespaceListerExpansion +} + +// multiClusterServiceNamespaceLister implements the MultiClusterServiceNamespaceLister +// interface. +type multiClusterServiceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all MultiClusterServices in the indexer for a given namespace. +func (s multiClusterServiceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha3.MultiClusterService, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.MultiClusterService)) + }) + return ret, err +} + +// Get retrieves the MultiClusterService from the indexer for a given namespace and name. +func (s multiClusterServiceNamespaceLister) Get(name string) (*v1alpha3.MultiClusterService, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha3.Resource("multiclusterservice"), name) + } + return obj.(*v1alpha3.MultiClusterService), nil +}