@@ -18,20 +18,22 @@ package v1alpha1
18
18
19
19
import (
20
20
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21
+ "k8s.io/apimachinery/pkg/types"
21
22
)
22
23
23
24
type ExtensionManagedState string
24
25
25
26
const (
26
- // Pause resolution of this Extension
27
+ // Peform reconcilliation of this Extension
27
28
ManagedStateActive ExtensionManagedState = "Active"
28
- // Peform resolution of this Extension
29
+ // Pause reconcilliation of this Extension
29
30
ManagedStatePaused ExtensionManagedState = "Paused"
30
31
)
31
32
32
33
type ExtensionSourcePackage struct {
33
34
//+kubebuilder:validation:MaxLength:=48
34
35
//+kubebuilder:validation:Pattern:=^[a-z0-9]+(-[a-z0-9]+)*$
36
+ // name specifies the name of the name of the package
35
37
Name string `json:"name"`
36
38
37
39
//+kubebuilder:validation:MaxLength:=64
@@ -42,12 +44,20 @@ type ExtensionSourcePackage struct {
42
44
// Examples: 1.2.3, 1.0.0-alpha, 1.0.0-rc.1
43
45
//
44
46
// For more information on semver, please see https://semver.org/
47
+ // version constraint definition
45
48
Version string `json:"version,omitempty"`
46
49
47
50
//+kubebuilder:validation:MaxLength:=48
48
51
//+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$
49
- // Channel constraint definition
52
+ // channel constraint definition
50
53
Channel string `json:"channel,omitempty"`
54
+
55
+ //+kubebuilder:validation:Enum:=Enforce;Ignore
56
+ //+kubebuilder:default:=Enforce
57
+ //+kubebuilder:Optional
58
+ //
59
+ // upgradeConstraintPolicy Defines the policy for how to handle upgrade constraints
60
+ UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy,omitempty"`
51
61
}
52
62
53
63
// TODO: Implement ExtensionSourceDirect containing a URL or other reference mechanism
@@ -66,31 +76,30 @@ type ExtensionSpec struct {
66
76
//+kubebuilder:default:=Active
67
77
//+kubebuilder:Optional
68
78
//
69
- // Pause reconciliation on this Extension
79
+ // managed controls the management state of the extension. "Active" means this extension will be reconciled and "Paused" means this extension will be ignored.
70
80
Managed ExtensionManagedState `json:"managed,omitempty"`
71
81
72
- //+kubebuilder:validation:MaxLength:=64
82
+ //+kubebuilder:validation:MaxLength:=253
73
83
//+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$
74
84
//
75
- // ServiceAccount name used to install this extension
85
+ // serviceAccountName is he name of a service account in the Extension's namespace that will be used to manage the installation and lifecycle of the extension.
76
86
ServiceAccountName string `json:"serviceAccountName"`
77
87
78
- //+kubebuilder:validation:MaxLength:=64
88
+ //+kubebuilder:validation:MaxLength:=253
79
89
//+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$
80
90
//+kubebuilder:Optional
81
91
//
82
- // Location of installation TBD??
92
+ // defaultNamespace is the location of installation if different than the resource namespace
83
93
DefaultNamespace string `json:"defaultNamespace,omitempty"`
84
94
85
- // Source of Extension to be installed
95
+ // source of Extension to be installed
86
96
Source ExtensionSource `json:"source"`
87
97
88
- //+kubebuilder:validation:Enum:=Enforce;Ignore
89
- //+kubebuilder:default:=Enforce
90
98
//+kubebuilder:Optional
91
99
//
92
- // Defines the policy for how to handle upgrade constraints
93
- UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy,omitempty"`
100
+ // watchNamespaces indicates which namespaces the extension should watch.
101
+ // This feature is currently supported only with RegistryV1 bundles.
102
+ WatchNamespaces []string `json:"watchNamespaces,omitempty"`
94
103
}
95
104
96
105
// ExtensionStatus defines the observed state of Extension
@@ -131,3 +140,30 @@ type ExtensionList struct {
131
140
func init () {
132
141
SchemeBuilder .Register (& Extension {}, & ExtensionList {})
133
142
}
143
+
144
+ func (r * Extension ) GetPackageSpec () * ExtensionSourcePackage {
145
+ return r .Spec .Source .Package .DeepCopy ()
146
+ }
147
+
148
+ func (r * Extension ) GetGeneration () int64 {
149
+ return r .ObjectMeta .GetGeneration ()
150
+ }
151
+
152
+ func (r * Extension ) GetConditions () * []metav1.Condition {
153
+ return & r .Status .Conditions
154
+ }
155
+
156
+ func (r * Extension ) SetInstalledBundleResource (s string ) {
157
+ r .Status .InstalledBundleResource = s
158
+ }
159
+
160
+ func (r * Extension ) GetUID () types.UID {
161
+ return r .ObjectMeta .GetUID ()
162
+ }
163
+
164
+ func (r * Extension ) GetUpgradeConstraintPolicy () UpgradeConstraintPolicy {
165
+ if r .Spec .Source .Package != nil {
166
+ return r .Spec .Source .Package .UpgradeConstraintPolicy
167
+ }
168
+ return ""
169
+ }
0 commit comments