Skip to content

Commit f28d639

Browse files
committed
[cozystack-operator] Add Package and PackageSource reconcilers
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 2d4e568 commit f28d639

10 files changed

Lines changed: 1452 additions & 3 deletions

File tree

‎api/v1alpha1/package_types.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,15 @@ type PackageStatus struct {
8686
// Conditions represents the latest available observations of a Package's state
8787
// +optional
8888
Conditions []metav1.Condition `json:"conditions,omitempty"`
89+
90+
// Dependencies tracks the readiness status of each dependency
91+
// Key is the dependency package name, value indicates if the dependency is ready
92+
// +optional
93+
Dependencies map[string]DependencyStatus `json:"dependencies,omitempty"`
94+
}
95+
96+
// DependencyStatus represents the readiness status of a dependency
97+
type DependencyStatus struct {
98+
// Ready indicates whether the dependency is ready
99+
Ready bool `json:"ready"`
89100
}

‎api/v1alpha1/packagesource_types.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
// +kubebuilder:object:root=true
24-
// +kubebuilder:resource:scope=Cluster,shortName={pkgsrc,pkgsrcs}
24+
// +kubebuilder:resource:scope=Cluster,shortName={pks}
2525
// +kubebuilder:subresource:status
2626
// +kubebuilder:printcolumn:name="Variants",type="string",JSONPath=".status.variants",description="Package variants (comma-separated)"
2727
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status",description="Ready status"

‎api/v1alpha1/zz_generated.deepcopy.go‎

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

‎cmd/cozystack-operator/main.go‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
cozyv1alpha1 "github.com/cozystack/cozystack/api/v1alpha1"
3232
helmv2 "github.com/fluxcd/helm-controller/api/v2"
3333
sourcev1 "github.com/fluxcd/source-controller/api/v1"
34+
sourcewatcherv1beta1 "github.com/fluxcd/source-watcher/api/v2/v1beta1"
3435
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
3536
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3637
"k8s.io/apimachinery/pkg/runtime"
@@ -45,6 +46,7 @@ import (
4546
"sigs.k8s.io/controller-runtime/pkg/webhook"
4647

4748
"github.com/cozystack/cozystack/internal/fluxinstall"
49+
"github.com/cozystack/cozystack/internal/operator"
4850
// +kubebuilder:scaffold:imports
4951
)
5052

@@ -59,6 +61,7 @@ func init() {
5961
utilruntime.Must(cozyv1alpha1.AddToScheme(scheme))
6062
utilruntime.Must(helmv2.AddToScheme(scheme))
6163
utilruntime.Must(sourcev1.AddToScheme(scheme))
64+
utilruntime.Must(sourcewatcherv1beta1.AddToScheme(scheme))
6265
// +kubebuilder:scaffold:scheme
6366
}
6467

@@ -166,6 +169,24 @@ func main() {
166169
}
167170
}
168171

172+
// Setup PackageSource reconciler
173+
if err := (&operator.PackageSourceReconciler{
174+
Client: mgr.GetClient(),
175+
Scheme: mgr.GetScheme(),
176+
}).SetupWithManager(mgr); err != nil {
177+
setupLog.Error(err, "unable to create controller", "controller", "PackageSource")
178+
os.Exit(1)
179+
}
180+
181+
// Setup Package reconciler
182+
if err := (&operator.PackageReconciler{
183+
Client: mgr.GetClient(),
184+
Scheme: mgr.GetScheme(),
185+
}).SetupWithManager(mgr); err != nil {
186+
setupLog.Error(err, "unable to create controller", "controller", "Package")
187+
os.Exit(1)
188+
}
189+
169190
// +kubebuilder:scaffold:builder
170191

171192
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {

‎go.mod‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ go 1.25.0
77
require (
88
github.com/fluxcd/helm-controller/api v1.4.3
99
github.com/fluxcd/source-controller/api v1.7.4
10+
github.com/fluxcd/source-watcher/api/v2 v2.0.3
1011
github.com/go-logr/logr v1.4.3
1112
github.com/go-logr/zapr v1.3.0
1213
github.com/google/gofuzz v1.2.0

‎go.sum‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ github.com/fluxcd/pkg/apis/meta v1.23.0 h1:fLis5YcHnOsyKYptzBtituBm5EWNx13I0bXQs
4545
github.com/fluxcd/pkg/apis/meta v1.23.0/go.mod h1:UWsIbBPCxYvoVklr2mV2uLFBf/n17dNAmKFjRfApdDo=
4646
github.com/fluxcd/source-controller/api v1.7.4 h1:+EOVnRA9LmLxOx7J273l7IOEU39m+Slt/nQGBy69ygs=
4747
github.com/fluxcd/source-controller/api v1.7.4/go.mod h1:ruf49LEgZRBfcP+eshl2n9SX1MfHayCcViAIGnZcaDY=
48+
github.com/fluxcd/source-watcher/api/v2 v2.0.3 h1:SsVGAaMBxzvcgrOz/Kl6c2ybMHVqoiEFwtI+bDuSeSs=
49+
github.com/fluxcd/source-watcher/api/v2 v2.0.3/go.mod h1:Nx3QZweVyuhaOtSNrw+oxifG+qrakPvjgNAN9qlUTb0=
4850
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
4951
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
5052
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=

0 commit comments

Comments
 (0)