diff --git a/config/crds/core.kubeadmiral.io_clustercollectedstatuses.yaml b/config/crds/core.kubeadmiral.io_clustercollectedstatuses.yaml new file mode 100644 index 00000000..5159d603 --- /dev/null +++ b/config/crds/core.kubeadmiral.io_clustercollectedstatuses.yaml @@ -0,0 +1,70 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.11.1 + creationTimestamp: null + name: clustercollectedstatuses.core.kubeadmiral.io +spec: + group: core.kubeadmiral.io + names: + kind: ClusterCollectedStatus + listKind: ClusterCollectedStatusList + plural: clustercollectedstatuses + shortNames: + - ccs + singular: clustercollectedstatus + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: ClusterCollectedStatus stores the collected fields of Kubernetes + objects from member clusters, that are propagated by a ClusterFederatedObject. + 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 + clusters: + description: Clusters is the list of member clusters and collected fields + for its propagated Kubernetes object. + items: + description: CollectedFieldsWithCluster stores the collected fields + of a Kubernetes object in a member cluster. + properties: + cluster: + description: Cluster is the name of the member cluster. + type: string + collectedFields: + description: CollectedFields is the the set of fields collected + for the Kubernetes object. + x-kubernetes-preserve-unknown-fields: true + error: + description: Error records any errors encountered while collecting + fields from the cluster. + type: string + required: + - cluster + - collectedFields + type: object + type: array + 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 + lastUpdateTime: + description: LastUpdateTime is the last time that a collection was performed. + format: date-time + type: string + metadata: + type: object + required: + - clusters + - lastUpdateTime + type: object + served: true + storage: true diff --git a/config/crds/core.kubeadmiral.io_clusterfederatedobjects.yaml b/config/crds/core.kubeadmiral.io_clusterfederatedobjects.yaml new file mode 100644 index 00000000..33dade49 --- /dev/null +++ b/config/crds/core.kubeadmiral.io_clusterfederatedobjects.yaml @@ -0,0 +1,228 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.11.1 + creationTimestamp: null + name: clusterfederatedobjects.core.kubeadmiral.io +spec: + group: core.kubeadmiral.io + names: + kind: ClusterFederatedObject + listKind: ClusterFederatedObjectList + plural: clusterfederatedobjects + shortNames: + - cfo + singular: clusterfederatedobject + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: ClusterFederatedObject describes a cluster-scoped Kubernetes + object and how it should be propagated to different member clusters. + 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 defines the desired behavior of the ClusterFederatedObject. + properties: + follows: + description: Follows defines other objects, or "leaders", that the + Kubernetes object should follow during propagation, i.e. the Kubernetes + object should be propagated to all member clusters that its "leaders" + are placed in. + items: + description: LeaderReference contains the identifying metadata of + a "leader" Kubernetes object. + properties: + group: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + required: + - kind + - name + type: object + type: array + overrides: + description: Overrides describe the overrides that should be applied + to the base template of the Kubernetes object before it is propagated + to individual member clusters. + items: + description: OverrideWithController describes the overrides that + will be applied to a Kubernetes object before it is propagated + to individual member clusters. + properties: + clusters: + description: Override is the list of member clusters and their + respective override patches. + items: + description: ClusterReferenceWithPatches represents a single + member cluster and a list of override patches for the cluster. + properties: + cluster: + description: Cluster is the name of the member cluster. + type: string + patches: + description: Patches is the list of override patches for + the member cluster. + items: + description: OverridePatch defines a JSON patch. + properties: + op: + type: string + path: + type: string + value: + x-kubernetes-preserve-unknown-fields: true + required: + - path + type: object + type: array + required: + - cluster + type: object + type: array + controller: + description: Controller identifies the controller responsible + for this override. + type: string + required: + - clusters + - controller + type: object + type: array + placements: + description: Placements describe the member clusters that the Kubernetes + object will be propagated to, which is a union of all the listed + clusters. + items: + description: PlacementWithController describes the member clusters + that a Kubernetes object should be propagated to. + properties: + controller: + description: Controller identifies the controller responsible + for this placement. + type: string + placement: + description: Placement is the list of member clusters that the + Kubernetes object should be propagated to. + items: + description: ClusterReference represents a single member cluster. + properties: + cluster: + description: Cluster is the name of the member cluster. + type: string + required: + - cluster + type: object + type: array + required: + - controller + - placement + type: object + type: array + template: + description: Template is the base template of the Kubernetes object + to be propagated. + x-kubernetes-preserve-unknown-fields: true + required: + - follows + - overrides + - placements + - template + type: object + status: + description: Status describes the most recently observed status of the + ClusterFederatedObject. + properties: + clusters: + description: Clusters contains the propagation status of the Kubernetes + object for individual member clusters. + items: + description: PropagationStatus describes the propagation of a Kubernetes + object to a given member cluster. + properties: + cluster: + description: Cluster is the name of the member cluster. + type: string + lastObservedGeneration: + description: LastObservedGeneration is the last observed generation + of the Kubernetes object in the member cluster. + format: int64 + type: integer + status: + description: Status describes the current status of propagating + the Kubernetes object to the member cluster. + type: string + required: + - cluster + - status + type: object + type: array + collisionCount: + description: CollisionCount can be used in conjunction with RevisionHistory + to implement rollbacks. + format: int32 + type: integer + conditions: + description: Conditions describe the current state of this FederatedObject. + items: + description: GenericFederatedObjectCondition contains the current + details about a particular condition of a FederatedObject. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the status + of this condition changed. + format: date-time + type: string + lastUpdateTime: + description: LastUpdateTime is the last time a reconciliation + for this condition occurred. + format: date-time + type: string + reason: + description: Reason is the reason for the last status change + of this condition. + type: string + status: + description: Status is the status of the condition, one of True, + False or Unknown. + type: string + type: + description: Type is the type of the condition. + type: string + required: + - status + - type + type: object + type: array + syncedGeneration: + description: SyncedGeneration is the generation of this FederatedObject + when it was last synced to selected member clusters. + format: int64 + type: integer + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crds/core.kubeadmiral.io_clusterpropagationpolicies.yaml b/config/crds/core.kubeadmiral.io_clusterpropagationpolicies.yaml index 9c4a19fd..828a179f 100644 --- a/config/crds/core.kubeadmiral.io_clusterpropagationpolicies.yaml +++ b/config/crds/core.kubeadmiral.io_clusterpropagationpolicies.yaml @@ -124,13 +124,13 @@ spec: description: DisableFollowerScheduling is a boolean that determines if follower scheduling is disabled. Resources that depend on other resources (e.g. deployments) are called leaders, and resources that are depended on (e.g. configmaps and secrets) are called followers. If a leader enables follower scheduling, its followers will additionally be scheduled to clusters where the leader is scheduled. type: boolean maxClusters: - description: MaxClusters is the maximum number of replicas that the federated object can be propagated to The maximum number of clusters is unbounded if no value is provided. + description: MaxClusters is the maximum number of replicas that the federated object can be propagated to. The maximum number of clusters is unbounded if no value is provided. format: int64 type: integer placement: - description: Placement is an explicit list of clusters used to select member clusters to propagate resources + description: Placement is an explicit list of clusters used to select member clusters to propagate resources to. items: - description: Placement describes a cluster that a federated object can be propagated to and its propagation preferences. + description: DesiredPlacement describes a cluster that a federated object can be propagated to and its propagation preferences. properties: cluster: description: Cluster is the name of the FederatedCluster to propagate to. @@ -180,7 +180,7 @@ spec: description: StickyCluster determines if a federated object can be rescheduled. type: boolean tolerations: - description: Tolerations describe a set of cluster taints that the policy tolerates + description: Tolerations describe a set of cluster taints that the policy tolerates. items: description: The pod this Toleration is attached to tolerates any taint that matches the triple using the matching operator . properties: diff --git a/config/crds/core.kubeadmiral.io_collectedstatuses.yaml b/config/crds/core.kubeadmiral.io_collectedstatuses.yaml new file mode 100644 index 00000000..815d4ed2 --- /dev/null +++ b/config/crds/core.kubeadmiral.io_collectedstatuses.yaml @@ -0,0 +1,70 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.11.1 + creationTimestamp: null + name: collectedstatuses.core.kubeadmiral.io +spec: + group: core.kubeadmiral.io + names: + kind: CollectedStatus + listKind: CollectedStatusList + plural: collectedstatuses + shortNames: + - cs + singular: collectedstatus + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: CollectedStatus stores the collected fields of Kubernetes objects + from member clusters, that are propagated by a FederatedObject. + 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 + clusters: + description: Clusters is the list of member clusters and collected fields + for its propagated Kubernetes object. + items: + description: CollectedFieldsWithCluster stores the collected fields + of a Kubernetes object in a member cluster. + properties: + cluster: + description: Cluster is the name of the member cluster. + type: string + collectedFields: + description: CollectedFields is the the set of fields collected + for the Kubernetes object. + x-kubernetes-preserve-unknown-fields: true + error: + description: Error records any errors encountered while collecting + fields from the cluster. + type: string + required: + - cluster + - collectedFields + type: object + type: array + 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 + lastUpdateTime: + description: LastUpdateTime is the last time that a collection was performed. + format: date-time + type: string + metadata: + type: object + required: + - clusters + - lastUpdateTime + type: object + served: true + storage: true diff --git a/config/crds/core.kubeadmiral.io_federatedclusters.yaml b/config/crds/core.kubeadmiral.io_federatedclusters.yaml index bfd0853f..be926b74 100644 --- a/config/crds/core.kubeadmiral.io_federatedclusters.yaml +++ b/config/crds/core.kubeadmiral.io_federatedclusters.yaml @@ -107,15 +107,13 @@ spec: description: The list of api resource types defined in the federated cluster items: - description: APIResource defines how to configure the dynamic client - for an API resource. + description: APIResource represents a Kubernetes API resource. properties: group: description: Group of the resource. type: string kind: - description: Camel-cased singular name of the resource (e.g. - ConfigMap) + description: Kind of the resource. type: string pluralName: description: Lower-cased plural name of the resource (e.g. configmaps). If diff --git a/config/crds/core.kubeadmiral.io_federatedobjects.yaml b/config/crds/core.kubeadmiral.io_federatedobjects.yaml new file mode 100644 index 00000000..46110d16 --- /dev/null +++ b/config/crds/core.kubeadmiral.io_federatedobjects.yaml @@ -0,0 +1,228 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.11.1 + creationTimestamp: null + name: federatedobjects.core.kubeadmiral.io +spec: + group: core.kubeadmiral.io + names: + kind: FederatedObject + listKind: FederatedObjectList + plural: federatedobjects + shortNames: + - fo + singular: federatedobject + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: FederatedObject describes a namespace-scoped Kubernetes object + and how it should be propagated to different member clusters. + 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 defines the desired behavior of the FederatedObject. + properties: + follows: + description: Follows defines other objects, or "leaders", that the + Kubernetes object should follow during propagation, i.e. the Kubernetes + object should be propagated to all member clusters that its "leaders" + are placed in. + items: + description: LeaderReference contains the identifying metadata of + a "leader" Kubernetes object. + properties: + group: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + required: + - kind + - name + type: object + type: array + overrides: + description: Overrides describe the overrides that should be applied + to the base template of the Kubernetes object before it is propagated + to individual member clusters. + items: + description: OverrideWithController describes the overrides that + will be applied to a Kubernetes object before it is propagated + to individual member clusters. + properties: + clusters: + description: Override is the list of member clusters and their + respective override patches. + items: + description: ClusterReferenceWithPatches represents a single + member cluster and a list of override patches for the cluster. + properties: + cluster: + description: Cluster is the name of the member cluster. + type: string + patches: + description: Patches is the list of override patches for + the member cluster. + items: + description: OverridePatch defines a JSON patch. + properties: + op: + type: string + path: + type: string + value: + x-kubernetes-preserve-unknown-fields: true + required: + - path + type: object + type: array + required: + - cluster + type: object + type: array + controller: + description: Controller identifies the controller responsible + for this override. + type: string + required: + - clusters + - controller + type: object + type: array + placements: + description: Placements describe the member clusters that the Kubernetes + object will be propagated to, which is a union of all the listed + clusters. + items: + description: PlacementWithController describes the member clusters + that a Kubernetes object should be propagated to. + properties: + controller: + description: Controller identifies the controller responsible + for this placement. + type: string + placement: + description: Placement is the list of member clusters that the + Kubernetes object should be propagated to. + items: + description: ClusterReference represents a single member cluster. + properties: + cluster: + description: Cluster is the name of the member cluster. + type: string + required: + - cluster + type: object + type: array + required: + - controller + - placement + type: object + type: array + template: + description: Template is the base template of the Kubernetes object + to be propagated. + x-kubernetes-preserve-unknown-fields: true + required: + - follows + - overrides + - placements + - template + type: object + status: + description: Status describes the most recently observed status of the + FederatedObject. + properties: + clusters: + description: Clusters contains the propagation status of the Kubernetes + object for individual member clusters. + items: + description: PropagationStatus describes the propagation of a Kubernetes + object to a given member cluster. + properties: + cluster: + description: Cluster is the name of the member cluster. + type: string + lastObservedGeneration: + description: LastObservedGeneration is the last observed generation + of the Kubernetes object in the member cluster. + format: int64 + type: integer + status: + description: Status describes the current status of propagating + the Kubernetes object to the member cluster. + type: string + required: + - cluster + - status + type: object + type: array + collisionCount: + description: CollisionCount can be used in conjunction with RevisionHistory + to implement rollbacks. + format: int32 + type: integer + conditions: + description: Conditions describe the current state of this FederatedObject. + items: + description: GenericFederatedObjectCondition contains the current + details about a particular condition of a FederatedObject. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the status + of this condition changed. + format: date-time + type: string + lastUpdateTime: + description: LastUpdateTime is the last time a reconciliation + for this condition occurred. + format: date-time + type: string + reason: + description: Reason is the reason for the last status change + of this condition. + type: string + status: + description: Status is the status of the condition, one of True, + False or Unknown. + type: string + type: + description: Type is the type of the condition. + type: string + required: + - status + - type + type: object + type: array + syncedGeneration: + description: SyncedGeneration is the generation of this FederatedObject + when it was last synced to selected member clusters. + format: int64 + type: integer + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/crds/core.kubeadmiral.io_federatedtypeconfigs.yaml b/config/crds/core.kubeadmiral.io_federatedtypeconfigs.yaml index 44ed05d5..c38a577f 100644 --- a/config/crds/core.kubeadmiral.io_federatedtypeconfigs.yaml +++ b/config/crds/core.kubeadmiral.io_federatedtypeconfigs.yaml @@ -20,8 +20,8 @@ spec: - name: v1alpha1 schema: openAPIV3Schema: - description: FederatedTypeConfig is the Schema for the federatedtypeconfigs - API + description: FederatedTypeConfig specifies an API resource type to federate + and various type-specific options. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -38,54 +38,29 @@ spec: spec: properties: autoMigration: - description: Configurations for auto migration. + description: Configuration for AutoMigration. If left empty, the AutoMigration + feature will be disabled. properties: enabled: - description: Whether or not to enable auto migration. + description: Whether or not to automatically migrate unschedulable + pods to a different cluster. type: boolean required: - enabled type: object controllers: - description: The controllers that must run before the resource can - be propagated to member clusters. Each inner slice specifies a step. - Step T must complete before step T+1 can commence. Controllers within - each step can execute in parallel. + description: The controllers that must run before the source object + can be propagated to member clusters. Each inner slice specifies + a step. Step T must complete before step T+1 can commence. Controllers + within each step can execute in parallel. items: items: type: string type: array type: array - federatedType: - description: Configuration for the federated type that defines (via - template, placement and overrides fields) how the target type should - appear in multiple cluster. - properties: - group: - description: Group of the resource. - type: string - kind: - description: Camel-cased singular name of the resource (e.g. ConfigMap) - type: string - pluralName: - description: Lower-cased plural name of the resource (e.g. configmaps). If - not provided, it will be computed by lower-casing the kind and - suffixing an 's'. - type: string - scope: - description: Scope of the resource. - type: string - version: - description: Version of the resource. - type: string - required: - - kind - - pluralName - - scope - - version - type: object pathDefinition: - description: Defines the paths in the target object schema. + description: Defines the paths to various fields in the target object's + schema. properties: availableReplicasStatus: description: Path to a numeric field that reflects the number @@ -114,22 +89,35 @@ spec: type: string type: object revisionHistory: - description: Whether or not keep revisionHistory for the federatedType - resource - type: string + description: Configuration for RevisionHistory. If left empty, the + RevisionHistory feature will be disabled. + properties: + enabled: + description: Whether or not preserve a RevisionHistory for the + federated object during updates. + type: boolean + required: + - enabled + type: object rolloutPlan: - description: Whether or not to plan the rollout process - type: string + description: Configuration for RolloutPlan. If left empty, the RolloutPlan + feature will be disabled. + properties: + enabled: + description: Whether or not to synchronize the rollout process + across clusters. + type: boolean + required: + - enabled + type: object sourceType: - description: The configuration of the source type. If set, each object - of the source type will be federated to object of the federated - type with the same name and namespace. + description: The API resource type to be federated. properties: group: description: Group of the resource. type: string kind: - description: Camel-cased singular name of the resource (e.g. ConfigMap) + description: Kind of the resource. type: string pluralName: description: Lower-cased plural name of the resource (e.g. configmaps). If @@ -149,89 +137,37 @@ spec: - version type: object statusAggregation: - description: Whether or not Status should be aggregated to source - type object - type: string + description: Configuration for StatusAggregation. If left empty, the + StatusAggregation feature will be disabled. + properties: + enabled: + description: Whether or not to enable status aggregation. + type: boolean + required: + - enabled + type: object statusCollection: - description: Whether or not Status object should be populated. + description: Configuration for StatusCollection. If left empty, the + StatusCollection feature will be disabled. properties: + enabled: + description: Whether or not to enable status collection. + type: boolean fields: + description: Contains the fields to be collected during status + collection. Each field is a dot separated string that corresponds + to its path in the source object's schema. E.g. `metadata.creationTimestamp`. items: type: string type: array - type: object - statusType: - description: Configuration for the status type that holds information - about which type holds the status of the federated resource. If - not provided, the group and version will default to those provided - for the federated type api resource. - properties: - group: - description: Group of the resource. - type: string - kind: - description: Camel-cased singular name of the resource (e.g. ConfigMap) - type: string - pluralName: - description: Lower-cased plural name of the resource (e.g. configmaps). If - not provided, it will be computed by lower-casing the kind and - suffixing an 's'. - type: string - scope: - description: Scope of the resource. - type: string - version: - description: Version of the resource. - type: string - required: - - kind - - pluralName - - scope - - version - type: object - targetType: - description: The configuration of the target type. If not set, the - pluralName and groupName fields will be set from the metadata.name - of this resource. The kind field must be set. - properties: - group: - description: Group of the resource. - type: string - kind: - description: Camel-cased singular name of the resource (e.g. ConfigMap) - type: string - pluralName: - description: Lower-cased plural name of the resource (e.g. configmaps). If - not provided, it will be computed by lower-casing the kind and - suffixing an 's'. - type: string - scope: - description: Scope of the resource. - type: string - version: - description: Version of the resource. - type: string required: - - kind - - pluralName - - scope - - version + - enabled type: object required: - - federatedType - - targetType - type: object - status: - description: FederatedTypeConfigStatus defines the observed state of FederatedTypeConfig - properties: - observedGeneration: - description: ObservedGeneration is the generation as observed by the - controller consuming the FederatedTypeConfig. - format: int64 - type: integer - required: - - observedGeneration + - sourceType type: object + required: + - spec type: object served: true storage: true diff --git a/config/crds/core.kubeadmiral.io_propagationpolicies.yaml b/config/crds/core.kubeadmiral.io_propagationpolicies.yaml index a936c82e..780b1563 100644 --- a/config/crds/core.kubeadmiral.io_propagationpolicies.yaml +++ b/config/crds/core.kubeadmiral.io_propagationpolicies.yaml @@ -124,13 +124,13 @@ spec: description: DisableFollowerScheduling is a boolean that determines if follower scheduling is disabled. Resources that depend on other resources (e.g. deployments) are called leaders, and resources that are depended on (e.g. configmaps and secrets) are called followers. If a leader enables follower scheduling, its followers will additionally be scheduled to clusters where the leader is scheduled. type: boolean maxClusters: - description: MaxClusters is the maximum number of replicas that the federated object can be propagated to The maximum number of clusters is unbounded if no value is provided. + description: MaxClusters is the maximum number of replicas that the federated object can be propagated to. The maximum number of clusters is unbounded if no value is provided. format: int64 type: integer placement: - description: Placement is an explicit list of clusters used to select member clusters to propagate resources + description: Placement is an explicit list of clusters used to select member clusters to propagate resources to. items: - description: Placement describes a cluster that a federated object can be propagated to and its propagation preferences. + description: DesiredPlacement describes a cluster that a federated object can be propagated to and its propagation preferences. properties: cluster: description: Cluster is the name of the FederatedCluster to propagate to. @@ -180,7 +180,7 @@ spec: description: StickyCluster determines if a federated object can be rescheduled. type: boolean tolerations: - description: Tolerations describe a set of cluster taints that the policy tolerates + description: Tolerations describe a set of cluster taints that the policy tolerates. items: description: The pod this Toleration is attached to tolerates any taint that matches the triple using the matching operator . properties: diff --git a/hack/generate-groups.sh b/hack/generate-groups.sh index 2696a43e..5d0fd12a 100644 --- a/hack/generate-groups.sh +++ b/hack/generate-groups.sh @@ -30,7 +30,6 @@ YQ_VERSION=${YQ_VERSION:-"v4.33.1"} MODULE_NAME=${MODULE_NAME:-"github.com/kubewharf/kubeadmiral"} groups=( core/v1alpha1 - types/v1alpha1 ) # install code-generator binaries diff --git a/hack/typos.toml b/hack/typos.toml index f878a8ac..f3299954 100644 --- a/hack/typos.toml +++ b/hack/typos.toml @@ -1,5 +1,9 @@ [files] -extend-exclude = ["go.mod", "go.sum"] +extend-exclude = ["go.mod", "go.sum", "config/crds/"] + +[default] +extend-ignore-re = ["shortName=[a-z]+"] [default.extend-identifiers] ANDed = "ANDed" + diff --git a/pkg/apis/core/v1alpha1/extensions_federatedobject.go b/pkg/apis/core/v1alpha1/extensions_federatedobject.go new file mode 100644 index 00000000..af48d8f5 --- /dev/null +++ b/pkg/apis/core/v1alpha1/extensions_federatedobject.go @@ -0,0 +1,117 @@ +/* +Copyright 2023 The KubeAdmiral Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "reflect" + "sort" + + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/sets" +) + +// Placement extensions + +// GetPlacementUnion returns the union of all clusters listed under the Placement field of the FederatedObject. +func (o *FederatedObject) GetPlacementUnion() sets.Set[string] { + set := sets.New[string]() + for _, placement := range o.Spec.Placements { + for _, cluster := range placement.Placement { + set.Insert(cluster.Cluster) + } + } + return set +} + +// GetControllerPlacement returns the slice containing all the ClusterPlacements from a given controller. Returns nil if +// the controller is not present. +func (o *FederatedObject) GetControllerPlacement(controller string) []ClusterReference { + for _, placement := range o.Spec.Placements { + if placement.Controller == controller { + return placement.Placement + } + } + return nil +} + +// SetControllerPlacement sets the ClusterPlacements for a given controller. If clusterNames is nil or empty, the previous +// placement for the given controller will be deleted. Returns a bool indicating if the FederatedObject has changed. +func (o *FederatedObject) SetControllerPlacement(controller string, clusterNames []string) bool { + if len(clusterNames) == 0 { + return o.DeleteControllerPlacement(controller) + } + + newPlacement := make([]ClusterReference, len(clusterNames)) + for i, name := range clusterNames { + newPlacement[i] = ClusterReference{Cluster: name} + } + // sort the clusters by name for readability and to avoid unnecessary updates + sort.Slice(newPlacement, func(i, j int) bool { + return newPlacement[i].Cluster < newPlacement[j].Cluster + }) + + oldPlacementWithControllerIdx := -1 + for i := range o.Spec.Placements { + if o.Spec.Placements[i].Controller == controller { + oldPlacementWithControllerIdx = i + break + } + } + + newPlacmentWithController := PlacementWithController{ + Controller: controller, + Placement: newPlacement, + } + if oldPlacementWithControllerIdx == -1 { + o.Spec.Placements = append(o.Spec.Placements, newPlacmentWithController) + return true + } + if !reflect.DeepEqual(newPlacmentWithController, o.Spec.Placements[oldPlacementWithControllerIdx]) { + o.Spec.Placements[oldPlacementWithControllerIdx] = newPlacmentWithController + return true + } + + return false +} + +// DeleteClusterPlacement deletes a controller's placement, returning a bool to indicate if the FederatedObject has +// changed. +func (o *FederatedObject) DeleteControllerPlacement(controller string) bool { + oldPlacementIdx := -1 + for i := range o.Spec.Placements { + if o.Spec.Placements[i].Controller == controller { + oldPlacementIdx = i + break + } + } + + if oldPlacementIdx == -1 { + return false + } + + o.Spec.Placements = append(o.Spec.Placements[:oldPlacementIdx], o.Spec.Placements[(oldPlacementIdx+1):]...) + return true +} + +// Follower extensions + +func (l *LeaderReference) GroupKind() schema.GroupKind { + return schema.GroupKind{ + Group: l.Group, + Kind: l.Kind, + } +} diff --git a/pkg/apis/core/v1alpha1/extensions_federatedtypeconfig.go b/pkg/apis/core/v1alpha1/extensions_federatedtypeconfig.go index 901d0d3a..a2e3b3b5 100644 --- a/pkg/apis/core/v1alpha1/extensions_federatedtypeconfig.go +++ b/pkg/apis/core/v1alpha1/extensions_federatedtypeconfig.go @@ -33,63 +33,36 @@ func (f *FederatedTypeConfig) GetObjectMeta() metav1.ObjectMeta { return f.ObjectMeta } -func (f *FederatedTypeConfig) GetTargetType() metav1.APIResource { - return apiResourceToMeta(f.Spec.TargetType) -} - func (f *FederatedTypeConfig) GetNamespaced() bool { - return f.Spec.TargetType.Namespaced() + return f.Spec.SourceType.Namespaced() } func (f *FederatedTypeConfig) GetPropagationEnabled() bool { return true } -func (f *FederatedTypeConfig) GetFederatedType() metav1.APIResource { - return apiResourceToMeta(f.Spec.FederatedType) -} - -func (f *FederatedTypeConfig) GetStatusType() *metav1.APIResource { - if f.Spec.StatusType == nil { - return nil - } - metaAPIResource := apiResourceToMeta(*f.Spec.StatusType) - return &metaAPIResource -} - -func (f *FederatedTypeConfig) GetSourceType() *metav1.APIResource { - if f.Spec.SourceType == nil { - return nil - } - meta := apiResourceToMeta(*f.Spec.SourceType) - return &meta +func (f *FederatedTypeConfig) GetSourceType() metav1.APIResource { + return apiResourceToMeta(f.Spec.SourceType) } -func (f *FederatedTypeConfig) GetStatusEnabled() bool { +func (f *FederatedTypeConfig) GetStatusCollectionEnabled() bool { return f.Spec.StatusCollection != nil } func (f *FederatedTypeConfig) GetStatusAggregationEnabled() bool { - return f.Spec.StatusAggregation != nil && - *f.Spec.StatusAggregation == StatusAggregationEnabled + return f.Spec.StatusAggregation != nil && f.Spec.StatusAggregation.Enabled } func (f *FederatedTypeConfig) GetPolicyRcEnabled() bool { return true // TODO: should this be configurable? } -func (f *FederatedTypeConfig) GetFederateEnabled() bool { - return f.Spec.SourceType != nil -} - func (f *FederatedTypeConfig) GetRevisionHistoryEnabled() bool { - return f.Spec.RevisionHistory != nil && - *f.Spec.RevisionHistory == RevisionHistoryEnabled + return f.Spec.RevisionHistory != nil && f.Spec.RevisionHistory.Enabled } func (f *FederatedTypeConfig) GetRolloutPlanEnabled() bool { - return f.Spec.RolloutPlan != nil && - *f.Spec.RolloutPlan == RolloutPlanEnabled + return f.Spec.RolloutPlan != nil && f.Spec.RolloutPlan.Enabled } func (f *FederatedTypeConfig) GetControllers() [][]string { diff --git a/pkg/apis/core/v1alpha1/register.go b/pkg/apis/core/v1alpha1/register.go index 275677e9..41cde200 100644 --- a/pkg/apis/core/v1alpha1/register.go +++ b/pkg/apis/core/v1alpha1/register.go @@ -53,6 +53,12 @@ func init() { // Adds the list of known types to api.Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, + &FederatedObject{}, + &FederatedObjectList{}, + &ClusterFederatedObject{}, + &ClusterFederatedObjectList{}, + &CollectedStatus{}, + &CollectedStatusList{}, &FederatedCluster{}, &FederatedClusterList{}, &FederatedTypeConfig{}, diff --git a/pkg/apis/core/v1alpha1/types_collectedstatus.go b/pkg/apis/core/v1alpha1/types_collectedstatus.go new file mode 100644 index 00000000..ec59748b --- /dev/null +++ b/pkg/apis/core/v1alpha1/types_collectedstatus.go @@ -0,0 +1,95 @@ +/* +Copyright 2023 The KubeAdmiral Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:validation:Required +// +kubebuilder:resource:path=collectedstatuses,shortName=cs,singular=collectedstatus +// +kubebuilder:object:root=true + +// CollectedStatus stores the collected fields of Kubernetes objects from member clusters, that are propagated by a +// FederatedObject. +type CollectedStatus struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + GenericCollectedStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true + +// CollectedStatusList contains a list of CollectedStatuses. +type CollectedStatusList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []CollectedStatus `json:"items"` +} + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:validation:Required +// +kubebuilder:resource:path=clustercollectedstatuses,shortName=ccs,singular=clustercollectedstatus,scope=Cluster +// +kubebuilder:object:root=true + +// ClusterCollectedStatus stores the collected fields of Kubernetes objects from member clusters, that are propagated by +// a ClusterFederatedObject. +type ClusterCollectedStatus struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + GenericCollectedStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterCollectedStatusList contains a list of ClusterCollectedStatuses. +type ClusterCollectedStatusList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ClusterCollectedStatus `json:"items"` +} + +// GenericCollectedStatus contains the shared fields of CollectedStatus and ClusterCollectedStatus +type GenericCollectedStatus struct { + // Clusters is the list of member clusters and collected fields for its propagated Kubernetes object. + Clusters []CollectedFieldsWithCluster `json:"clusters"` + + // LastUpdateTime is the last time that a collection was performed. + LastUpdateTime metav1.Time `json:"lastUpdateTime"` +} + +// CollectedFieldsWithCluster stores the collected fields of a Kubernetes object in a member cluster. +type CollectedFieldsWithCluster struct { + // Cluster is the name of the member cluster. + Cluster string `json:"cluster"` + // CollectedFields is the the set of fields collected for the Kubernetes object. + CollectedFields apiextensionsv1.JSON `json:"collectedFields"` + // Error records any errors encountered while collecting fields from the cluster. + // +optional + Error string `json:"error,omitempty"` +} diff --git a/pkg/apis/core/v1alpha1/types_federatedobject.go b/pkg/apis/core/v1alpha1/types_federatedobject.go new file mode 100644 index 00000000..2ceb348c --- /dev/null +++ b/pkg/apis/core/v1alpha1/types_federatedobject.go @@ -0,0 +1,254 @@ +/* +Copyright 2023 The KubeAdmiral Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:validation:Required +// +kubebuilder:resource:path=federatedobjects,shortName=fo,singular=federatedobject +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true + +// FederatedObject describes a namespace-scoped Kubernetes object and how it should be propagated to different member +// clusters. +type FederatedObject struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired behavior of the FederatedObject. + Spec GenericFederatedObjectSpec `json:"spec"` + + // Status describes the most recently observed status of the FederatedObject. + // +optional + Status GenericFederatedObjectStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true + +// FederatedObjectList contains a list of FederatedObject. +type FederatedObjectList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []FederatedObject `json:"items"` +} + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:validation:Required +// +kubebuilder:resource:path=clusterfederatedobjects,shortName=cfo,singular=clusterfederatedobject,scope=Cluster +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status + +// ClusterFederatedObject describes a cluster-scoped Kubernetes object and how it should be propagated to different +// member clusters. +type ClusterFederatedObject struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired behavior of the ClusterFederatedObject. + Spec GenericFederatedObjectSpec `json:"spec"` + + // Status describes the most recently observed status of the ClusterFederatedObject. + // +optional + Status GenericFederatedObjectStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterFederatedObjectList contains a list of ClusterFederatedObject. +type ClusterFederatedObjectList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ClusterFederatedObject `json:"items"` +} + +// GenericFederatedObjectSpec defines the desired behavior of a FederatedObject or ClusterFederatedObject. +type GenericFederatedObjectSpec struct { + // Template is the base template of the Kubernetes object to be propagated. + Template apiextensionsv1.JSON `json:"template"` + // Overrides describe the overrides that should be applied to the base template of the Kubernetes object before it + // is propagated to individual member clusters. + Overrides []OverrideWithController `json:"overrides"` + // Placements describe the member clusters that the Kubernetes object will be propagated to, which is a union of all + // the listed clusters. + Placements []PlacementWithController `json:"placements"` + // Follows defines other objects, or "leaders", that the Kubernetes object should follow during propagation, i.e. + // the Kubernetes object should be propagated to all member clusters that its "leaders" are placed in. + Follows []LeaderReference `json:"follows"` +} + +// GenericFederatedObjectStatus describes the most recently observed status of a FederatedObject or ClusterFederatedObject. +type GenericFederatedObjectStatus struct { + // SyncedGeneration is the generation of this FederatedObject when it was last synced to selected member clusters. + SyncedGeneration int64 `json:"syncedGeneration,omitempty"` + // Conditions describe the current state of this FederatedObject. + Conditions []GenericFederatedObjectCondition `json:"conditions,omitempty"` + // Clusters contains the propagation status of the Kubernetes object for individual member clusters. + Clusters []PropagationStatus `json:"clusters,omitempty"` + + // CollisionCount can be used in conjunction with RevisionHistory to implement rollbacks. + // +optional + CollisionCount *int32 `json:"collisionCount,omitempty"` +} + +// PlacementWithController describes the member clusters that a Kubernetes object should be propagated to. +type PlacementWithController struct { + // Controller identifies the controller responsible for this placement. + Controller string `json:"controller"` + // Placement is the list of member clusters that the Kubernetes object should be propagated to. + Placement []ClusterReference `json:"placement"` +} + +// ClusterReference represents a single member cluster. +type ClusterReference struct { + // Cluster is the name of the member cluster. + Cluster string `json:"cluster"` +} + +// OverrideWithController describes the overrides that will be applied to a Kubernetes object before it is propagated to +// individual member clusters. +type OverrideWithController struct { + // Controller identifies the controller responsible for this override. + Controller string `json:"controller"` + // Override is the list of member clusters and their respective override patches. + Override []ClusterReferenceWithPatches `json:"clusters"` +} + +// ClusterReferenceWithPatches represents a single member cluster and a list of override patches for the cluster. +type ClusterReferenceWithPatches struct { + // Cluster is the name of the member cluster. + Cluster string `json:"cluster"` + // Patches is the list of override patches for the member cluster. + Patches OverridePatches `json:"patches,omitempty"` +} + +// OverridePatch defines a JSON patch. +type OverridePatch struct { + Op string `json:"op,omitempty"` + Path string `json:"path"` + Value apiextensionsv1.JSON `json:"value,omitempty"` +} + +// OverridePatches is a list of OverridePatch. +type OverridePatches []OverridePatch + +// LeaderReference contains the identifying metadata of a "leader" Kubernetes object. +type LeaderReference struct { + Group string `json:"group,omitempty"` + Kind string `json:"kind"` + Namespace string `json:"namespace,omitempty"` + Name string `json:"name"` +} + +// GenericFederatedObjectCondition contains the current details about a particular condition of a FederatedObject. +type GenericFederatedObjectCondition struct { + // Type is the type of the condition. + Type FederatedObjectConditionType `json:"type"` + // Status is the status of the condition, one of True, False or Unknown. + Status corev1.ConditionStatus `json:"status"` + // LastUpdateTime is the last time a reconciliation for this condition occurred. + // +optional + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` + // LastTransitionTime is the last time the status of this condition changed. + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + // Reason is the reason for the last status change of this condition. + // +optional + Reason FederatedObjectConditionReason `json:"reason,omitempty"` +} + +// PropagationStatus describes the propagation of a Kubernetes object to a given member cluster. +type PropagationStatus struct { + // Cluster is the name of the member cluster. + Cluster string `json:"cluster"` + // Status describes the current status of propagating the Kubernetes object to the member cluster. + Status PropagationStatusType `json:"status"` + // LastObservedGeneration is the last observed generation of the Kubernetes object in the member cluster. + LastObservedGeneration int64 `json:"lastObservedGeneration,omitempty"` +} + +// FederatedObjectConditionType is a unique, camel-case word to describe the type of a FederatedObjectCondition. +type FederatedObjectConditionType string + +const ( + PropagationConditionType FederatedObjectConditionType = "Propagated" +) + +// FederatedObjectConditionReason is a unique, camel-case word to describe the reason for the last status change of a +// FederatedObjectCondition. +type FederatedObjectConditionReason string + +const ( + AggregateSuccess FederatedObjectConditionReason = "" + SyncRevisionsFailed FederatedObjectConditionReason = "SyncRevisionsFailed" + ClusterRetrievalFailed FederatedObjectConditionReason = "ClusterRetrievalFailed" + ComputePlacementFailed FederatedObjectConditionReason = "ComputePlacementFailed" + PlanRolloutFailed FederatedObjectConditionReason = "PlanRolloutFailed" + CheckClusters FederatedObjectConditionReason = "CheckClusters" + NamespaceNotFederated FederatedObjectConditionReason = "NamespaceNotFederated" + EnsureDeletionFailed FederatedObjectConditionReason = "EnsureDeletionFailed" +) + +// PropagationStatusType is a unique, camel-case word to describe the current status of propagating a Kubernetes object +// to a member cluster. +type PropagationStatusType string + +const ( + ClusterPropagationOK PropagationStatusType = "OK" + WaitingForRemoval PropagationStatusType = "WaitingForRemoval" + + // Cluster-specific errors + + ClusterNotReady PropagationStatusType = "ClusterNotReady" + ClusterTerminating PropagationStatusType = "ClusterTerminating" + CachedRetrievalFailed PropagationStatusType = "CachedRetrievalFailed" + ComputeResourceFailed PropagationStatusType = "ComputeResourceFailed" + ApplyOverridesFailed PropagationStatusType = "ApplyOverridesFailed" + CreationFailed PropagationStatusType = "CreationFailed" + UpdateFailed PropagationStatusType = "UpdateFailed" + DeletionFailed PropagationStatusType = "DeletionFailed" + LabelRemovalFailed PropagationStatusType = "LabelRemovalFailed" + RetrievalFailed PropagationStatusType = "RetrievalFailed" + AlreadyExists PropagationStatusType = "AlreadyExists" + FieldRetentionFailed PropagationStatusType = "FieldRetentionFailed" + SetLastReplicasetNameFailed PropagationStatusType = "SetLastReplicasetNameFailed" + VersionRetrievalFailed PropagationStatusType = "VersionRetrievalFailed" + ClientRetrievalFailed PropagationStatusType = "ClientRetrievalFailed" + ManagedLabelFalse PropagationStatusType = "ManagedLabelFalse" + FinalizerCheckFailed PropagationStatusType = "FinalizerCheckFailed" + + // Operation timeout errors + + CreationTimedOut PropagationStatusType = "CreationTimedOut" + UpdateTimedOut PropagationStatusType = "UpdateTimedOut" + DeletionTimedOut PropagationStatusType = "DeletionTimedOut" + LabelRemovalTimedOut PropagationStatusType = "LabelRemovalTimedOut" +) diff --git a/pkg/apis/core/v1alpha1/types_federatedtypeconfig.go b/pkg/apis/core/v1alpha1/types_federatedtypeconfig.go index 5847bff8..641622f4 100644 --- a/pkg/apis/core/v1alpha1/types_federatedtypeconfig.go +++ b/pkg/apis/core/v1alpha1/types_federatedtypeconfig.go @@ -25,30 +25,19 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -const ( - StatusAggregationEnabled StatusAggregationMode = "Enabled" - StatusAggregationDisabled StatusAggregationMode = "Disabled" - - RevisionHistoryEnabled RevisionHistoryMode = "Enabled" - RevisionHistoryDisabled RevisionHistoryMode = "Disabled" - - RolloutPlanEnabled RolloutPlanMode = "Enabled" - RolloutPlanDisabled RolloutPlanMode = "Disabled" -) - // +genclient // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:validation:Required // +kubebuilder:resource:path=federatedtypeconfigs,shortName=ftc,scope=Cluster // +kubebuilder:subresource:status -// FederatedTypeConfig is the Schema for the federatedtypeconfigs API +// FederatedTypeConfig specifies an API resource type to federate and various type-specific options. type FederatedTypeConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec FederatedTypeConfigSpec `json:"spec,omitempty"` - Status FederatedTypeConfigStatus `json:"status,omitempty"` + Spec FederatedTypeConfigSpec `json:"spec"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -61,53 +50,37 @@ type FederatedTypeConfigList struct { } type FederatedTypeConfigSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // The configuration of the source type. If set, each object of the source - // type will be federated to object of the federated type with the same name - // and namespace. - SourceType *APIResource `json:"sourceType,omitempty"` - // The configuration of the target type. If not set, the pluralName and - // groupName fields will be set from the metadata.name of this resource. The - // kind field must be set. - TargetType APIResource `json:"targetType"` - // Configuration for the federated type that defines (via - // template, placement and overrides fields) how the target type - // should appear in multiple cluster. - FederatedType APIResource `json:"federatedType"` - // Configuration for the status type that holds information about which type - // holds the status of the federated resource. If not provided, the group - // and version will default to those provided for the federated type api - // resource. - // +optional - StatusType *APIResource `json:"statusType,omitempty"` + // The API resource type to be federated. + SourceType APIResource `json:"sourceType"` - // Whether or not Status object should be populated. + // Configuration for StatusAggregation. If left empty, the StatusAggregation feature will be disabled. // +optional - StatusCollection *StatusCollection `json:"statusCollection,omitempty"` - // Whether or not Status should be aggregated to source type object - StatusAggregation *StatusAggregationMode `json:"statusAggregation,omitempty"` - // Whether or not keep revisionHistory for the federatedType resource - RevisionHistory *RevisionHistoryMode `json:"revisionHistory,omitempty"` - // Whether or not to plan the rollout process + StatusAggregation *StatusAggregationConfig `json:"statusAggregation,omitempty"` + // Configuration for RevisionHistory. If left empty, the RevisionHistory feature will be disabled. // +optional - RolloutPlan *RolloutPlanMode `json:"rolloutPlan,omitempty"` - // Configurations for auto migration. + RevisionHistory *RevisionHistoryConfig `json:"revisionHistory,omitempty"` + // Configuration for RolloutPlan. If left empty, the RolloutPlan feature will be disabled. + // +optional + RolloutPlan *RolloutPlanConfig `json:"rolloutPlan,omitempty"` + // Configuration for StatusCollection. If left empty, the StatusCollection feature will be disabled. + // +optional + StatusCollection *StatusCollectionConfig `json:"statusCollection,omitempty"` + // Configuration for AutoMigration. If left empty, the AutoMigration feature will be disabled. // +optional AutoMigration *AutoMigrationConfig `json:"autoMigration,omitempty"` - // The controllers that must run before the resource can be propagated to member clusters. + // The controllers that must run before the source object can be propagated to member clusters. // Each inner slice specifies a step. Step T must complete before step T+1 can commence. // Controllers within each step can execute in parallel. // +optional Controllers [][]string `json:"controllers,omitempty"` - // Defines the paths in the target object schema. + // Defines the paths to various fields in the target object's schema. // +optional PathDefinition PathDefinition `json:"pathDefinition,omitempty"` } +// PathDefinition contains paths to various fields in the source object that are required by controllers. type PathDefinition struct { // Path to a metav1.LabelSelector field that selects the replicas for this object. // E.g. `spec.selector` for Deployment and ReplicaSet. @@ -135,47 +108,51 @@ type PathDefinition struct { ReadyReplicasStatus string `json:"readyReplicasStatus,omitempty"` } -// FederatedTypeConfigStatus defines the observed state of FederatedTypeConfig -type FederatedTypeConfigStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // ObservedGeneration is the generation as observed by the controller consuming the FederatedTypeConfig. - ObservedGeneration int64 `json:"observedGeneration"` -} - -// StatusCollection defines the fields that the status controller needs to collect -type StatusCollection struct { +// StatusCollectionConfig defines the configurations for the StatusCollection feature. +type StatusCollectionConfig struct { + // Whether or not to enable status collection. + Enabled bool `json:"enabled"` + // Contains the fields to be collected during status collection. Each field is a dot separated string that + // corresponds to its path in the source object's schema. + // E.g. `metadata.creationTimestamp`. Fields []string `json:"fields,omitempty"` } -// StatusAggregationMode defines the state of status aggregation. -type StatusAggregationMode string +// StatusAggregationConfig defines the configurations for the StatusAggregation feature. +type StatusAggregationConfig struct { + // Whether or not to enable status aggregation. + Enabled bool `json:"enabled"` +} -type RevisionHistoryMode string +// RevisionHistoryConfig defines the configurations for the RevisionHistory feature. +type RevisionHistoryConfig struct { + // Whether or not preserve a RevisionHistory for the federated object during updates. + Enabled bool `json:"enabled"` +} -type RolloutPlanMode string +// RolloutPlanConfig defines the configurations for the RolloutPlan feature. +type RolloutPlanConfig struct { + // Whether or not to synchronize the rollout process across clusters. + Enabled bool `json:"enabled"` +} +// AutoMigrationConfig defines the configurations for the AutoMigration feature. type AutoMigrationConfig struct { - // Whether or not to enable auto migration. + // Whether or not to automatically migrate unschedulable pods to a different cluster. Enabled bool `json:"enabled"` } -// APIResource defines how to configure the dynamic client for an API resource. +// APIResource represents a Kubernetes API resource. type APIResource struct { - // metav1.GroupVersion is not used since the json annotation of - // the fields enforces them as mandatory. - // Group of the resource. // +optional Group string `json:"group,omitempty"` // Version of the resource. Version string `json:"version"` - // Camel-cased singular name of the resource (e.g. ConfigMap) + // Kind of the resource. Kind string `json:"kind"` - // Lower-cased plural name of the resource (e.g. configmaps). If - // not provided, it will be computed by lower-casing the kind and - // suffixing an 's'. + // Lower-cased plural name of the resource (e.g. configmaps). If not provided, + // it will be computed by lower-casing the kind and suffixing an 's'. PluralName string `json:"pluralName"` // Scope of the resource. Scope apiextv1beta1.ResourceScope `json:"scope"` diff --git a/pkg/apis/core/v1alpha1/types_propagationpolicy.go b/pkg/apis/core/v1alpha1/types_propagationpolicy.go index 0055eb41..5773cb86 100644 --- a/pkg/apis/core/v1alpha1/types_propagationpolicy.go +++ b/pkg/apis/core/v1alpha1/types_propagationpolicy.go @@ -78,17 +78,17 @@ type PropagationPolicySpec struct { // A empty or nil ClusterAffinity selects everything. // +optional ClusterAffinity []ClusterSelectorTerm `json:"clusterAffinity,omitempty"` - // Tolerations describe a set of cluster taints that the policy tolerates + // Tolerations describe a set of cluster taints that the policy tolerates. // +optional Tolerations []corev1.Toleration `json:"tolerations,omitempty"` - // MaxClusters is the maximum number of replicas that the federated object can be propagated to + // MaxClusters is the maximum number of replicas that the federated object can be propagated to. // The maximum number of clusters is unbounded if no value is provided. // +optional MaxClusters *int64 `json:"maxClusters,omitempty"` - // Placement is an explicit list of clusters used to select member clusters to propagate resources + // Placement is an explicit list of clusters used to select member clusters to propagate resources to. // +optional - Placements []Placement `json:"placement,omitempty"` + Placements []DesiredPlacement `json:"placement,omitempty"` // DisableFollowerScheduling is a boolean that determines if follower scheduling is disabled. // Resources that depend on other resources (e.g. deployments) are called leaders, @@ -118,14 +118,14 @@ type PropagationPolicyStatus struct { type SchedulingMode string const ( - // Duplicate mode means the federated object will be duplicated to member clusters + // Duplicate mode means the federated object will be duplicated to member clusters. SchedulingModeDuplicate SchedulingMode = "Duplicate" - // Divide mode means the federated object's replicas will be divided between member clusters + // Divide mode means the federated object's replicas will be divided between member clusters. SchedulingModeDivide SchedulingMode = "Divide" ) -// Placement describes a cluster that a federated object can be propagated to and its propagation preferences. -type Placement struct { +// DesiredPlacement describes a cluster that a federated object can be propagated to and its propagation preferences. +type DesiredPlacement struct { // Cluster is the name of the FederatedCluster to propagate to. Cluster string `json:"cluster"` // Preferences contains the cluster's propagation preferences. diff --git a/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go index 13f5f4a1..1226a6c0 100644 --- a/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -81,6 +81,66 @@ func (in *AutoMigrationTrigger) DeepCopy() *AutoMigrationTrigger { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterCollectedStatus) DeepCopyInto(out *ClusterCollectedStatus) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.GenericCollectedStatus.DeepCopyInto(&out.GenericCollectedStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterCollectedStatus. +func (in *ClusterCollectedStatus) DeepCopy() *ClusterCollectedStatus { + if in == nil { + return nil + } + out := new(ClusterCollectedStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterCollectedStatus) 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 *ClusterCollectedStatusList) DeepCopyInto(out *ClusterCollectedStatusList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterCollectedStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterCollectedStatusList. +func (in *ClusterCollectedStatusList) DeepCopy() *ClusterCollectedStatusList { + if in == nil { + return nil + } + out := new(ClusterCollectedStatusList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterCollectedStatusList) 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 *ClusterCondition) DeepCopyInto(out *ClusterCondition) { *out = *in @@ -99,6 +159,67 @@ func (in *ClusterCondition) DeepCopy() *ClusterCondition { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterFederatedObject) DeepCopyInto(out *ClusterFederatedObject) { + *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 ClusterFederatedObject. +func (in *ClusterFederatedObject) DeepCopy() *ClusterFederatedObject { + if in == nil { + return nil + } + out := new(ClusterFederatedObject) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterFederatedObject) 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 *ClusterFederatedObjectList) DeepCopyInto(out *ClusterFederatedObjectList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterFederatedObject, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterFederatedObjectList. +func (in *ClusterFederatedObjectList) DeepCopy() *ClusterFederatedObjectList { + if in == nil { + return nil + } + out := new(ClusterFederatedObjectList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterFederatedObjectList) 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 *ClusterObjectVersion) DeepCopyInto(out *ClusterObjectVersion) { *out = *in @@ -297,6 +418,45 @@ func (in *ClusterPropagationPolicyList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterReference) DeepCopyInto(out *ClusterReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterReference. +func (in *ClusterReference) DeepCopy() *ClusterReference { + if in == nil { + return nil + } + out := new(ClusterReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterReferenceWithPatches) DeepCopyInto(out *ClusterReferenceWithPatches) { + *out = *in + if in.Patches != nil { + in, out := &in.Patches, &out.Patches + *out = make(OverridePatches, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterReferenceWithPatches. +func (in *ClusterReferenceWithPatches) DeepCopy() *ClusterReferenceWithPatches { + if in == nil { + return nil + } + out := new(ClusterReferenceWithPatches) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterSelectorRequirement) DeepCopyInto(out *ClusterSelectorRequirement) { *out = *in @@ -348,6 +508,100 @@ func (in *ClusterSelectorTerm) DeepCopy() *ClusterSelectorTerm { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CollectedFieldsWithCluster) DeepCopyInto(out *CollectedFieldsWithCluster) { + *out = *in + in.CollectedFields.DeepCopyInto(&out.CollectedFields) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectedFieldsWithCluster. +func (in *CollectedFieldsWithCluster) DeepCopy() *CollectedFieldsWithCluster { + if in == nil { + return nil + } + out := new(CollectedFieldsWithCluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CollectedStatus) DeepCopyInto(out *CollectedStatus) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.GenericCollectedStatus.DeepCopyInto(&out.GenericCollectedStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectedStatus. +func (in *CollectedStatus) DeepCopy() *CollectedStatus { + if in == nil { + return nil + } + out := new(CollectedStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CollectedStatus) 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 *CollectedStatusList) DeepCopyInto(out *CollectedStatusList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CollectedStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectedStatusList. +func (in *CollectedStatusList) DeepCopy() *CollectedStatusList { + if in == nil { + return nil + } + out := new(CollectedStatusList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CollectedStatusList) 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 *DesiredPlacement) DeepCopyInto(out *DesiredPlacement) { + *out = *in + in.Preferences.DeepCopyInto(&out.Preferences) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DesiredPlacement. +func (in *DesiredPlacement) DeepCopy() *DesiredPlacement { + if in == nil { + return nil + } + out := new(DesiredPlacement) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FederatedCluster) DeepCopyInto(out *FederatedCluster) { *out = *in @@ -462,13 +716,73 @@ func (in *FederatedClusterStatus) DeepCopy() *FederatedClusterStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FederatedObject) DeepCopyInto(out *FederatedObject) { + *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 FederatedObject. +func (in *FederatedObject) DeepCopy() *FederatedObject { + if in == nil { + return nil + } + out := new(FederatedObject) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FederatedObject) 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 *FederatedObjectList) DeepCopyInto(out *FederatedObjectList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]FederatedObject, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedObjectList. +func (in *FederatedObjectList) DeepCopy() *FederatedObjectList { + if in == nil { + return nil + } + out := new(FederatedObjectList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FederatedObjectList) 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 *FederatedTypeConfig) DeepCopyInto(out *FederatedTypeConfig) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status return } @@ -526,38 +840,27 @@ func (in *FederatedTypeConfigList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FederatedTypeConfigSpec) DeepCopyInto(out *FederatedTypeConfigSpec) { *out = *in - if in.SourceType != nil { - in, out := &in.SourceType, &out.SourceType - *out = new(APIResource) - **out = **in - } - out.TargetType = in.TargetType - out.FederatedType = in.FederatedType - if in.StatusType != nil { - in, out := &in.StatusType, &out.StatusType - *out = new(APIResource) - **out = **in - } - if in.StatusCollection != nil { - in, out := &in.StatusCollection, &out.StatusCollection - *out = new(StatusCollection) - (*in).DeepCopyInto(*out) - } + out.SourceType = in.SourceType if in.StatusAggregation != nil { in, out := &in.StatusAggregation, &out.StatusAggregation - *out = new(StatusAggregationMode) + *out = new(StatusAggregationConfig) **out = **in } if in.RevisionHistory != nil { in, out := &in.RevisionHistory, &out.RevisionHistory - *out = new(RevisionHistoryMode) + *out = new(RevisionHistoryConfig) **out = **in } if in.RolloutPlan != nil { in, out := &in.RolloutPlan, &out.RolloutPlan - *out = new(RolloutPlanMode) + *out = new(RolloutPlanConfig) **out = **in } + if in.StatusCollection != nil { + in, out := &in.StatusCollection, &out.StatusCollection + *out = new(StatusCollectionConfig) + (*in).DeepCopyInto(*out) + } if in.AutoMigration != nil { in, out := &in.AutoMigration, &out.AutoMigration *out = new(AutoMigrationConfig) @@ -589,17 +892,112 @@ func (in *FederatedTypeConfigSpec) DeepCopy() *FederatedTypeConfigSpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FederatedTypeConfigStatus) DeepCopyInto(out *FederatedTypeConfigStatus) { +func (in *GenericCollectedStatus) DeepCopyInto(out *GenericCollectedStatus) { + *out = *in + if in.Clusters != nil { + in, out := &in.Clusters, &out.Clusters + *out = make([]CollectedFieldsWithCluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericCollectedStatus. +func (in *GenericCollectedStatus) DeepCopy() *GenericCollectedStatus { + if in == nil { + return nil + } + out := new(GenericCollectedStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GenericFederatedObjectCondition) DeepCopyInto(out *GenericFederatedObjectCondition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericFederatedObjectCondition. +func (in *GenericFederatedObjectCondition) DeepCopy() *GenericFederatedObjectCondition { + if in == nil { + return nil + } + out := new(GenericFederatedObjectCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GenericFederatedObjectSpec) DeepCopyInto(out *GenericFederatedObjectSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) + if in.Overrides != nil { + in, out := &in.Overrides, &out.Overrides + *out = make([]OverrideWithController, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Placements != nil { + in, out := &in.Placements, &out.Placements + *out = make([]PlacementWithController, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Follows != nil { + in, out := &in.Follows, &out.Follows + *out = make([]LeaderReference, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericFederatedObjectSpec. +func (in *GenericFederatedObjectSpec) DeepCopy() *GenericFederatedObjectSpec { + if in == nil { + return nil + } + out := new(GenericFederatedObjectSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GenericFederatedObjectStatus) DeepCopyInto(out *GenericFederatedObjectStatus) { *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]GenericFederatedObjectCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Clusters != nil { + in, out := &in.Clusters, &out.Clusters + *out = make([]PropagationStatus, len(*in)) + copy(*out, *in) + } + if in.CollisionCount != nil { + in, out := &in.CollisionCount, &out.CollisionCount + *out = new(int32) + **out = **in + } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedTypeConfigStatus. -func (in *FederatedTypeConfigStatus) DeepCopy() *FederatedTypeConfigStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericFederatedObjectStatus. +func (in *GenericFederatedObjectStatus) DeepCopy() *GenericFederatedObjectStatus { if in == nil { return nil } - out := new(FederatedTypeConfigStatus) + out := new(GenericFederatedObjectStatus) in.DeepCopyInto(out) return out } @@ -665,6 +1063,22 @@ func (in *JsonPatchOverrider) DeepCopy() *JsonPatchOverrider { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LeaderReference) DeepCopyInto(out *LeaderReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LeaderReference. +func (in *LeaderReference) DeepCopy() *LeaderReference { + if in == nil { + return nil + } + out := new(LeaderReference) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LocalSecretReference) DeepCopyInto(out *LocalSecretReference) { *out = *in @@ -681,6 +1095,45 @@ func (in *LocalSecretReference) DeepCopy() *LocalSecretReference { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OverridePatch) DeepCopyInto(out *OverridePatch) { + *out = *in + in.Value.DeepCopyInto(&out.Value) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverridePatch. +func (in *OverridePatch) DeepCopy() *OverridePatch { + if in == nil { + return nil + } + out := new(OverridePatch) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in OverridePatches) DeepCopyInto(out *OverridePatches) { + { + in := &in + *out = make(OverridePatches, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverridePatches. +func (in OverridePatches) DeepCopy() OverridePatches { + if in == nil { + return nil + } + out := new(OverridePatches) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OverridePolicy) DeepCopyInto(out *OverridePolicy) { *out = *in @@ -785,6 +1238,29 @@ func (in *OverrideRule) DeepCopy() *OverrideRule { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OverrideWithController) DeepCopyInto(out *OverrideWithController) { + *out = *in + if in.Override != nil { + in, out := &in.Override, &out.Override + *out = make([]ClusterReferenceWithPatches, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverrideWithController. +func (in *OverrideWithController) DeepCopy() *OverrideWithController { + if in == nil { + return nil + } + out := new(OverrideWithController) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Overriders) DeepCopyInto(out *Overriders) { *out = *in @@ -825,18 +1301,22 @@ func (in *PathDefinition) DeepCopy() *PathDefinition { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Placement) DeepCopyInto(out *Placement) { +func (in *PlacementWithController) DeepCopyInto(out *PlacementWithController) { *out = *in - in.Preferences.DeepCopyInto(&out.Preferences) + if in.Placement != nil { + in, out := &in.Placement, &out.Placement + *out = make([]ClusterReference, len(*in)) + copy(*out, *in) + } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Placement. -func (in *Placement) DeepCopy() *Placement { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlacementWithController. +func (in *PlacementWithController) DeepCopy() *PlacementWithController { if in == nil { return nil } - out := new(Placement) + out := new(PlacementWithController) in.DeepCopyInto(out) return out } @@ -1118,7 +1598,7 @@ func (in *PropagationPolicySpec) DeepCopyInto(out *PropagationPolicySpec) { } if in.Placements != nil { in, out := &in.Placements, &out.Placements - *out = make([]Placement, len(*in)) + *out = make([]DesiredPlacement, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -1163,6 +1643,22 @@ func (in *PropagationPolicyStatus) DeepCopy() *PropagationPolicyStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PropagationStatus) DeepCopyInto(out *PropagationStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PropagationStatus. +func (in *PropagationStatus) DeepCopy() *PropagationStatus { + if in == nil { + return nil + } + out := new(PropagationStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReplicaRescheduling) DeepCopyInto(out *ReplicaRescheduling) { *out = *in @@ -1214,6 +1710,38 @@ func (in *Resources) DeepCopy() *Resources { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionHistoryConfig) DeepCopyInto(out *RevisionHistoryConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionHistoryConfig. +func (in *RevisionHistoryConfig) DeepCopy() *RevisionHistoryConfig { + if in == nil { + return nil + } + out := new(RevisionHistoryConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolloutPlanConfig) DeepCopyInto(out *RolloutPlanConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolloutPlanConfig. +func (in *RolloutPlanConfig) DeepCopy() *RolloutPlanConfig { + if in == nil { + return nil + } + out := new(RolloutPlanConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SchedulerPluginWebhookConfiguration) DeepCopyInto(out *SchedulerPluginWebhookConfiguration) { *out = *in @@ -1390,7 +1918,23 @@ func (in *SchedulingProfileSpec) DeepCopy() *SchedulingProfileSpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StatusCollection) DeepCopyInto(out *StatusCollection) { +func (in *StatusAggregationConfig) DeepCopyInto(out *StatusAggregationConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatusAggregationConfig. +func (in *StatusAggregationConfig) DeepCopy() *StatusAggregationConfig { + if in == nil { + return nil + } + out := new(StatusAggregationConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StatusCollectionConfig) DeepCopyInto(out *StatusCollectionConfig) { *out = *in if in.Fields != nil { in, out := &in.Fields, &out.Fields @@ -1400,12 +1944,12 @@ func (in *StatusCollection) DeepCopyInto(out *StatusCollection) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatusCollection. -func (in *StatusCollection) DeepCopy() *StatusCollection { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatusCollectionConfig. +func (in *StatusCollectionConfig) DeepCopy() *StatusCollectionConfig { if in == nil { return nil } - out := new(StatusCollection) + out := new(StatusCollectionConfig) in.DeepCopyInto(out) return out } diff --git a/pkg/apis/schedulerwebhook/v1alpha1/types.go b/pkg/apis/schedulerwebhook/v1alpha1/types.go index e58013d2..3832313f 100644 --- a/pkg/apis/schedulerwebhook/v1alpha1/types.go +++ b/pkg/apis/schedulerwebhook/v1alpha1/types.go @@ -62,7 +62,7 @@ type SchedulingUnit struct { // MaxClusters is the max clusters set in the PropgationPolicy. MaxClusters *int64 `json:"maxClusters,omitempty"` // Placements is the placements set in the PropgationPolicy. - Placements []fedcorev1a1.Placement `json:"placements,omitempty"` + Placements []fedcorev1a1.DesiredPlacement `json:"placements,omitempty"` } type FilterRequest struct { diff --git a/pkg/apis/types/register.go b/pkg/apis/types/register.go deleted file mode 100644 index a7dcef5b..00000000 --- a/pkg/apis/types/register.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2023 The KubeAdmiral Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package types - -const GroupName = "types.kubeadmiral.io" diff --git a/pkg/apis/types/v1alpha1/doc.go b/pkg/apis/types/v1alpha1/doc.go deleted file mode 100644 index 7398f16f..00000000 --- a/pkg/apis/types/v1alpha1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2023 The KubeAdmiral Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +k8s:deepcopy-gen=package -// +groupName=types.kubeadmiral.io - -package v1alpha1 diff --git a/pkg/apis/types/v1alpha1/extensions_follower.go b/pkg/apis/types/v1alpha1/extensions_follower.go deleted file mode 100644 index 7fb7a832..00000000 --- a/pkg/apis/types/v1alpha1/extensions_follower.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright 2023 The KubeAdmiral Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - - "github.com/kubewharf/kubeadmiral/pkg/controllers/common" -) - -func SetFollows(uns *unstructured.Unstructured, leaders []LeaderReference) error { - leaderMaps := make([]interface{}, 0, len(leaders)) - for _, leader := range leaders { - leaderMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&leader) - if err != nil { - return err - } - leaderMaps = append(leaderMaps, leaderMap) - } - - return unstructured.SetNestedSlice(uns.Object, leaderMaps, common.FollowsPath...) -} - -func (l *LeaderReference) GroupKind() schema.GroupKind { - return schema.GroupKind{ - Group: l.Group, - Kind: l.Kind, - } -} diff --git a/pkg/apis/types/v1alpha1/extensions_placements.go b/pkg/apis/types/v1alpha1/extensions_placements.go deleted file mode 100644 index e5a0ec77..00000000 --- a/pkg/apis/types/v1alpha1/extensions_placements.go +++ /dev/null @@ -1,120 +0,0 @@ -/* -Copyright 2023 The KubeAdmiral Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "reflect" - "sort" -) - -func (object *GenericObjectWithPlacements) ClusterNameUnion() map[string]struct{} { - set := map[string]struct{}{} - for _, placement := range object.Spec.Placements { - for _, cluster := range placement.Placement.Clusters { - set[cluster.Name] = struct{}{} - } - } - - return set -} - -func (spec *GenericSpecWithPlacements) GetPlacementOrNil(controller string) *Placement { - for i := range spec.Placements { - placement := &spec.Placements[i] - if placement.Controller == controller { - return &placement.Placement - } - } - - return nil -} - -func (spec *GenericSpecWithPlacements) GetOrCreatePlacement(controller string) *Placement { - for i := range spec.Placements { - placement := &spec.Placements[i] - if placement.Controller == controller { - return &placement.Placement - } - } - - spec.Placements = append(spec.Placements, PlacementWithController{ - Controller: controller, - }) - return &spec.Placements[len(spec.Placements)-1].Placement -} - -func (spec *GenericSpecWithPlacements) DeletePlacement(controller string) (hasChange bool) { - index := -1 - for i, placement := range spec.Placements { - if placement.Controller == controller { - index = i - break - } - } - - if index == -1 { - return false - } - - spec.Placements = append(spec.Placements[:index], spec.Placements[(index+1):]...) - - return true -} - -func (spec *GenericSpecWithPlacements) SetPlacementNames(controller string, newClusterNames map[string]struct{}) (hasChange bool) { - if len(newClusterNames) == 0 { - return spec.DeletePlacement(controller) - } - - placement := spec.GetOrCreatePlacement(controller) - oldClusterNames := placement.ClusterNames() - - if !reflect.DeepEqual(newClusterNames, oldClusterNames) { - placement.Clusters = nil - - // write the clusters in ascending order for better readability - sortedClusterNames := make([]string, 0, len(newClusterNames)) - for clusterName := range newClusterNames { - sortedClusterNames = append(sortedClusterNames, clusterName) - } - sort.Strings(sortedClusterNames) - for _, name := range sortedClusterNames { - placement.Clusters = append(placement.Clusters, GenericClusterReference{Name: name}) - } - - return true - } - - return false -} - -func (spec *Placement) ClusterNames() map[string]struct{} { - set := map[string]struct{}{} - - for _, cluster := range spec.Clusters { - set[cluster.Name] = struct{}{} - } - - return set -} - -func (spec *Placement) SetClusterNames(names []string) { - spec.Clusters = nil - for _, name := range names { - spec.Clusters = append(spec.Clusters, GenericClusterReference{Name: name}) - } -} diff --git a/pkg/apis/types/v1alpha1/register.go b/pkg/apis/types/v1alpha1/register.go deleted file mode 100644 index 39048c4d..00000000 --- a/pkg/apis/types/v1alpha1/register.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright 2023 The KubeAdmiral Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - - "github.com/kubewharf/kubeadmiral/pkg/apis/types" -) - -// GroupVersion is the identifier for the API which includes -// the name of the group and the version of the API -var SchemeGroupVersion = schema.GroupVersion{ - Group: types.GroupName, - Version: "v1alpha1", -} - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -var ( - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. - SchemeBuilder runtime.SchemeBuilder - localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme -) - -func init() { - // We only register manually written functions here. The registration of the - // generated functions takes place in the generated files. The separation - // makes the code compile even when the generated files are missing. - localSchemeBuilder.Register(addKnownTypes) -} - -// Adds the list of known types to api.Scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &FederatedDeployment{}, - &FederatedDeploymentList{}, - ) - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} diff --git a/pkg/apis/types/v1alpha1/types_federateddeployment.go b/pkg/apis/types/v1alpha1/types_federateddeployment.go deleted file mode 100644 index 63333b42..00000000 --- a/pkg/apis/types/v1alpha1/types_federateddeployment.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2023 The KubeAdmiral Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - appsv1 "k8s.io/api/apps/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +kubebuilder:skip - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// FederatedDeployment is the Schema for the federateddeployments API -type FederatedDeployment struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec FederatedDeploymentSpec `json:"spec,omitempty"` - Status GenericFederatedStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// FederatedDeploymentList contains a list of FederatedDeployment -type FederatedDeploymentList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []FederatedDeployment `json:"items"` -} - -// FederatedDeploymentSpec defines the desired state of FederatedDeployment -type FederatedDeploymentSpec struct { - GenericSpecWithPlacements `json:",inline"` - GenericSpecWithOverrides `json:",inline"` - - Template appsv1.Deployment `json:"template,omitempty"` - - // revisionHistoryLimit is the maximum number of revisions that will - // be maintained in the FederatedDeployment's revision history. The revision history - // consists of all revisions not represented by a currently applied - // FederatedDeploymentSpec version. The default value is 10. - - // +kubebuilder:default:=10 - RevisionHistoryLimit int64 `json:"revisionHistoryLimit,omitempty"` - - RetainReplicas bool `json:"retainReplicas,omitempty"` -} diff --git a/pkg/apis/types/v1alpha1/types_follower.go b/pkg/apis/types/v1alpha1/types_follower.go deleted file mode 100644 index 01fda934..00000000 --- a/pkg/apis/types/v1alpha1/types_follower.go +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright 2023 The KubeAdmiral Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +kubebuilder:skip - -type GenericFederatedFollower struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec GenericFollowerSpec `json:"spec,omitempty"` -} - -type GenericFollowerSpec struct { - GenericSpecWithPlacements `json:",inline"` - GenericSpecWithFollows `json:",inline"` -} - -type GenericSpecWithFollows struct { - Follows []LeaderReference `json:"follows,omitempty"` -} - -type LeaderReference struct { - Group string `json:"group,omitempty"` - Kind string `json:"kind"` - Namespace string `json:"namespace,omitempty"` - Name string `json:"name"` -} diff --git a/pkg/apis/types/v1alpha1/types_overrides.go b/pkg/apis/types/v1alpha1/types_overrides.go deleted file mode 100644 index 4731b2c2..00000000 --- a/pkg/apis/types/v1alpha1/types_overrides.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -This file may have been modified by The KubeAdmiral Authors -("KubeAdmiral Modifications"). All KubeAdmiral Modifications -are Copyright 2023 The KubeAdmiral Authors. -*/ - -package v1alpha1 - -import "github.com/jinzhu/copier" - -// +kubebuilder:skip - -// GenericObjectWithOverrides represents a generic FederatedObject and its overrides field -type GenericObjectWithOverrides struct { - Spec *GenericSpecWithOverrides `json:"spec,omitempty"` -} - -type GenericSpecWithOverrides struct { - Overrides []ControllerOverride `json:"overrides,omitempty"` -} - -type ControllerOverride struct { - Controller string `json:"controller"` - Clusters []ClusterOverride `json:"clusters"` -} - -type ClusterOverride struct { - ClusterName string `json:"clusterName"` - Patches []OverridePatch `json:"paths,omitempty"` -} - -// +k8s:deepcopy-gen=false - -type OverridePatch struct { - Op string `json:"op,omitempty"` - Path string `json:"path"` - Value interface{} `json:"value,omitempty"` -} - -// As controller-gen doesn't support interface member by now(2019-12-13), we hack it. -// ref: https://github.com/kubernetes-sigs/kubebuilder/issues/528 -func (in *OverridePatch) DeepCopyInto(out *OverridePatch) { - copier.Copy(out, in) -} - -type OverridePatches []OverridePatch diff --git a/pkg/apis/types/v1alpha1/types_overrides_test.go b/pkg/apis/types/v1alpha1/types_overrides_test.go deleted file mode 100644 index 9235dad3..00000000 --- a/pkg/apis/types/v1alpha1/types_overrides_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2023 The KubeAdmiral Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestClusterOverride_DeepCopyInto(t *testing.T) { - in := &OverridePatch{ - Op: "foo", - Path: "bar", - Value: []interface{}{1, "foo", "haha"}, - } - - out := new(OverridePatch) - in.DeepCopyInto(out) - - if !assert.Equal(t, in, out) { - t.Fail() - } -} diff --git a/pkg/apis/types/v1alpha1/types_placements.go b/pkg/apis/types/v1alpha1/types_placements.go deleted file mode 100644 index 828ed4be..00000000 --- a/pkg/apis/types/v1alpha1/types_placements.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -This file may have been modified by The KubeAdmiral Authors -("KubeAdmiral Modifications"). All KubeAdmiral Modifications -are Copyright 2023 The KubeAdmiral Authors. -*/ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +kubebuilder:skip - -// GenericObjectWithPlacements represents a generic FederatedObject and its placement field -type GenericObjectWithPlacements struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec GenericSpecWithPlacements `json:"spec,omitempty"` -} - -type GenericSpecWithPlacements struct { - Placements []PlacementWithController `json:"placements,omitempty"` -} - -type PlacementWithController struct { - Controller string `json:"controller"` - Placement Placement `json:"placement"` -} - -type Placement struct { - Clusters []GenericClusterReference `json:"clusters,omitempty"` -} - -type GenericClusterReference struct { - Name string `json:"name"` -} diff --git a/pkg/apis/types/v1alpha1/types_status.go b/pkg/apis/types/v1alpha1/types_status.go deleted file mode 100644 index 7ab123f4..00000000 --- a/pkg/apis/types/v1alpha1/types_status.go +++ /dev/null @@ -1,119 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -This file may have been modified by The KubeAdmiral Authors -("KubeAdmiral Modifications"). All KubeAdmiral Modifications -are Copyright 2023 The KubeAdmiral Authors. -*/ - -package v1alpha1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +kubebuilder:skip - -// GenericObjectWithStatus represents a generic FederatedObject and its status field -type GenericObjectWithStatus struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Status *GenericFederatedStatus `json:"status,omitempty"` -} - -type GenericFederatedStatus struct { - CollisionCount *int32 `json:"collisionCount,omitempty"` - SyncedGeneration int64 `json:"syncedGeneration,omitempty"` - Conditions []*GenericCondition `json:"conditions,omitempty"` - Clusters []GenericClusterStatus `json:"clusters,omitempty"` -} - -type GenericCondition struct { - // Type of cluster condition - Type ConditionType `json:"type"` - // Status of the condition, one of True, False, Unknown. - Status corev1.ConditionStatus `json:"status"` - // Last time reconciliation resulted in an error or the last time a - // change was propagated to member clusters. - // +optional - LastUpdateTime string `json:"lastUpdateTime,omitempty"` - // Last time the condition transit from one status to another. - // +optional - LastTransitionTime string `json:"lastTransitionTime,omitempty"` - // (brief) reason for the condition's last transition. - // +optional - Reason AggregateReason `json:"reason,omitempty"` -} - -type GenericClusterStatus struct { - Name string `json:"name"` - Status PropagationStatus `json:"status,omitempty"` - Generation int64 `json:"generation,omitempty"` -} - -type PropagationStatus string - -const ( - ClusterPropagationOK PropagationStatus = "OK" - WaitingForRemoval PropagationStatus = "WaitingForRemoval" - - // Cluster-specific errors - - ClusterNotReady PropagationStatus = "ClusterNotReady" - ClusterTerminating PropagationStatus = "ClusterTerminating" - CachedRetrievalFailed PropagationStatus = "CachedRetrievalFailed" - ComputeResourceFailed PropagationStatus = "ComputeResourceFailed" - ApplyOverridesFailed PropagationStatus = "ApplyOverridesFailed" - CreationFailed PropagationStatus = "CreationFailed" - UpdateFailed PropagationStatus = "UpdateFailed" - DeletionFailed PropagationStatus = "DeletionFailed" - LabelRemovalFailed PropagationStatus = "LabelRemovalFailed" - RetrievalFailed PropagationStatus = "RetrievalFailed" - AlreadyExists PropagationStatus = "AlreadyExists" - FieldRetentionFailed PropagationStatus = "FieldRetentionFailed" - SetLastReplicasetNameFailed PropagationStatus = "SetLastReplicasetNameFailed" - VersionRetrievalFailed PropagationStatus = "VersionRetrievalFailed" - ClientRetrievalFailed PropagationStatus = "ClientRetrievalFailed" - ManagedLabelFalse PropagationStatus = "ManagedLabelFalse" - FinalizerCheckFailed PropagationStatus = "FinalizerCheckFailed" - - // Operation timeout errors - - CreationTimedOut PropagationStatus = "CreationTimedOut" - UpdateTimedOut PropagationStatus = "UpdateTimedOut" - DeletionTimedOut PropagationStatus = "DeletionTimedOut" - LabelRemovalTimedOut PropagationStatus = "LabelRemovalTimedOut" -) - -type AggregateReason string - -const ( - AggregateSuccess AggregateReason = "" - SyncRevisionsFailed AggregateReason = "SyncRevisionsFailed" - ClusterRetrievalFailed AggregateReason = "ClusterRetrievalFailed" - ComputePlacementFailed AggregateReason = "ComputePlacementFailed" - PlanRolloutFailed AggregateReason = "PlanRolloutFailed" - CheckClusters AggregateReason = "CheckClusters" - NamespaceNotFederated AggregateReason = "NamespaceNotFederated" - EnsureDeletionFailed AggregateReason = "EnsureDeletionFailed" -) - -type ConditionType string - -const ( - PropagationConditionType ConditionType = "Propagation" -) diff --git a/pkg/apis/types/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/types/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index 4ab1d070..00000000 --- a/pkg/apis/types/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,464 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterOverride) DeepCopyInto(out *ClusterOverride) { - *out = *in - if in.Patches != nil { - in, out := &in.Patches, &out.Patches - *out = make([]OverridePatch, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOverride. -func (in *ClusterOverride) DeepCopy() *ClusterOverride { - if in == nil { - return nil - } - out := new(ClusterOverride) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ControllerOverride) DeepCopyInto(out *ControllerOverride) { - *out = *in - if in.Clusters != nil { - in, out := &in.Clusters, &out.Clusters - *out = make([]ClusterOverride, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerOverride. -func (in *ControllerOverride) DeepCopy() *ControllerOverride { - if in == nil { - return nil - } - out := new(ControllerOverride) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FederatedDeployment) DeepCopyInto(out *FederatedDeployment) { - *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 FederatedDeployment. -func (in *FederatedDeployment) DeepCopy() *FederatedDeployment { - if in == nil { - return nil - } - out := new(FederatedDeployment) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FederatedDeployment) 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 *FederatedDeploymentList) DeepCopyInto(out *FederatedDeploymentList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]FederatedDeployment, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedDeploymentList. -func (in *FederatedDeploymentList) DeepCopy() *FederatedDeploymentList { - if in == nil { - return nil - } - out := new(FederatedDeploymentList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FederatedDeploymentList) 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 *FederatedDeploymentSpec) DeepCopyInto(out *FederatedDeploymentSpec) { - *out = *in - in.GenericSpecWithPlacements.DeepCopyInto(&out.GenericSpecWithPlacements) - in.GenericSpecWithOverrides.DeepCopyInto(&out.GenericSpecWithOverrides) - in.Template.DeepCopyInto(&out.Template) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedDeploymentSpec. -func (in *FederatedDeploymentSpec) DeepCopy() *FederatedDeploymentSpec { - if in == nil { - return nil - } - out := new(FederatedDeploymentSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericClusterReference) DeepCopyInto(out *GenericClusterReference) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericClusterReference. -func (in *GenericClusterReference) DeepCopy() *GenericClusterReference { - if in == nil { - return nil - } - out := new(GenericClusterReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericClusterStatus) DeepCopyInto(out *GenericClusterStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericClusterStatus. -func (in *GenericClusterStatus) DeepCopy() *GenericClusterStatus { - if in == nil { - return nil - } - out := new(GenericClusterStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericCondition) DeepCopyInto(out *GenericCondition) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericCondition. -func (in *GenericCondition) DeepCopy() *GenericCondition { - if in == nil { - return nil - } - out := new(GenericCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericFederatedFollower) DeepCopyInto(out *GenericFederatedFollower) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericFederatedFollower. -func (in *GenericFederatedFollower) DeepCopy() *GenericFederatedFollower { - if in == nil { - return nil - } - out := new(GenericFederatedFollower) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericFederatedStatus) DeepCopyInto(out *GenericFederatedStatus) { - *out = *in - if in.CollisionCount != nil { - in, out := &in.CollisionCount, &out.CollisionCount - *out = new(int32) - **out = **in - } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]*GenericCondition, len(*in)) - for i := range *in { - if (*in)[i] != nil { - in, out := &(*in)[i], &(*out)[i] - *out = new(GenericCondition) - **out = **in - } - } - } - if in.Clusters != nil { - in, out := &in.Clusters, &out.Clusters - *out = make([]GenericClusterStatus, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericFederatedStatus. -func (in *GenericFederatedStatus) DeepCopy() *GenericFederatedStatus { - if in == nil { - return nil - } - out := new(GenericFederatedStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericFollowerSpec) DeepCopyInto(out *GenericFollowerSpec) { - *out = *in - in.GenericSpecWithPlacements.DeepCopyInto(&out.GenericSpecWithPlacements) - in.GenericSpecWithFollows.DeepCopyInto(&out.GenericSpecWithFollows) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericFollowerSpec. -func (in *GenericFollowerSpec) DeepCopy() *GenericFollowerSpec { - if in == nil { - return nil - } - out := new(GenericFollowerSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericObjectWithOverrides) DeepCopyInto(out *GenericObjectWithOverrides) { - *out = *in - if in.Spec != nil { - in, out := &in.Spec, &out.Spec - *out = new(GenericSpecWithOverrides) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericObjectWithOverrides. -func (in *GenericObjectWithOverrides) DeepCopy() *GenericObjectWithOverrides { - if in == nil { - return nil - } - out := new(GenericObjectWithOverrides) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericObjectWithPlacements) DeepCopyInto(out *GenericObjectWithPlacements) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericObjectWithPlacements. -func (in *GenericObjectWithPlacements) DeepCopy() *GenericObjectWithPlacements { - if in == nil { - return nil - } - out := new(GenericObjectWithPlacements) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericObjectWithStatus) DeepCopyInto(out *GenericObjectWithStatus) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - if in.Status != nil { - in, out := &in.Status, &out.Status - *out = new(GenericFederatedStatus) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericObjectWithStatus. -func (in *GenericObjectWithStatus) DeepCopy() *GenericObjectWithStatus { - if in == nil { - return nil - } - out := new(GenericObjectWithStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericSpecWithFollows) DeepCopyInto(out *GenericSpecWithFollows) { - *out = *in - if in.Follows != nil { - in, out := &in.Follows, &out.Follows - *out = make([]LeaderReference, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericSpecWithFollows. -func (in *GenericSpecWithFollows) DeepCopy() *GenericSpecWithFollows { - if in == nil { - return nil - } - out := new(GenericSpecWithFollows) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericSpecWithOverrides) DeepCopyInto(out *GenericSpecWithOverrides) { - *out = *in - if in.Overrides != nil { - in, out := &in.Overrides, &out.Overrides - *out = make([]ControllerOverride, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericSpecWithOverrides. -func (in *GenericSpecWithOverrides) DeepCopy() *GenericSpecWithOverrides { - if in == nil { - return nil - } - out := new(GenericSpecWithOverrides) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GenericSpecWithPlacements) DeepCopyInto(out *GenericSpecWithPlacements) { - *out = *in - if in.Placements != nil { - in, out := &in.Placements, &out.Placements - *out = make([]PlacementWithController, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericSpecWithPlacements. -func (in *GenericSpecWithPlacements) DeepCopy() *GenericSpecWithPlacements { - if in == nil { - return nil - } - out := new(GenericSpecWithPlacements) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LeaderReference) DeepCopyInto(out *LeaderReference) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LeaderReference. -func (in *LeaderReference) DeepCopy() *LeaderReference { - if in == nil { - return nil - } - out := new(LeaderReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in OverridePatches) DeepCopyInto(out *OverridePatches) { - { - in := &in - *out = make(OverridePatches, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - return - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverridePatches. -func (in OverridePatches) DeepCopy() OverridePatches { - if in == nil { - return nil - } - out := new(OverridePatches) - in.DeepCopyInto(out) - return *out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Placement) DeepCopyInto(out *Placement) { - *out = *in - if in.Clusters != nil { - in, out := &in.Clusters, &out.Clusters - *out = make([]GenericClusterReference, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Placement. -func (in *Placement) DeepCopy() *Placement { - if in == nil { - return nil - } - out := new(Placement) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PlacementWithController) DeepCopyInto(out *PlacementWithController) { - *out = *in - in.Placement.DeepCopyInto(&out.Placement) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlacementWithController. -func (in *PlacementWithController) DeepCopy() *PlacementWithController { - if in == nil { - return nil - } - out := new(PlacementWithController) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index fcbfb1d8..a412bed1 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -6,7 +6,6 @@ import ( "fmt" corev1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/typed/core/v1alpha1" - typesv1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/typed/types/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -15,15 +14,13 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface - TypesV1alpha1() typesv1alpha1.TypesV1alpha1Interface } // Clientset contains the clients for groups. Each group has exactly one // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - coreV1alpha1 *corev1alpha1.CoreV1alpha1Client - typesV1alpha1 *typesv1alpha1.TypesV1alpha1Client + coreV1alpha1 *corev1alpha1.CoreV1alpha1Client } // CoreV1alpha1 retrieves the CoreV1alpha1Client @@ -31,11 +28,6 @@ func (c *Clientset) CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface { return c.coreV1alpha1 } -// TypesV1alpha1 retrieves the TypesV1alpha1Client -func (c *Clientset) TypesV1alpha1() typesv1alpha1.TypesV1alpha1Interface { - return c.typesV1alpha1 -} - // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -61,10 +53,6 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } - cs.typesV1alpha1, err = typesv1alpha1.NewForConfig(&configShallowCopy) - if err != nil { - return nil, err - } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -78,7 +66,6 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.coreV1alpha1 = corev1alpha1.NewForConfigOrDie(c) - cs.typesV1alpha1 = typesv1alpha1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -88,7 +75,6 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.coreV1alpha1 = corev1alpha1.New(c) - cs.typesV1alpha1 = typesv1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 2bc5d5c6..acfa6e6d 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -6,8 +6,6 @@ import ( clientset "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned" corev1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/typed/core/v1alpha1" fakecorev1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/typed/core/v1alpha1/fake" - typesv1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/typed/types/v1alpha1" - faketypesv1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/typed/types/v1alpha1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -66,8 +64,3 @@ var _ clientset.Interface = &Clientset{} func (c *Clientset) CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface { return &fakecorev1alpha1.FakeCoreV1alpha1{Fake: &c.Fake} } - -// TypesV1alpha1 retrieves the TypesV1alpha1Client -func (c *Clientset) TypesV1alpha1() typesv1alpha1.TypesV1alpha1Interface { - return &faketypesv1alpha1.FakeTypesV1alpha1{Fake: &c.Fake} -} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 6b917261..61d39e93 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -4,7 +4,6 @@ package fake import ( corev1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" - typesv1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/types/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -17,7 +16,6 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ corev1alpha1.AddToScheme, - typesv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index debbc83b..270ba800 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -4,7 +4,6 @@ package scheme import ( corev1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" - typesv1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/types/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -17,7 +16,6 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ corev1alpha1.AddToScheme, - typesv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/clustercollectedstatus.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/clustercollectedstatus.go new file mode 100644 index 00000000..debfbbcf --- /dev/null +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/clustercollectedstatus.go @@ -0,0 +1,152 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + scheme "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ClusterCollectedStatusesGetter has a method to return a ClusterCollectedStatusInterface. +// A group's client should implement this interface. +type ClusterCollectedStatusesGetter interface { + ClusterCollectedStatuses() ClusterCollectedStatusInterface +} + +// ClusterCollectedStatusInterface has methods to work with ClusterCollectedStatus resources. +type ClusterCollectedStatusInterface interface { + Create(ctx context.Context, clusterCollectedStatus *v1alpha1.ClusterCollectedStatus, opts v1.CreateOptions) (*v1alpha1.ClusterCollectedStatus, error) + Update(ctx context.Context, clusterCollectedStatus *v1alpha1.ClusterCollectedStatus, opts v1.UpdateOptions) (*v1alpha1.ClusterCollectedStatus, 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) (*v1alpha1.ClusterCollectedStatus, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterCollectedStatusList, 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 *v1alpha1.ClusterCollectedStatus, err error) + ClusterCollectedStatusExpansion +} + +// clusterCollectedStatuses implements ClusterCollectedStatusInterface +type clusterCollectedStatuses struct { + client rest.Interface +} + +// newClusterCollectedStatuses returns a ClusterCollectedStatuses +func newClusterCollectedStatuses(c *CoreV1alpha1Client) *clusterCollectedStatuses { + return &clusterCollectedStatuses{ + client: c.RESTClient(), + } +} + +// Get takes name of the clusterCollectedStatus, and returns the corresponding clusterCollectedStatus object, and an error if there is any. +func (c *clusterCollectedStatuses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterCollectedStatus, err error) { + result = &v1alpha1.ClusterCollectedStatus{} + err = c.client.Get(). + Resource("clustercollectedstatuses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterCollectedStatuses that match those selectors. +func (c *clusterCollectedStatuses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterCollectedStatusList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ClusterCollectedStatusList{} + err = c.client.Get(). + Resource("clustercollectedstatuses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterCollectedStatuses. +func (c *clusterCollectedStatuses) 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("clustercollectedstatuses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a clusterCollectedStatus and creates it. Returns the server's representation of the clusterCollectedStatus, and an error, if there is any. +func (c *clusterCollectedStatuses) Create(ctx context.Context, clusterCollectedStatus *v1alpha1.ClusterCollectedStatus, opts v1.CreateOptions) (result *v1alpha1.ClusterCollectedStatus, err error) { + result = &v1alpha1.ClusterCollectedStatus{} + err = c.client.Post(). + Resource("clustercollectedstatuses"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterCollectedStatus). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a clusterCollectedStatus and updates it. Returns the server's representation of the clusterCollectedStatus, and an error, if there is any. +func (c *clusterCollectedStatuses) Update(ctx context.Context, clusterCollectedStatus *v1alpha1.ClusterCollectedStatus, opts v1.UpdateOptions) (result *v1alpha1.ClusterCollectedStatus, err error) { + result = &v1alpha1.ClusterCollectedStatus{} + err = c.client.Put(). + Resource("clustercollectedstatuses"). + Name(clusterCollectedStatus.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterCollectedStatus). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the clusterCollectedStatus and deletes it. Returns an error if one occurs. +func (c *clusterCollectedStatuses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("clustercollectedstatuses"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterCollectedStatuses) 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("clustercollectedstatuses"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched clusterCollectedStatus. +func (c *clusterCollectedStatuses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterCollectedStatus, err error) { + result = &v1alpha1.ClusterCollectedStatus{} + err = c.client.Patch(pt). + Resource("clustercollectedstatuses"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/clusterfederatedobject.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/clusterfederatedobject.go new file mode 100644 index 00000000..f6d60848 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/clusterfederatedobject.go @@ -0,0 +1,168 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + scheme "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ClusterFederatedObjectsGetter has a method to return a ClusterFederatedObjectInterface. +// A group's client should implement this interface. +type ClusterFederatedObjectsGetter interface { + ClusterFederatedObjects() ClusterFederatedObjectInterface +} + +// ClusterFederatedObjectInterface has methods to work with ClusterFederatedObject resources. +type ClusterFederatedObjectInterface interface { + Create(ctx context.Context, clusterFederatedObject *v1alpha1.ClusterFederatedObject, opts v1.CreateOptions) (*v1alpha1.ClusterFederatedObject, error) + Update(ctx context.Context, clusterFederatedObject *v1alpha1.ClusterFederatedObject, opts v1.UpdateOptions) (*v1alpha1.ClusterFederatedObject, error) + UpdateStatus(ctx context.Context, clusterFederatedObject *v1alpha1.ClusterFederatedObject, opts v1.UpdateOptions) (*v1alpha1.ClusterFederatedObject, 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) (*v1alpha1.ClusterFederatedObject, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterFederatedObjectList, 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 *v1alpha1.ClusterFederatedObject, err error) + ClusterFederatedObjectExpansion +} + +// clusterFederatedObjects implements ClusterFederatedObjectInterface +type clusterFederatedObjects struct { + client rest.Interface +} + +// newClusterFederatedObjects returns a ClusterFederatedObjects +func newClusterFederatedObjects(c *CoreV1alpha1Client) *clusterFederatedObjects { + return &clusterFederatedObjects{ + client: c.RESTClient(), + } +} + +// Get takes name of the clusterFederatedObject, and returns the corresponding clusterFederatedObject object, and an error if there is any. +func (c *clusterFederatedObjects) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterFederatedObject, err error) { + result = &v1alpha1.ClusterFederatedObject{} + err = c.client.Get(). + Resource("clusterfederatedobjects"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterFederatedObjects that match those selectors. +func (c *clusterFederatedObjects) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterFederatedObjectList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ClusterFederatedObjectList{} + err = c.client.Get(). + Resource("clusterfederatedobjects"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterFederatedObjects. +func (c *clusterFederatedObjects) 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("clusterfederatedobjects"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a clusterFederatedObject and creates it. Returns the server's representation of the clusterFederatedObject, and an error, if there is any. +func (c *clusterFederatedObjects) Create(ctx context.Context, clusterFederatedObject *v1alpha1.ClusterFederatedObject, opts v1.CreateOptions) (result *v1alpha1.ClusterFederatedObject, err error) { + result = &v1alpha1.ClusterFederatedObject{} + err = c.client.Post(). + Resource("clusterfederatedobjects"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterFederatedObject). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a clusterFederatedObject and updates it. Returns the server's representation of the clusterFederatedObject, and an error, if there is any. +func (c *clusterFederatedObjects) Update(ctx context.Context, clusterFederatedObject *v1alpha1.ClusterFederatedObject, opts v1.UpdateOptions) (result *v1alpha1.ClusterFederatedObject, err error) { + result = &v1alpha1.ClusterFederatedObject{} + err = c.client.Put(). + Resource("clusterfederatedobjects"). + Name(clusterFederatedObject.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterFederatedObject). + 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 *clusterFederatedObjects) UpdateStatus(ctx context.Context, clusterFederatedObject *v1alpha1.ClusterFederatedObject, opts v1.UpdateOptions) (result *v1alpha1.ClusterFederatedObject, err error) { + result = &v1alpha1.ClusterFederatedObject{} + err = c.client.Put(). + Resource("clusterfederatedobjects"). + Name(clusterFederatedObject.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterFederatedObject). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the clusterFederatedObject and deletes it. Returns an error if one occurs. +func (c *clusterFederatedObjects) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("clusterfederatedobjects"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterFederatedObjects) 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("clusterfederatedobjects"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched clusterFederatedObject. +func (c *clusterFederatedObjects) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterFederatedObject, err error) { + result = &v1alpha1.ClusterFederatedObject{} + err = c.client.Patch(pt). + Resource("clusterfederatedobjects"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/collectedstatus.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/collectedstatus.go new file mode 100644 index 00000000..8dc06495 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/collectedstatus.go @@ -0,0 +1,162 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + scheme "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// CollectedStatusesGetter has a method to return a CollectedStatusInterface. +// A group's client should implement this interface. +type CollectedStatusesGetter interface { + CollectedStatuses(namespace string) CollectedStatusInterface +} + +// CollectedStatusInterface has methods to work with CollectedStatus resources. +type CollectedStatusInterface interface { + Create(ctx context.Context, collectedStatus *v1alpha1.CollectedStatus, opts v1.CreateOptions) (*v1alpha1.CollectedStatus, error) + Update(ctx context.Context, collectedStatus *v1alpha1.CollectedStatus, opts v1.UpdateOptions) (*v1alpha1.CollectedStatus, 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) (*v1alpha1.CollectedStatus, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.CollectedStatusList, 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 *v1alpha1.CollectedStatus, err error) + CollectedStatusExpansion +} + +// collectedStatuses implements CollectedStatusInterface +type collectedStatuses struct { + client rest.Interface + ns string +} + +// newCollectedStatuses returns a CollectedStatuses +func newCollectedStatuses(c *CoreV1alpha1Client, namespace string) *collectedStatuses { + return &collectedStatuses{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the collectedStatus, and returns the corresponding collectedStatus object, and an error if there is any. +func (c *collectedStatuses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CollectedStatus, err error) { + result = &v1alpha1.CollectedStatus{} + err = c.client.Get(). + Namespace(c.ns). + Resource("collectedstatuses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of CollectedStatuses that match those selectors. +func (c *collectedStatuses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.CollectedStatusList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.CollectedStatusList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("collectedstatuses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested collectedStatuses. +func (c *collectedStatuses) 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("collectedstatuses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a collectedStatus and creates it. Returns the server's representation of the collectedStatus, and an error, if there is any. +func (c *collectedStatuses) Create(ctx context.Context, collectedStatus *v1alpha1.CollectedStatus, opts v1.CreateOptions) (result *v1alpha1.CollectedStatus, err error) { + result = &v1alpha1.CollectedStatus{} + err = c.client.Post(). + Namespace(c.ns). + Resource("collectedstatuses"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(collectedStatus). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a collectedStatus and updates it. Returns the server's representation of the collectedStatus, and an error, if there is any. +func (c *collectedStatuses) Update(ctx context.Context, collectedStatus *v1alpha1.CollectedStatus, opts v1.UpdateOptions) (result *v1alpha1.CollectedStatus, err error) { + result = &v1alpha1.CollectedStatus{} + err = c.client.Put(). + Namespace(c.ns). + Resource("collectedstatuses"). + Name(collectedStatus.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(collectedStatus). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the collectedStatus and deletes it. Returns an error if one occurs. +func (c *collectedStatuses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("collectedstatuses"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *collectedStatuses) 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("collectedstatuses"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched collectedStatus. +func (c *collectedStatuses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.CollectedStatus, err error) { + result = &v1alpha1.CollectedStatus{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("collectedstatuses"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/core_client.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/core_client.go index d3554ac8..798e756f 100644 --- a/pkg/client/clientset/versioned/typed/core/v1alpha1/core_client.go +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/core_client.go @@ -10,10 +10,14 @@ import ( type CoreV1alpha1Interface interface { RESTClient() rest.Interface + ClusterCollectedStatusesGetter + ClusterFederatedObjectsGetter ClusterOverridePoliciesGetter ClusterPropagatedVersionsGetter ClusterPropagationPoliciesGetter + CollectedStatusesGetter FederatedClustersGetter + FederatedObjectsGetter FederatedTypeConfigsGetter OverridePoliciesGetter PropagatedVersionsGetter @@ -27,6 +31,14 @@ type CoreV1alpha1Client struct { restClient rest.Interface } +func (c *CoreV1alpha1Client) ClusterCollectedStatuses() ClusterCollectedStatusInterface { + return newClusterCollectedStatuses(c) +} + +func (c *CoreV1alpha1Client) ClusterFederatedObjects() ClusterFederatedObjectInterface { + return newClusterFederatedObjects(c) +} + func (c *CoreV1alpha1Client) ClusterOverridePolicies() ClusterOverridePolicyInterface { return newClusterOverridePolicies(c) } @@ -39,10 +51,18 @@ func (c *CoreV1alpha1Client) ClusterPropagationPolicies() ClusterPropagationPoli return newClusterPropagationPolicies(c) } +func (c *CoreV1alpha1Client) CollectedStatuses(namespace string) CollectedStatusInterface { + return newCollectedStatuses(c, namespace) +} + func (c *CoreV1alpha1Client) FederatedClusters() FederatedClusterInterface { return newFederatedClusters(c) } +func (c *CoreV1alpha1Client) FederatedObjects(namespace string) FederatedObjectInterface { + return newFederatedObjects(c, namespace) +} + func (c *CoreV1alpha1Client) FederatedTypeConfigs() FederatedTypeConfigInterface { return newFederatedTypeConfigs(c) } diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_clustercollectedstatus.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_clustercollectedstatus.go new file mode 100644 index 00000000..25043d39 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_clustercollectedstatus.go @@ -0,0 +1,106 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeClusterCollectedStatuses implements ClusterCollectedStatusInterface +type FakeClusterCollectedStatuses struct { + Fake *FakeCoreV1alpha1 +} + +var clustercollectedstatusesResource = schema.GroupVersionResource{Group: "core.kubeadmiral.io", Version: "v1alpha1", Resource: "clustercollectedstatuses"} + +var clustercollectedstatusesKind = schema.GroupVersionKind{Group: "core.kubeadmiral.io", Version: "v1alpha1", Kind: "ClusterCollectedStatus"} + +// Get takes name of the clusterCollectedStatus, and returns the corresponding clusterCollectedStatus object, and an error if there is any. +func (c *FakeClusterCollectedStatuses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterCollectedStatus, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(clustercollectedstatusesResource, name), &v1alpha1.ClusterCollectedStatus{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterCollectedStatus), err +} + +// List takes label and field selectors, and returns the list of ClusterCollectedStatuses that match those selectors. +func (c *FakeClusterCollectedStatuses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterCollectedStatusList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(clustercollectedstatusesResource, clustercollectedstatusesKind, opts), &v1alpha1.ClusterCollectedStatusList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ClusterCollectedStatusList{ListMeta: obj.(*v1alpha1.ClusterCollectedStatusList).ListMeta} + for _, item := range obj.(*v1alpha1.ClusterCollectedStatusList).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 clusterCollectedStatuses. +func (c *FakeClusterCollectedStatuses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(clustercollectedstatusesResource, opts)) +} + +// Create takes the representation of a clusterCollectedStatus and creates it. Returns the server's representation of the clusterCollectedStatus, and an error, if there is any. +func (c *FakeClusterCollectedStatuses) Create(ctx context.Context, clusterCollectedStatus *v1alpha1.ClusterCollectedStatus, opts v1.CreateOptions) (result *v1alpha1.ClusterCollectedStatus, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(clustercollectedstatusesResource, clusterCollectedStatus), &v1alpha1.ClusterCollectedStatus{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterCollectedStatus), err +} + +// Update takes the representation of a clusterCollectedStatus and updates it. Returns the server's representation of the clusterCollectedStatus, and an error, if there is any. +func (c *FakeClusterCollectedStatuses) Update(ctx context.Context, clusterCollectedStatus *v1alpha1.ClusterCollectedStatus, opts v1.UpdateOptions) (result *v1alpha1.ClusterCollectedStatus, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(clustercollectedstatusesResource, clusterCollectedStatus), &v1alpha1.ClusterCollectedStatus{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterCollectedStatus), err +} + +// Delete takes name of the clusterCollectedStatus and deletes it. Returns an error if one occurs. +func (c *FakeClusterCollectedStatuses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(clustercollectedstatusesResource, name), &v1alpha1.ClusterCollectedStatus{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterCollectedStatuses) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(clustercollectedstatusesResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ClusterCollectedStatusList{}) + return err +} + +// Patch applies the patch and returns the patched clusterCollectedStatus. +func (c *FakeClusterCollectedStatuses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterCollectedStatus, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(clustercollectedstatusesResource, name, pt, data, subresources...), &v1alpha1.ClusterCollectedStatus{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterCollectedStatus), err +} diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_clusterfederatedobject.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_clusterfederatedobject.go new file mode 100644 index 00000000..32101b81 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_clusterfederatedobject.go @@ -0,0 +1,117 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeClusterFederatedObjects implements ClusterFederatedObjectInterface +type FakeClusterFederatedObjects struct { + Fake *FakeCoreV1alpha1 +} + +var clusterfederatedobjectsResource = schema.GroupVersionResource{Group: "core.kubeadmiral.io", Version: "v1alpha1", Resource: "clusterfederatedobjects"} + +var clusterfederatedobjectsKind = schema.GroupVersionKind{Group: "core.kubeadmiral.io", Version: "v1alpha1", Kind: "ClusterFederatedObject"} + +// Get takes name of the clusterFederatedObject, and returns the corresponding clusterFederatedObject object, and an error if there is any. +func (c *FakeClusterFederatedObjects) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterFederatedObject, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(clusterfederatedobjectsResource, name), &v1alpha1.ClusterFederatedObject{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterFederatedObject), err +} + +// List takes label and field selectors, and returns the list of ClusterFederatedObjects that match those selectors. +func (c *FakeClusterFederatedObjects) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterFederatedObjectList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(clusterfederatedobjectsResource, clusterfederatedobjectsKind, opts), &v1alpha1.ClusterFederatedObjectList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ClusterFederatedObjectList{ListMeta: obj.(*v1alpha1.ClusterFederatedObjectList).ListMeta} + for _, item := range obj.(*v1alpha1.ClusterFederatedObjectList).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 clusterFederatedObjects. +func (c *FakeClusterFederatedObjects) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(clusterfederatedobjectsResource, opts)) +} + +// Create takes the representation of a clusterFederatedObject and creates it. Returns the server's representation of the clusterFederatedObject, and an error, if there is any. +func (c *FakeClusterFederatedObjects) Create(ctx context.Context, clusterFederatedObject *v1alpha1.ClusterFederatedObject, opts v1.CreateOptions) (result *v1alpha1.ClusterFederatedObject, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(clusterfederatedobjectsResource, clusterFederatedObject), &v1alpha1.ClusterFederatedObject{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterFederatedObject), err +} + +// Update takes the representation of a clusterFederatedObject and updates it. Returns the server's representation of the clusterFederatedObject, and an error, if there is any. +func (c *FakeClusterFederatedObjects) Update(ctx context.Context, clusterFederatedObject *v1alpha1.ClusterFederatedObject, opts v1.UpdateOptions) (result *v1alpha1.ClusterFederatedObject, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(clusterfederatedobjectsResource, clusterFederatedObject), &v1alpha1.ClusterFederatedObject{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterFederatedObject), 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 *FakeClusterFederatedObjects) UpdateStatus(ctx context.Context, clusterFederatedObject *v1alpha1.ClusterFederatedObject, opts v1.UpdateOptions) (*v1alpha1.ClusterFederatedObject, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(clusterfederatedobjectsResource, "status", clusterFederatedObject), &v1alpha1.ClusterFederatedObject{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterFederatedObject), err +} + +// Delete takes name of the clusterFederatedObject and deletes it. Returns an error if one occurs. +func (c *FakeClusterFederatedObjects) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(clusterfederatedobjectsResource, name), &v1alpha1.ClusterFederatedObject{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterFederatedObjects) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(clusterfederatedobjectsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ClusterFederatedObjectList{}) + return err +} + +// Patch applies the patch and returns the patched clusterFederatedObject. +func (c *FakeClusterFederatedObjects) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterFederatedObject, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(clusterfederatedobjectsResource, name, pt, data, subresources...), &v1alpha1.ClusterFederatedObject{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterFederatedObject), err +} diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_collectedstatus.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_collectedstatus.go new file mode 100644 index 00000000..18833904 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_collectedstatus.go @@ -0,0 +1,114 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeCollectedStatuses implements CollectedStatusInterface +type FakeCollectedStatuses struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var collectedstatusesResource = schema.GroupVersionResource{Group: "core.kubeadmiral.io", Version: "v1alpha1", Resource: "collectedstatuses"} + +var collectedstatusesKind = schema.GroupVersionKind{Group: "core.kubeadmiral.io", Version: "v1alpha1", Kind: "CollectedStatus"} + +// Get takes name of the collectedStatus, and returns the corresponding collectedStatus object, and an error if there is any. +func (c *FakeCollectedStatuses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CollectedStatus, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(collectedstatusesResource, c.ns, name), &v1alpha1.CollectedStatus{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CollectedStatus), err +} + +// List takes label and field selectors, and returns the list of CollectedStatuses that match those selectors. +func (c *FakeCollectedStatuses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.CollectedStatusList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(collectedstatusesResource, collectedstatusesKind, c.ns, opts), &v1alpha1.CollectedStatusList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.CollectedStatusList{ListMeta: obj.(*v1alpha1.CollectedStatusList).ListMeta} + for _, item := range obj.(*v1alpha1.CollectedStatusList).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 collectedStatuses. +func (c *FakeCollectedStatuses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(collectedstatusesResource, c.ns, opts)) + +} + +// Create takes the representation of a collectedStatus and creates it. Returns the server's representation of the collectedStatus, and an error, if there is any. +func (c *FakeCollectedStatuses) Create(ctx context.Context, collectedStatus *v1alpha1.CollectedStatus, opts v1.CreateOptions) (result *v1alpha1.CollectedStatus, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(collectedstatusesResource, c.ns, collectedStatus), &v1alpha1.CollectedStatus{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CollectedStatus), err +} + +// Update takes the representation of a collectedStatus and updates it. Returns the server's representation of the collectedStatus, and an error, if there is any. +func (c *FakeCollectedStatuses) Update(ctx context.Context, collectedStatus *v1alpha1.CollectedStatus, opts v1.UpdateOptions) (result *v1alpha1.CollectedStatus, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(collectedstatusesResource, c.ns, collectedStatus), &v1alpha1.CollectedStatus{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CollectedStatus), err +} + +// Delete takes name of the collectedStatus and deletes it. Returns an error if one occurs. +func (c *FakeCollectedStatuses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(collectedstatusesResource, c.ns, name), &v1alpha1.CollectedStatus{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCollectedStatuses) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(collectedstatusesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.CollectedStatusList{}) + return err +} + +// Patch applies the patch and returns the patched collectedStatus. +func (c *FakeCollectedStatuses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.CollectedStatus, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(collectedstatusesResource, c.ns, name, pt, data, subresources...), &v1alpha1.CollectedStatus{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CollectedStatus), err +} diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go index 3bc3329e..751322e8 100644 --- a/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_core_client.go @@ -12,6 +12,14 @@ type FakeCoreV1alpha1 struct { *testing.Fake } +func (c *FakeCoreV1alpha1) ClusterCollectedStatuses() v1alpha1.ClusterCollectedStatusInterface { + return &FakeClusterCollectedStatuses{c} +} + +func (c *FakeCoreV1alpha1) ClusterFederatedObjects() v1alpha1.ClusterFederatedObjectInterface { + return &FakeClusterFederatedObjects{c} +} + func (c *FakeCoreV1alpha1) ClusterOverridePolicies() v1alpha1.ClusterOverridePolicyInterface { return &FakeClusterOverridePolicies{c} } @@ -24,10 +32,18 @@ func (c *FakeCoreV1alpha1) ClusterPropagationPolicies() v1alpha1.ClusterPropagat return &FakeClusterPropagationPolicies{c} } +func (c *FakeCoreV1alpha1) CollectedStatuses(namespace string) v1alpha1.CollectedStatusInterface { + return &FakeCollectedStatuses{c, namespace} +} + func (c *FakeCoreV1alpha1) FederatedClusters() v1alpha1.FederatedClusterInterface { return &FakeFederatedClusters{c} } +func (c *FakeCoreV1alpha1) FederatedObjects(namespace string) v1alpha1.FederatedObjectInterface { + return &FakeFederatedObjects{c, namespace} +} + func (c *FakeCoreV1alpha1) FederatedTypeConfigs() v1alpha1.FederatedTypeConfigInterface { return &FakeFederatedTypeConfigs{c} } diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_federatedobject.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_federatedobject.go new file mode 100644 index 00000000..a05fcf61 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_federatedobject.go @@ -0,0 +1,126 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeFederatedObjects implements FederatedObjectInterface +type FakeFederatedObjects struct { + Fake *FakeCoreV1alpha1 + ns string +} + +var federatedobjectsResource = schema.GroupVersionResource{Group: "core.kubeadmiral.io", Version: "v1alpha1", Resource: "federatedobjects"} + +var federatedobjectsKind = schema.GroupVersionKind{Group: "core.kubeadmiral.io", Version: "v1alpha1", Kind: "FederatedObject"} + +// Get takes name of the federatedObject, and returns the corresponding federatedObject object, and an error if there is any. +func (c *FakeFederatedObjects) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.FederatedObject, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(federatedobjectsResource, c.ns, name), &v1alpha1.FederatedObject{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FederatedObject), err +} + +// List takes label and field selectors, and returns the list of FederatedObjects that match those selectors. +func (c *FakeFederatedObjects) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FederatedObjectList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(federatedobjectsResource, federatedobjectsKind, c.ns, opts), &v1alpha1.FederatedObjectList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.FederatedObjectList{ListMeta: obj.(*v1alpha1.FederatedObjectList).ListMeta} + for _, item := range obj.(*v1alpha1.FederatedObjectList).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 federatedObjects. +func (c *FakeFederatedObjects) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(federatedobjectsResource, c.ns, opts)) + +} + +// Create takes the representation of a federatedObject and creates it. Returns the server's representation of the federatedObject, and an error, if there is any. +func (c *FakeFederatedObjects) Create(ctx context.Context, federatedObject *v1alpha1.FederatedObject, opts v1.CreateOptions) (result *v1alpha1.FederatedObject, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(federatedobjectsResource, c.ns, federatedObject), &v1alpha1.FederatedObject{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FederatedObject), err +} + +// Update takes the representation of a federatedObject and updates it. Returns the server's representation of the federatedObject, and an error, if there is any. +func (c *FakeFederatedObjects) Update(ctx context.Context, federatedObject *v1alpha1.FederatedObject, opts v1.UpdateOptions) (result *v1alpha1.FederatedObject, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(federatedobjectsResource, c.ns, federatedObject), &v1alpha1.FederatedObject{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FederatedObject), 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 *FakeFederatedObjects) UpdateStatus(ctx context.Context, federatedObject *v1alpha1.FederatedObject, opts v1.UpdateOptions) (*v1alpha1.FederatedObject, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(federatedobjectsResource, "status", c.ns, federatedObject), &v1alpha1.FederatedObject{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FederatedObject), err +} + +// Delete takes name of the federatedObject and deletes it. Returns an error if one occurs. +func (c *FakeFederatedObjects) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(federatedobjectsResource, c.ns, name), &v1alpha1.FederatedObject{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeFederatedObjects) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(federatedobjectsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.FederatedObjectList{}) + return err +} + +// Patch applies the patch and returns the patched federatedObject. +func (c *FakeFederatedObjects) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.FederatedObject, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(federatedobjectsResource, c.ns, name, pt, data, subresources...), &v1alpha1.FederatedObject{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.FederatedObject), err +} diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_federatedtypeconfig.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_federatedtypeconfig.go index 69b2d6dd..03d0de02 100644 --- a/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_federatedtypeconfig.go +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/fake/fake_federatedtypeconfig.go @@ -80,17 +80,6 @@ func (c *FakeFederatedTypeConfigs) Update(ctx context.Context, federatedTypeConf return obj.(*v1alpha1.FederatedTypeConfig), 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 *FakeFederatedTypeConfigs) UpdateStatus(ctx context.Context, federatedTypeConfig *v1alpha1.FederatedTypeConfig, opts v1.UpdateOptions) (*v1alpha1.FederatedTypeConfig, error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(federatedtypeconfigsResource, "status", federatedTypeConfig), &v1alpha1.FederatedTypeConfig{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.FederatedTypeConfig), err -} - // Delete takes name of the federatedTypeConfig and deletes it. Returns an error if one occurs. func (c *FakeFederatedTypeConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/federatedobject.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/federatedobject.go new file mode 100644 index 00000000..0876f448 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/federatedobject.go @@ -0,0 +1,179 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + scheme "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// FederatedObjectsGetter has a method to return a FederatedObjectInterface. +// A group's client should implement this interface. +type FederatedObjectsGetter interface { + FederatedObjects(namespace string) FederatedObjectInterface +} + +// FederatedObjectInterface has methods to work with FederatedObject resources. +type FederatedObjectInterface interface { + Create(ctx context.Context, federatedObject *v1alpha1.FederatedObject, opts v1.CreateOptions) (*v1alpha1.FederatedObject, error) + Update(ctx context.Context, federatedObject *v1alpha1.FederatedObject, opts v1.UpdateOptions) (*v1alpha1.FederatedObject, error) + UpdateStatus(ctx context.Context, federatedObject *v1alpha1.FederatedObject, opts v1.UpdateOptions) (*v1alpha1.FederatedObject, 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) (*v1alpha1.FederatedObject, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.FederatedObjectList, 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 *v1alpha1.FederatedObject, err error) + FederatedObjectExpansion +} + +// federatedObjects implements FederatedObjectInterface +type federatedObjects struct { + client rest.Interface + ns string +} + +// newFederatedObjects returns a FederatedObjects +func newFederatedObjects(c *CoreV1alpha1Client, namespace string) *federatedObjects { + return &federatedObjects{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the federatedObject, and returns the corresponding federatedObject object, and an error if there is any. +func (c *federatedObjects) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.FederatedObject, err error) { + result = &v1alpha1.FederatedObject{} + err = c.client.Get(). + Namespace(c.ns). + Resource("federatedobjects"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of FederatedObjects that match those selectors. +func (c *federatedObjects) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FederatedObjectList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.FederatedObjectList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("federatedobjects"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested federatedObjects. +func (c *federatedObjects) 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("federatedobjects"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a federatedObject and creates it. Returns the server's representation of the federatedObject, and an error, if there is any. +func (c *federatedObjects) Create(ctx context.Context, federatedObject *v1alpha1.FederatedObject, opts v1.CreateOptions) (result *v1alpha1.FederatedObject, err error) { + result = &v1alpha1.FederatedObject{} + err = c.client.Post(). + Namespace(c.ns). + Resource("federatedobjects"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedObject). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a federatedObject and updates it. Returns the server's representation of the federatedObject, and an error, if there is any. +func (c *federatedObjects) Update(ctx context.Context, federatedObject *v1alpha1.FederatedObject, opts v1.UpdateOptions) (result *v1alpha1.FederatedObject, err error) { + result = &v1alpha1.FederatedObject{} + err = c.client.Put(). + Namespace(c.ns). + Resource("federatedobjects"). + Name(federatedObject.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedObject). + 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 *federatedObjects) UpdateStatus(ctx context.Context, federatedObject *v1alpha1.FederatedObject, opts v1.UpdateOptions) (result *v1alpha1.FederatedObject, err error) { + result = &v1alpha1.FederatedObject{} + err = c.client.Put(). + Namespace(c.ns). + Resource("federatedobjects"). + Name(federatedObject.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedObject). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the federatedObject and deletes it. Returns an error if one occurs. +func (c *federatedObjects) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("federatedobjects"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *federatedObjects) 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("federatedobjects"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched federatedObject. +func (c *federatedObjects) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.FederatedObject, err error) { + result = &v1alpha1.FederatedObject{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("federatedobjects"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/federatedtypeconfig.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/federatedtypeconfig.go index b7961c34..8a76b301 100644 --- a/pkg/client/clientset/versioned/typed/core/v1alpha1/federatedtypeconfig.go +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/federatedtypeconfig.go @@ -24,7 +24,6 @@ type FederatedTypeConfigsGetter interface { type FederatedTypeConfigInterface interface { Create(ctx context.Context, federatedTypeConfig *v1alpha1.FederatedTypeConfig, opts v1.CreateOptions) (*v1alpha1.FederatedTypeConfig, error) Update(ctx context.Context, federatedTypeConfig *v1alpha1.FederatedTypeConfig, opts v1.UpdateOptions) (*v1alpha1.FederatedTypeConfig, error) - UpdateStatus(ctx context.Context, federatedTypeConfig *v1alpha1.FederatedTypeConfig, opts v1.UpdateOptions) (*v1alpha1.FederatedTypeConfig, 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) (*v1alpha1.FederatedTypeConfig, error) @@ -113,21 +112,6 @@ func (c *federatedTypeConfigs) Update(ctx context.Context, federatedTypeConfig * 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 *federatedTypeConfigs) UpdateStatus(ctx context.Context, federatedTypeConfig *v1alpha1.FederatedTypeConfig, opts v1.UpdateOptions) (result *v1alpha1.FederatedTypeConfig, err error) { - result = &v1alpha1.FederatedTypeConfig{} - err = c.client.Put(). - Resource("federatedtypeconfigs"). - Name(federatedTypeConfig.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(federatedTypeConfig). - Do(ctx). - Into(result) - return -} - // Delete takes name of the federatedTypeConfig and deletes it. Returns an error if one occurs. func (c *federatedTypeConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). diff --git a/pkg/client/clientset/versioned/typed/core/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/core/v1alpha1/generated_expansion.go index ad30121e..bf602db7 100644 --- a/pkg/client/clientset/versioned/typed/core/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/core/v1alpha1/generated_expansion.go @@ -2,14 +2,22 @@ package v1alpha1 +type ClusterCollectedStatusExpansion interface{} + +type ClusterFederatedObjectExpansion interface{} + type ClusterOverridePolicyExpansion interface{} type ClusterPropagatedVersionExpansion interface{} type ClusterPropagationPolicyExpansion interface{} +type CollectedStatusExpansion interface{} + type FederatedClusterExpansion interface{} +type FederatedObjectExpansion interface{} + type FederatedTypeConfigExpansion interface{} type OverridePolicyExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/types/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/types/v1alpha1/doc.go deleted file mode 100644 index 93a7ca4e..00000000 --- a/pkg/client/clientset/versioned/typed/types/v1alpha1/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/types/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/types/v1alpha1/fake/doc.go deleted file mode 100644 index 2b5ba4c8..00000000 --- a/pkg/client/clientset/versioned/typed/types/v1alpha1/fake/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Code generated by client-gen. DO NOT EDIT. - -// Package fake has the automatically generated clients. -package fake diff --git a/pkg/client/clientset/versioned/typed/types/v1alpha1/fake/fake_types_client.go b/pkg/client/clientset/versioned/typed/types/v1alpha1/fake/fake_types_client.go deleted file mode 100644 index 04f47b5f..00000000 --- a/pkg/client/clientset/versioned/typed/types/v1alpha1/fake/fake_types_client.go +++ /dev/null @@ -1,19 +0,0 @@ -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeTypesV1alpha1 struct { - *testing.Fake -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeTypesV1alpha1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/pkg/client/clientset/versioned/typed/types/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/types/v1alpha1/generated_expansion.go deleted file mode 100644 index 95037b31..00000000 --- a/pkg/client/clientset/versioned/typed/types/v1alpha1/generated_expansion.go +++ /dev/null @@ -1,3 +0,0 @@ -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/types/v1alpha1/types_client.go b/pkg/client/clientset/versioned/typed/types/v1alpha1/types_client.go deleted file mode 100644 index 136186ff..00000000 --- a/pkg/client/clientset/versioned/typed/types/v1alpha1/types_client.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/types/v1alpha1" - "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned/scheme" - rest "k8s.io/client-go/rest" -) - -type TypesV1alpha1Interface interface { - RESTClient() rest.Interface -} - -// TypesV1alpha1Client is used to interact with features provided by the types.kubeadmiral.io group. -type TypesV1alpha1Client struct { - restClient rest.Interface -} - -// NewForConfig creates a new TypesV1alpha1Client for the given config. -func NewForConfig(c *rest.Config) (*TypesV1alpha1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &TypesV1alpha1Client{client}, nil -} - -// NewForConfigOrDie creates a new TypesV1alpha1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *TypesV1alpha1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new TypesV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *TypesV1alpha1Client { - return &TypesV1alpha1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1alpha1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *TypesV1alpha1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/pkg/client/generic/scheme/register.go b/pkg/client/generic/scheme/register.go index fc5bd2f9..3f08214a 100644 --- a/pkg/client/generic/scheme/register.go +++ b/pkg/client/generic/scheme/register.go @@ -29,7 +29,6 @@ import ( k8sscheme "k8s.io/client-go/kubernetes/scheme" fedcorev1a1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" - fedtypesv1a1 "github.com/kubewharf/kubeadmiral/pkg/apis/types/v1alpha1" ) var ( @@ -38,7 +37,6 @@ var ( ParameterCodec = runtime.NewParameterCodec(Scheme) localSchemeBuilder = runtime.SchemeBuilder{ fedcorev1a1.AddToScheme, - fedtypesv1a1.AddToScheme, k8sscheme.AddToScheme, } ) diff --git a/pkg/client/informers/externalversions/core/v1alpha1/clustercollectedstatus.go b/pkg/client/informers/externalversions/core/v1alpha1/clustercollectedstatus.go new file mode 100644 index 00000000..7bbe62a6 --- /dev/null +++ b/pkg/client/informers/externalversions/core/v1alpha1/clustercollectedstatus.go @@ -0,0 +1,73 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + versioned "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubewharf/kubeadmiral/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/listers/core/v1alpha1" + 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" +) + +// ClusterCollectedStatusInformer provides access to a shared informer and lister for +// ClusterCollectedStatuses. +type ClusterCollectedStatusInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ClusterCollectedStatusLister +} + +type clusterCollectedStatusInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewClusterCollectedStatusInformer constructs a new informer for ClusterCollectedStatus 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 NewClusterCollectedStatusInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterCollectedStatusInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterCollectedStatusInformer constructs a new informer for ClusterCollectedStatus 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 NewFilteredClusterCollectedStatusInformer(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.CoreV1alpha1().ClusterCollectedStatuses().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().ClusterCollectedStatuses().Watch(context.TODO(), options) + }, + }, + &corev1alpha1.ClusterCollectedStatus{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterCollectedStatusInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterCollectedStatusInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterCollectedStatusInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.ClusterCollectedStatus{}, f.defaultInformer) +} + +func (f *clusterCollectedStatusInformer) Lister() v1alpha1.ClusterCollectedStatusLister { + return v1alpha1.NewClusterCollectedStatusLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/core/v1alpha1/clusterfederatedobject.go b/pkg/client/informers/externalversions/core/v1alpha1/clusterfederatedobject.go new file mode 100644 index 00000000..924968ff --- /dev/null +++ b/pkg/client/informers/externalversions/core/v1alpha1/clusterfederatedobject.go @@ -0,0 +1,73 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + versioned "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubewharf/kubeadmiral/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/listers/core/v1alpha1" + 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" +) + +// ClusterFederatedObjectInformer provides access to a shared informer and lister for +// ClusterFederatedObjects. +type ClusterFederatedObjectInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ClusterFederatedObjectLister +} + +type clusterFederatedObjectInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewClusterFederatedObjectInformer constructs a new informer for ClusterFederatedObject 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 NewClusterFederatedObjectInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterFederatedObjectInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterFederatedObjectInformer constructs a new informer for ClusterFederatedObject 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 NewFilteredClusterFederatedObjectInformer(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.CoreV1alpha1().ClusterFederatedObjects().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().ClusterFederatedObjects().Watch(context.TODO(), options) + }, + }, + &corev1alpha1.ClusterFederatedObject{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterFederatedObjectInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterFederatedObjectInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterFederatedObjectInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.ClusterFederatedObject{}, f.defaultInformer) +} + +func (f *clusterFederatedObjectInformer) Lister() v1alpha1.ClusterFederatedObjectLister { + return v1alpha1.NewClusterFederatedObjectLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/core/v1alpha1/collectedstatus.go b/pkg/client/informers/externalversions/core/v1alpha1/collectedstatus.go new file mode 100644 index 00000000..19f310af --- /dev/null +++ b/pkg/client/informers/externalversions/core/v1alpha1/collectedstatus.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + versioned "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubewharf/kubeadmiral/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/listers/core/v1alpha1" + 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" +) + +// CollectedStatusInformer provides access to a shared informer and lister for +// CollectedStatuses. +type CollectedStatusInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.CollectedStatusLister +} + +type collectedStatusInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewCollectedStatusInformer constructs a new informer for CollectedStatus 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 NewCollectedStatusInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredCollectedStatusInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredCollectedStatusInformer constructs a new informer for CollectedStatus 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 NewFilteredCollectedStatusInformer(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.CoreV1alpha1().CollectedStatuses(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().CollectedStatuses(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.CollectedStatus{}, + resyncPeriod, + indexers, + ) +} + +func (f *collectedStatusInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredCollectedStatusInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *collectedStatusInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.CollectedStatus{}, f.defaultInformer) +} + +func (f *collectedStatusInformer) Lister() v1alpha1.CollectedStatusLister { + return v1alpha1.NewCollectedStatusLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/core/v1alpha1/federatedobject.go b/pkg/client/informers/externalversions/core/v1alpha1/federatedobject.go new file mode 100644 index 00000000..89930604 --- /dev/null +++ b/pkg/client/informers/externalversions/core/v1alpha1/federatedobject.go @@ -0,0 +1,74 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + corev1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + versioned "github.com/kubewharf/kubeadmiral/pkg/client/clientset/versioned" + internalinterfaces "github.com/kubewharf/kubeadmiral/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/client/listers/core/v1alpha1" + 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" +) + +// FederatedObjectInformer provides access to a shared informer and lister for +// FederatedObjects. +type FederatedObjectInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.FederatedObjectLister +} + +type federatedObjectInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewFederatedObjectInformer constructs a new informer for FederatedObject 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 NewFederatedObjectInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredFederatedObjectInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredFederatedObjectInformer constructs a new informer for FederatedObject 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 NewFilteredFederatedObjectInformer(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.CoreV1alpha1().FederatedObjects(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CoreV1alpha1().FederatedObjects(namespace).Watch(context.TODO(), options) + }, + }, + &corev1alpha1.FederatedObject{}, + resyncPeriod, + indexers, + ) +} + +func (f *federatedObjectInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredFederatedObjectInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *federatedObjectInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&corev1alpha1.FederatedObject{}, f.defaultInformer) +} + +func (f *federatedObjectInformer) Lister() v1alpha1.FederatedObjectLister { + return v1alpha1.NewFederatedObjectLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/core/v1alpha1/interface.go b/pkg/client/informers/externalversions/core/v1alpha1/interface.go index 29d7e46c..dda83f1d 100644 --- a/pkg/client/informers/externalversions/core/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/core/v1alpha1/interface.go @@ -8,14 +8,22 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // ClusterCollectedStatuses returns a ClusterCollectedStatusInformer. + ClusterCollectedStatuses() ClusterCollectedStatusInformer + // ClusterFederatedObjects returns a ClusterFederatedObjectInformer. + ClusterFederatedObjects() ClusterFederatedObjectInformer // ClusterOverridePolicies returns a ClusterOverridePolicyInformer. ClusterOverridePolicies() ClusterOverridePolicyInformer // ClusterPropagatedVersions returns a ClusterPropagatedVersionInformer. ClusterPropagatedVersions() ClusterPropagatedVersionInformer // ClusterPropagationPolicies returns a ClusterPropagationPolicyInformer. ClusterPropagationPolicies() ClusterPropagationPolicyInformer + // CollectedStatuses returns a CollectedStatusInformer. + CollectedStatuses() CollectedStatusInformer // FederatedClusters returns a FederatedClusterInformer. FederatedClusters() FederatedClusterInformer + // FederatedObjects returns a FederatedObjectInformer. + FederatedObjects() FederatedObjectInformer // FederatedTypeConfigs returns a FederatedTypeConfigInformer. FederatedTypeConfigs() FederatedTypeConfigInformer // OverridePolicies returns a OverridePolicyInformer. @@ -41,6 +49,16 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// ClusterCollectedStatuses returns a ClusterCollectedStatusInformer. +func (v *version) ClusterCollectedStatuses() ClusterCollectedStatusInformer { + return &clusterCollectedStatusInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// ClusterFederatedObjects returns a ClusterFederatedObjectInformer. +func (v *version) ClusterFederatedObjects() ClusterFederatedObjectInformer { + return &clusterFederatedObjectInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + // ClusterOverridePolicies returns a ClusterOverridePolicyInformer. func (v *version) ClusterOverridePolicies() ClusterOverridePolicyInformer { return &clusterOverridePolicyInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} @@ -56,11 +74,21 @@ func (v *version) ClusterPropagationPolicies() ClusterPropagationPolicyInformer return &clusterPropagationPolicyInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } +// CollectedStatuses returns a CollectedStatusInformer. +func (v *version) CollectedStatuses() CollectedStatusInformer { + return &collectedStatusInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // FederatedClusters returns a FederatedClusterInformer. func (v *version) FederatedClusters() FederatedClusterInformer { return &federatedClusterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } +// FederatedObjects returns a FederatedObjectInformer. +func (v *version) FederatedObjects() FederatedObjectInformer { + return &federatedObjectInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // FederatedTypeConfigs returns a FederatedTypeConfigInformer. func (v *version) FederatedTypeConfigs() FederatedTypeConfigInformer { return &federatedTypeConfigInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index adde4a0e..36478bbc 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -37,14 +37,22 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=core.kubeadmiral.io, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("clustercollectedstatuses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().ClusterCollectedStatuses().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("clusterfederatedobjects"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().ClusterFederatedObjects().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("clusteroverridepolicies"): return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().ClusterOverridePolicies().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("clusterpropagatedversions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().ClusterPropagatedVersions().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("clusterpropagationpolicies"): return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().ClusterPropagationPolicies().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("collectedstatuses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().CollectedStatuses().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("federatedclusters"): return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().FederatedClusters().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("federatedobjects"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().FederatedObjects().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("federatedtypeconfigs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().FederatedTypeConfigs().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("overridepolicies"): diff --git a/pkg/client/listers/core/v1alpha1/clustercollectedstatus.go b/pkg/client/listers/core/v1alpha1/clustercollectedstatus.go new file mode 100644 index 00000000..049128eb --- /dev/null +++ b/pkg/client/listers/core/v1alpha1/clustercollectedstatus.go @@ -0,0 +1,52 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterCollectedStatusLister helps list ClusterCollectedStatuses. +// All objects returned here must be treated as read-only. +type ClusterCollectedStatusLister interface { + // List lists all ClusterCollectedStatuses in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ClusterCollectedStatus, err error) + // Get retrieves the ClusterCollectedStatus from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ClusterCollectedStatus, error) + ClusterCollectedStatusListerExpansion +} + +// clusterCollectedStatusLister implements the ClusterCollectedStatusLister interface. +type clusterCollectedStatusLister struct { + indexer cache.Indexer +} + +// NewClusterCollectedStatusLister returns a new ClusterCollectedStatusLister. +func NewClusterCollectedStatusLister(indexer cache.Indexer) ClusterCollectedStatusLister { + return &clusterCollectedStatusLister{indexer: indexer} +} + +// List lists all ClusterCollectedStatuses in the indexer. +func (s *clusterCollectedStatusLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterCollectedStatus, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ClusterCollectedStatus)) + }) + return ret, err +} + +// Get retrieves the ClusterCollectedStatus from the index for a given name. +func (s *clusterCollectedStatusLister) Get(name string) (*v1alpha1.ClusterCollectedStatus, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("clustercollectedstatus"), name) + } + return obj.(*v1alpha1.ClusterCollectedStatus), nil +} diff --git a/pkg/client/listers/core/v1alpha1/clusterfederatedobject.go b/pkg/client/listers/core/v1alpha1/clusterfederatedobject.go new file mode 100644 index 00000000..aef44204 --- /dev/null +++ b/pkg/client/listers/core/v1alpha1/clusterfederatedobject.go @@ -0,0 +1,52 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterFederatedObjectLister helps list ClusterFederatedObjects. +// All objects returned here must be treated as read-only. +type ClusterFederatedObjectLister interface { + // List lists all ClusterFederatedObjects in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ClusterFederatedObject, err error) + // Get retrieves the ClusterFederatedObject from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ClusterFederatedObject, error) + ClusterFederatedObjectListerExpansion +} + +// clusterFederatedObjectLister implements the ClusterFederatedObjectLister interface. +type clusterFederatedObjectLister struct { + indexer cache.Indexer +} + +// NewClusterFederatedObjectLister returns a new ClusterFederatedObjectLister. +func NewClusterFederatedObjectLister(indexer cache.Indexer) ClusterFederatedObjectLister { + return &clusterFederatedObjectLister{indexer: indexer} +} + +// List lists all ClusterFederatedObjects in the indexer. +func (s *clusterFederatedObjectLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterFederatedObject, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ClusterFederatedObject)) + }) + return ret, err +} + +// Get retrieves the ClusterFederatedObject from the index for a given name. +func (s *clusterFederatedObjectLister) Get(name string) (*v1alpha1.ClusterFederatedObject, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("clusterfederatedobject"), name) + } + return obj.(*v1alpha1.ClusterFederatedObject), nil +} diff --git a/pkg/client/listers/core/v1alpha1/collectedstatus.go b/pkg/client/listers/core/v1alpha1/collectedstatus.go new file mode 100644 index 00000000..dca31a03 --- /dev/null +++ b/pkg/client/listers/core/v1alpha1/collectedstatus.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// CollectedStatusLister helps list CollectedStatuses. +// All objects returned here must be treated as read-only. +type CollectedStatusLister interface { + // List lists all CollectedStatuses in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.CollectedStatus, err error) + // CollectedStatuses returns an object that can list and get CollectedStatuses. + CollectedStatuses(namespace string) CollectedStatusNamespaceLister + CollectedStatusListerExpansion +} + +// collectedStatusLister implements the CollectedStatusLister interface. +type collectedStatusLister struct { + indexer cache.Indexer +} + +// NewCollectedStatusLister returns a new CollectedStatusLister. +func NewCollectedStatusLister(indexer cache.Indexer) CollectedStatusLister { + return &collectedStatusLister{indexer: indexer} +} + +// List lists all CollectedStatuses in the indexer. +func (s *collectedStatusLister) List(selector labels.Selector) (ret []*v1alpha1.CollectedStatus, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.CollectedStatus)) + }) + return ret, err +} + +// CollectedStatuses returns an object that can list and get CollectedStatuses. +func (s *collectedStatusLister) CollectedStatuses(namespace string) CollectedStatusNamespaceLister { + return collectedStatusNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// CollectedStatusNamespaceLister helps list and get CollectedStatuses. +// All objects returned here must be treated as read-only. +type CollectedStatusNamespaceLister interface { + // List lists all CollectedStatuses in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.CollectedStatus, err error) + // Get retrieves the CollectedStatus from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.CollectedStatus, error) + CollectedStatusNamespaceListerExpansion +} + +// collectedStatusNamespaceLister implements the CollectedStatusNamespaceLister +// interface. +type collectedStatusNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all CollectedStatuses in the indexer for a given namespace. +func (s collectedStatusNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.CollectedStatus, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.CollectedStatus)) + }) + return ret, err +} + +// Get retrieves the CollectedStatus from the indexer for a given namespace and name. +func (s collectedStatusNamespaceLister) Get(name string) (*v1alpha1.CollectedStatus, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("collectedstatus"), name) + } + return obj.(*v1alpha1.CollectedStatus), nil +} diff --git a/pkg/client/listers/core/v1alpha1/expansion_generated.go b/pkg/client/listers/core/v1alpha1/expansion_generated.go index 3227125f..167f089d 100644 --- a/pkg/client/listers/core/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/core/v1alpha1/expansion_generated.go @@ -2,6 +2,14 @@ package v1alpha1 +// ClusterCollectedStatusListerExpansion allows custom methods to be added to +// ClusterCollectedStatusLister. +type ClusterCollectedStatusListerExpansion interface{} + +// ClusterFederatedObjectListerExpansion allows custom methods to be added to +// ClusterFederatedObjectLister. +type ClusterFederatedObjectListerExpansion interface{} + // ClusterOverridePolicyListerExpansion allows custom methods to be added to // ClusterOverridePolicyLister. type ClusterOverridePolicyListerExpansion interface{} @@ -14,10 +22,26 @@ type ClusterPropagatedVersionListerExpansion interface{} // ClusterPropagationPolicyLister. type ClusterPropagationPolicyListerExpansion interface{} +// CollectedStatusListerExpansion allows custom methods to be added to +// CollectedStatusLister. +type CollectedStatusListerExpansion interface{} + +// CollectedStatusNamespaceListerExpansion allows custom methods to be added to +// CollectedStatusNamespaceLister. +type CollectedStatusNamespaceListerExpansion interface{} + // FederatedClusterListerExpansion allows custom methods to be added to // FederatedClusterLister. type FederatedClusterListerExpansion interface{} +// FederatedObjectListerExpansion allows custom methods to be added to +// FederatedObjectLister. +type FederatedObjectListerExpansion interface{} + +// FederatedObjectNamespaceListerExpansion allows custom methods to be added to +// FederatedObjectNamespaceLister. +type FederatedObjectNamespaceListerExpansion interface{} + // FederatedTypeConfigListerExpansion allows custom methods to be added to // FederatedTypeConfigLister. type FederatedTypeConfigListerExpansion interface{} diff --git a/pkg/client/listers/core/v1alpha1/federatedobject.go b/pkg/client/listers/core/v1alpha1/federatedobject.go new file mode 100644 index 00000000..3af305af --- /dev/null +++ b/pkg/client/listers/core/v1alpha1/federatedobject.go @@ -0,0 +1,83 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// FederatedObjectLister helps list FederatedObjects. +// All objects returned here must be treated as read-only. +type FederatedObjectLister interface { + // List lists all FederatedObjects in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.FederatedObject, err error) + // FederatedObjects returns an object that can list and get FederatedObjects. + FederatedObjects(namespace string) FederatedObjectNamespaceLister + FederatedObjectListerExpansion +} + +// federatedObjectLister implements the FederatedObjectLister interface. +type federatedObjectLister struct { + indexer cache.Indexer +} + +// NewFederatedObjectLister returns a new FederatedObjectLister. +func NewFederatedObjectLister(indexer cache.Indexer) FederatedObjectLister { + return &federatedObjectLister{indexer: indexer} +} + +// List lists all FederatedObjects in the indexer. +func (s *federatedObjectLister) List(selector labels.Selector) (ret []*v1alpha1.FederatedObject, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.FederatedObject)) + }) + return ret, err +} + +// FederatedObjects returns an object that can list and get FederatedObjects. +func (s *federatedObjectLister) FederatedObjects(namespace string) FederatedObjectNamespaceLister { + return federatedObjectNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// FederatedObjectNamespaceLister helps list and get FederatedObjects. +// All objects returned here must be treated as read-only. +type FederatedObjectNamespaceLister interface { + // List lists all FederatedObjects in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.FederatedObject, err error) + // Get retrieves the FederatedObject from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.FederatedObject, error) + FederatedObjectNamespaceListerExpansion +} + +// federatedObjectNamespaceLister implements the FederatedObjectNamespaceLister +// interface. +type federatedObjectNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all FederatedObjects in the indexer for a given namespace. +func (s federatedObjectNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.FederatedObject, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.FederatedObject)) + }) + return ret, err +} + +// Get retrieves the FederatedObject from the indexer for a given namespace and name. +func (s federatedObjectNamespaceLister) Get(name string) (*v1alpha1.FederatedObject, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("federatedobject"), name) + } + return obj.(*v1alpha1.FederatedObject), nil +} diff --git a/pkg/controllers/scheduler/extensions/webhook/v1alpha1/adapter.go b/pkg/controllers/scheduler/extensions/webhook/v1alpha1/adapter.go index 23e3fed7..c7c7a811 100644 --- a/pkg/controllers/scheduler/extensions/webhook/v1alpha1/adapter.go +++ b/pkg/controllers/scheduler/extensions/webhook/v1alpha1/adapter.go @@ -38,7 +38,7 @@ func ConvertSchedulingUnit(su *framework.SchedulingUnit) *schedwebhookv1a1.Sched } } - placements := []fedcorev1a1.Placement{} + placements := []fedcorev1a1.ClusterReference{} for cluster := range su.ClusterNames { var weight *int64 if w, ok := su.Weights[cluster]; ok { @@ -50,7 +50,7 @@ func ConvertSchedulingUnit(su *framework.SchedulingUnit) *schedwebhookv1a1.Sched maxReplicas = &max } - placement := fedcorev1a1.Placement{ + placement := fedcorev1a1.ClusterReference{ Cluster: cluster, Preferences: fedcorev1a1.Preferences{ MinReplicas: su.MinReplicas[cluster], diff --git a/pkg/controllers/scheduler/extensions/webhook/v1alpha1/adapter_test.go b/pkg/controllers/scheduler/extensions/webhook/v1alpha1/adapter_test.go index 6f3010c0..394b6e84 100644 --- a/pkg/controllers/scheduler/extensions/webhook/v1alpha1/adapter_test.go +++ b/pkg/controllers/scheduler/extensions/webhook/v1alpha1/adapter_test.go @@ -155,7 +155,7 @@ func TestConvertSchedulingUnit(t *testing.T) { }, }, MaxClusters: pointer.Int64(5), - Placements: []fedcorev1a1.Placement{ + Placements: []fedcorev1a1.DesiredPlacement{ { Cluster: "cluster1", }, @@ -348,7 +348,7 @@ func TestConvertSchedulingUnit(t *testing.T) { }, }, MaxClusters: pointer.Int64(5), - Placements: []fedcorev1a1.Placement{ + Placements: []fedcorev1a1.DesiredPlacement{ { Cluster: "cluster1", }, diff --git a/pkg/controllers/scheduler/scheduler_test.go b/pkg/controllers/scheduler/scheduler_test.go index 5f2975cb..e6e2c06f 100644 --- a/pkg/controllers/scheduler/scheduler_test.go +++ b/pkg/controllers/scheduler/scheduler_test.go @@ -351,7 +351,7 @@ func TestGetSchedulingUnitWithAnnotationOverrides(t *testing.T) { "label": "value1", }, MaxClusters: pointer.Int64(5), - Placements: []fedcorev1a1.Placement{ + Placements: []fedcorev1a1.ClusterReference{ { Cluster: "cluster1", }, diff --git a/pkg/controllers/scheduler/schedulingunit.go b/pkg/controllers/scheduler/schedulingunit.go index 47414418..06eb401f 100644 --- a/pkg/controllers/scheduler/schedulingunit.go +++ b/pkg/controllers/scheduler/schedulingunit.go @@ -473,7 +473,7 @@ func getWeightsFromObject(object *unstructured.Unstructured) (map[string]int64, return nil, false } - var placements []fedcorev1a1.Placement + var placements []fedcorev1a1.ClusterReference err := json.Unmarshal([]byte(annotation), &placements) if err != nil { klog.Errorf( @@ -531,7 +531,7 @@ func getMinReplicasFromObject(object *unstructured.Unstructured) (map[string]int return nil, false } - var placements []fedcorev1a1.Placement + var placements []fedcorev1a1.ClusterReference err := json.Unmarshal([]byte(annotation), &placements) if err != nil { klog.Errorf( @@ -589,7 +589,7 @@ func getMaxReplicasFromObject(object *unstructured.Unstructured) (map[string]int return nil, false } - var placements []fedcorev1a1.Placement + var placements []fedcorev1a1.ClusterReference err := json.Unmarshal([]byte(annotation), &placements) if err != nil { klog.Errorf( @@ -647,7 +647,7 @@ func getClusterNamesFromObject(object *unstructured.Unstructured) (map[string]st return nil, false } - var placements []fedcorev1a1.Placement + var placements []fedcorev1a1.ClusterReference err := json.Unmarshal([]byte(annotation), &placements) if err != nil { klog.Errorf( diff --git a/pkg/controllers/util/placement.go b/pkg/controllers/util/placement.go deleted file mode 100644 index 4dc8fafb..00000000 --- a/pkg/controllers/util/placement.go +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -This file may have been modified by The KubeAdmiral Authors -("KubeAdmiral Modifications"). All KubeAdmiral Modifications -are Copyright 2023 The KubeAdmiral Authors. -*/ - -package util - -import ( - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - - fedtypesv1a1 "github.com/kubewharf/kubeadmiral/pkg/apis/types/v1alpha1" - "github.com/kubewharf/kubeadmiral/pkg/controllers/common" -) - -func UnmarshalGenericPlacements(uns *unstructured.Unstructured) (*fedtypesv1a1.GenericObjectWithPlacements, error) { - placements := &fedtypesv1a1.GenericObjectWithPlacements{} - err := UnstructuredToInterface(uns, placements) - if err != nil { - return nil, err - } - return placements, nil -} - -func SetGenericPlacements(uns *unstructured.Unstructured, placements []fedtypesv1a1.PlacementWithController) error { - unsPlacements, err := InterfaceToUnstructured(placements) - if err != nil { - return err - } - - return unstructured.SetNestedField(uns.Object, unsPlacements, common.PlacementsPath...) -} - -func SetPlacementClusterNames(uns *unstructured.Unstructured, controller string, clusters map[string]struct{}) (hasChange bool, err error) { - obj, err := UnmarshalGenericPlacements(uns) - if err != nil { - return false, err - } - - if hasChange := obj.Spec.SetPlacementNames(controller, clusters); !hasChange { - return false, nil - } - - return true, SetGenericPlacements(uns, obj.Spec.Placements) -} diff --git a/test/e2e/framework/policies/propagationpolicy.go b/test/e2e/framework/policies/propagationpolicy.go index defa6f7a..22c3986c 100644 --- a/test/e2e/framework/policies/propagationpolicy.go +++ b/test/e2e/framework/policies/propagationpolicy.go @@ -39,12 +39,12 @@ func PropagationPolicyForClustersWithPlacements( Spec: fedcorev1a1.PropagationPolicySpec{ SchedulingMode: fedcorev1a1.SchedulingModeDuplicate, StickyCluster: false, - Placements: []fedcorev1a1.Placement{}, + Placements: []fedcorev1a1.ClusterReference{}, }, } for _, c := range clusters { - policy.Spec.Placements = append(policy.Spec.Placements, fedcorev1a1.Placement{Cluster: c.Name}) + policy.Spec.Placements = append(policy.Spec.Placements, fedcorev1a1.ClusterReference{Cluster: c.Name}) } return policy