Skip to content

Commit cc02ecb

Browse files
committed
Add OperatorCondition v2 with spec.conditions array
Signed-off-by: Vu Dinh <vudinh@outlook.com>
1 parent 0e2de6b commit cc02ecb

File tree

6 files changed

+347
-2
lines changed

6 files changed

+347
-2
lines changed

crds/operators.coreos.com_operatorconditions.yaml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,125 @@ spec:
1919
scope: Namespaced
2020
versions:
2121
- name: v1
22+
schema:
23+
openAPIV3Schema:
24+
description: OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator.
25+
type: object
26+
required:
27+
- metadata
28+
properties:
29+
apiVersion:
30+
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'
31+
type: string
32+
kind:
33+
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'
34+
type: string
35+
metadata:
36+
type: object
37+
spec:
38+
description: OperatorConditionSpec allows a cluster admin to convey information about the state of an operator to OLM, potentially overriding state reported by the operator.
39+
type: object
40+
properties:
41+
deployments:
42+
type: array
43+
items:
44+
type: string
45+
overrides:
46+
type: array
47+
items:
48+
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
49+
type: object
50+
required:
51+
- message
52+
- reason
53+
- status
54+
- type
55+
properties:
56+
lastTransitionTime:
57+
description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
58+
type: string
59+
format: date-time
60+
message:
61+
description: message is a human readable message indicating details about the transition. This may be an empty string.
62+
type: string
63+
maxLength: 32768
64+
observedGeneration:
65+
description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
66+
type: integer
67+
format: int64
68+
minimum: 0
69+
reason:
70+
description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.
71+
type: string
72+
maxLength: 1024
73+
minLength: 1
74+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
75+
status:
76+
description: status of the condition, one of True, False, Unknown.
77+
type: string
78+
enum:
79+
- "True"
80+
- "False"
81+
- Unknown
82+
type:
83+
description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
84+
type: string
85+
maxLength: 316
86+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
87+
serviceAccounts:
88+
type: array
89+
items:
90+
type: string
91+
status:
92+
description: OperatorConditionStatus allows an operator to convey information its state to OLM. The status may trail the actual state of a system.
93+
type: object
94+
properties:
95+
conditions:
96+
type: array
97+
items:
98+
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
99+
type: object
100+
required:
101+
- lastTransitionTime
102+
- message
103+
- reason
104+
- status
105+
- type
106+
properties:
107+
lastTransitionTime:
108+
description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
109+
type: string
110+
format: date-time
111+
message:
112+
description: message is a human readable message indicating details about the transition. This may be an empty string.
113+
type: string
114+
maxLength: 32768
115+
observedGeneration:
116+
description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
117+
type: integer
118+
format: int64
119+
minimum: 0
120+
reason:
121+
description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.
122+
type: string
123+
maxLength: 1024
124+
minLength: 1
125+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
126+
status:
127+
description: status of the condition, one of True, False, Unknown.
128+
type: string
129+
enum:
130+
- "True"
131+
- "False"
132+
- Unknown
133+
type:
134+
description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
135+
type: string
136+
maxLength: 316
137+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
138+
served: false
139+
storage: false
140+
- name: v2
22141
schema:
23142
openAPIV3Schema:
24143
description: OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator.

pkg/operators/v1/operatorcondition_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ type OperatorConditionSpec struct {
1414
ServiceAccounts []string `json:"serviceAccounts,omitempty"`
1515
Deployments []string `json:"deployments,omitempty"`
1616
Overrides []metav1.Condition `json:"overrides,omitempty"`
17-
Conditions []metav1.Condition `json:"conditions,omitempty"`
1817
}
1918

2019
// OperatorConditionStatus allows an operator to convey information its state to OLM. The status may trail the actual
@@ -25,7 +24,6 @@ type OperatorConditionStatus struct {
2524

2625
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2726
// +genclient
28-
// +kubebuilder:storageversion
2927
// +kubebuilder:resource:shortName=condition,categories=olm
3028
// +kubebuilder:subresource:status
3129
// OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator.

pkg/operators/v2/doc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// +groupName=operators.coreos.com
2+
3+
// Package v2 contains resources types for version v2 of the operators.coreos.com API group.
4+
package v2
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// +kubebuilder:object:generate=true
2+
3+
// Package v2 contains API Schema definitions for the operator v2 API group.
4+
package v2
5+
6+
import (
7+
"k8s.io/apimachinery/pkg/runtime/schema"
8+
"sigs.k8s.io/controller-runtime/pkg/scheme"
9+
)
10+
11+
var (
12+
// GroupVersion is group version used to register these objects.
13+
GroupVersion = schema.GroupVersion{Group: "operators.coreos.com", Version: "v2"}
14+
15+
// SchemeGroupVersion is required for compatibility with client generation.
16+
SchemeGroupVersion = GroupVersion
17+
18+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
19+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
20+
21+
// AddToScheme adds the types in this group-version to the given scheme.
22+
AddToScheme = SchemeBuilder.AddToScheme
23+
)
24+
25+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
26+
func Resource(resource string) schema.GroupResource {
27+
return GroupVersion.WithResource(resource).GroupResource()
28+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package v2
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
const (
8+
// Upgradeable indicates that the operator is upgradeable
9+
Upgradeable string = "Upgradeable"
10+
)
11+
12+
// OperatorConditionSpec allows an operator to report state to OLM and provides
13+
// cluster admins with the ability to manually override state reported by the operator.
14+
type OperatorConditionSpec struct {
15+
ServiceAccounts []string `json:"serviceAccounts,omitempty"`
16+
Deployments []string `json:"deployments,omitempty"`
17+
Overrides []metav1.Condition `json:"overrides,omitempty"`
18+
Conditions []metav1.Condition `json:"conditions,omitempty"`
19+
}
20+
21+
// OperatorConditionStatus allows OLM to convey which conditions have been observed.
22+
type OperatorConditionStatus struct {
23+
Conditions []metav1.Condition `json:"conditions,omitempty"`
24+
}
25+
26+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
27+
// +genclient
28+
// +kubebuilder:storageversion
29+
// +kubebuilder:resource:shortName=condition,categories=olm
30+
// +kubebuilder:subresource:status
31+
// OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator.
32+
type OperatorCondition struct {
33+
metav1.TypeMeta `json:",inline"`
34+
metav1.ObjectMeta `json:"metadata"`
35+
36+
Spec OperatorConditionSpec `json:"spec,omitempty"`
37+
Status OperatorConditionStatus `json:"status,omitempty"`
38+
}
39+
40+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
41+
// OperatorConditionList represents a list of Conditions.
42+
type OperatorConditionList struct {
43+
metav1.TypeMeta `json:",inline"`
44+
metav1.ListMeta `json:"metadata"`
45+
46+
Items []OperatorCondition `json:"items"`
47+
}
48+
49+
func init() {
50+
SchemeBuilder.Register(&OperatorCondition{}, &OperatorConditionList{})
51+
}

pkg/operators/v2/zz_generated.deepcopy.go

Lines changed: 145 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)