@@ -65,6 +65,7 @@ import (
6565 "github.com/fluxcd/pkg/ssa"
6666 "github.com/fluxcd/pkg/tar"
6767 sourcev1 "github.com/fluxcd/source-controller/api/v1"
68+ sourcev1alpha1 "github.com/fluxcd/source-controller/api/v1alpha1"
6869 sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
6970
7071 kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
@@ -159,6 +160,29 @@ func (r *KustomizationReconciler) SetupWithManager(ctx context.Context, mgr ctrl
159160 handler .EnqueueRequestsFromMapFunc (r .requestsForRevisionChangeOf (bucketIndexKey )),
160161 builder .WithPredicates (SourceRevisionChangePredicate {}),
161162 ).
163+ Watches (
164+ & sourcev1alpha1.Artifact {},
165+ handler .EnqueueRequestsFromMapFunc (
166+ func (ctx context.Context , a client.Object ) []reconcile.Request {
167+ artifact , ok := a .(* sourcev1alpha1.Artifact )
168+ if ! ok {
169+ return nil
170+ }
171+
172+ var kustomizations kustomizev1.KustomizationList
173+ if err := r .List (ctx , & kustomizations , client.MatchingFields {".spec.sourceRef.name" : artifact .Name , ".spec.sourceRef.kinde" : "artifact" }); err != nil {
174+ return nil
175+ }
176+ requests := make ([]reconcile.Request , len (kustomizations .Items ))
177+ for i := range kustomizations .Items {
178+ requests [i ] = reconcile.Request {
179+ NamespacedName : client .ObjectKeyFromObject (& kustomizations .Items [i ]),
180+ }
181+ }
182+ return requests
183+ },
184+ ),
185+ ).
162186 WithOptions (controller.Options {
163187 RateLimiter : opts .RateLimiter ,
164188 }).
@@ -569,6 +593,16 @@ func (r *KustomizationReconciler) getSource(ctx context.Context,
569593 return src , fmt .Errorf ("unable to get source '%s': %w" , namespacedName , err )
570594 }
571595 src = & bucket
596+ case sourcev1alpha1 .ArtifactKind :
597+ var artifact sourcev1alpha1.Artifact
598+ err := r .Client .Get (ctx , namespacedName , & artifact )
599+ if err != nil {
600+ if apierrors .IsNotFound (err ) {
601+ return src , err
602+ }
603+ return src , fmt .Errorf ("unable to get source '%s': %w" , namespacedName , err )
604+ }
605+ src = & artifact
572606 default :
573607 return src , fmt .Errorf ("source `%s` kind '%s' not supported" ,
574608 obj .Spec .SourceRef .Name , obj .Spec .SourceRef .Kind )
0 commit comments