Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 844b773

Browse files
!feat: migrate module manager to declarative v2 (#203)
* !feat: migrate module manager to declarative v2 * !feat: migrate module manager to declarative v2 / remove declarative v1 * !feat: migrate module manager to declarative v2 / remove declarative v1 * !feat: migrate module manager to declarative v2 / remove declarative v1 * chore: fixup ci rate limit * chore: remaining tests and removal of todos * chore: enable periodic consistency check * chore: cleanup & dep updates * chore: add configurable log level to mm * chore: apply QPS/Burts from KCP clients into SKR * chore: make status fields optional * chore: move crd get after prerequisite connection check * chore: fixup always setting conditions to false in initialize * feat: introduce parsing cache * feat: manifest custom ready check * chore: avoid chart loading when not handlin prerequisites * !!feat: crazy async syncs * Revert "!!feat: crazy async syncs" This reverts commit 2322bbe. * chore: add omitempty in favor of optional
1 parent 3cfa8d2 commit 844b773

Some content is hidden

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

72 files changed

+1975
-5903
lines changed

.github/workflows/ci.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,15 @@ jobs:
9393
- name: Override Kustomize Controller Image TAG in Pull Request to PR Image
9494
if: github.event_name == 'pull_request'
9595
run: |
96-
wget -qO - "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
96+
wget --header="Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
97+
-qO - "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
9798
mv kustomize /usr/local/bin/
9899
cd $(go env GOPATH)/src/github.com/${{ github.repository }}/config/manager
99100
kustomize edit set image controller="*:PR-${{ github.event.pull_request.number }}"
100101
- name: Set up k3d
101-
run: wget -qO - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=$K3D_VERSION bash
102+
run: |
103+
wget --header="Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
104+
-qO - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=$K3D_VERSION bash
102105
- id: kyma
103106
uses: jakobmoellersap/[email protected]
104107
with:

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN go mod download
1313
COPY main.go main.go
1414
COPY api api/
1515
COPY pkg pkg/
16-
COPY internal/pkg internal/pkg/
16+
COPY internal internal/
1717
COPY controllers controllers/
1818

1919
# Build

api/v1alpha1/manifest_types.go

+24-98
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
"fmt"
21+
22+
declarative "github.com/kyma-project/module-manager/pkg/declarative/v2"
2023
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2124
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2225
"k8s.io/apimachinery/pkg/runtime"
@@ -26,15 +29,6 @@ import (
2629

2730
const ManifestKind = "Manifest"
2831

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-
3832
// InstallInfo defines installation information.
3933
type InstallInfo struct {
4034
// Source can either be described as ImageSpec, HelmChartSpec or KustomizeSpec
@@ -48,59 +42,26 @@ type InstallInfo struct {
4842
// ManifestSpec defines the specification of Manifest.
4943
type ManifestSpec struct {
5044
// Remote indicates if Manifest should be installed on a remote cluster
51-
// +kubebuilder:validation:Optional
5245
// +kubebuilder:default:=true
53-
Remote bool `json:"remote"`
46+
Remote bool `json:"remote,omitempty"`
5447

5548
// Config specifies OCI image configuration for Manifest
56-
// +kubebuilder:validation:Optional
57-
Config types.ImageSpec `json:"config"`
49+
Config types.ImageSpec `json:"config,omitempty"`
5850

5951
// Installs specifies a list of installations for Manifest
6052
Installs []InstallInfo `json:"installs"`
6153

6254
//+kubebuilder:pruning:PreserveUnknownFields
63-
// +kubebuilder:validation:Optional
55+
//+kubebuilder:validation:XEmbeddedResource
6456
// Resource specifies a resource to be watched for state updates
65-
Resource unstructured.Unstructured `json:"resource"`
57+
Resource unstructured.Unstructured `json:"resource,omitempty"`
6658

6759
// CRDs specifies the custom resource definitions' ImageSpec
68-
// +kubebuilder:validation:Optional
69-
CRDs types.ImageSpec `json:"crds"`
60+
CRDs types.ImageSpec `json:"crds,omitempty"`
7061
}
7162

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-
9063
// 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
10465

10566
// InstallItem describes install information for ManifestCondition.
10667
type InstallItem struct {
@@ -117,53 +78,6 @@ type InstallItem struct {
11778
Overrides string `json:"overrides"`
11879
}
11980

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-
16781
//+kubebuilder:object:root=true
16882
//+kubebuilder:subresource:status
16983
//+kubebuilder:printcolumn:name="State",type=string,JSONPath=".status.state"
@@ -172,14 +86,26 @@ const (
17286
// Manifest is the Schema for the manifests API.
17387
type Manifest struct {
17488
metav1.TypeMeta `json:",inline"`
175-
metav1.ObjectMeta `json:"metadata"`
89+
metav1.ObjectMeta `json:"metadata,omitempty"`
17690

17791
// Spec specifies the content and configuration for Manifest
178-
Spec ManifestSpec `json:"spec"`
92+
Spec ManifestSpec `json:"spec,omitempty"`
17993

18094
// Status signifies the current status of the Manifest
18195
// +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)
183109
}
184110

185111
//+kubebuilder:object:root=true

api/v1alpha1/zz_generated.deepcopy.go

+9-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)