diff --git a/Makefile b/Makefile index 92a40d1aa..17787d193 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ $(call add-crd-gen,workv1,./work/v1,./work/v1,./work/v1) $(call add-crd-gen,workv1alpha1,./work/v1alpha1,./work/v1alpha1,./work/v1alpha1) $(call add-crd-gen,operator,./operator/v1,./operator/v1,./operator/v1) $(call add-crd-gen,addonv1alpha1,./addon/v1alpha1,./addon/v1alpha1,./addon/v1alpha1) +$(call add-crd-gen,addonv1beta1,./addon/v1alpha1 ./addon/v1beta1,./addon/v1beta1,./addon/v1beta1) RUNTIME ?= podman RUNTIME_IMAGE_NAME ?= openshift-api-generator diff --git a/addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml b/addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml index d8842c6db..a7b75c961 100644 --- a/addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml +++ b/addon/v1alpha1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml @@ -191,6 +191,12 @@ spec: description: RegistrationConfig defines the configuration of the addon agent to register to hub. The Klusterlet agent will create a csr for the addon agent with the registrationConfig. type: object properties: + registrationNamespace: + description: RegistrationNamespace is the namespace on the managed cluster to put the registration secret for the addon agent. If it is not set, open-cluster-management-agent-addon namespace is used to install the addon agent. + type: string + default: open-cluster-management-agent-addon + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ signerName: description: signerName is the name of signer that addon agent will use to create csr. type: string diff --git a/addon/v1alpha1/types_managedclusteraddon.go b/addon/v1alpha1/types_managedclusteraddon.go index f7ce437ec..87f946159 100644 --- a/addon/v1alpha1/types_managedclusteraddon.go +++ b/addon/v1alpha1/types_managedclusteraddon.go @@ -66,6 +66,14 @@ type RegistrationConfig struct { // // +optional Subject Subject `json:"subject,omitempty"` + + // RegistrationNamespace is the namespace on the managed cluster to put the registration secret for the addon agent. + // If it is not set, open-cluster-management-agent-addon namespace is used to install the addon agent. + // +optional + // +kubebuilder:default=open-cluster-management-agent-addon + // +kubebuilder:validation:MaxLength=63 + // +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + RegistrationNamespace string `json:"registrationNamespace,omitempty"` } type AddOnConfig struct { diff --git a/addon/v1alpha1/zz_generated.swagger_doc_generated.go b/addon/v1alpha1/zz_generated.swagger_doc_generated.go index 2278ea4b3..0b2da5b74 100644 --- a/addon/v1alpha1/zz_generated.swagger_doc_generated.go +++ b/addon/v1alpha1/zz_generated.swagger_doc_generated.go @@ -221,9 +221,10 @@ func (ObjectReference) SwaggerDoc() map[string]string { } var map_RegistrationConfig = map[string]string{ - "": "RegistrationConfig defines the configuration of the addon agent to register to hub. The Klusterlet agent will create a csr for the addon agent with the registrationConfig.", - "signerName": "signerName is the name of signer that addon agent will use to create csr.", - "subject": "subject is the user subject of the addon agent to be registered to the hub. If it is not set, the addon agent will have the default subject \"subject\": {\n\t\"user\": \"system:open-cluster-management:addon:{addonName}:{clusterName}:{agentName}\",\n\t\"groups: [\"system:open-cluster-management:addon\", \"system:open-cluster-management:addon:{addonName}\", \"system:authenticated\"]\n}", + "": "RegistrationConfig defines the configuration of the addon agent to register to hub. The Klusterlet agent will create a csr for the addon agent with the registrationConfig.", + "signerName": "signerName is the name of signer that addon agent will use to create csr.", + "subject": "subject is the user subject of the addon agent to be registered to the hub. If it is not set, the addon agent will have the default subject \"subject\": {\n\t\"user\": \"system:open-cluster-management:addon:{addonName}:{clusterName}:{agentName}\",\n\t\"groups: [\"system:open-cluster-management:addon\", \"system:open-cluster-management:addon:{addonName}\", \"system:authenticated\"]\n}", + "registrationNamespace": "RegistrationNamespace is the namespace on the managed cluster to put the registration secret for the addon agent. If it is not set, open-cluster-management-agent-addon namespace is used to install the addon agent.", } func (RegistrationConfig) SwaggerDoc() map[string]string { diff --git a/addon/v1beta1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml b/addon/v1beta1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml new file mode 100644 index 000000000..5b3fec711 --- /dev/null +++ b/addon/v1beta1/0000_00_addon.open-cluster-management.io_clustermanagementaddons.crd.yaml @@ -0,0 +1,231 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: clustermanagementaddons.addon.open-cluster-management.io +spec: + group: addon.open-cluster-management.io + names: + kind: ClusterManagementAddOn + listKind: ClusterManagementAddOnList + plural: clustermanagementaddons + singular: clustermanagementaddon + preserveUnknownFields: false + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .spec.addOnMeta.displayName + name: DISPLAY NAME + type: string + name: v1beta1 + schema: + openAPIV3Schema: + description: ClusterManagementAddOn represents the registration of an add-on to the cluster manager. This resource allows the user to discover which add-on is available for the cluster manager and also provides metadata information about the add-on. This resource also provides a linkage to ManagedClusterAddOn, the name of the ClusterManagementAddOn resource will be used for the namespace-scoped ManagedClusterAddOn resource. ClusterManagementAddOn is a cluster-scoped resource. + type: object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: spec represents a desired configuration for the agent on the cluster management add-on. + type: object + properties: + addOnMeta: + description: addOnMeta is a reference to the metadata information for the add-on. + type: object + properties: + description: + description: description represents the detailed description of the add-on. + type: string + displayName: + description: displayName represents the name of add-on that will be displayed. + type: string + defaultConfigs: + description: defaultConfigs represents a list of default add-on configurations. In scenario where all add-ons have the same configuration. User can override the default configuration by defining the configs in the install strategy for specific clusters. + type: array + items: + type: object + required: + - name + - resource + properties: + group: + description: group of the add-on configuration. + type: string + default: "" + name: + description: name of the add-on configuration. + type: string + minLength: 1 + namespace: + description: namespace of the add-on configuration. If this field is not set, the configuration is in the cluster scope. + type: string + resource: + description: resource of the add-on configuration. + type: string + minLength: 1 + installStrategy: + description: InstallStrategy represents that related ManagedClusterAddOns should be installed on certain clusters. + type: object + default: + type: Manual + properties: + placements: + description: Placements is a list of placement references honored when install strategy type is Placements. All clusters selected by these placements will install the addon If one cluster belongs to multiple placements, it will only apply the strategy defined later in the order. That is to say, The latter strategy overrides the previous one. + type: array + items: + type: object + required: + - name + - namespace + properties: + configs: + description: Configs is the configuration of managedClusterAddon during installation. User can override the configuration by updating the managedClusterAddon directly. + type: array + items: + type: object + required: + - name + - resource + properties: + group: + description: group of the add-on configuration. + type: string + default: "" + name: + description: name of the add-on configuration. + type: string + minLength: 1 + namespace: + description: namespace of the add-on configuration. If this field is not set, the configuration is in the cluster scope. + type: string + resource: + description: resource of the add-on configuration. + type: string + minLength: 1 + name: + description: Name is the name of the placement + type: string + minLength: 1 + namespace: + description: Namespace is the namespace of the placement + type: string + minLength: 1 + x-kubernetes-list-map-keys: + - namespace + - name + x-kubernetes-list-type: map + type: + description: 'Type is the type of the install strategy, it can be: - Manual: no automatic install - Placements: install to clusters selected by placements.' + type: string + default: Manual + enum: + - Manual + - Placements + status: + description: status represents the current status of cluster management add-on. + type: object + served: true + storage: true + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .spec.addOnMeta.displayName + name: DISPLAY NAME + type: string + - jsonPath: .spec.addOnConfiguration.crdName + name: CRD NAME + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: ClusterManagementAddOn represents the registration of an add-on to the cluster manager. This resource allows the user to discover which add-on is available for the cluster manager and also provides metadata information about the add-on. This resource also provides a linkage to ManagedClusterAddOn, the name of the ClusterManagementAddOn resource will be used for the namespace-scoped ManagedClusterAddOn resource. ClusterManagementAddOn is a cluster-scoped resource. + type: object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: spec represents a desired configuration for the agent on the cluster management add-on. + type: object + properties: + addOnConfiguration: + description: 'Deprecated: Use supportedConfigs filed instead addOnConfiguration is a reference to configuration information for the add-on. In scenario where a multiple add-ons share the same add-on CRD, multiple ClusterManagementAddOn resources need to be created and reference the same AddOnConfiguration.' + type: object + properties: + crName: + description: crName is the name of the CR used to configure instances of the managed add-on. This field should be configured if add-on CR have a consistent name across the all of the ManagedCluster instaces. + type: string + crdName: + description: crdName is the name of the CRD used to configure instances of the managed add-on. This field should be configured if the add-on have a CRD that controls the configuration of the add-on. + type: string + lastObservedGeneration: + description: lastObservedGeneration is the observed generation of the custom resource for the configuration of the addon. + type: integer + format: int64 + addOnMeta: + description: addOnMeta is a reference to the metadata information for the add-on. + type: object + properties: + description: + description: description represents the detailed description of the add-on. + type: string + displayName: + description: displayName represents the name of add-on that will be displayed. + type: string + supportedConfigs: + description: supportedConfigs is a list of configuration types supported by add-on. An empty list means the add-on does not require configurations. The default is an empty list + type: array + items: + description: ConfigMeta represents a collection of metadata information for add-on configuration. + type: object + required: + - resource + properties: + defaultConfig: + description: defaultConfig represents the namespace and name of the default add-on configuration. In scenario where all add-ons have a same configuration. + type: object + required: + - name + properties: + name: + description: name of the add-on configuration. + type: string + minLength: 1 + namespace: + description: namespace of the add-on configuration. If this field is not set, the configuration is in the cluster scope. + type: string + group: + description: group of the add-on configuration. + type: string + default: "" + resource: + description: resource of the add-on configuration. + type: string + minLength: 1 + x-kubernetes-list-map-keys: + - group + - resource + x-kubernetes-list-type: map + status: + description: status represents the current status of cluster management add-on. + type: object + served: true + storage: false + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/addon/v1beta1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml b/addon/v1beta1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml new file mode 100644 index 000000000..c218ff0b7 --- /dev/null +++ b/addon/v1beta1/0000_01_addon.open-cluster-management.io_managedclusteraddons.crd.yaml @@ -0,0 +1,494 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: managedclusteraddons.addon.open-cluster-management.io +spec: + group: addon.open-cluster-management.io + names: + kind: ManagedClusterAddOn + listKind: ManagedClusterAddOnList + plural: managedclusteraddons + singular: managedclusteraddon + scope: Namespaced + preserveUnknownFields: false + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Available")].status + name: Available + type: string + - jsonPath: .status.conditions[?(@.type=="Degraded")].status + name: Degraded + type: string + - jsonPath: .status.conditions[?(@.type=="Progressing")].status + name: Progressing + type: string + name: v1beta1 + schema: + openAPIV3Schema: + description: ManagedClusterAddOn is the Custom Resource object which holds the current state of an add-on. This object is used by add-on operators to convey their state. This resource should be created in the ManagedCluster namespace. + type: object + required: + - spec + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: spec holds configuration that could apply to any operator. + type: object + properties: + configs: + description: configs is a list of add-on configurations. In scenario where the current add-on has its own configurations. An empty list means there are no defautl configurations for add-on. The default is an empty list + type: array + items: + type: object + required: + - name + - resource + properties: + group: + description: group of the add-on configuration. + type: string + default: "" + name: + description: name of the add-on configuration. + type: string + minLength: 1 + namespace: + description: namespace of the add-on configuration. If this field is not set, the configuration is in the cluster scope. + type: string + resource: + description: resource of the add-on configuration. + type: string + minLength: 1 + status: + description: status holds the information about the state of an operator. It is consistent with status information across the Kubernetes ecosystem. + type: object + properties: + addOnMeta: + description: addOnMeta is a reference to the metadata information for the add-on. This should be same as the addOnMeta for the corresponding ClusterManagementAddOn resource. + type: object + properties: + description: + description: description represents the detailed description of the add-on. + type: string + displayName: + description: displayName represents the name of add-on that will be displayed. + type: string + conditions: + description: conditions describe the state of the managed and monitored components for the operator. + type: array + items: + description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + type: object + required: + - lastTransitionTime + - message + - reason + - status + - type + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + type: string + format: date-time + message: + description: message is a human readable message indicating details about the transition. This may be an empty string. + type: string + maxLength: 32768 + observedGeneration: + description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + type: integer + format: int64 + minimum: 0 + reason: + description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. + type: string + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + status: + description: status of the condition, one of True, False, Unknown. + type: string + enum: + - "True" + - "False" + - Unknown + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + type: string + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + configReferences: + description: configReferences is a list of current add-on configuration references. This will be overridden by the clustermanagementaddon configuration references. + type: array + items: + description: ConfigReference is a reference to the current add-on configuration. This resource is used to locate the configuration resource for the current add-on. + type: object + required: + - name + - resource + properties: + group: + description: group of the add-on configuration. + type: string + default: "" + lastObservedGeneration: + description: lastObservedGeneration is the observed generation of the add-on configuration. + type: integer + format: int64 + name: + description: name of the add-on configuration. + type: string + minLength: 1 + namespace: + description: namespace of the add-on configuration. If this field is not set, the configuration is in the cluster scope. + type: string + resource: + description: resource of the add-on configuration. + type: string + minLength: 1 + healthCheck: + description: healthCheck indicates how to check the healthiness status of the current addon. It should be set by each addon implementation, by default, the lease mode will be used. + type: object + properties: + mode: + description: mode indicates which mode will be used to check the healthiness status of the addon. + type: string + default: Lease + enum: + - Lease + - Customized + registrations: + description: registrations is the conifigurations for the addon agent to register to hub. It should be set by each addon controller on hub to define how the addon agent on managedcluster is registered. With the registration defined, The addon agent can access to kube apiserver with kube style API or other endpoints on hub cluster with client certificate authentication. A csr will be created per registration configuration. If more than one registrationConfig is defined, a csr will be created for each registration configuration. It is not allowed that multiple registrationConfigs have the same signer name. After the csr is approved on the hub cluster, the klusterlet agent will create a secret in the installNamespace for the registrationConfig. If the signerName is "kubernetes.io/kube-apiserver-client", the secret name will be "{addon name}-hub-kubeconfig" whose contents includes key/cert and kubeconfig. Otherwise, the secret name will be "{addon name}-{signer name}-client-cert" whose contents includes key/cert. + type: array + items: + description: RegistrationConfig defines the configuration of the addon agent to register to hub. The Klusterlet agent will create a csr for the addon agent with the registrationConfig. + type: object + required: + - signerName + properties: + registrationNamespace: + description: RegistrationNamespace is the namespace on the managed cluster to put the registration secret for the addon agent. If it is not set, open-cluster-management-agent-addon namespace is used to install the addon agent. + type: string + default: open-cluster-management-agent-addon + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + signerName: + description: signerName is the name of signer that addon agent will use to create csr. + type: string + maxLength: 571 + minLength: 5 + subject: + description: "subject is the user subject of the addon agent to be registered to the hub. If it is not set, the addon agent will have the default subject \"subject\": { \t\"user\": \"system:open-cluster-management:addon:{addonName}:{clusterName}:{agentName}\", \t\"groups: [\"system:open-cluster-management:addon\", \"system:open-cluster-management:addon:{addonName}\", \"system:authenticated\"] }" + type: object + properties: + groups: + description: groups is the user group of the addon agent. + type: array + items: + type: string + organizationUnit: + description: organizationUnit is the ou of the addon agent + type: array + items: + type: string + user: + description: user is the user name of the addon agent. + type: string + x-kubernetes-list-map-keys: + - signerName + x-kubernetes-list-type: map + relatedObjects: + description: 'relatedObjects is a list of objects that are "interesting" or related to this operator. Common uses are: 1. the detailed resource driving the operator 2. operator namespaces 3. operand namespaces 4. related ClusterManagementAddon resource' + type: array + items: + description: ObjectReference contains enough information to let you inspect or modify the referred object. + type: object + required: + - group + - name + - resource + properties: + group: + description: group of the referent. + type: string + name: + description: name of the referent. + type: string + namespace: + description: namespace of the referent. + type: string + resource: + description: resource of the referent. + type: string + supportedConfigs: + description: SupportedConfigs is a list of configuration types that are allowed to override the add-on configurations defined in ClusterManagementAddOn spec. The default is an empty list, which means the add-on configurations can not be overridden. + type: array + items: + description: ConfigGroupResource represents the GroupResource of the add-on configuration + type: object + required: + - resource + properties: + group: + description: group of the add-on configuration. + type: string + default: "" + resource: + description: resource of the add-on configuration. + type: string + minLength: 1 + x-kubernetes-list-map-keys: + - group + - resource + x-kubernetes-list-type: map + served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Available")].status + name: Available + type: string + - jsonPath: .status.conditions[?(@.type=="Degraded")].status + name: Degraded + type: string + - jsonPath: .status.conditions[?(@.type=="Progressing")].status + name: Progressing + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: ManagedClusterAddOn is the Custom Resource object which holds the current state of an add-on. This object is used by add-on operators to convey their state. This resource should be created in the ManagedCluster namespace. + type: object + required: + - spec + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: spec holds configuration that could apply to any operator. + type: object + properties: + configs: + description: configs is a list of add-on configurations. In scenario where the current add-on has its own configurations. An empty list means there are no defautl configurations for add-on. The default is an empty list + type: array + items: + type: object + required: + - name + - resource + properties: + group: + description: group of the add-on configuration. + type: string + default: "" + name: + description: name of the add-on configuration. + type: string + minLength: 1 + namespace: + description: namespace of the add-on configuration. If this field is not set, the configuration is in the cluster scope. + type: string + resource: + description: resource of the add-on configuration. + type: string + minLength: 1 + installNamespace: + description: installNamespace is the namespace on the managed cluster to install the addon agent. If it is not set, open-cluster-management-agent-addon namespace is used to install the addon agent. + type: string + default: open-cluster-management-agent-addon + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + status: + description: status holds the information about the state of an operator. It is consistent with status information across the Kubernetes ecosystem. + type: object + properties: + addOnConfiguration: + description: 'Deprecated: Use configReference instead addOnConfiguration is a reference to configuration information for the add-on. This resource is use to locate the configuration resource for the add-on.' + type: object + properties: + crName: + description: crName is the name of the CR used to configure instances of the managed add-on. This field should be configured if add-on CR have a consistent name across the all of the ManagedCluster instaces. + type: string + crdName: + description: crdName is the name of the CRD used to configure instances of the managed add-on. This field should be configured if the add-on have a CRD that controls the configuration of the add-on. + type: string + lastObservedGeneration: + description: lastObservedGeneration is the observed generation of the custom resource for the configuration of the addon. + type: integer + format: int64 + addOnMeta: + description: addOnMeta is a reference to the metadata information for the add-on. This should be same as the addOnMeta for the corresponding ClusterManagementAddOn resource. + type: object + properties: + description: + description: description represents the detailed description of the add-on. + type: string + displayName: + description: displayName represents the name of add-on that will be displayed. + type: string + conditions: + description: conditions describe the state of the managed and monitored components for the operator. + type: array + items: + description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + type: object + required: + - lastTransitionTime + - message + - reason + - status + - type + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + type: string + format: date-time + message: + description: message is a human readable message indicating details about the transition. This may be an empty string. + type: string + maxLength: 32768 + observedGeneration: + description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + type: integer + format: int64 + minimum: 0 + reason: + description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. + type: string + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + status: + description: status of the condition, one of True, False, Unknown. + type: string + enum: + - "True" + - "False" + - Unknown + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + type: string + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + configReferences: + description: configReferences is a list of current add-on configuration references. This will be overridden by the clustermanagementaddon configuration references. + type: array + items: + description: ConfigReference is a reference to the current add-on configuration. This resource is used to locate the configuration resource for the current add-on. + type: object + required: + - name + - resource + properties: + group: + description: group of the add-on configuration. + type: string + default: "" + lastObservedGeneration: + description: lastObservedGeneration is the observed generation of the add-on configuration. + type: integer + format: int64 + name: + description: name of the add-on configuration. + type: string + minLength: 1 + namespace: + description: namespace of the add-on configuration. If this field is not set, the configuration is in the cluster scope. + type: string + resource: + description: resource of the add-on configuration. + type: string + minLength: 1 + healthCheck: + description: healthCheck indicates how to check the healthiness status of the current addon. It should be set by each addon implementation, by default, the lease mode will be used. + type: object + properties: + mode: + description: mode indicates which mode will be used to check the healthiness status of the addon. + type: string + default: Lease + enum: + - Lease + - Customized + registrations: + description: registrations is the conifigurations for the addon agent to register to hub. It should be set by each addon controller on hub to define how the addon agent on managedcluster is registered. With the registration defined, The addon agent can access to kube apiserver with kube style API or other endpoints on hub cluster with client certificate authentication. A csr will be created per registration configuration. If more than one registrationConfig is defined, a csr will be created for each registration configuration. It is not allowed that multiple registrationConfigs have the same signer name. After the csr is approved on the hub cluster, the klusterlet agent will create a secret in the installNamespace for the registrationConfig. If the signerName is "kubernetes.io/kube-apiserver-client", the secret name will be "{addon name}-hub-kubeconfig" whose contents includes key/cert and kubeconfig. Otherwise, the secret name will be "{addon name}-{signer name}-client-cert" whose contents includes key/cert. + type: array + items: + description: RegistrationConfig defines the configuration of the addon agent to register to hub. The Klusterlet agent will create a csr for the addon agent with the registrationConfig. + type: object + properties: + registrationNamespace: + description: RegistrationNamespace is the namespace on the managed cluster to put the registration secret for the addon agent. If it is not set, open-cluster-management-agent-addon namespace is used to install the addon agent. + type: string + default: open-cluster-management-agent-addon + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + signerName: + description: signerName is the name of signer that addon agent will use to create csr. + type: string + maxLength: 571 + minLength: 5 + subject: + description: "subject is the user subject of the addon agent to be registered to the hub. If it is not set, the addon agent will have the default subject \"subject\": { \t\"user\": \"system:open-cluster-management:addon:{addonName}:{clusterName}:{agentName}\", \t\"groups: [\"system:open-cluster-management:addon\", \"system:open-cluster-management:addon:{addonName}\", \"system:authenticated\"] }" + type: object + properties: + groups: + description: groups is the user group of the addon agent. + type: array + items: + type: string + organizationUnit: + description: organizationUnit is the ou of the addon agent + type: array + items: + type: string + user: + description: user is the user name of the addon agent. + type: string + relatedObjects: + description: 'relatedObjects is a list of objects that are "interesting" or related to this operator. Common uses are: 1. the detailed resource driving the operator 2. operator namespaces 3. operand namespaces 4. related ClusterManagementAddon resource' + type: array + items: + description: ObjectReference contains enough information to let you inspect or modify the referred object. + type: object + required: + - group + - name + - resource + properties: + group: + description: group of the referent. + type: string + name: + description: name of the referent. + type: string + namespace: + description: namespace of the referent. + type: string + resource: + description: resource of the referent. + type: string + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/addon/v1beta1/doc.go b/addon/v1beta1/doc.go new file mode 100644 index 000000000..e15f5cfc9 --- /dev/null +++ b/addon/v1beta1/doc.go @@ -0,0 +1,8 @@ +// Package v1beta1 contains API Schema definitions for the addon v1beta1 API group +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +k8s:openapi-gen=true + +// +kubebuilder:validation:Optional +// +groupName=addon.open-cluster-management.io +package v1beta1 diff --git a/addon/v1beta1/register.go b/addon/v1beta1/register.go new file mode 100644 index 000000000..b810a08a5 --- /dev/null +++ b/addon/v1beta1/register.go @@ -0,0 +1,40 @@ +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + GroupName = "addon.open-cluster-management.io" + GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // Install is a function which adds this version to a scheme + Install = schemeBuilder.AddToScheme + + // SchemeGroupVersion generated code relies on this name + // Deprecated + SchemeGroupVersion = GroupVersion + // AddToScheme exists solely to keep the old generators creating valid code + // DEPRECATED + AddToScheme = schemeBuilder.AddToScheme +) + +// Resource generated code relies on this being here, but it logically belongs to the group +// DEPRECATED +func Resource(resource string) schema.GroupResource { + return schema.GroupResource{Group: GroupName, Resource: resource} +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(GroupVersion, + &ClusterManagementAddOn{}, + &ClusterManagementAddOnList{}, + &ManagedClusterAddOn{}, + &ManagedClusterAddOnList{}, + ) + metav1.AddToGroupVersion(scheme, GroupVersion) + return nil +} diff --git a/addon/v1beta1/types_clustermanagementaddon.go b/addon/v1beta1/types_clustermanagementaddon.go new file mode 100644 index 000000000..ae96b2310 --- /dev/null +++ b/addon/v1beta1/types_clustermanagementaddon.go @@ -0,0 +1,159 @@ +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope="Cluster" +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="DISPLAY NAME",type=string,JSONPath=`.spec.addOnMeta.displayName` + +// ClusterManagementAddOn represents the registration of an add-on to the cluster manager. +// This resource allows the user to discover which add-on is available for the cluster manager and +// also provides metadata information about the add-on. +// This resource also provides a linkage to ManagedClusterAddOn, the name of the ClusterManagementAddOn +// resource will be used for the namespace-scoped ManagedClusterAddOn resource. +// ClusterManagementAddOn is a cluster-scoped resource. +type ClusterManagementAddOn struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // spec represents a desired configuration for the agent on the cluster management add-on. + // +required + Spec ClusterManagementAddOnSpec `json:"spec"` + + // status represents the current status of cluster management add-on. + // +optional + Status ClusterManagementAddOnStatus `json:"status,omitempty"` +} + +// ClusterManagementAddOnSpec provides information for the add-on. +type ClusterManagementAddOnSpec struct { + // addOnMeta is a reference to the metadata information for the add-on. + // +optional + AddOnMeta AddOnMeta `json:"addOnMeta,omitempty"` + + // defaultConfigs represents a list of default add-on configurations. + // In scenario where all add-ons have the same configuration. + // User can override the default configuration by defining the configs in the + // install strategy for specific clusters. + // +optional + DefaultConfigs []AddOnConfig `json:"defaultConfigs,omitempty"` + + // InstallStrategy represents that related ManagedClusterAddOns should be installed + // on certain clusters. + // +optional + // +kubebuilder:default={type: Manual} + InstallStrategy *InstallStrategy `json:"installStrategy,omitempty"` +} + +// AddOnMeta represents a collection of metadata information for the add-on. +type AddOnMeta struct { + // displayName represents the name of add-on that will be displayed. + // +optional + DisplayName string `json:"displayName,omitempty"` + + // description represents the detailed description of the add-on. + // +optional + Description string `json:"description,omitempty"` +} + +// ConfigGroupResource represents the GroupResource of the add-on configuration +type ConfigGroupResource struct { + // group of the add-on configuration. + // +optional + // +kubebuilder:default="" + Group string `json:"group"` + + // resource of the add-on configuration. + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + Resource string `json:"resource"` +} + +// ConfigReferent represents the namespace and name for an add-on configuration. +type ConfigReferent struct { + // namespace of the add-on configuration. + // If this field is not set, the configuration is in the cluster scope. + // +optional + Namespace string `json:"namespace,omitempty"` + + // name of the add-on configuration. + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength:=1 + Name string `json:"name"` +} + +// InstallStrategy represents that related ManagedClusterAddOns should be installed +// on certain clusters. +type InstallStrategy struct { + // Type is the type of the install strategy, it can be: + // - Manual: no automatic install + // - Placements: install to clusters selected by placements. + // +kubebuilder:validation:Enum=Manual;Placements + // +kubebuilder:default:=Manual + // +optional + Type string `json:"type"` + // Placements is a list of placement references honored when install strategy type is + // Placements. All clusters selected by these placements will install the addon + // If one cluster belongs to multiple placements, it will only apply the strategy defined + // later in the order. That is to say, The latter strategy overrides the previous one. + // +optional + // +listType=map + // +listMapKey=namespace + // +listMapKey=name + Placements []PlacementStrategy `json:"placements,omitempty"` +} + +const ( + // AddonInstallStrategyManual is the addon install strategy representing no automatic addon installation + AddonInstallStrategyManual string = "Manual" + // AddonInstallStrategyManualPlacements is the addon install strategy representing the addon installation + // is based on placement decisions. + AddonInstallStrategyManualPlacements string = "Placements" +) + +type PlacementRef struct { + // Namespace is the namespace of the placement + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength:=1 + Namespace string `json:"namespace"` + // Name is the name of the placement + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength:=1 + Name string `json:"name"` +} + +type PlacementStrategy struct { + // Placement is the reference to a placement + Placement PlacementRef `json:",inline"` + // Configs is the configuration of managedClusterAddon during installation. + // User can override the configuration by updating the managedClusterAddon directly. + // +optional + Configs []AddOnConfig `json:"configs,omitempty"` +} + +// ClusterManagementAddOnStatus represents the current status of cluster management add-on. +type ClusterManagementAddOnStatus struct { +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// ClusterManagementAddOnList is a collection of cluster management add-ons. +type ClusterManagementAddOnList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // Items is a list of cluster management add-ons. + Items []ClusterManagementAddOn `json:"items"` +} diff --git a/addon/v1beta1/types_managedclusteraddon.go b/addon/v1beta1/types_managedclusteraddon.go new file mode 100644 index 000000000..fa3d1c085 --- /dev/null +++ b/addon/v1beta1/types_managedclusteraddon.go @@ -0,0 +1,279 @@ +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="Available",type=string,JSONPath=`.status.conditions[?(@.type=="Available")].status` +// +kubebuilder:printcolumn:name="Degraded",type=string,JSONPath=`.status.conditions[?(@.type=="Degraded")].status` +// +kubebuilder:printcolumn:name="Progressing",type=string,JSONPath=`.status.conditions[?(@.type=="Progressing")].status` + +// ManagedClusterAddOn is the Custom Resource object which holds the current state +// of an add-on. This object is used by add-on operators to convey their state. +// This resource should be created in the ManagedCluster namespace. +type ManagedClusterAddOn struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + // spec holds configuration that could apply to any operator. + // +kubebuilder:validation:Required + // +required + Spec ManagedClusterAddOnSpec `json:"spec"` + + // status holds the information about the state of an operator. It is consistent with status information across + // the Kubernetes ecosystem. + // +optional + Status ManagedClusterAddOnStatus `json:"status"` +} + +// ManagedClusterAddOnSpec defines the install configuration of +// an addon agent on managed cluster. +type ManagedClusterAddOnSpec struct { + // configs is a list of add-on configurations. + // In scenario where the current add-on has its own configurations. + // An empty list means there are no defautl configurations for add-on. + // The default is an empty list + // +optional + Configs []AddOnConfig `json:"configs,omitempty"` +} + +// RegistrationConfig defines the configuration of the addon agent to register to hub. The Klusterlet agent will +// create a csr for the addon agent with the registrationConfig. +type RegistrationConfig struct { + // signerName is the name of signer that addon agent will use to create csr. + // +required + // +kubebuilder:validation:MaxLength=571 + // +kubebuilder:validation:MinLength=5 + // +kubebuilder:validation:Required + SignerName string `json:"signerName"` + + // subject is the user subject of the addon agent to be registered to the hub. + // If it is not set, the addon agent will have the default subject + // "subject": { + // "user": "system:open-cluster-management:addon:{addonName}:{clusterName}:{agentName}", + // "groups: ["system:open-cluster-management:addon", "system:open-cluster-management:addon:{addonName}", "system:authenticated"] + // } + // + // +optional + Subject Subject `json:"subject,omitempty"` + + // RegistrationNamespace is the namespace on the managed cluster to put the registration secret for the addon agent. + // If it is not set, open-cluster-management-agent-addon namespace is used to install the addon agent. + // +optional + // +kubebuilder:default=open-cluster-management-agent-addon + // +kubebuilder:validation:MaxLength=63 + // +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + RegistrationNamespace string `json:"registrationNamespace,omitempty"` +} + +type AddOnConfig struct { + // group and resource of add-on configuration. + ConfigGroupResource `json:",inline"` + + // name and namespace of add-on configuration. + ConfigReferent `json:",inline"` +} + +// Subject is the user subject of the addon agent to be registered to the hub. +type Subject struct { + // user is the user name of the addon agent. + User string `json:"user"` + + // groups is the user group of the addon agent. + // +optional + Groups []string `json:"groups,omitempty"` + + // organizationUnit is the ou of the addon agent + // +optional + OrganizationUnits []string `json:"organizationUnit,omitempty"` +} + +// ManagedClusterAddOnStatus provides information about the status of the operator. +// +k8s:deepcopy-gen=true +type ManagedClusterAddOnStatus struct { + // conditions describe the state of the managed and monitored components for the operator. + // +patchMergeKey=type + // +patchStrategy=merge + // +optional + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` + + // relatedObjects is a list of objects that are "interesting" or related to this operator. Common uses are: + // 1. the detailed resource driving the operator + // 2. operator namespaces + // 3. operand namespaces + // 4. related ClusterManagementAddon resource + // +optional + RelatedObjects []ObjectReference `json:"relatedObjects,omitempty"` + + // addOnMeta is a reference to the metadata information for the add-on. + // This should be same as the addOnMeta for the corresponding ClusterManagementAddOn resource. + // +optional + AddOnMeta AddOnMeta `json:"addOnMeta,omitempty"` + + // SupportedConfigs is a list of configuration types that are allowed to override the add-on configurations defined + // in ClusterManagementAddOn spec. + // The default is an empty list, which means the add-on configurations can not be overridden. + // +optional + // +listType=map + // +listMapKey=group + // +listMapKey=resource + SupportedConfigs []ConfigGroupResource `json:"supportedConfigs,omitempty"` + + // configReferences is a list of current add-on configuration references. + // This will be overridden by the clustermanagementaddon configuration references. + // +optional + ConfigReferences []ConfigReference `json:"configReferences,omitempty"` + + // registrations is the conifigurations for the addon agent to register to hub. It should be set by each addon controller + // on hub to define how the addon agent on managedcluster is registered. With the registration defined, + // The addon agent can access to kube apiserver with kube style API or other endpoints on hub cluster with client + // certificate authentication. A csr will be created per registration configuration. If more than one + // registrationConfig is defined, a csr will be created for each registration configuration. It is not allowed that + // multiple registrationConfigs have the same signer name. After the csr is approved on the hub cluster, the klusterlet + // agent will create a secret in the installNamespace for the registrationConfig. If the signerName is + // "kubernetes.io/kube-apiserver-client", the secret name will be "{addon name}-hub-kubeconfig" whose contents includes + // key/cert and kubeconfig. Otherwise, the secret name will be "{addon name}-{signer name}-client-cert" whose contents includes key/cert. + // +optional + // +listType=map + // +listMapKey=signerName + Registrations []RegistrationConfig `json:"registrations,omitempty"` + + // healthCheck indicates how to check the healthiness status of the current addon. It should be + // set by each addon implementation, by default, the lease mode will be used. + // +optional + HealthCheck HealthCheck `json:"healthCheck,omitempty"` +} + +const ( + // ManagedClusterAddOnConditionAvailable represents that the addon agent is running on the managed cluster + ManagedClusterAddOnConditionAvailable string = "Available" + + // ManagedClusterAddOnConditionDegraded represents that the addon agent is providing degraded service on + // the managed cluster. + ManagedClusterAddOnConditionDegraded string = "Degraded" + + // ManagedClusterAddOnCondtionConfigured represents that the addon agent is configured with its configuration + ManagedClusterAddOnCondtionConfigured string = "Configured" +) + +// ObjectReference contains enough information to let you inspect or modify the referred object. +type ObjectReference struct { + // group of the referent. + // +kubebuilder:validation:Required + // +required + Group string `json:"group"` + // resource of the referent. + // +kubebuilder:validation:Required + // +required + Resource string `json:"resource"` + // namespace of the referent. + // +optional + Namespace string `json:"namespace,omitempty"` + // name of the referent. + // +kubebuilder:validation:Required + // +required + Name string `json:"name"` +} + +// ConfigReference is a reference to the current add-on configuration. +// This resource is used to locate the configuration resource for the current add-on. +type ConfigReference struct { + // This field is synced from ClusterManagementAddOn configGroupResource field. + ConfigGroupResource `json:",inline"` + + // This field is synced from ClusterManagementAddOn defaultConfig and ManagedClusterAddOn config fields. + // If both of them are defined, the ManagedClusterAddOn configs will overwrite the ClusterManagementAddOn + // defaultConfigs. + ConfigReferent `json:",inline"` + + // lastObservedGeneration is the observed generation of the add-on configuration. + LastObservedGeneration int64 `json:"lastObservedGeneration"` +} + +// HealthCheckMode indicates the mode for the addon to check its healthiness status +// +kubebuilder:validation:Enum=Lease;Customized +type HealthCheckMode string + +const ( + // HealthCheckModeLease, the addon maintains a lease in its installation namespace with + // its status, the registration agent will check this lease to maintain the addon healthiness + // status. + HealthCheckModeLease HealthCheckMode = "Lease" + + // HealthCheckModeCustomized, the addon maintains its healthiness status by itself. + HealthCheckModeCustomized HealthCheckMode = "Customized" +) + +type HealthCheck struct { + // mode indicates which mode will be used to check the healthiness status of the addon. + // +optional + // +kubebuilder:default=Lease + Mode HealthCheckMode `json:"mode,omitempty"` +} + +// ManagedClusterAddOnList is a list of ManagedClusterAddOn resources. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type ManagedClusterAddOnList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []ManagedClusterAddOn `json:"items"` +} + +const ( + // Label and annotation keys set on ManagedClusterAddon. + + // AddonLabelKey is the label key to set addon name. It is to set on the resources on the hub relating + // to an addon + AddonLabelKey = "open-cluster-management.io/addon-name" + + // DisableAddonAutomaticInstallationAnnotationKey is the annotation key for disabling the functionality of + // installing addon automatically. it should be set on ManagedClusterAddon resource only. + DisableAddonAutomaticInstallationAnnotationKey = "addon.open-cluster-management.io/disable-automatic-installation" + + // AddonNamespaceLabelKey is the label key to set namespace of ManagedClusterAddon. + AddonNamespaceLabelKey = "open-cluster-management.io/addon-namespace" + + // Label and annotation keys set on manifests of addon agent. + + // AddonPreDeleteHookLabelKey is the label key to identify that a resource manifest is used as pre-delete hook for an addon + // and should be created and deleted before the specified ManagedClusterAddon is deleted. + // Deprecated, and will be removed in the future release, please use annotation AddonPreDeleteHookAnnotationKey from v0.10.0. + AddonPreDeleteHookLabelKey = "open-cluster-management.io/addon-pre-delete" + + // AddonPreDeleteHookAnnotationKey is the annotation key to identify that a resource manifest is used as pre-delete hook for an addon + // and should be created and deleted before the specified ManagedClusterAddon is deleted. + AddonPreDeleteHookAnnotationKey = "addon.open-cluster-management.io/addon-pre-delete" + + // HostingClusterNameAnnotationKey is the annotation key for indicating the hosting cluster name, it should be set + // on ManagedClusterAddon resource only. + HostingClusterNameAnnotationKey = "addon.open-cluster-management.io/hosting-cluster-name" + + // DeletionOrphanAnnotationKey is an annotation for the manifest of addon indicating that it will not be cleaned up + // after the addon is deleted. + DeletionOrphanAnnotationKey = "addon.open-cluster-management.io/deletion-orphan" + + // HostedManifestLocationLabelKey is the label key to identify where a resource manifest of addon agent + // with this label should be deployed in Hosted mode. + // Deprecated, will be removed in the future release, please use annotation HostedManifestLocationAnnotationKey from v0.10.0. + HostedManifestLocationLabelKey = "addon.open-cluster-management.io/hosted-manifest-location" + + // HostedManifestLocationAnnotationKey is the annotation key to identify where a resource manifest of addon agent + // with this annotation should be deployed in Hosted mode. + HostedManifestLocationAnnotationKey = "addon.open-cluster-management.io/hosted-manifest-location" + + // HostedManifestLocationManagedValue is a value of the annotation HostedManifestLocationAnnotationKey, + // indicates the manifest will be deployed on the managed cluster in Hosted mode, + // it is the default value of a manifest in Hosted mode. + HostedManifestLocationManagedValue = "managed" + // HostedManifestLocationHostingValue is a value of the annotation HostedManifestLocationAnnotationKey, + // indicates the manifest will be deployed on the hosting cluster in Hosted mode. + HostedManifestLocationHostingValue = "hosting" + // HostedManifestLocationNoneValue is a value of the annotation HostedManifestLocationAnnotationKey,, + // indicates the manifest will not be deployed in Hosted mode. + HostedManifestLocationNoneValue = "none" +) diff --git a/addon/v1beta1/zz_generated.deepcopy.go b/addon/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 000000000..020058bd8 --- /dev/null +++ b/addon/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,464 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddOnConfig) DeepCopyInto(out *AddOnConfig) { + *out = *in + out.ConfigGroupResource = in.ConfigGroupResource + out.ConfigReferent = in.ConfigReferent + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnConfig. +func (in *AddOnConfig) DeepCopy() *AddOnConfig { + if in == nil { + return nil + } + out := new(AddOnConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddOnMeta) DeepCopyInto(out *AddOnMeta) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnMeta. +func (in *AddOnMeta) DeepCopy() *AddOnMeta { + if in == nil { + return nil + } + out := new(AddOnMeta) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterManagementAddOn) DeepCopyInto(out *ClusterManagementAddOn) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterManagementAddOn. +func (in *ClusterManagementAddOn) DeepCopy() *ClusterManagementAddOn { + if in == nil { + return nil + } + out := new(ClusterManagementAddOn) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterManagementAddOn) 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 *ClusterManagementAddOnList) DeepCopyInto(out *ClusterManagementAddOnList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterManagementAddOn, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterManagementAddOnList. +func (in *ClusterManagementAddOnList) DeepCopy() *ClusterManagementAddOnList { + if in == nil { + return nil + } + out := new(ClusterManagementAddOnList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterManagementAddOnList) 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 *ClusterManagementAddOnSpec) DeepCopyInto(out *ClusterManagementAddOnSpec) { + *out = *in + out.AddOnMeta = in.AddOnMeta + if in.DefaultConfigs != nil { + in, out := &in.DefaultConfigs, &out.DefaultConfigs + *out = make([]AddOnConfig, len(*in)) + copy(*out, *in) + } + if in.InstallStrategy != nil { + in, out := &in.InstallStrategy, &out.InstallStrategy + *out = new(InstallStrategy) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterManagementAddOnSpec. +func (in *ClusterManagementAddOnSpec) DeepCopy() *ClusterManagementAddOnSpec { + if in == nil { + return nil + } + out := new(ClusterManagementAddOnSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterManagementAddOnStatus) DeepCopyInto(out *ClusterManagementAddOnStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterManagementAddOnStatus. +func (in *ClusterManagementAddOnStatus) DeepCopy() *ClusterManagementAddOnStatus { + if in == nil { + return nil + } + out := new(ClusterManagementAddOnStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigGroupResource) DeepCopyInto(out *ConfigGroupResource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigGroupResource. +func (in *ConfigGroupResource) DeepCopy() *ConfigGroupResource { + if in == nil { + return nil + } + out := new(ConfigGroupResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigReference) DeepCopyInto(out *ConfigReference) { + *out = *in + out.ConfigGroupResource = in.ConfigGroupResource + out.ConfigReferent = in.ConfigReferent + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigReference. +func (in *ConfigReference) DeepCopy() *ConfigReference { + if in == nil { + return nil + } + out := new(ConfigReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigReferent) DeepCopyInto(out *ConfigReferent) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigReferent. +func (in *ConfigReferent) DeepCopy() *ConfigReferent { + if in == nil { + return nil + } + out := new(ConfigReferent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HealthCheck) DeepCopyInto(out *HealthCheck) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthCheck. +func (in *HealthCheck) DeepCopy() *HealthCheck { + if in == nil { + return nil + } + out := new(HealthCheck) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallStrategy) DeepCopyInto(out *InstallStrategy) { + *out = *in + if in.Placements != nil { + in, out := &in.Placements, &out.Placements + *out = make([]PlacementStrategy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallStrategy. +func (in *InstallStrategy) DeepCopy() *InstallStrategy { + if in == nil { + return nil + } + out := new(InstallStrategy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ManagedClusterAddOn) DeepCopyInto(out *ManagedClusterAddOn) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterAddOn. +func (in *ManagedClusterAddOn) DeepCopy() *ManagedClusterAddOn { + if in == nil { + return nil + } + out := new(ManagedClusterAddOn) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ManagedClusterAddOn) 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 *ManagedClusterAddOnList) DeepCopyInto(out *ManagedClusterAddOnList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ManagedClusterAddOn, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterAddOnList. +func (in *ManagedClusterAddOnList) DeepCopy() *ManagedClusterAddOnList { + if in == nil { + return nil + } + out := new(ManagedClusterAddOnList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ManagedClusterAddOnList) 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 *ManagedClusterAddOnSpec) DeepCopyInto(out *ManagedClusterAddOnSpec) { + *out = *in + if in.Configs != nil { + in, out := &in.Configs, &out.Configs + *out = make([]AddOnConfig, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterAddOnSpec. +func (in *ManagedClusterAddOnSpec) DeepCopy() *ManagedClusterAddOnSpec { + if in == nil { + return nil + } + out := new(ManagedClusterAddOnSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ManagedClusterAddOnStatus) DeepCopyInto(out *ManagedClusterAddOnStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.RelatedObjects != nil { + in, out := &in.RelatedObjects, &out.RelatedObjects + *out = make([]ObjectReference, len(*in)) + copy(*out, *in) + } + out.AddOnMeta = in.AddOnMeta + if in.SupportedConfigs != nil { + in, out := &in.SupportedConfigs, &out.SupportedConfigs + *out = make([]ConfigGroupResource, len(*in)) + copy(*out, *in) + } + if in.ConfigReferences != nil { + in, out := &in.ConfigReferences, &out.ConfigReferences + *out = make([]ConfigReference, len(*in)) + copy(*out, *in) + } + if in.Registrations != nil { + in, out := &in.Registrations, &out.Registrations + *out = make([]RegistrationConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + out.HealthCheck = in.HealthCheck + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterAddOnStatus. +func (in *ManagedClusterAddOnStatus) DeepCopy() *ManagedClusterAddOnStatus { + if in == nil { + return nil + } + out := new(ManagedClusterAddOnStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ObjectReference) DeepCopyInto(out *ObjectReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectReference. +func (in *ObjectReference) DeepCopy() *ObjectReference { + if in == nil { + return nil + } + out := new(ObjectReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PlacementRef) DeepCopyInto(out *PlacementRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlacementRef. +func (in *PlacementRef) DeepCopy() *PlacementRef { + if in == nil { + return nil + } + out := new(PlacementRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PlacementStrategy) DeepCopyInto(out *PlacementStrategy) { + *out = *in + out.Placement = in.Placement + if in.Configs != nil { + in, out := &in.Configs, &out.Configs + *out = make([]AddOnConfig, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlacementStrategy. +func (in *PlacementStrategy) DeepCopy() *PlacementStrategy { + if in == nil { + return nil + } + out := new(PlacementStrategy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegistrationConfig) DeepCopyInto(out *RegistrationConfig) { + *out = *in + in.Subject.DeepCopyInto(&out.Subject) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistrationConfig. +func (in *RegistrationConfig) DeepCopy() *RegistrationConfig { + if in == nil { + return nil + } + out := new(RegistrationConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Subject) DeepCopyInto(out *Subject) { + *out = *in + if in.Groups != nil { + in, out := &in.Groups, &out.Groups + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.OrganizationUnits != nil { + in, out := &in.OrganizationUnits, &out.OrganizationUnits + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subject. +func (in *Subject) DeepCopy() *Subject { + if in == nil { + return nil + } + out := new(Subject) + in.DeepCopyInto(out) + return out +} diff --git a/addon/v1beta1/zz_generated.swagger_doc_generated.go b/addon/v1beta1/zz_generated.swagger_doc_generated.go new file mode 100644 index 000000000..2abdc94d9 --- /dev/null +++ b/addon/v1beta1/zz_generated.swagger_doc_generated.go @@ -0,0 +1,203 @@ +package v1beta1 + +// This file contains a collection of methods that can be used from go-restful to +// generate Swagger API documentation for its models. Please read this PR for more +// information on the implementation: https://github.com/emicklei/go-restful/pull/215 +// +// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if +// they are on one line! For multiple line or blocks that you want to ignore use ---. +// Any context after a --- is ignored. +// +// Those methods can be generated by using hack/update-swagger-docs.sh + +// AUTO-GENERATED FUNCTIONS START HERE +var map_AddOnMeta = map[string]string{ + "": "AddOnMeta represents a collection of metadata information for the add-on.", + "displayName": "displayName represents the name of add-on that will be displayed.", + "description": "description represents the detailed description of the add-on.", +} + +func (AddOnMeta) SwaggerDoc() map[string]string { + return map_AddOnMeta +} + +var map_ClusterManagementAddOn = map[string]string{ + "": "ClusterManagementAddOn represents the registration of an add-on to the cluster manager. This resource allows the user to discover which add-on is available for the cluster manager and also provides metadata information about the add-on. This resource also provides a linkage to ManagedClusterAddOn, the name of the ClusterManagementAddOn resource will be used for the namespace-scoped ManagedClusterAddOn resource. ClusterManagementAddOn is a cluster-scoped resource.", + "spec": "spec represents a desired configuration for the agent on the cluster management add-on.", + "status": "status represents the current status of cluster management add-on.", +} + +func (ClusterManagementAddOn) SwaggerDoc() map[string]string { + return map_ClusterManagementAddOn +} + +var map_ClusterManagementAddOnList = map[string]string{ + "": "ClusterManagementAddOnList is a collection of cluster management add-ons.", + "metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "items": "Items is a list of cluster management add-ons.", +} + +func (ClusterManagementAddOnList) SwaggerDoc() map[string]string { + return map_ClusterManagementAddOnList +} + +var map_ClusterManagementAddOnSpec = map[string]string{ + "": "ClusterManagementAddOnSpec provides information for the add-on.", + "addOnMeta": "addOnMeta is a reference to the metadata information for the add-on.", + "defaultConfigs": "defaultConfigs represents a list of default add-on configurations. In scenario where all add-ons have the same configuration. User can override the default configuration by defining the configs in the install strategy for specific clusters.", + "installStrategy": "InstallStrategy represents that related ManagedClusterAddOns should be installed on certain clusters.", +} + +func (ClusterManagementAddOnSpec) SwaggerDoc() map[string]string { + return map_ClusterManagementAddOnSpec +} + +var map_ClusterManagementAddOnStatus = map[string]string{ + "": "ClusterManagementAddOnStatus represents the current status of cluster management add-on.", +} + +func (ClusterManagementAddOnStatus) SwaggerDoc() map[string]string { + return map_ClusterManagementAddOnStatus +} + +var map_ConfigGroupResource = map[string]string{ + "": "ConfigGroupResource represents the GroupResource of the add-on configuration", + "group": "group of the add-on configuration.", + "resource": "resource of the add-on configuration.", +} + +func (ConfigGroupResource) SwaggerDoc() map[string]string { + return map_ConfigGroupResource +} + +var map_ConfigReferent = map[string]string{ + "": "ConfigReferent represents the namespace and name for an add-on configuration.", + "namespace": "namespace of the add-on configuration. If this field is not set, the configuration is in the cluster scope.", + "name": "name of the add-on configuration.", +} + +func (ConfigReferent) SwaggerDoc() map[string]string { + return map_ConfigReferent +} + +var map_InstallStrategy = map[string]string{ + "": "InstallStrategy represents that related ManagedClusterAddOns should be installed on certain clusters.", + "type": "Type is the type of the install strategy, it can be: - Manual: no automatic install - Placements: install to clusters selected by placements.", + "placements": "Placements is a list of placement references honored when install strategy type is Placements. All clusters selected by these placements will install the addon If one cluster belongs to multiple placements, it will only apply the strategy defined later in the order. That is to say, The latter strategy overrides the previous one.", +} + +func (InstallStrategy) SwaggerDoc() map[string]string { + return map_InstallStrategy +} + +var map_PlacementRef = map[string]string{ + "namespace": "Namespace is the namespace of the placement", + "name": "Name is the name of the placement", +} + +func (PlacementRef) SwaggerDoc() map[string]string { + return map_PlacementRef +} + +var map_PlacementStrategy = map[string]string{ + "configs": "Configs is the configuration of managedClusterAddon during installation. User can override the configuration by updating the managedClusterAddon directly.", +} + +func (PlacementStrategy) SwaggerDoc() map[string]string { + return map_PlacementStrategy +} + +var map_ConfigReference = map[string]string{ + "": "ConfigReference is a reference to the current add-on configuration. This resource is used to locate the configuration resource for the current add-on.", + "lastObservedGeneration": "lastObservedGeneration is the observed generation of the add-on configuration.", +} + +func (ConfigReference) SwaggerDoc() map[string]string { + return map_ConfigReference +} + +var map_HealthCheck = map[string]string{ + "mode": "mode indicates which mode will be used to check the healthiness status of the addon.", +} + +func (HealthCheck) SwaggerDoc() map[string]string { + return map_HealthCheck +} + +var map_ManagedClusterAddOn = map[string]string{ + "": "ManagedClusterAddOn is the Custom Resource object which holds the current state of an add-on. This object is used by add-on operators to convey their state. This resource should be created in the ManagedCluster namespace.", + "spec": "spec holds configuration that could apply to any operator.", + "status": "status holds the information about the state of an operator. It is consistent with status information across the Kubernetes ecosystem.", +} + +func (ManagedClusterAddOn) SwaggerDoc() map[string]string { + return map_ManagedClusterAddOn +} + +var map_ManagedClusterAddOnList = map[string]string{ + "": "ManagedClusterAddOnList is a list of ManagedClusterAddOn resources.", +} + +func (ManagedClusterAddOnList) SwaggerDoc() map[string]string { + return map_ManagedClusterAddOnList +} + +var map_ManagedClusterAddOnSpec = map[string]string{ + "": "ManagedClusterAddOnSpec defines the install configuration of an addon agent on managed cluster.", + "configs": "configs is a list of add-on configurations. In scenario where the current add-on has its own configurations. An empty list means there are no defautl configurations for add-on. The default is an empty list", +} + +func (ManagedClusterAddOnSpec) SwaggerDoc() map[string]string { + return map_ManagedClusterAddOnSpec +} + +var map_ManagedClusterAddOnStatus = map[string]string{ + "": "ManagedClusterAddOnStatus provides information about the status of the operator.", + "conditions": "conditions describe the state of the managed and monitored components for the operator.", + "relatedObjects": "relatedObjects is a list of objects that are \"interesting\" or related to this operator. Common uses are: 1. the detailed resource driving the operator 2. operator namespaces 3. operand namespaces 4. related ClusterManagementAddon resource", + "addOnMeta": "addOnMeta is a reference to the metadata information for the add-on. This should be same as the addOnMeta for the corresponding ClusterManagementAddOn resource.", + "supportedConfigs": "SupportedConfigs is a list of configuration types that are allowed to override the add-on configurations defined in ClusterManagementAddOn spec. The default is an empty list, which means the add-on configurations can not be overridden.", + "configReferences": "configReferences is a list of current add-on configuration references. This will be overridden by the clustermanagementaddon configuration references.", + "registrations": "registrations is the conifigurations for the addon agent to register to hub. It should be set by each addon controller on hub to define how the addon agent on managedcluster is registered. With the registration defined, The addon agent can access to kube apiserver with kube style API or other endpoints on hub cluster with client certificate authentication. A csr will be created per registration configuration. If more than one registrationConfig is defined, a csr will be created for each registration configuration. It is not allowed that multiple registrationConfigs have the same signer name. After the csr is approved on the hub cluster, the klusterlet agent will create a secret in the installNamespace for the registrationConfig. If the signerName is \"kubernetes.io/kube-apiserver-client\", the secret name will be \"{addon name}-hub-kubeconfig\" whose contents includes key/cert and kubeconfig. Otherwise, the secret name will be \"{addon name}-{signer name}-client-cert\" whose contents includes key/cert.", + "healthCheck": "healthCheck indicates how to check the healthiness status of the current addon. It should be set by each addon implementation, by default, the lease mode will be used.", +} + +func (ManagedClusterAddOnStatus) SwaggerDoc() map[string]string { + return map_ManagedClusterAddOnStatus +} + +var map_ObjectReference = map[string]string{ + "": "ObjectReference contains enough information to let you inspect or modify the referred object.", + "group": "group of the referent.", + "resource": "resource of the referent.", + "namespace": "namespace of the referent.", + "name": "name of the referent.", +} + +func (ObjectReference) SwaggerDoc() map[string]string { + return map_ObjectReference +} + +var map_RegistrationConfig = map[string]string{ + "": "RegistrationConfig defines the configuration of the addon agent to register to hub. The Klusterlet agent will create a csr for the addon agent with the registrationConfig.", + "signerName": "signerName is the name of signer that addon agent will use to create csr.", + "subject": "subject is the user subject of the addon agent to be registered to the hub. If it is not set, the addon agent will have the default subject \"subject\": {\n\t\"user\": \"system:open-cluster-management:addon:{addonName}:{clusterName}:{agentName}\",\n\t\"groups: [\"system:open-cluster-management:addon\", \"system:open-cluster-management:addon:{addonName}\", \"system:authenticated\"]\n}", + "registrationNamespace": "RegistrationNamespace is the namespace on the managed cluster to put the registration secret for the addon agent. If it is not set, open-cluster-management-agent-addon namespace is used to install the addon agent.", +} + +func (RegistrationConfig) SwaggerDoc() map[string]string { + return map_RegistrationConfig +} + +var map_Subject = map[string]string{ + "": "Subject is the user subject of the addon agent to be registered to the hub.", + "user": "user is the user name of the addon agent.", + "groups": "groups is the user group of the addon agent.", + "organizationUnit": "organizationUnit is the ou of the addon agent", +} + +func (Subject) SwaggerDoc() map[string]string { + return map_Subject +} + +// AUTO-GENERATED FUNCTIONS END HERE diff --git a/client/addon/clientset/versioned/clientset.go b/client/addon/clientset/versioned/clientset.go index 49a244d9b..325bfd28f 100644 --- a/client/addon/clientset/versioned/clientset.go +++ b/client/addon/clientset/versioned/clientset.go @@ -10,11 +10,13 @@ import ( rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" addonv1alpha1 "open-cluster-management.io/api/client/addon/clientset/versioned/typed/addon/v1alpha1" + addonv1beta1 "open-cluster-management.io/api/client/addon/clientset/versioned/typed/addon/v1beta1" ) type Interface interface { Discovery() discovery.DiscoveryInterface AddonV1alpha1() addonv1alpha1.AddonV1alpha1Interface + AddonV1beta1() addonv1beta1.AddonV1beta1Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -22,6 +24,7 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient addonV1alpha1 *addonv1alpha1.AddonV1alpha1Client + addonV1beta1 *addonv1beta1.AddonV1beta1Client } // AddonV1alpha1 retrieves the AddonV1alpha1Client @@ -29,6 +32,11 @@ func (c *Clientset) AddonV1alpha1() addonv1alpha1.AddonV1alpha1Interface { return c.addonV1alpha1 } +// AddonV1beta1 retrieves the AddonV1beta1Client +func (c *Clientset) AddonV1beta1() addonv1beta1.AddonV1beta1Interface { + return c.addonV1beta1 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -77,6 +85,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.addonV1beta1, err = addonv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { @@ -99,6 +111,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.addonV1alpha1 = addonv1alpha1.New(c) + cs.addonV1beta1 = addonv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/client/addon/clientset/versioned/fake/clientset_generated.go b/client/addon/clientset/versioned/fake/clientset_generated.go index e27067934..34f5106dd 100644 --- a/client/addon/clientset/versioned/fake/clientset_generated.go +++ b/client/addon/clientset/versioned/fake/clientset_generated.go @@ -11,6 +11,8 @@ import ( clientset "open-cluster-management.io/api/client/addon/clientset/versioned" addonv1alpha1 "open-cluster-management.io/api/client/addon/clientset/versioned/typed/addon/v1alpha1" fakeaddonv1alpha1 "open-cluster-management.io/api/client/addon/clientset/versioned/typed/addon/v1alpha1/fake" + addonv1beta1 "open-cluster-management.io/api/client/addon/clientset/versioned/typed/addon/v1beta1" + fakeaddonv1beta1 "open-cluster-management.io/api/client/addon/clientset/versioned/typed/addon/v1beta1/fake" ) // NewSimpleClientset returns a clientset that will respond with the provided objects. @@ -67,3 +69,8 @@ var ( func (c *Clientset) AddonV1alpha1() addonv1alpha1.AddonV1alpha1Interface { return &fakeaddonv1alpha1.FakeAddonV1alpha1{Fake: &c.Fake} } + +// AddonV1beta1 retrieves the AddonV1beta1Client +func (c *Clientset) AddonV1beta1() addonv1beta1.AddonV1beta1Interface { + return &fakeaddonv1beta1.FakeAddonV1beta1{Fake: &c.Fake} +} diff --git a/client/addon/clientset/versioned/fake/register.go b/client/addon/clientset/versioned/fake/register.go index 447229cde..3da3c7f8b 100644 --- a/client/addon/clientset/versioned/fake/register.go +++ b/client/addon/clientset/versioned/fake/register.go @@ -9,6 +9,7 @@ import ( serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" + addonv1beta1 "open-cluster-management.io/api/addon/v1beta1" ) var scheme = runtime.NewScheme() @@ -16,6 +17,7 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ addonv1alpha1.AddToScheme, + addonv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/client/addon/clientset/versioned/scheme/register.go b/client/addon/clientset/versioned/scheme/register.go index 9dd616b51..2ee64b885 100644 --- a/client/addon/clientset/versioned/scheme/register.go +++ b/client/addon/clientset/versioned/scheme/register.go @@ -9,6 +9,7 @@ import ( serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" + addonv1beta1 "open-cluster-management.io/api/addon/v1beta1" ) var Scheme = runtime.NewScheme() @@ -16,6 +17,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ addonv1alpha1.AddToScheme, + addonv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/client/addon/clientset/versioned/typed/addon/v1beta1/addon_client.go b/client/addon/clientset/versioned/typed/addon/v1beta1/addon_client.go new file mode 100644 index 000000000..5eccedf0e --- /dev/null +++ b/client/addon/clientset/versioned/typed/addon/v1beta1/addon_client.go @@ -0,0 +1,96 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "net/http" + + rest "k8s.io/client-go/rest" + v1beta1 "open-cluster-management.io/api/addon/v1beta1" + "open-cluster-management.io/api/client/addon/clientset/versioned/scheme" +) + +type AddonV1beta1Interface interface { + RESTClient() rest.Interface + ClusterManagementAddOnsGetter + ManagedClusterAddOnsGetter +} + +// AddonV1beta1Client is used to interact with features provided by the addon.open-cluster-management.io group. +type AddonV1beta1Client struct { + restClient rest.Interface +} + +func (c *AddonV1beta1Client) ClusterManagementAddOns() ClusterManagementAddOnInterface { + return newClusterManagementAddOns(c) +} + +func (c *AddonV1beta1Client) ManagedClusterAddOns(namespace string) ManagedClusterAddOnInterface { + return newManagedClusterAddOns(c, namespace) +} + +// NewForConfig creates a new AddonV1beta1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*AddonV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new AddonV1beta1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*AddonV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &AddonV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new AddonV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AddonV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AddonV1beta1Client for the given RESTClient. +func New(c rest.Interface) *AddonV1beta1Client { + return &AddonV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.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 *AddonV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/client/addon/clientset/versioned/typed/addon/v1beta1/clustermanagementaddon.go b/client/addon/clientset/versioned/typed/addon/v1beta1/clustermanagementaddon.go new file mode 100644 index 000000000..1caf807c5 --- /dev/null +++ b/client/addon/clientset/versioned/typed/addon/v1beta1/clustermanagementaddon.go @@ -0,0 +1,168 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + 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" + v1beta1 "open-cluster-management.io/api/addon/v1beta1" + scheme "open-cluster-management.io/api/client/addon/clientset/versioned/scheme" +) + +// ClusterManagementAddOnsGetter has a method to return a ClusterManagementAddOnInterface. +// A group's client should implement this interface. +type ClusterManagementAddOnsGetter interface { + ClusterManagementAddOns() ClusterManagementAddOnInterface +} + +// ClusterManagementAddOnInterface has methods to work with ClusterManagementAddOn resources. +type ClusterManagementAddOnInterface interface { + Create(ctx context.Context, clusterManagementAddOn *v1beta1.ClusterManagementAddOn, opts v1.CreateOptions) (*v1beta1.ClusterManagementAddOn, error) + Update(ctx context.Context, clusterManagementAddOn *v1beta1.ClusterManagementAddOn, opts v1.UpdateOptions) (*v1beta1.ClusterManagementAddOn, error) + UpdateStatus(ctx context.Context, clusterManagementAddOn *v1beta1.ClusterManagementAddOn, opts v1.UpdateOptions) (*v1beta1.ClusterManagementAddOn, 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) (*v1beta1.ClusterManagementAddOn, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ClusterManagementAddOnList, 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 *v1beta1.ClusterManagementAddOn, err error) + ClusterManagementAddOnExpansion +} + +// clusterManagementAddOns implements ClusterManagementAddOnInterface +type clusterManagementAddOns struct { + client rest.Interface +} + +// newClusterManagementAddOns returns a ClusterManagementAddOns +func newClusterManagementAddOns(c *AddonV1beta1Client) *clusterManagementAddOns { + return &clusterManagementAddOns{ + client: c.RESTClient(), + } +} + +// Get takes name of the clusterManagementAddOn, and returns the corresponding clusterManagementAddOn object, and an error if there is any. +func (c *clusterManagementAddOns) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ClusterManagementAddOn, err error) { + result = &v1beta1.ClusterManagementAddOn{} + err = c.client.Get(). + Resource("clustermanagementaddons"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterManagementAddOns that match those selectors. +func (c *clusterManagementAddOns) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ClusterManagementAddOnList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ClusterManagementAddOnList{} + err = c.client.Get(). + Resource("clustermanagementaddons"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterManagementAddOns. +func (c *clusterManagementAddOns) 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(). + Resource("clustermanagementaddons"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a clusterManagementAddOn and creates it. Returns the server's representation of the clusterManagementAddOn, and an error, if there is any. +func (c *clusterManagementAddOns) Create(ctx context.Context, clusterManagementAddOn *v1beta1.ClusterManagementAddOn, opts v1.CreateOptions) (result *v1beta1.ClusterManagementAddOn, err error) { + result = &v1beta1.ClusterManagementAddOn{} + err = c.client.Post(). + Resource("clustermanagementaddons"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterManagementAddOn). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a clusterManagementAddOn and updates it. Returns the server's representation of the clusterManagementAddOn, and an error, if there is any. +func (c *clusterManagementAddOns) Update(ctx context.Context, clusterManagementAddOn *v1beta1.ClusterManagementAddOn, opts v1.UpdateOptions) (result *v1beta1.ClusterManagementAddOn, err error) { + result = &v1beta1.ClusterManagementAddOn{} + err = c.client.Put(). + Resource("clustermanagementaddons"). + Name(clusterManagementAddOn.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterManagementAddOn). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *clusterManagementAddOns) UpdateStatus(ctx context.Context, clusterManagementAddOn *v1beta1.ClusterManagementAddOn, opts v1.UpdateOptions) (result *v1beta1.ClusterManagementAddOn, err error) { + result = &v1beta1.ClusterManagementAddOn{} + err = c.client.Put(). + Resource("clustermanagementaddons"). + Name(clusterManagementAddOn.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterManagementAddOn). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the clusterManagementAddOn and deletes it. Returns an error if one occurs. +func (c *clusterManagementAddOns) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("clustermanagementaddons"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterManagementAddOns) 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(). + Resource("clustermanagementaddons"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched clusterManagementAddOn. +func (c *clusterManagementAddOns) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ClusterManagementAddOn, err error) { + result = &v1beta1.ClusterManagementAddOn{} + err = c.client.Patch(pt). + Resource("clustermanagementaddons"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client/addon/clientset/versioned/typed/addon/v1beta1/doc.go b/client/addon/clientset/versioned/typed/addon/v1beta1/doc.go new file mode 100644 index 000000000..897c0995f --- /dev/null +++ b/client/addon/clientset/versioned/typed/addon/v1beta1/doc.go @@ -0,0 +1,4 @@ +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/client/addon/clientset/versioned/typed/addon/v1beta1/fake/doc.go b/client/addon/clientset/versioned/typed/addon/v1beta1/fake/doc.go new file mode 100644 index 000000000..2b5ba4c8e --- /dev/null +++ b/client/addon/clientset/versioned/typed/addon/v1beta1/fake/doc.go @@ -0,0 +1,4 @@ +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addon_client.go b/client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addon_client.go new file mode 100644 index 000000000..fd1e36b1d --- /dev/null +++ b/client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_addon_client.go @@ -0,0 +1,28 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1beta1 "open-cluster-management.io/api/client/addon/clientset/versioned/typed/addon/v1beta1" +) + +type FakeAddonV1beta1 struct { + *testing.Fake +} + +func (c *FakeAddonV1beta1) ClusterManagementAddOns() v1beta1.ClusterManagementAddOnInterface { + return &FakeClusterManagementAddOns{c} +} + +func (c *FakeAddonV1beta1) ManagedClusterAddOns(namespace string) v1beta1.ManagedClusterAddOnInterface { + return &FakeManagedClusterAddOns{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAddonV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_clustermanagementaddon.go b/client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_clustermanagementaddon.go new file mode 100644 index 000000000..20bd4e09e --- /dev/null +++ b/client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_clustermanagementaddon.go @@ -0,0 +1,117 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta1 "open-cluster-management.io/api/addon/v1beta1" +) + +// FakeClusterManagementAddOns implements ClusterManagementAddOnInterface +type FakeClusterManagementAddOns struct { + Fake *FakeAddonV1beta1 +} + +var clustermanagementaddonsResource = schema.GroupVersionResource{Group: "addon.open-cluster-management.io", Version: "v1beta1", Resource: "clustermanagementaddons"} + +var clustermanagementaddonsKind = schema.GroupVersionKind{Group: "addon.open-cluster-management.io", Version: "v1beta1", Kind: "ClusterManagementAddOn"} + +// Get takes name of the clusterManagementAddOn, and returns the corresponding clusterManagementAddOn object, and an error if there is any. +func (c *FakeClusterManagementAddOns) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ClusterManagementAddOn, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(clustermanagementaddonsResource, name), &v1beta1.ClusterManagementAddOn{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ClusterManagementAddOn), err +} + +// List takes label and field selectors, and returns the list of ClusterManagementAddOns that match those selectors. +func (c *FakeClusterManagementAddOns) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ClusterManagementAddOnList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(clustermanagementaddonsResource, clustermanagementaddonsKind, opts), &v1beta1.ClusterManagementAddOnList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.ClusterManagementAddOnList{ListMeta: obj.(*v1beta1.ClusterManagementAddOnList).ListMeta} + for _, item := range obj.(*v1beta1.ClusterManagementAddOnList).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 clusterManagementAddOns. +func (c *FakeClusterManagementAddOns) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(clustermanagementaddonsResource, opts)) +} + +// Create takes the representation of a clusterManagementAddOn and creates it. Returns the server's representation of the clusterManagementAddOn, and an error, if there is any. +func (c *FakeClusterManagementAddOns) Create(ctx context.Context, clusterManagementAddOn *v1beta1.ClusterManagementAddOn, opts v1.CreateOptions) (result *v1beta1.ClusterManagementAddOn, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(clustermanagementaddonsResource, clusterManagementAddOn), &v1beta1.ClusterManagementAddOn{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ClusterManagementAddOn), err +} + +// Update takes the representation of a clusterManagementAddOn and updates it. Returns the server's representation of the clusterManagementAddOn, and an error, if there is any. +func (c *FakeClusterManagementAddOns) Update(ctx context.Context, clusterManagementAddOn *v1beta1.ClusterManagementAddOn, opts v1.UpdateOptions) (result *v1beta1.ClusterManagementAddOn, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(clustermanagementaddonsResource, clusterManagementAddOn), &v1beta1.ClusterManagementAddOn{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ClusterManagementAddOn), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeClusterManagementAddOns) UpdateStatus(ctx context.Context, clusterManagementAddOn *v1beta1.ClusterManagementAddOn, opts v1.UpdateOptions) (*v1beta1.ClusterManagementAddOn, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(clustermanagementaddonsResource, "status", clusterManagementAddOn), &v1beta1.ClusterManagementAddOn{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ClusterManagementAddOn), err +} + +// Delete takes name of the clusterManagementAddOn and deletes it. Returns an error if one occurs. +func (c *FakeClusterManagementAddOns) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(clustermanagementaddonsResource, name, opts), &v1beta1.ClusterManagementAddOn{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterManagementAddOns) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(clustermanagementaddonsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.ClusterManagementAddOnList{}) + return err +} + +// Patch applies the patch and returns the patched clusterManagementAddOn. +func (c *FakeClusterManagementAddOns) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ClusterManagementAddOn, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(clustermanagementaddonsResource, name, pt, data, subresources...), &v1beta1.ClusterManagementAddOn{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ClusterManagementAddOn), err +} diff --git a/client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_managedclusteraddon.go b/client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_managedclusteraddon.go new file mode 100644 index 000000000..2410313c6 --- /dev/null +++ b/client/addon/clientset/versioned/typed/addon/v1beta1/fake/fake_managedclusteraddon.go @@ -0,0 +1,126 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta1 "open-cluster-management.io/api/addon/v1beta1" +) + +// FakeManagedClusterAddOns implements ManagedClusterAddOnInterface +type FakeManagedClusterAddOns struct { + Fake *FakeAddonV1beta1 + ns string +} + +var managedclusteraddonsResource = schema.GroupVersionResource{Group: "addon.open-cluster-management.io", Version: "v1beta1", Resource: "managedclusteraddons"} + +var managedclusteraddonsKind = schema.GroupVersionKind{Group: "addon.open-cluster-management.io", Version: "v1beta1", Kind: "ManagedClusterAddOn"} + +// Get takes name of the managedClusterAddOn, and returns the corresponding managedClusterAddOn object, and an error if there is any. +func (c *FakeManagedClusterAddOns) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ManagedClusterAddOn, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(managedclusteraddonsResource, c.ns, name), &v1beta1.ManagedClusterAddOn{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ManagedClusterAddOn), err +} + +// List takes label and field selectors, and returns the list of ManagedClusterAddOns that match those selectors. +func (c *FakeManagedClusterAddOns) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ManagedClusterAddOnList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(managedclusteraddonsResource, managedclusteraddonsKind, c.ns, opts), &v1beta1.ManagedClusterAddOnList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.ManagedClusterAddOnList{ListMeta: obj.(*v1beta1.ManagedClusterAddOnList).ListMeta} + for _, item := range obj.(*v1beta1.ManagedClusterAddOnList).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 managedClusterAddOns. +func (c *FakeManagedClusterAddOns) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(managedclusteraddonsResource, c.ns, opts)) + +} + +// Create takes the representation of a managedClusterAddOn and creates it. Returns the server's representation of the managedClusterAddOn, and an error, if there is any. +func (c *FakeManagedClusterAddOns) Create(ctx context.Context, managedClusterAddOn *v1beta1.ManagedClusterAddOn, opts v1.CreateOptions) (result *v1beta1.ManagedClusterAddOn, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(managedclusteraddonsResource, c.ns, managedClusterAddOn), &v1beta1.ManagedClusterAddOn{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ManagedClusterAddOn), err +} + +// Update takes the representation of a managedClusterAddOn and updates it. Returns the server's representation of the managedClusterAddOn, and an error, if there is any. +func (c *FakeManagedClusterAddOns) Update(ctx context.Context, managedClusterAddOn *v1beta1.ManagedClusterAddOn, opts v1.UpdateOptions) (result *v1beta1.ManagedClusterAddOn, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(managedclusteraddonsResource, c.ns, managedClusterAddOn), &v1beta1.ManagedClusterAddOn{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ManagedClusterAddOn), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeManagedClusterAddOns) UpdateStatus(ctx context.Context, managedClusterAddOn *v1beta1.ManagedClusterAddOn, opts v1.UpdateOptions) (*v1beta1.ManagedClusterAddOn, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(managedclusteraddonsResource, "status", c.ns, managedClusterAddOn), &v1beta1.ManagedClusterAddOn{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ManagedClusterAddOn), err +} + +// Delete takes name of the managedClusterAddOn and deletes it. Returns an error if one occurs. +func (c *FakeManagedClusterAddOns) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(managedclusteraddonsResource, c.ns, name, opts), &v1beta1.ManagedClusterAddOn{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeManagedClusterAddOns) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(managedclusteraddonsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.ManagedClusterAddOnList{}) + return err +} + +// Patch applies the patch and returns the patched managedClusterAddOn. +func (c *FakeManagedClusterAddOns) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ManagedClusterAddOn, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(managedclusteraddonsResource, c.ns, name, pt, data, subresources...), &v1beta1.ManagedClusterAddOn{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.ManagedClusterAddOn), err +} diff --git a/client/addon/clientset/versioned/typed/addon/v1beta1/generated_expansion.go b/client/addon/clientset/versioned/typed/addon/v1beta1/generated_expansion.go new file mode 100644 index 000000000..fb89504b4 --- /dev/null +++ b/client/addon/clientset/versioned/typed/addon/v1beta1/generated_expansion.go @@ -0,0 +1,7 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +type ClusterManagementAddOnExpansion interface{} + +type ManagedClusterAddOnExpansion interface{} diff --git a/client/addon/clientset/versioned/typed/addon/v1beta1/managedclusteraddon.go b/client/addon/clientset/versioned/typed/addon/v1beta1/managedclusteraddon.go new file mode 100644 index 000000000..f5686d7a5 --- /dev/null +++ b/client/addon/clientset/versioned/typed/addon/v1beta1/managedclusteraddon.go @@ -0,0 +1,179 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + 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" + v1beta1 "open-cluster-management.io/api/addon/v1beta1" + scheme "open-cluster-management.io/api/client/addon/clientset/versioned/scheme" +) + +// ManagedClusterAddOnsGetter has a method to return a ManagedClusterAddOnInterface. +// A group's client should implement this interface. +type ManagedClusterAddOnsGetter interface { + ManagedClusterAddOns(namespace string) ManagedClusterAddOnInterface +} + +// ManagedClusterAddOnInterface has methods to work with ManagedClusterAddOn resources. +type ManagedClusterAddOnInterface interface { + Create(ctx context.Context, managedClusterAddOn *v1beta1.ManagedClusterAddOn, opts v1.CreateOptions) (*v1beta1.ManagedClusterAddOn, error) + Update(ctx context.Context, managedClusterAddOn *v1beta1.ManagedClusterAddOn, opts v1.UpdateOptions) (*v1beta1.ManagedClusterAddOn, error) + UpdateStatus(ctx context.Context, managedClusterAddOn *v1beta1.ManagedClusterAddOn, opts v1.UpdateOptions) (*v1beta1.ManagedClusterAddOn, 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) (*v1beta1.ManagedClusterAddOn, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ManagedClusterAddOnList, 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 *v1beta1.ManagedClusterAddOn, err error) + ManagedClusterAddOnExpansion +} + +// managedClusterAddOns implements ManagedClusterAddOnInterface +type managedClusterAddOns struct { + client rest.Interface + ns string +} + +// newManagedClusterAddOns returns a ManagedClusterAddOns +func newManagedClusterAddOns(c *AddonV1beta1Client, namespace string) *managedClusterAddOns { + return &managedClusterAddOns{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the managedClusterAddOn, and returns the corresponding managedClusterAddOn object, and an error if there is any. +func (c *managedClusterAddOns) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ManagedClusterAddOn, err error) { + result = &v1beta1.ManagedClusterAddOn{} + err = c.client.Get(). + Namespace(c.ns). + Resource("managedclusteraddons"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ManagedClusterAddOns that match those selectors. +func (c *managedClusterAddOns) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ManagedClusterAddOnList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ManagedClusterAddOnList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("managedclusteraddons"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested managedClusterAddOns. +func (c *managedClusterAddOns) 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("managedclusteraddons"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a managedClusterAddOn and creates it. Returns the server's representation of the managedClusterAddOn, and an error, if there is any. +func (c *managedClusterAddOns) Create(ctx context.Context, managedClusterAddOn *v1beta1.ManagedClusterAddOn, opts v1.CreateOptions) (result *v1beta1.ManagedClusterAddOn, err error) { + result = &v1beta1.ManagedClusterAddOn{} + err = c.client.Post(). + Namespace(c.ns). + Resource("managedclusteraddons"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(managedClusterAddOn). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a managedClusterAddOn and updates it. Returns the server's representation of the managedClusterAddOn, and an error, if there is any. +func (c *managedClusterAddOns) Update(ctx context.Context, managedClusterAddOn *v1beta1.ManagedClusterAddOn, opts v1.UpdateOptions) (result *v1beta1.ManagedClusterAddOn, err error) { + result = &v1beta1.ManagedClusterAddOn{} + err = c.client.Put(). + Namespace(c.ns). + Resource("managedclusteraddons"). + Name(managedClusterAddOn.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(managedClusterAddOn). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *managedClusterAddOns) UpdateStatus(ctx context.Context, managedClusterAddOn *v1beta1.ManagedClusterAddOn, opts v1.UpdateOptions) (result *v1beta1.ManagedClusterAddOn, err error) { + result = &v1beta1.ManagedClusterAddOn{} + err = c.client.Put(). + Namespace(c.ns). + Resource("managedclusteraddons"). + Name(managedClusterAddOn.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(managedClusterAddOn). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the managedClusterAddOn and deletes it. Returns an error if one occurs. +func (c *managedClusterAddOns) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("managedclusteraddons"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *managedClusterAddOns) 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("managedclusteraddons"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched managedClusterAddOn. +func (c *managedClusterAddOns) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ManagedClusterAddOn, err error) { + result = &v1beta1.ManagedClusterAddOn{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("managedclusteraddons"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client/addon/informers/externalversions/addon/interface.go b/client/addon/informers/externalversions/addon/interface.go index da2dd3f85..26c2b07e3 100644 --- a/client/addon/informers/externalversions/addon/interface.go +++ b/client/addon/informers/externalversions/addon/interface.go @@ -4,6 +4,7 @@ package addon import ( v1alpha1 "open-cluster-management.io/api/client/addon/informers/externalversions/addon/v1alpha1" + v1beta1 "open-cluster-management.io/api/client/addon/informers/externalversions/addon/v1beta1" internalinterfaces "open-cluster-management.io/api/client/addon/informers/externalversions/internalinterfaces" ) @@ -11,6 +12,8 @@ import ( type Interface interface { // V1alpha1 provides access to shared informers for resources in V1alpha1. V1alpha1() v1alpha1.Interface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface } type group struct { @@ -28,3 +31,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1alpha1() v1alpha1.Interface { return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/client/addon/informers/externalversions/addon/v1beta1/clustermanagementaddon.go b/client/addon/informers/externalversions/addon/v1beta1/clustermanagementaddon.go new file mode 100644 index 000000000..336336234 --- /dev/null +++ b/client/addon/informers/externalversions/addon/v1beta1/clustermanagementaddon.go @@ -0,0 +1,73 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + time "time" + + 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" + addonv1beta1 "open-cluster-management.io/api/addon/v1beta1" + versioned "open-cluster-management.io/api/client/addon/clientset/versioned" + internalinterfaces "open-cluster-management.io/api/client/addon/informers/externalversions/internalinterfaces" + v1beta1 "open-cluster-management.io/api/client/addon/listers/addon/v1beta1" +) + +// ClusterManagementAddOnInformer provides access to a shared informer and lister for +// ClusterManagementAddOns. +type ClusterManagementAddOnInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.ClusterManagementAddOnLister +} + +type clusterManagementAddOnInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewClusterManagementAddOnInformer constructs a new informer for ClusterManagementAddOn 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 NewClusterManagementAddOnInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterManagementAddOnInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterManagementAddOnInformer constructs a new informer for ClusterManagementAddOn 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 NewFilteredClusterManagementAddOnInformer(client versioned.Interface, 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.AddonV1beta1().ClusterManagementAddOns().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AddonV1beta1().ClusterManagementAddOns().Watch(context.TODO(), options) + }, + }, + &addonv1beta1.ClusterManagementAddOn{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterManagementAddOnInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterManagementAddOnInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterManagementAddOnInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&addonv1beta1.ClusterManagementAddOn{}, f.defaultInformer) +} + +func (f *clusterManagementAddOnInformer) Lister() v1beta1.ClusterManagementAddOnLister { + return v1beta1.NewClusterManagementAddOnLister(f.Informer().GetIndexer()) +} diff --git a/client/addon/informers/externalversions/addon/v1beta1/interface.go b/client/addon/informers/externalversions/addon/v1beta1/interface.go new file mode 100644 index 000000000..4b48ba354 --- /dev/null +++ b/client/addon/informers/externalversions/addon/v1beta1/interface.go @@ -0,0 +1,36 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + internalinterfaces "open-cluster-management.io/api/client/addon/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ClusterManagementAddOns returns a ClusterManagementAddOnInformer. + ClusterManagementAddOns() ClusterManagementAddOnInformer + // ManagedClusterAddOns returns a ManagedClusterAddOnInformer. + ManagedClusterAddOns() ManagedClusterAddOnInformer +} + +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} +} + +// ClusterManagementAddOns returns a ClusterManagementAddOnInformer. +func (v *version) ClusterManagementAddOns() ClusterManagementAddOnInformer { + return &clusterManagementAddOnInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// ManagedClusterAddOns returns a ManagedClusterAddOnInformer. +func (v *version) ManagedClusterAddOns() ManagedClusterAddOnInformer { + return &managedClusterAddOnInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/client/addon/informers/externalversions/addon/v1beta1/managedclusteraddon.go b/client/addon/informers/externalversions/addon/v1beta1/managedclusteraddon.go new file mode 100644 index 000000000..e40fbbece --- /dev/null +++ b/client/addon/informers/externalversions/addon/v1beta1/managedclusteraddon.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + time "time" + + 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" + addonv1beta1 "open-cluster-management.io/api/addon/v1beta1" + versioned "open-cluster-management.io/api/client/addon/clientset/versioned" + internalinterfaces "open-cluster-management.io/api/client/addon/informers/externalversions/internalinterfaces" + v1beta1 "open-cluster-management.io/api/client/addon/listers/addon/v1beta1" +) + +// ManagedClusterAddOnInformer provides access to a shared informer and lister for +// ManagedClusterAddOns. +type ManagedClusterAddOnInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.ManagedClusterAddOnLister +} + +type managedClusterAddOnInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewManagedClusterAddOnInformer constructs a new informer for ManagedClusterAddOn 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 NewManagedClusterAddOnInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredManagedClusterAddOnInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredManagedClusterAddOnInformer constructs a new informer for ManagedClusterAddOn 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 NewFilteredManagedClusterAddOnInformer(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.AddonV1beta1().ManagedClusterAddOns(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AddonV1beta1().ManagedClusterAddOns(namespace).Watch(context.TODO(), options) + }, + }, + &addonv1beta1.ManagedClusterAddOn{}, + resyncPeriod, + indexers, + ) +} + +func (f *managedClusterAddOnInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredManagedClusterAddOnInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *managedClusterAddOnInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&addonv1beta1.ManagedClusterAddOn{}, f.defaultInformer) +} + +func (f *managedClusterAddOnInformer) Lister() v1beta1.ManagedClusterAddOnLister { + return v1beta1.NewManagedClusterAddOnLister(f.Informer().GetIndexer()) +} diff --git a/client/addon/informers/externalversions/generic.go b/client/addon/informers/externalversions/generic.go index c6a129e57..90b02926e 100644 --- a/client/addon/informers/externalversions/generic.go +++ b/client/addon/informers/externalversions/generic.go @@ -8,6 +8,7 @@ import ( schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" v1alpha1 "open-cluster-management.io/api/addon/v1alpha1" + v1beta1 "open-cluster-management.io/api/addon/v1beta1" ) // GenericInformer is type of SharedIndexInformer which will locate and delegate to other @@ -44,6 +45,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha1.SchemeGroupVersion.WithResource("managedclusteraddons"): return &genericInformer{resource: resource.GroupResource(), informer: f.Addon().V1alpha1().ManagedClusterAddOns().Informer()}, nil + // Group=addon.open-cluster-management.io, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("clustermanagementaddons"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Addon().V1beta1().ClusterManagementAddOns().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("managedclusteraddons"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Addon().V1beta1().ManagedClusterAddOns().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/client/addon/listers/addon/v1beta1/clustermanagementaddon.go b/client/addon/listers/addon/v1beta1/clustermanagementaddon.go new file mode 100644 index 000000000..70005f4aa --- /dev/null +++ b/client/addon/listers/addon/v1beta1/clustermanagementaddon.go @@ -0,0 +1,52 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "open-cluster-management.io/api/addon/v1beta1" +) + +// ClusterManagementAddOnLister helps list ClusterManagementAddOns. +// All objects returned here must be treated as read-only. +type ClusterManagementAddOnLister interface { + // List lists all ClusterManagementAddOns in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.ClusterManagementAddOn, err error) + // Get retrieves the ClusterManagementAddOn from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta1.ClusterManagementAddOn, error) + ClusterManagementAddOnListerExpansion +} + +// clusterManagementAddOnLister implements the ClusterManagementAddOnLister interface. +type clusterManagementAddOnLister struct { + indexer cache.Indexer +} + +// NewClusterManagementAddOnLister returns a new ClusterManagementAddOnLister. +func NewClusterManagementAddOnLister(indexer cache.Indexer) ClusterManagementAddOnLister { + return &clusterManagementAddOnLister{indexer: indexer} +} + +// List lists all ClusterManagementAddOns in the indexer. +func (s *clusterManagementAddOnLister) List(selector labels.Selector) (ret []*v1beta1.ClusterManagementAddOn, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.ClusterManagementAddOn)) + }) + return ret, err +} + +// Get retrieves the ClusterManagementAddOn from the index for a given name. +func (s *clusterManagementAddOnLister) Get(name string) (*v1beta1.ClusterManagementAddOn, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("clustermanagementaddon"), name) + } + return obj.(*v1beta1.ClusterManagementAddOn), nil +} diff --git a/client/addon/listers/addon/v1beta1/expansion_generated.go b/client/addon/listers/addon/v1beta1/expansion_generated.go new file mode 100644 index 000000000..a9755e01a --- /dev/null +++ b/client/addon/listers/addon/v1beta1/expansion_generated.go @@ -0,0 +1,15 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +// ClusterManagementAddOnListerExpansion allows custom methods to be added to +// ClusterManagementAddOnLister. +type ClusterManagementAddOnListerExpansion interface{} + +// ManagedClusterAddOnListerExpansion allows custom methods to be added to +// ManagedClusterAddOnLister. +type ManagedClusterAddOnListerExpansion interface{} + +// ManagedClusterAddOnNamespaceListerExpansion allows custom methods to be added to +// ManagedClusterAddOnNamespaceLister. +type ManagedClusterAddOnNamespaceListerExpansion interface{} diff --git a/client/addon/listers/addon/v1beta1/managedclusteraddon.go b/client/addon/listers/addon/v1beta1/managedclusteraddon.go new file mode 100644 index 000000000..ffcca487e --- /dev/null +++ b/client/addon/listers/addon/v1beta1/managedclusteraddon.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "open-cluster-management.io/api/addon/v1beta1" +) + +// ManagedClusterAddOnLister helps list ManagedClusterAddOns. +// All objects returned here must be treated as read-only. +type ManagedClusterAddOnLister interface { + // List lists all ManagedClusterAddOns in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.ManagedClusterAddOn, err error) + // ManagedClusterAddOns returns an object that can list and get ManagedClusterAddOns. + ManagedClusterAddOns(namespace string) ManagedClusterAddOnNamespaceLister + ManagedClusterAddOnListerExpansion +} + +// managedClusterAddOnLister implements the ManagedClusterAddOnLister interface. +type managedClusterAddOnLister struct { + indexer cache.Indexer +} + +// NewManagedClusterAddOnLister returns a new ManagedClusterAddOnLister. +func NewManagedClusterAddOnLister(indexer cache.Indexer) ManagedClusterAddOnLister { + return &managedClusterAddOnLister{indexer: indexer} +} + +// List lists all ManagedClusterAddOns in the indexer. +func (s *managedClusterAddOnLister) List(selector labels.Selector) (ret []*v1beta1.ManagedClusterAddOn, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.ManagedClusterAddOn)) + }) + return ret, err +} + +// ManagedClusterAddOns returns an object that can list and get ManagedClusterAddOns. +func (s *managedClusterAddOnLister) ManagedClusterAddOns(namespace string) ManagedClusterAddOnNamespaceLister { + return managedClusterAddOnNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ManagedClusterAddOnNamespaceLister helps list and get ManagedClusterAddOns. +// All objects returned here must be treated as read-only. +type ManagedClusterAddOnNamespaceLister interface { + // List lists all ManagedClusterAddOns in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.ManagedClusterAddOn, err error) + // Get retrieves the ManagedClusterAddOn from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta1.ManagedClusterAddOn, error) + ManagedClusterAddOnNamespaceListerExpansion +} + +// managedClusterAddOnNamespaceLister implements the ManagedClusterAddOnNamespaceLister +// interface. +type managedClusterAddOnNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ManagedClusterAddOns in the indexer for a given namespace. +func (s managedClusterAddOnNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.ManagedClusterAddOn, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.ManagedClusterAddOn)) + }) + return ret, err +} + +// Get retrieves the ManagedClusterAddOn from the indexer for a given namespace and name. +func (s managedClusterAddOnNamespaceLister) Get(name string) (*v1beta1.ManagedClusterAddOn, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("managedclusteraddon"), name) + } + return obj.(*v1beta1.ManagedClusterAddOn), nil +} diff --git a/hack/lib/init.sh b/hack/lib/init.sh index 8d4b01dbd..1a6a1e360 100644 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -18,6 +18,7 @@ work/v1 \ work/v1alpha1 \ operator/v1 \ addon/v1alpha1 \ +addon/v1beta1 \ " API_PACKAGES="\ @@ -28,5 +29,6 @@ open-cluster-management.io/api/cluster/v1beta2,\ open-cluster-management.io/api/work/v1,\ open-cluster-management.io/api/work/v1alpha1,\ open-cluster-management.io/api/operator/v1,\ -open-cluster-management.io/api/addon/v1alpha1\ +open-cluster-management.io/api/addon/v1alpha1,\ +open-cluster-management.io/api/addon/v1beta1\ " diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 964ba6d39..77e3ec64a 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -51,7 +51,7 @@ for group in addon; do bash ${CODEGEN_PKG}/generate-groups.sh "client,lister,informer" \ open-cluster-management.io/api/client/${group} \ open-cluster-management.io/api \ - "${group}:v1alpha1" \ + "${group}:v1alpha1,v1beta1" \ --go-header-file ${SCRIPT_ROOT}/hack/boilerplate.txt \ ${verify} done diff --git a/hack/update-deepcopy.sh b/hack/update-deepcopy.sh index 0d7d06e62..0375639b4 100755 --- a/hack/update-deepcopy.sh +++ b/hack/update-deepcopy.sh @@ -10,6 +10,6 @@ verify="${VERIFY:-}" GOFLAGS="" bash ${CODEGEN_PKG}/generate-groups.sh "deepcopy" \ open-cluster-management.io/api/generated \ open-cluster-management.io/api \ - "cluster:v1 cluster:v1alpha1 cluster:v1beta1 cluster:v1beta2 work:v1alpha1 work:v1 operator:v1 addon:v1alpha1" \ + "cluster:v1 cluster:v1alpha1 cluster:v1beta1 cluster:v1beta2 work:v1alpha1 work:v1 operator:v1 addon:v1alpha1 addon:v1beta1" \ --go-header-file ${SCRIPT_ROOT}/hack/empty.txt \ ${verify} diff --git a/hack/verify-crds.sh b/hack/verify-crds.sh index 5db181ede..1579a49b6 100755 --- a/hack/verify-crds.sh +++ b/hack/verify-crds.sh @@ -14,6 +14,7 @@ work/v1/*.crd.yaml work/v1alpha1/*crd.yaml operator/v1/*.crd.yaml addon/v1alpha1/*.crd.yaml +addon/v1beta1/*.crd.yaml " FAILS=false diff --git a/test/integration/clustermanagementaddon_test.go b/test/integration/clustermanagementaddon_test.go index 4fc791ee1..12a2c9175 100644 --- a/test/integration/clustermanagementaddon_test.go +++ b/test/integration/clustermanagementaddon_test.go @@ -12,6 +12,7 @@ import ( "k8s.io/apimachinery/pkg/util/rand" addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" + addonv1beta1 "open-cluster-management.io/api/addon/v1beta1" ) var _ = ginkgo.Describe("ClusterManagementAddOn API test", func() { @@ -22,100 +23,209 @@ var _ = ginkgo.Describe("ClusterManagementAddOn API test", func() { clusterManagementAddOnName = fmt.Sprintf("cma-%s", rand.String(5)) }) - ginkgo.It("Should create a ClusterManagementAddOn", func() { - clusterManagementAddOn := &addonv1alpha1.ClusterManagementAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: clusterManagementAddOnName, - }, - Spec: addonv1alpha1.ClusterManagementAddOnSpec{ - AddOnMeta: addonv1alpha1.AddOnMeta{ - DisplayName: "test", - Description: "for test", + ginkgo.Context("ClusterManagementAddOn v1alpha1 API", func() { + ginkgo.It("Should create a ClusterManagementAddOn", func() { + clusterManagementAddOn := &addonv1alpha1.ClusterManagementAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterManagementAddOnName, }, - SupportedConfigs: []addonv1alpha1.ConfigMeta{ - { - ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ - Group: "test.addon", - Resource: "tests", + Spec: addonv1alpha1.ClusterManagementAddOnSpec{ + AddOnMeta: addonv1alpha1.AddOnMeta{ + DisplayName: "test", + Description: "for test", + }, + SupportedConfigs: []addonv1alpha1.ConfigMeta{ + { + ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ + Group: "test.addon", + Resource: "tests", + }, + DefaultConfig: &addonv1alpha1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, }, - DefaultConfig: &addonv1alpha1.ConfigReferent{ - Namespace: testNamespace, - Name: "test", + }, + }, + } + + _, err := hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create( + context.TODO(), + clusterManagementAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("Should create a ClusterManagementAddOn with empty spec", func() { + clusterManagementAddOn := &addonv1alpha1.ClusterManagementAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterManagementAddOnName, + }, + Spec: addonv1alpha1.ClusterManagementAddOnSpec{}, + } + + _, err := hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create( + context.TODO(), + clusterManagementAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("Should not create a ClusterManagementAddOn when its configuration resource is empty", func() { + clusterManagementAddOn := &addonv1alpha1.ClusterManagementAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterManagementAddOnName, + }, + Spec: addonv1alpha1.ClusterManagementAddOnSpec{ + SupportedConfigs: []addonv1alpha1.ConfigMeta{ + { + ConfigGroupResource: addonv1alpha1.ConfigGroupResource{Group: "test.addon"}, }, }, }, - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create( - context.TODO(), - clusterManagementAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - }) + } - ginkgo.It("Should create a ClusterManagementAddOn with empty spec", func() { - clusterManagementAddOn := &addonv1alpha1.ClusterManagementAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: clusterManagementAddOnName, - }, - Spec: addonv1alpha1.ClusterManagementAddOnSpec{}, - } - - _, err := hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create( - context.TODO(), - clusterManagementAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - }) + _, err := hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create( + context.TODO(), + clusterManagementAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) - ginkgo.It("Should not create a ClusterManagementAddOn when its configuration resource is empty", func() { - clusterManagementAddOn := &addonv1alpha1.ClusterManagementAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: clusterManagementAddOnName, - }, - Spec: addonv1alpha1.ClusterManagementAddOnSpec{ - SupportedConfigs: []addonv1alpha1.ConfigMeta{ - { - ConfigGroupResource: addonv1alpha1.ConfigGroupResource{Group: "test.addon"}, + ginkgo.It("Should not create a ClusterManagementAddOn when its configuration name is empty", func() { + clusterManagementAddOn := &addonv1alpha1.ClusterManagementAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterManagementAddOnName, + }, + Spec: addonv1alpha1.ClusterManagementAddOnSpec{ + SupportedConfigs: []addonv1alpha1.ConfigMeta{ + { + ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ + Group: "test.addon", + Resource: "tests", + }, + DefaultConfig: &addonv1alpha1.ConfigReferent{}, + }, }, }, - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create( - context.TODO(), - clusterManagementAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + } + + _, err := hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create( + context.TODO(), + clusterManagementAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) }) - ginkgo.It("Should not create a ClusterManagementAddOn when its configuration name is empty", func() { - clusterManagementAddOn := &addonv1alpha1.ClusterManagementAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: clusterManagementAddOnName, - }, - Spec: addonv1alpha1.ClusterManagementAddOnSpec{ - SupportedConfigs: []addonv1alpha1.ConfigMeta{ - { - ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ - Group: "test.addon", - Resource: "tests", + ginkgo.Context("ClusterManagementAddOn v1beta1 API", func() { + ginkgo.It("Should create a ClusterManagementAddOn", func() { + clusterManagementAddOn := &addonv1beta1.ClusterManagementAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterManagementAddOnName, + }, + Spec: addonv1beta1.ClusterManagementAddOnSpec{ + AddOnMeta: addonv1beta1.AddOnMeta{ + DisplayName: "test", + Description: "for test", + }, + DefaultConfigs: []addonv1beta1.AddOnConfig{ + { + ConfigGroupResource: addonv1beta1.ConfigGroupResource{ + Group: "test.addon", + Resource: "tests", + }, + ConfigReferent: addonv1beta1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, }, - DefaultConfig: &addonv1alpha1.ConfigReferent{}, }, }, - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ClusterManagementAddOns().Create( - context.TODO(), - clusterManagementAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + } + + _, err := hubAddonClient.AddonV1beta1().ClusterManagementAddOns().Create( + context.TODO(), + clusterManagementAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("Should create a ClusterManagementAddOn with empty spec", func() { + clusterManagementAddOn := &addonv1beta1.ClusterManagementAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterManagementAddOnName, + }, + Spec: addonv1beta1.ClusterManagementAddOnSpec{}, + } + + _, err := hubAddonClient.AddonV1beta1().ClusterManagementAddOns().Create( + context.TODO(), + clusterManagementAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + clusterManagementAddOn, err = hubAddonClient.AddonV1beta1().ClusterManagementAddOns().Get( + context.TODO(), + clusterManagementAddOnName, + metav1.GetOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + gomega.Expect(clusterManagementAddOn.Spec.InstallStrategy.Type).To(gomega.Equal(addonv1beta1.AddonInstallStrategyManual)) + }) + + ginkgo.It("Should not create a ClusterManagementAddOn when its configuration resource is empty", func() { + clusterManagementAddOn := &addonv1beta1.ClusterManagementAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterManagementAddOnName, + }, + Spec: addonv1beta1.ClusterManagementAddOnSpec{ + DefaultConfigs: []addonv1beta1.AddOnConfig{ + { + ConfigGroupResource: addonv1beta1.ConfigGroupResource{Group: "test.addon"}, + }, + }, + }, + } + + _, err := hubAddonClient.AddonV1beta1().ClusterManagementAddOns().Create( + context.TODO(), + clusterManagementAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) + + ginkgo.It("Should not create a ClusterManagementAddOn when its configuration name is empty", func() { + clusterManagementAddOn := &addonv1beta1.ClusterManagementAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterManagementAddOnName, + }, + Spec: addonv1beta1.ClusterManagementAddOnSpec{ + DefaultConfigs: []addonv1beta1.AddOnConfig{ + { + ConfigGroupResource: addonv1beta1.ConfigGroupResource{ + Group: "test.addon", + Resource: "tests", + }, + ConfigReferent: addonv1beta1.ConfigReferent{}, + }, + }, + }, + } + + _, err := hubAddonClient.AddonV1beta1().ClusterManagementAddOns().Create( + context.TODO(), + clusterManagementAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) }) }) diff --git a/test/integration/managedclusteraddon_test.go b/test/integration/managedclusteraddon_test.go index 3aea914fa..7d5fc6342 100644 --- a/test/integration/managedclusteraddon_test.go +++ b/test/integration/managedclusteraddon_test.go @@ -10,6 +10,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/rand" addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" + addonv1beta1 "open-cluster-management.io/api/addon/v1beta1" ) const installNamespaceMaxLength = 63 @@ -21,268 +22,464 @@ var _ = ginkgo.Describe("ManagedClusterAddOn API test", func() { managedClusterAddOnName = fmt.Sprintf("mca-%s", rand.String(5)) }) - ginkgo.It("Should create a ManagedClusterAddOn", func() { - managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: managedClusterAddOnName, - }, - Spec: addonv1alpha1.ManagedClusterAddOnSpec{ - InstallNamespace: testNamespace, - Configs: []addonv1alpha1.AddOnConfig{ - { - ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ - Group: "test.group", - Resource: "tests", + ginkgo.Context("ManagedClusterAddOn v1alpha1 API", func() { + ginkgo.It("Should create a ManagedClusterAddOn", func() { + managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1alpha1.ManagedClusterAddOnSpec{ + InstallNamespace: testNamespace, + Configs: []addonv1alpha1.AddOnConfig{ + { + ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ + Group: "test.group", + Resource: "tests", + }, + ConfigReferent: addonv1alpha1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, }, - ConfigReferent: addonv1alpha1.ConfigReferent{ - Namespace: testNamespace, - Name: "test", + }, + }, + } + + _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + mca, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Get( + context.TODO(), + managedClusterAddOnName, + metav1.GetOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + gomega.Expect(mca.Spec.InstallNamespace).To(gomega.BeEquivalentTo(testNamespace)) + }) + + ginkgo.It("Should create a ManagedClusterAddOn with empty spec", func() { + managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1alpha1.ManagedClusterAddOnSpec{}, + } + + _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + mca, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Get( + context.TODO(), + managedClusterAddOnName, + metav1.GetOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + gomega.Expect(mca.Spec.InstallNamespace).To(gomega.BeEquivalentTo("open-cluster-management-agent-addon")) + }) + + ginkgo.It("Should update the ManagedClusterAddOn status without config", func() { + managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1alpha1.ManagedClusterAddOnSpec{}, + } + + _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + mca, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Get( + context.TODO(), + managedClusterAddOnName, + metav1.GetOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + mca.Status.Registrations = []addonv1alpha1.RegistrationConfig{ + { + SignerName: "addontest", + }, + } + + _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).UpdateStatus( + context.TODO(), + mca, + metav1.UpdateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("Should update the ManagedClusterAddOn status with config", func() { + managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1alpha1.ManagedClusterAddOnSpec{ + InstallNamespace: testNamespace, + Configs: []addonv1alpha1.AddOnConfig{ + { + ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ + Group: "test.group", + Resource: "tests", + }, + ConfigReferent: addonv1alpha1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, }, }, }, - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( - context.TODO(), - managedClusterAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - - mca, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Get( - context.TODO(), - managedClusterAddOnName, - metav1.GetOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - gomega.Expect(mca.Spec.InstallNamespace).To(gomega.BeEquivalentTo(testNamespace)) - }) + } + + _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + mca, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Get( + context.TODO(), + managedClusterAddOnName, + metav1.GetOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + gomega.Expect(mca.Spec.InstallNamespace).To(gomega.BeEquivalentTo(testNamespace)) + + mca.Status.ConfigReferences = []addonv1alpha1.ConfigReference{ + { + ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ + Group: "test.group", + Resource: "tests", + }, + ConfigReferent: addonv1alpha1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, + LastObservedGeneration: 1, + }, + } - ginkgo.It("Should create a ManagedClusterAddOn with empty spec", func() { - managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: managedClusterAddOnName, - }, - Spec: addonv1alpha1.ManagedClusterAddOnSpec{}, - } - - _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( - context.TODO(), - managedClusterAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - - mca, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Get( - context.TODO(), - managedClusterAddOnName, - metav1.GetOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - gomega.Expect(mca.Spec.InstallNamespace).To(gomega.BeEquivalentTo("open-cluster-management-agent-addon")) - }) + _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).UpdateStatus( + context.TODO(), + mca, + metav1.UpdateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) - ginkgo.It("Should update the ManagedClusterAddOn status without config", func() { - managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: managedClusterAddOnName, - }, - Spec: addonv1alpha1.ManagedClusterAddOnSpec{}, - } - - _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( - context.TODO(), - managedClusterAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - - mca, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Get( - context.TODO(), - managedClusterAddOnName, - metav1.GetOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - - mca.Status.Registrations = []addonv1alpha1.RegistrationConfig{ - { - SignerName: "addontest", - }, - } - - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).UpdateStatus( - context.TODO(), - mca, - metav1.UpdateOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - }) + }) - ginkgo.It("Should update the ManagedClusterAddOn status with config", func() { - managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: managedClusterAddOnName, - }, - Spec: addonv1alpha1.ManagedClusterAddOnSpec{ - InstallNamespace: testNamespace, - Configs: []addonv1alpha1.AddOnConfig{ - { - ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ - Group: "test.group", - Resource: "tests", - }, - ConfigReferent: addonv1alpha1.ConfigReferent{ - Namespace: testNamespace, - Name: "test", + ginkgo.It("Should create a ManagedClusterAddOn with install namespace", func() { + managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1alpha1.ManagedClusterAddOnSpec{ + InstallNamespace: rand.String(installNamespaceMaxLength), + }, + } + + _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("Should not create a ManagedClusterAddOn with a wrong install namespace", func() { + managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1alpha1.ManagedClusterAddOnSpec{ + InstallNamespace: "#test", + }, + } + + _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) + + ginkgo.It("Should not create a ManagedClusterAddOn with a long install namespace", func() { + managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1alpha1.ManagedClusterAddOnSpec{ + InstallNamespace: rand.String(installNamespaceMaxLength + 1), + }, + } + + _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) + + ginkgo.It("Should not create a ManagedClusterAddOn when its config type is empty", func() { + managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1alpha1.ManagedClusterAddOnSpec{ + Configs: []addonv1alpha1.AddOnConfig{ + { + ConfigReferent: addonv1alpha1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, }, }, }, - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( - context.TODO(), - managedClusterAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - - mca, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Get( - context.TODO(), - managedClusterAddOnName, - metav1.GetOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - gomega.Expect(mca.Spec.InstallNamespace).To(gomega.BeEquivalentTo(testNamespace)) - - mca.Status.ConfigReferences = []addonv1alpha1.ConfigReference{ - { - ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ - Group: "test.group", - Resource: "tests", + } + + _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) + + ginkgo.It("Should not create a ManagedClusterAddOn when its config name is empty", func() { + managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, }, - ConfigReferent: addonv1alpha1.ConfigReferent{ - Namespace: testNamespace, - Name: "test", + Spec: addonv1alpha1.ManagedClusterAddOnSpec{ + Configs: []addonv1alpha1.AddOnConfig{ + { + ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ + Group: "test.group", + Resource: "tests", + }, + ConfigReferent: addonv1alpha1.ConfigReferent{ + Namespace: testNamespace, + }, + }, + }, }, - LastObservedGeneration: 1, - }, - } - - _, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).UpdateStatus( - context.TODO(), - mca, - metav1.UpdateOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - + } + + _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) }) - ginkgo.It("Should create a ManagedClusterAddOn with install namespace", func() { - managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: managedClusterAddOnName, - }, - Spec: addonv1alpha1.ManagedClusterAddOnSpec{ - InstallNamespace: rand.String(installNamespaceMaxLength), - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( - context.TODO(), - managedClusterAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(err).ToNot(gomega.HaveOccurred()) - }) + ginkgo.Context("ManagedClusterAddOn v1beta1 API", func() { + ginkgo.It("Should create a ManagedClusterAddOn", func() { + managedClusterAddOn := &addonv1beta1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1beta1.ManagedClusterAddOnSpec{ + Configs: []addonv1beta1.AddOnConfig{ + { + ConfigGroupResource: addonv1beta1.ConfigGroupResource{ + Group: "test.group", + Resource: "tests", + }, + ConfigReferent: addonv1beta1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, + }, + }, + }, + } + + _, err := hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("Should create a ManagedClusterAddOn with empty spec", func() { + managedClusterAddOn := &addonv1beta1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1beta1.ManagedClusterAddOnSpec{}, + } + + _, err := hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("Should update the ManagedClusterAddOn status without config", func() { + managedClusterAddOn := &addonv1beta1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1beta1.ManagedClusterAddOnSpec{}, + } + + _, err := hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + mca, err := hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).Get( + context.TODO(), + managedClusterAddOnName, + metav1.GetOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + mca.Status.Registrations = []addonv1beta1.RegistrationConfig{ + { + SignerName: "addontest", + }, + } + + _, err = hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).UpdateStatus( + context.TODO(), + mca, + metav1.UpdateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) + + ginkgo.It("Should update the ManagedClusterAddOn status with config", func() { + managedClusterAddOn := &addonv1beta1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1beta1.ManagedClusterAddOnSpec{ + Configs: []addonv1beta1.AddOnConfig{ + { + ConfigGroupResource: addonv1beta1.ConfigGroupResource{ + Group: "test.group", + Resource: "tests", + }, + ConfigReferent: addonv1beta1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, + }, + }, + }, + } + + _, err := hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + mca, err := hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).Get( + context.TODO(), + managedClusterAddOnName, + metav1.GetOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + mca.Status.ConfigReferences = []addonv1beta1.ConfigReference{ + { + ConfigGroupResource: addonv1beta1.ConfigGroupResource{ + Group: "test.group", + Resource: "tests", + }, + ConfigReferent: addonv1beta1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, + LastObservedGeneration: 1, + }, + } - ginkgo.It("Should not create a ManagedClusterAddOn with a wrong install namespace", func() { - managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: managedClusterAddOnName, - }, - Spec: addonv1alpha1.ManagedClusterAddOnSpec{ - InstallNamespace: "#test", - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( - context.TODO(), - managedClusterAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) - }) + _, err = hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).UpdateStatus( + context.TODO(), + mca, + metav1.UpdateOptions{}, + ) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) - ginkgo.It("Should not create a ManagedClusterAddOn with a long install namespace", func() { - managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: managedClusterAddOnName, - }, - Spec: addonv1alpha1.ManagedClusterAddOnSpec{ - InstallNamespace: rand.String(installNamespaceMaxLength + 1), - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( - context.TODO(), - managedClusterAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) - }) + }) - ginkgo.It("Should not create a ManagedClusterAddOn when its config type is empty", func() { - managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: managedClusterAddOnName, - }, - Spec: addonv1alpha1.ManagedClusterAddOnSpec{ - Configs: []addonv1alpha1.AddOnConfig{ - { - ConfigReferent: addonv1alpha1.ConfigReferent{ - Namespace: testNamespace, - Name: "test", + ginkgo.It("Should not create a ManagedClusterAddOn when its config type is empty", func() { + managedClusterAddOn := &addonv1beta1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1beta1.ManagedClusterAddOnSpec{ + Configs: []addonv1beta1.AddOnConfig{ + { + ConfigReferent: addonv1beta1.ConfigReferent{ + Namespace: testNamespace, + Name: "test", + }, }, }, }, - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( - context.TODO(), - managedClusterAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) - }) - - ginkgo.It("Should not create a ManagedClusterAddOn when its config name is empty", func() { - managedClusterAddOn := &addonv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: managedClusterAddOnName, - }, - Spec: addonv1alpha1.ManagedClusterAddOnSpec{ - Configs: []addonv1alpha1.AddOnConfig{ - { - ConfigGroupResource: addonv1alpha1.ConfigGroupResource{ - Group: "test.group", - Resource: "tests", - }, - ConfigReferent: addonv1alpha1.ConfigReferent{ - Namespace: testNamespace, + } + + _, err := hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) + + ginkgo.It("Should not create a ManagedClusterAddOn when its config name is empty", func() { + managedClusterAddOn := &addonv1beta1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: managedClusterAddOnName, + }, + Spec: addonv1beta1.ManagedClusterAddOnSpec{ + Configs: []addonv1beta1.AddOnConfig{ + { + ConfigGroupResource: addonv1beta1.ConfigGroupResource{ + Group: "test.group", + Resource: "tests", + }, + ConfigReferent: addonv1beta1.ConfigReferent{ + Namespace: testNamespace, + }, }, }, }, - }, - } - - _, err := hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(testNamespace).Create( - context.TODO(), - managedClusterAddOn, - metav1.CreateOptions{}, - ) - gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + } + + _, err := hubAddonClient.AddonV1beta1().ManagedClusterAddOns(testNamespace).Create( + context.TODO(), + managedClusterAddOn, + metav1.CreateOptions{}, + ) + gomega.Expect(errors.IsInvalid(err)).To(gomega.BeTrue()) + }) }) }) diff --git a/test/integration/suite_test.go b/test/integration/suite_test.go index 58ebc4e29..b4fe67299 100644 --- a/test/integration/suite_test.go +++ b/test/integration/suite_test.go @@ -50,7 +50,8 @@ var _ = ginkgo.BeforeSuite(func(done ginkgo.Done) { filepath.Join(".", "cluster", "v1alpha1", "0000_02_clusters.open-cluster-management.io_clusterclaims.crd.yaml"), filepath.Join(".", "cluster", "v1alpha1", "0000_05_clusters.open-cluster-management.io_addonplacementscores.crd.yaml"), - filepath.Join(".", "addon", "v1alpha1"), + filepath.Join(".", "addon", "v1beta1"), + filepath.Join(".", "addon", "v1alpha1", "0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml"), filepath.Join(".", "operator", "v1", "0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml"), filepath.Join(".", "operator", "v1", "0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml"), },