Skip to content

Commit 29cfdd7

Browse files
committed
Adds HelmChart as an ArtifactGenerator source
Signed-off-by: Renato Vassão <renatomvd@hotmail.com>
1 parent 1b5dd51 commit 29cfdd7

4 files changed

Lines changed: 17 additions & 1 deletion

File tree

api/v1beta1/artifactgenerator_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ type SourceReference struct {
8383
Namespace string `json:"namespace,omitempty"`
8484

8585
// Kind of the source.
86-
// +kubebuilder:validation:Enum=Bucket;GitRepository;OCIRepository
86+
// +kubebuilder:validation:Enum=Bucket;GitRepository;OCIRepository;HelmChart
8787
// +required
8888
Kind string `json:"kind"`
8989
}

config/crd/bases/source.extensions.fluxcd.io_artifactgenerators.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ spec:
158158
- Bucket
159159
- GitRepository
160160
- OCIRepository
161+
- HelmChart
161162
type: string
162163
name:
163164
description: Name of the source.

internal/controller/artifactgenerator_controller.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ func (r *ArtifactGeneratorReconciler) observeSources(ctx context.Context,
308308
return nil, fmt.Errorf("unable to get source '%s': %w", namespacedName, err)
309309
}
310310
source = &bucket
311+
case sourcev1.HelmChartKind:
312+
var chart sourcev1.HelmChart
313+
err := r.Get(ctx, namespacedName, &chart)
314+
if err != nil {
315+
if apierrors.IsNotFound(err) {
316+
return nil, err
317+
}
318+
return nil, fmt.Errorf("unable to get source '%s': %w", namespacedName, err)
319+
}
320+
source = &chart
311321
default:
312322
return nil, fmt.Errorf("source `%s` kind '%s' not supported",
313323
src.Name, src.Kind)

internal/controller/artifactgenerator_manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ func (r *ArtifactGeneratorReconciler) SetupWithManager(ctx context.Context,
8080
handler.EnqueueRequestsFromMapFunc(r.requestsForSourceChange),
8181
builder.WithPredicates(sourceChangePredicate),
8282
).
83+
Watches(
84+
&sourcev1.HelmChart{},
85+
handler.EnqueueRequestsFromMapFunc(r.requestsForSourceChange),
86+
builder.WithPredicates(sourceChangePredicate),
87+
).
8388
WithOptions(controller.Options{
8489
RateLimiter: opts.RateLimiter,
8590
}).

0 commit comments

Comments
 (0)