Skip to content

Commit

Permalink
operator/v1/types: Declare Kubebuilder list semantics for CVO
Browse files Browse the repository at this point in the history
The conditions labels are suggested by
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go:

  // Condition contains details for one aspect of the current state of this API Resource.
  // ---
  // This struct is intended for direct use as an array at the field path .status.conditions.  For example,
  //
  //      type FooStatus struct{
  //          // Represents the observations of a foo's current state.
  //          // Known .status.conditions.type are: "Available", "Progressing", and "Degraded"
  //          // +patchMergeKey=type
  //          // +patchStrategy=merge
  //          // +listType=map
  //          // +listMapKey=type
  //          Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
  • Loading branch information
PratikMahajan committed Dec 5, 2023
1 parent 85597e9 commit 6164bff
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ spec:
unmanaged:
description: 'unmanaged controls if cluster version operator should stop managing the resources in this cluster. Default: false'
type: boolean
x-kubernetes-list-map-keys:
- kind
- group
- namespace
- name
x-kubernetes-list-type: map
upstream:
description: upstream may be used to specify the preferred update server. By default it will use the appropriate update server for the cluster and region.
type: string
Expand All @@ -171,6 +177,7 @@ spec:
type: array
items:
type: string
x-kubernetes-list-type: set
image:
description: image is a container image location that contains the update. When this field is part of spec, image is optional if version is specified and the availableUpdates field contains a matching version.
type: string
Expand All @@ -181,6 +188,7 @@ spec:
description: version is a semantic version identifying the update version. When this field is part of spec, version is optional if image is specified.
type: string
nullable: true
x-kubernetes-list-type: atomic
capabilities:
description: capabilities describes the state of optional, core cluster components.
type: object
Expand Down Expand Up @@ -293,6 +301,7 @@ spec:
type: array
items:
type: string
x-kubernetes-list-type: set
image:
description: image is a container image location that contains the update. When this field is part of spec, image is optional if version is specified and the availableUpdates field contains a matching version.
type: string
Expand Down Expand Up @@ -385,6 +394,9 @@ spec:
type:
description: type specifies the aspect reported by this condition.
type: string
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
desired:
description: desired is the version that the cluster is reconciling towards. If the cluster is not yet fully initialized desired will be set with the information available, which may be an image or a tag.
type: object
Expand All @@ -394,6 +406,7 @@ spec:
type: array
items:
type: string
x-kubernetes-list-type: set
image:
description: image is a container image location that contains the update. When this field is part of spec, image is optional if version is specified and the availableUpdates field contains a matching version.
type: string
Expand Down Expand Up @@ -440,6 +453,7 @@ spec:
version:
description: version is a semantic version identifying the update version. If the requested image does not define a version, or if a failure occurs retrieving the image, this value may be empty.
type: string
x-kubernetes-list-type: atomic
observedGeneration:
description: observedGeneration reports which version of the spec is being synced. If this value is not equal to metadata.generation, then the desired and conditions fields may represent a previous version.
type: integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ spec:
unmanaged:
description: 'unmanaged controls if cluster version operator should stop managing the resources in this cluster. Default: false'
type: boolean
x-kubernetes-list-map-keys:
- kind
- group
- namespace
- name
x-kubernetes-list-type: map
signatureStores:
description: "signatureStores contains the upstream URIs to verify release signatures. By default, CVO will use existing signature stores if this property is empty. The CVO will check the release signatures in the local ConfigMaps first. It will search for a valid signature in these stores in parallel only when local ConfigMaps did not include a valid signature. Validation will fail if none of the signature stores reply with valid signature before timeout. Setting signatureStores will replace the default signature stores with custom signature stores. Default stores can be used with custom signature stores by adding them manually. \n Items in this list should be a valid absolute http/https URI of an upstream signature store as per rfc1738. A maximum of 32 signature stores may be configured."
type: array
Expand Down Expand Up @@ -182,6 +188,7 @@ spec:
type: array
items:
type: string
x-kubernetes-list-type: set
image:
description: image is a container image location that contains the update. When this field is part of spec, image is optional if version is specified and the availableUpdates field contains a matching version.
type: string
Expand All @@ -192,6 +199,7 @@ spec:
description: version is a semantic version identifying the update version. When this field is part of spec, version is optional if image is specified.
type: string
nullable: true
x-kubernetes-list-type: atomic
capabilities:
description: capabilities describes the state of optional, core cluster components.
type: object
Expand Down Expand Up @@ -306,6 +314,7 @@ spec:
type: array
items:
type: string
x-kubernetes-list-type: set
image:
description: image is a container image location that contains the update. When this field is part of spec, image is optional if version is specified and the availableUpdates field contains a matching version.
type: string
Expand Down Expand Up @@ -398,6 +407,9 @@ spec:
type:
description: type specifies the aspect reported by this condition.
type: string
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
desired:
description: desired is the version that the cluster is reconciling towards. If the cluster is not yet fully initialized desired will be set with the information available, which may be an image or a tag.
type: object
Expand All @@ -407,6 +419,7 @@ spec:
type: array
items:
type: string
x-kubernetes-list-type: set
image:
description: image is a container image location that contains the update. When this field is part of spec, image is optional if version is specified and the availableUpdates field contains a matching version.
type: string
Expand Down Expand Up @@ -453,6 +466,7 @@ spec:
version:
description: version is a semantic version identifying the update version. If the requested image does not define a version, or if a failure occurs retrieving the image, this value may be empty.
type: string
x-kubernetes-list-type: atomic
observedGeneration:
description: observedGeneration reports which version of the spec is being synced. If this value is not equal to metadata.generation, then the desired and conditions fields may represent a previous version.
type: integer
Expand Down
14 changes: 13 additions & 1 deletion config/v1/types_cluster_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ type ClusterVersionSpec struct {
// overrides is list of overides for components that are managed by
// cluster version operator. Marking a component unmanaged will prevent
// the operator from creating or updating the object.
// +listType=map
// +listMapKey=kind
// +listMapKey=group
// +listMapKey=namespace
// +listMapKey=name
// +optional
Overrides []ComponentOverride `json:"overrides,omitempty"`
}
Expand All @@ -133,6 +138,7 @@ type ClusterVersionStatus struct {
// Completed if the rollout completed - if an update was failing or halfway
// applied the state will be Partial. Only a limited amount of update history
// is preserved.
// +listType=atomic
// +optional
History []UpdateHistory `json:"history,omitempty"`

Expand Down Expand Up @@ -160,8 +166,12 @@ type ClusterVersionStatus struct {
// by a temporary or permanent error. Conditions are only valid for the
// current desiredUpdate when metadata.generation is equal to
// status.generation.
// +listType=map
// +listMapKey=type
// +patchMergeKey=type
// +patchStrategy=merge
// +optional
Conditions []ClusterOperatorStatusCondition `json:"conditions,omitempty"`
Conditions []ClusterOperatorStatusCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`

// availableUpdates contains updates recommended for this
// cluster. Updates which appear in conditionalUpdates but not in
Expand All @@ -170,6 +180,7 @@ type ClusterVersionStatus struct {
// is unavailable, or if an invalid channel has been specified.
// +nullable
// +kubebuilder:validation:Required
// +listType=atomic
// +required
AvailableUpdates []Release `json:"availableUpdates"`

Expand Down Expand Up @@ -643,6 +654,7 @@ type Release struct {

// channels is the set of Cincinnati channels to which the release
// currently belongs.
// +listType=set
// +optional
Channels []string `json:"channels,omitempty"`
}
Expand Down
36 changes: 36 additions & 0 deletions openapi/generated_openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 21 additions & 5 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5250,7 +5250,14 @@
"items": {
"default": {},
"$ref": "#/definitions/com.github.openshift.api.config.v1.ComponentOverride"
}
},
"x-kubernetes-list-map-keys": [
"kind",
"group",
"namespace",
"name"
],
"x-kubernetes-list-type": "map"
},
"signatureStores": {
"description": "signatureStores contains the upstream URIs to verify release signatures. By default, CVO will use existing signature stores if this property is empty. The CVO will check the release signatures in the local ConfigMaps first. It will search for a valid signature in these stores in parallel only when local ConfigMaps did not include a valid signature. Validation will fail if none of the signature stores reply with valid signature before timeout. Setting signatureStores will replace the default signature stores with custom signature stores. Default stores can be used with custom signature stores by adding them manually.\n\nItems in this list should be a valid absolute http/https URI of an upstream signature store as per rfc1738. A maximum of 32 signature stores may be configured.",
Expand Down Expand Up @@ -5284,7 +5291,8 @@
"items": {
"default": {},
"$ref": "#/definitions/com.github.openshift.api.config.v1.Release"
}
},
"x-kubernetes-list-type": "atomic"
},
"capabilities": {
"description": "capabilities describes the state of optional, core cluster components.",
Expand All @@ -5306,7 +5314,13 @@
"items": {
"default": {},
"$ref": "#/definitions/com.github.openshift.api.config.v1.ClusterOperatorStatusCondition"
}
},
"x-kubernetes-list-map-keys": [
"type"
],
"x-kubernetes-list-type": "map",
"x-kubernetes-patch-merge-key": "type",
"x-kubernetes-patch-strategy": "merge"
},
"desired": {
"description": "desired is the version that the cluster is reconciling towards. If the cluster is not yet fully initialized desired will be set with the information available, which may be an image or a tag.",
Expand All @@ -5319,7 +5333,8 @@
"items": {
"default": {},
"$ref": "#/definitions/com.github.openshift.api.config.v1.UpdateHistory"
}
},
"x-kubernetes-list-type": "atomic"
},
"observedGeneration": {
"description": "observedGeneration reports which version of the spec is being synced. If this value is not equal to metadata.generation, then the desired and conditions fields may represent a previous version.",
Expand Down Expand Up @@ -9484,7 +9499,8 @@
"items": {
"type": "string",
"default": ""
}
},
"x-kubernetes-list-type": "set"
},
"image": {
"description": "image is a container image location that contains the update. When this field is part of spec, image is optional if version is specified and the availableUpdates field contains a matching version.",
Expand Down

0 comments on commit 6164bff

Please sign in to comment.