@@ -17,6 +17,9 @@ limitations under the License.
17
17
package v1alpha1
18
18
19
19
import (
20
+ "fmt"
21
+
22
+ declarative "github.com/kyma-project/module-manager/pkg/declarative/v2"
20
23
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21
24
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
22
25
"k8s.io/apimachinery/pkg/runtime"
@@ -26,15 +29,6 @@ import (
26
29
27
30
const ManifestKind = "Manifest"
28
31
29
- func (m * Manifest ) SetObservedGeneration () * Manifest {
30
- m .Status .ObservedGeneration = m .Generation
31
- return m
32
- }
33
-
34
- func (m * Manifest ) IsSpecUpdated () bool {
35
- return m .Status .ObservedGeneration != m .Generation
36
- }
37
-
38
32
// InstallInfo defines installation information.
39
33
type InstallInfo struct {
40
34
// Source can either be described as ImageSpec, HelmChartSpec or KustomizeSpec
@@ -48,59 +42,26 @@ type InstallInfo struct {
48
42
// ManifestSpec defines the specification of Manifest.
49
43
type ManifestSpec struct {
50
44
// Remote indicates if Manifest should be installed on a remote cluster
51
- // +kubebuilder:validation:Optional
52
45
// +kubebuilder:default:=true
53
- Remote bool `json:"remote"`
46
+ Remote bool `json:"remote,omitempty "`
54
47
55
48
// Config specifies OCI image configuration for Manifest
56
- // +kubebuilder:validation:Optional
57
- Config types.ImageSpec `json:"config"`
49
+ Config types.ImageSpec `json:"config,omitempty"`
58
50
59
51
// Installs specifies a list of installations for Manifest
60
52
Installs []InstallInfo `json:"installs"`
61
53
62
54
//+kubebuilder:pruning:PreserveUnknownFields
63
- // +kubebuilder:validation:Optional
55
+ //+kubebuilder:validation:XEmbeddedResource
64
56
// Resource specifies a resource to be watched for state updates
65
- Resource unstructured.Unstructured `json:"resource"`
57
+ Resource unstructured.Unstructured `json:"resource,omitempty "`
66
58
67
59
// CRDs specifies the custom resource definitions' ImageSpec
68
- // +kubebuilder:validation:Optional
69
- CRDs types.ImageSpec `json:"crds"`
60
+ CRDs types.ImageSpec `json:"crds,omitempty"`
70
61
}
71
62
72
- // +kubebuilder:validation:Enum=Processing;Deleting;Ready;Error
73
- type ManifestState string
74
-
75
- // Valid Helm States.
76
- const (
77
- // ManifestStateReady signifies Manifest is ready.
78
- ManifestStateReady ManifestState = "Ready"
79
-
80
- // ManifestStateProcessing signifies Manifest is reconciling.
81
- ManifestStateProcessing ManifestState = "Processing"
82
-
83
- // ManifestStateError signifies an error for Manifest.
84
- ManifestStateError ManifestState = "Error"
85
-
86
- // ManifestStateDeleting signifies Manifest is being deleted.
87
- ManifestStateDeleting ManifestState = "Deleting"
88
- )
89
-
90
63
// ManifestStatus defines the observed state of Manifest.
91
- type ManifestStatus struct {
92
- // State signifies current state of Manifest
93
- // +kubebuilder:validation:Enum=Ready;Processing;Error;Deleting;
94
- State ManifestState `json:"state"`
95
-
96
- // Conditions is a list of status conditions to indicate the status of Manifest
97
- // +kubebuilder:validation:Optional
98
- Conditions []ManifestCondition `json:"conditions"`
99
-
100
- // ObservedGeneration
101
- // +kubebuilder:validation:Optional
102
- ObservedGeneration int64 `json:"observedGeneration"`
103
- }
64
+ type ManifestStatus declarative.Status
104
65
105
66
// InstallItem describes install information for ManifestCondition.
106
67
type InstallItem struct {
@@ -117,53 +78,6 @@ type InstallItem struct {
117
78
Overrides string `json:"overrides"`
118
79
}
119
80
120
- // ManifestCondition describes condition information for Manifest.
121
- type ManifestCondition struct {
122
- // Type of ManifestCondition
123
- Type ManifestConditionType `json:"type"`
124
-
125
- // Status of the ManifestCondition
126
- // +kubebuilder:validation:Enum=True;False;Unknown
127
- Status ManifestConditionStatus `json:"status"`
128
-
129
- // Human-readable message indicating details about the last status transition.
130
- // +kubebuilder:validation:Optional
131
- Message string `json:"message"`
132
-
133
- // Machine-readable text indicating the reason for the condition's last transition.
134
- // +kubebuilder:validation:Optional
135
- Reason string `json:"reason"`
136
-
137
- // Timestamp for when Manifest last transitioned from one status to another.
138
- // +kubebuilder:validation:Optional
139
- LastTransitionTime * metav1.Time `json:"lastTransitionTime"`
140
-
141
- // InstallInfo contains a list of installations for Manifest
142
- // +kubebuilder:validation:Optional
143
- InstallInfo InstallItem `json:"installInfo"`
144
- }
145
-
146
- type ManifestConditionType string
147
-
148
- const (
149
- // ConditionTypeReady represents ManifestConditionType Ready.
150
- ConditionTypeReady ManifestConditionType = "Ready"
151
- )
152
-
153
- type ManifestConditionStatus string
154
-
155
- // Valid ManifestCondition Status.
156
- const (
157
- // ConditionStatusTrue signifies ManifestConditionStatus true.
158
- ConditionStatusTrue ManifestConditionStatus = "True"
159
-
160
- // ConditionStatusFalse signifies ManifestConditionStatus false.
161
- ConditionStatusFalse ManifestConditionStatus = "False"
162
-
163
- // ConditionStatusUnknown signifies ManifestConditionStatus unknown.
164
- ConditionStatusUnknown ManifestConditionStatus = "Unknown"
165
- )
166
-
167
81
//+kubebuilder:object:root=true
168
82
//+kubebuilder:subresource:status
169
83
//+kubebuilder:printcolumn:name="State",type=string,JSONPath=".status.state"
@@ -172,14 +86,26 @@ const (
172
86
// Manifest is the Schema for the manifests API.
173
87
type Manifest struct {
174
88
metav1.TypeMeta `json:",inline"`
175
- metav1.ObjectMeta `json:"metadata"`
89
+ metav1.ObjectMeta `json:"metadata,omitempty "`
176
90
177
91
// Spec specifies the content and configuration for Manifest
178
- Spec ManifestSpec `json:"spec"`
92
+ Spec ManifestSpec `json:"spec,omitempty "`
179
93
180
94
// Status signifies the current status of the Manifest
181
95
// +kubebuilder:validation:Optional
182
- Status ManifestStatus `json:"status"`
96
+ Status ManifestStatus `json:"status,omitempty"`
97
+ }
98
+
99
+ func (m * Manifest ) ComponentName () string {
100
+ return fmt .Sprintf ("manifest-%s" , m .Name )
101
+ }
102
+
103
+ func (m * Manifest ) GetStatus () declarative.Status {
104
+ return declarative .Status (m .Status )
105
+ }
106
+
107
+ func (m * Manifest ) SetStatus (status declarative.Status ) {
108
+ m .Status = ManifestStatus (status )
183
109
}
184
110
185
111
//+kubebuilder:object:root=true
0 commit comments