Skip to content

Commit 3a567ee

Browse files
Merge pull request #465 from tmshort/synchronize
NO-ISSUE: Synchronize From Upstream Repositories
2 parents 40dae8e + 921f919 commit 3a567ee

File tree

135 files changed

+13205
-1178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+13205
-1178
lines changed

api/v1/clusterextension_types_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"github.com/operator-framework/operator-controller/internal/operator-controller/conditionsets"
1515
)
1616

17+
// TODO Expand these tests to cover Types/Reasons/etc. from other APIs as well
18+
1719
func TestClusterExtensionTypeRegistration(t *testing.T) {
1820
types, err := parseConstants("Type")
1921
if err != nil {
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/*
2+
Copyright 2024.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
22+
"k8s.io/apimachinery/pkg/types"
23+
)
24+
25+
const (
26+
ClusterExtensionRevisionKind = "ClusterExtensionRevision"
27+
28+
// Condition Types
29+
ClusterExtensionRevisionTypeAvailable = "Available"
30+
ClusterExtensionRevisionTypeSucceeded = "Succeeded"
31+
32+
// Condition Reasons
33+
ClusterExtensionRevisionReasonAvailable = "Available"
34+
ClusterExtensionRevisionReasonReconcileFailure = "ReconcileFailure"
35+
ClusterExtensionRevisionReasonRevisionValidationFailure = "RevisionValidationFailure"
36+
ClusterExtensionRevisionReasonPhaseValidationError = "PhaseValidationError"
37+
ClusterExtensionRevisionReasonObjectCollisions = "ObjectCollisions"
38+
ClusterExtensionRevisionReasonRolloutSuccess = "RolloutSuccess"
39+
ClusterExtensionRevisionReasonProbeFailure = "ProbeFailure"
40+
ClusterExtensionRevisionReasonIncomplete = "Incomplete"
41+
ClusterExtensionRevisionReasonProgressing = "Progressing"
42+
)
43+
44+
// ClusterExtensionRevisionSpec defines the desired state of ClusterExtensionRevision.
45+
type ClusterExtensionRevisionSpec struct {
46+
// Specifies the lifecycle state of the ClusterExtensionRevision.
47+
//
48+
// +kubebuilder:default="Active"
49+
// +kubebuilder:validation:Enum=Active;Paused;Archived
50+
// +kubebuilder:validation:XValidation:rule="oldSelf == 'Active' || oldSelf == 'Paused' || oldSelf == 'Archived' && oldSelf == self", message="can not un-archive"
51+
LifecycleState ClusterExtensionRevisionLifecycleState `json:"lifecycleState,omitempty"`
52+
// Revision number orders changes over time, must always be previous revision +1.
53+
//
54+
// +kubebuilder:validation:Required
55+
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="revision is immutable"
56+
Revision int64 `json:"revision"`
57+
// Phases are groups of objects that will be applied at the same time.
58+
// All objects in the a phase will have to pass their probes in order to progress to the next phase.
59+
//
60+
// +kubebuilder:validation:Required
61+
// +kubebuilder:validation:XValidation:rule="self == oldSelf || oldSelf.size() == 0", message="phases is immutable"
62+
// +patchMergeKey=name
63+
// +patchStrategy=merge
64+
// +listType=map
65+
// +listMapKey=name
66+
Phases []ClusterExtensionRevisionPhase `json:"phases"`
67+
// Previous references previous revisions that objects can be adopted from.
68+
//
69+
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="previous is immutable"
70+
Previous []ClusterExtensionRevisionPrevious `json:"previous,omitempty"`
71+
}
72+
73+
// ClusterExtensionRevisionLifecycleState specifies the lifecycle state of the ClusterExtensionRevision.
74+
type ClusterExtensionRevisionLifecycleState string
75+
76+
const (
77+
// ClusterExtensionRevisionLifecycleStateActive / "Active" is the default lifecycle state.
78+
ClusterExtensionRevisionLifecycleStateActive ClusterExtensionRevisionLifecycleState = "Active"
79+
// ClusterExtensionRevisionLifecycleStatePaused / "Paused" disables reconciliation of the ClusterExtensionRevision.
80+
// Only Status updates will still propagated, but object changes will not be reconciled.
81+
ClusterExtensionRevisionLifecycleStatePaused ClusterExtensionRevisionLifecycleState = "Paused"
82+
// ClusterExtensionRevisionLifecycleStateArchived / "Archived" disables reconciliation while also "scaling to zero",
83+
// which deletes all objects that are not excluded via the pausedFor property and
84+
// removes itself from the owner list of all other objects previously under management.
85+
ClusterExtensionRevisionLifecycleStateArchived ClusterExtensionRevisionLifecycleState = "Archived"
86+
)
87+
88+
// ClusterExtensionRevisionPhase are groups of objects that will be applied at the same time.
89+
// All objects in the a phase will have to pass their probes in order to progress to the next phase.
90+
type ClusterExtensionRevisionPhase struct {
91+
// Name identifies this phase.
92+
//
93+
// +kubebuilder:validation:MaxLength=63
94+
// +kubebuilder:validation:Pattern=`^[a-z]([-a-z0-9]*[a-z0-9])?$`
95+
Name string `json:"name"`
96+
// Objects are a list of all the objects within this phase.
97+
Objects []ClusterExtensionRevisionObject `json:"objects"`
98+
}
99+
100+
// ClusterExtensionRevisionObject contains an object and settings for it.
101+
type ClusterExtensionRevisionObject struct {
102+
// +kubebuilder:validation:EmbeddedResource
103+
// +kubebuilder:pruning:PreserveUnknownFields
104+
Object unstructured.Unstructured `json:"object"`
105+
// CollisionProtection controls whether OLM can adopt and modify objects
106+
// already existing on the cluster or even owned by another controller.
107+
//
108+
// +kubebuilder:default="Prevent"
109+
CollisionProtection CollisionProtection `json:"collisionProtection,omitempty"`
110+
}
111+
112+
// CollisionProtection specifies if and how ownership collisions are prevented.
113+
type CollisionProtection string
114+
115+
const (
116+
// CollisionProtectionPrevent prevents owner collisions entirely
117+
// by only allowing to work with objects itself has created.
118+
CollisionProtectionPrevent CollisionProtection = "Prevent"
119+
// CollisionProtectionIfNoController allows to patch and override
120+
// objects already present if they are not owned by another controller.
121+
CollisionProtectionIfNoController CollisionProtection = "IfNoController"
122+
// CollisionProtectionNone allows to patch and override objects
123+
// already present and owned by other controllers.
124+
// Be careful! This setting may cause multiple controllers to fight over a resource,
125+
// causing load on the API server and etcd.
126+
CollisionProtectionNone CollisionProtection = "None"
127+
)
128+
129+
type ClusterExtensionRevisionPrevious struct {
130+
// +kubebuilder:validation:Required
131+
Name string `json:"name"`
132+
// +kubebuilder:validation:Required
133+
UID types.UID `json:"uid"`
134+
}
135+
136+
// ClusterExtensionRevisionStatus defines the observed state of a ClusterExtensionRevision.
137+
type ClusterExtensionRevisionStatus struct {
138+
// +patchMergeKey=type
139+
// +patchStrategy=merge
140+
// +listType=map
141+
// +listMapKey=type
142+
// +optional
143+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
144+
}
145+
146+
// +kubebuilder:object:root=true
147+
// +kubebuilder:resource:scope=Cluster
148+
// +kubebuilder:subresource:status
149+
150+
// ClusterExtensionRevision is the Schema for the clusterextensionrevisions API
151+
type ClusterExtensionRevision struct {
152+
metav1.TypeMeta `json:",inline"`
153+
metav1.ObjectMeta `json:"metadata,omitempty"`
154+
155+
// spec is an optional field that defines the desired state of the ClusterExtension.
156+
// +optional
157+
Spec ClusterExtensionRevisionSpec `json:"spec,omitempty"`
158+
159+
// status is an optional field that defines the observed state of the ClusterExtension.
160+
// +optional
161+
Status ClusterExtensionRevisionStatus `json:"status,omitempty"`
162+
}
163+
164+
// +kubebuilder:object:root=true
165+
166+
// ClusterExtensionRevisionList contains a list of ClusterExtensionRevision
167+
type ClusterExtensionRevisionList struct {
168+
metav1.TypeMeta `json:",inline"`
169+
170+
// +optional
171+
metav1.ListMeta `json:"metadata,omitempty"`
172+
173+
// items is a required list of ClusterExtensionRevision objects.
174+
//
175+
// +kubebuilder:validation:Required
176+
Items []ClusterExtensionRevision `json:"items"`
177+
}
178+
179+
func init() {
180+
SchemeBuilder.Register(&ClusterExtensionRevision{}, &ClusterExtensionRevisionList{})
181+
}

api/v1/common_types.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ const (
2020
TypeInstalled = "Installed"
2121
TypeProgressing = "Progressing"
2222

23+
// Installed reasons
24+
ReasonAbsent = "Absent"
25+
2326
// Progressing reasons
24-
ReasonSucceeded = "Succeeded"
25-
ReasonRetrying = "Retrying"
26-
ReasonBlocked = "Blocked"
27+
ReasonRolloutInProgress = "RolloutInProgress"
28+
ReasonRetrying = "Retrying"
29+
ReasonBlocked = "Blocked"
2730

28-
// Terminal reasons
31+
// Deprecation reasons
2932
ReasonDeprecated = "Deprecated"
30-
ReasonFailed = "Failed"
33+
34+
// Common reasons
35+
ReasonSucceeded = "Succeeded"
36+
ReasonFailed = "Failed"
3137
)

api/v1/zz_generated.deepcopy.go

Lines changed: 161 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)