Skip to content

Commit d45da10

Browse files
committed
Import ExternalArtifact CRD
Signed-off-by: Stefan Prodan <[email protected]>
1 parent 251bc85 commit d45da10

File tree

10 files changed

+51
-43
lines changed

10 files changed

+51
-43
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ SOURCE_CRD_VER = $(CRD_DEP_ROOT)/.src-crd-$(SOURCE_VER)
3737

3838
# HelmChart source CRD.
3939
HELMCHART_SOURCE_CRD ?= $(CRD_DEP_ROOT)/source.toolkit.fluxcd.io_helmcharts.yaml
40+
OCIREPO_CRD ?= $(CRD_DEP_ROOT)/source.toolkit.fluxcd.io_ocirepositories.yaml
41+
EA_CRD ?= $(CRD_DEP_ROOT)/source.toolkit.fluxcd.io_externalartifacts.yaml
4042

4143
# API (doc) generation utilities
4244
CONTROLLER_GEN_VERSION ?= v0.19.0
@@ -135,8 +137,14 @@ $(SOURCE_CRD_VER):
135137
$(HELMCHART_SOURCE_CRD):
136138
curl -s https://raw.githubusercontent.com/fluxcd/source-controller/${SOURCE_VER}/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml > $(HELMCHART_SOURCE_CRD)
137139

140+
$(OCIREPO_CRD):
141+
curl -s https://raw.githubusercontent.com/fluxcd/source-controller/${SOURCE_VER}/config/crd/bases/source.toolkit.fluxcd.io_ocirepositories.yaml -o $(OCIREPO_CRD)
142+
143+
$(EA_CRD):
144+
curl -s https://raw.githubusercontent.com/fluxcd/source-controller/${SOURCE_VER}/config/crd/bases/source.toolkit.fluxcd.io_externalartifacts.yaml -o $(EA_CRD)
145+
138146
# Download the CRDs the controller depends on
139-
download-crd-deps: $(SOURCE_CRD_VER) $(HELMCHART_SOURCE_CRD)
147+
download-crd-deps: $(SOURCE_CRD_VER) $(HELMCHART_SOURCE_CRD) $(OCIREPO_CRD) $(EA_CRD)
140148

141149
# Delete the downloaded CRD dependencies.
142150
cleanup-crd-deps:

api/v2/reference_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type CrossNamespaceSourceReference struct {
5050
APIVersion string `json:"apiVersion,omitempty"`
5151

5252
// Kind of the referent.
53-
// +kubebuilder:validation:Enum=OCIRepository;HelmChart
53+
// +kubebuilder:validation:Enum=OCIRepository;HelmChart;ExternalArtifact
5454
// +required
5555
Kind string `json:"kind"`
5656

config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ spec:
203203
enum:
204204
- OCIRepository
205205
- HelmChart
206+
- ExternalArtifact
206207
type: string
207208
name:
208209
description: Name of the referent.

config/default/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
namespace: helm-system
44
resources:
5-
- https://github.com/fluxcd/source-controller/releases/download/v1.6.0/source-controller.crds.yaml
6-
- https://github.com/fluxcd/source-controller/releases/download/v1.6.0/source-controller.deployment.yaml
5+
- https://github.com/fluxcd/source-controller/releases/download/v1.7.0-rc.2/source-controller.crds.yaml
6+
- https://github.com/fluxcd/source-controller/releases/download/v1.7.0-rc.2/source-controller.deployment.yaml
77
- ../crd
88
- ../rbac
99
- ../manager

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ require (
2121
github.com/fluxcd/pkg/apis/acl v0.9.0
2222
github.com/fluxcd/pkg/apis/event v0.19.0
2323
github.com/fluxcd/pkg/apis/kustomize v1.12.0
24-
github.com/fluxcd/pkg/apis/meta v1.20.0
25-
github.com/fluxcd/pkg/auth v0.29.0
24+
github.com/fluxcd/pkg/apis/meta v1.21.0
25+
github.com/fluxcd/pkg/auth v0.30.0
2626
github.com/fluxcd/pkg/cache v0.11.0
27-
github.com/fluxcd/pkg/chartutil v1.11.0
28-
github.com/fluxcd/pkg/runtime v0.82.0
27+
github.com/fluxcd/pkg/chartutil v1.12.0
28+
github.com/fluxcd/pkg/runtime v0.83.0
2929
github.com/fluxcd/pkg/ssa v0.53.0
3030
github.com/fluxcd/pkg/testserver v0.13.0
31-
github.com/fluxcd/source-controller/api v1.6.0
31+
github.com/fluxcd/source-controller/api v1.7.0-rc.2
3232
github.com/go-logr/logr v1.4.3
3333
github.com/google/cel-go v0.26.1
3434
github.com/google/go-cmp v0.7.0
@@ -100,7 +100,7 @@ require (
100100
github.com/containerd/platforms v0.2.1 // indirect
101101
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
102102
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
103-
github.com/docker/cli v28.2.2+incompatible // indirect
103+
github.com/docker/cli v28.3.3+incompatible // indirect
104104
github.com/docker/docker-credential-helpers v0.9.3 // indirect
105105
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
106106
github.com/evanphx/json-patch v5.9.11+incompatible // indirect

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr
124124
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
125125
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
126126
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
127-
github.com/docker/cli v28.2.2+incompatible h1:qzx5BNUDFqlvyq4AHzdNB7gSyVTmU4cgsyN9SdInc1A=
128-
github.com/docker/cli v28.2.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
127+
github.com/docker/cli v28.3.3+incompatible h1:fp9ZHAr1WWPGdIWBM1b3zLtgCF+83gRdVMTJsUeiyAo=
128+
github.com/docker/cli v28.3.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
129129
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
130130
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
131131
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8=
@@ -152,22 +152,22 @@ github.com/fluxcd/pkg/apis/event v0.19.0 h1:ZJU2voontkzp5rNYA4JMOu40S4tRcrWi4Do5
152152
github.com/fluxcd/pkg/apis/event v0.19.0/go.mod h1:deuIyUb6lh+Z1Ccvwwxhm1wNM3kpSo+vF1IgRnpaZfQ=
153153
github.com/fluxcd/pkg/apis/kustomize v1.12.0 h1:KvZN6xwgP/dNSeckL4a/Uv715XqiN1C3xS+jGcPejtE=
154154
github.com/fluxcd/pkg/apis/kustomize v1.12.0/go.mod h1:OojLxIdKm1JAAdh3sL4j4F+vfrLKb7kq1vr8bpyEKgg=
155-
github.com/fluxcd/pkg/apis/meta v1.20.0 h1:l9h0kWoDZTcYV0WJkFMgDXq6Q4tSojrJ+bHpFJSsaW0=
156-
github.com/fluxcd/pkg/apis/meta v1.20.0/go.mod h1:XUAEUgT4gkWDAEN79E141tmL+v4SV50tVZ/Ojpc/ueg=
157-
github.com/fluxcd/pkg/auth v0.29.0 h1:lLc63zjodqIqg5ydlU/Kp3Qa+wvh6G2khjop5MHALvk=
158-
github.com/fluxcd/pkg/auth v0.29.0/go.mod h1:bjZ+6RMSGgsQQK+aPfVP8HWuBbb+FLlFxMiqd8ywzik=
155+
github.com/fluxcd/pkg/apis/meta v1.21.0 h1:R+bN02chcs0HUmyVDQhqe/FHmYLjipVDMLnyYfNX850=
156+
github.com/fluxcd/pkg/apis/meta v1.21.0/go.mod h1:XUAEUgT4gkWDAEN79E141tmL+v4SV50tVZ/Ojpc/ueg=
157+
github.com/fluxcd/pkg/auth v0.30.0 h1:7JMnY1ClArvOsadt6hOxceu8Q2hLsYHFMt0DV3BQl4Q=
158+
github.com/fluxcd/pkg/auth v0.30.0/go.mod h1:me38o1nDfSLw6YvnkT9Ce/zqJZICZSA7j5pNMR3JUbc=
159159
github.com/fluxcd/pkg/cache v0.11.0 h1:fsE8S+una21fSNw4MDXGUIf0Gf1J+pqa4RbsVKf2aTI=
160160
github.com/fluxcd/pkg/cache v0.11.0/go.mod h1:2RTIU6PsJniHmfnllQWFEo7fa5V8KQlnMgn4o0sme40=
161-
github.com/fluxcd/pkg/chartutil v1.11.0 h1:mtMqxsIIHLHSZS+D/9OfFS5ykABIOD2EOQbo3RyvjZY=
162-
github.com/fluxcd/pkg/chartutil v1.11.0/go.mod h1:zQEbp6pHdRnhZN+RBjpQorRf9HKhqiO0bTk4vaOxbNU=
163-
github.com/fluxcd/pkg/runtime v0.82.0 h1:VdPPRJtj8/rcBdqY7GZSffoxe5elFHt+ymwQHNbPOlc=
164-
github.com/fluxcd/pkg/runtime v0.82.0/go.mod h1:rIDynMhU5upbn8ce3bXQhH5L6vtDw5MELycvtJG/+og=
161+
github.com/fluxcd/pkg/chartutil v1.12.0 h1:AsOXWYQIUpZMCtlyQeaPmlWBYqSfHZTQ6A6eTGAhBLc=
162+
github.com/fluxcd/pkg/chartutil v1.12.0/go.mod h1:W1VxE52pIaimf9upYQW/fvonU3BDs2zxM2zdg/48vEE=
163+
github.com/fluxcd/pkg/runtime v0.83.0 h1:XzpwKzo7GqfBE/BKpxG5B4U7cUnojnB407S9Dpp6oLU=
164+
github.com/fluxcd/pkg/runtime v0.83.0/go.mod h1:r8KLvXRguKtpLAa66fA19rIbwPViXm8az038IUabYvw=
165165
github.com/fluxcd/pkg/ssa v0.53.0 h1:EtKFAYWXohIGkzPhIrv8NbV5zYr4iZHY6DaNxMR9+bU=
166166
github.com/fluxcd/pkg/ssa v0.53.0/go.mod h1:0IZxnnH8XkDkFzWjoMJsFEwPIWPOk3Gc/WR5+gT/KgI=
167167
github.com/fluxcd/pkg/testserver v0.13.0 h1:xEpBcEYtD7bwvZ+i0ZmChxKkDo/wfQEV3xmnzVybSSg=
168168
github.com/fluxcd/pkg/testserver v0.13.0/go.mod h1:akRYv3FLQUsme15na9ihECRG6hBuqni4XEY9W8kzs8E=
169-
github.com/fluxcd/source-controller/api v1.6.0 h1:IxfjUczJ2pzbXIef6iQ0RHEH4AYA9anJfTGK8dzwODM=
170-
github.com/fluxcd/source-controller/api v1.6.0/go.mod h1:ZJcAi0nemsnBxjVgmJl0WQzNvB0rMETxQMTdoFosmMw=
169+
github.com/fluxcd/source-controller/api v1.7.0-rc.2 h1:ny21QMsZ1Gs5t5Rx7Pd1s0xc5UT7B4hGySzX+mhWHnw=
170+
github.com/fluxcd/source-controller/api v1.7.0-rc.2/go.mod h1:sbJibK4Ik+2AuTRRLXPA+n2u6nLUIGaxC07ava+RqeM=
171171
github.com/foxcpp/go-mockdns v1.1.0 h1:jI0rD8M0wuYAxL7r/ynTrCQQq0BVqfB99Vgk7DlmewI=
172172
github.com/foxcpp/go-mockdns v1.1.0/go.mod h1:IhLeSFGed3mJIAXPH2aiRQB+kqz7oqu8ld2qVbOu7Wk=
173173
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=

internal/controller/helmrelease_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ func isSourceReady(obj sourcev1.Source) (bool, string) {
838838
return false, fmt.Sprintf("unknown sourcev1 type: %T", obj)
839839
}
840840

841-
func isReady(obj conditions.Getter, artifact *sourcev1.Artifact) (bool, string) {
841+
func isReady(obj conditions.Getter, artifact *meta.Artifact) (bool, string) {
842842
observedGen, err := object.GetStatusObservedGeneration(obj)
843843
if err != nil {
844844
return false, err.Error()

internal/controller/helmrelease_controller_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) {
258258
},
259259
Status: sourcev1.HelmChartStatus{
260260
ObservedGeneration: 1,
261-
Artifact: &sourcev1.Artifact{},
261+
Artifact: &meta.Artifact{},
262262
Conditions: []metav1.Condition{
263263
{
264264
Type: meta.ReadyCondition,
@@ -314,7 +314,7 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) {
314314
},
315315
Status: sourcev1.HelmChartStatus{
316316
ObservedGeneration: 2,
317-
Artifact: &sourcev1.Artifact{},
317+
Artifact: &meta.Artifact{},
318318
Conditions: []metav1.Condition{
319319
{
320320
Type: meta.ReadyCondition,
@@ -372,7 +372,7 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) {
372372
},
373373
Status: sourcev1.HelmChartStatus{
374374
ObservedGeneration: 1,
375-
Artifact: &sourcev1.Artifact{
375+
Artifact: &meta.Artifact{
376376
URL: testServer.URL() + "/does-not-exist",
377377
},
378378
Conditions: []metav1.Condition{
@@ -1134,7 +1134,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T)
11341134
},
11351135
Status: sourcev1.HelmChartStatus{
11361136
ObservedGeneration: 2,
1137-
Artifact: &sourcev1.Artifact{
1137+
Artifact: &meta.Artifact{
11381138
URL: testServer.URL() + "/does-not-exist",
11391139
},
11401140
Conditions: []metav1.Condition{
@@ -1190,7 +1190,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T)
11901190
},
11911191
Status: sourcev1.HelmChartStatus{
11921192
ObservedGeneration: 1,
1193-
Artifact: &sourcev1.Artifact{},
1193+
Artifact: &meta.Artifact{},
11941194
Conditions: []metav1.Condition{
11951195
{
11961196
Type: meta.ReadyCondition,
@@ -1211,7 +1211,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromHelmChartSource(t *testing.T)
12111211
},
12121212
Status: sourcev1.HelmChartStatus{
12131213
ObservedGeneration: 2,
1214-
Artifact: &sourcev1.Artifact{
1214+
Artifact: &meta.Artifact{
12151215
URL: testServer.URL() + "/does-not-exist",
12161216
},
12171217
Conditions: []metav1.Condition{
@@ -1601,7 +1601,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin
16011601
},
16021602
Status: sourcev1.OCIRepositoryStatus{
16031603
ObservedGeneration: 2,
1604-
Artifact: &sourcev1.Artifact{},
1604+
Artifact: &meta.Artifact{},
16051605
Conditions: []metav1.Condition{
16061606
{
16071607
Type: meta.ReadyCondition,
@@ -1663,7 +1663,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin
16631663
},
16641664
Status: sourcev1.OCIRepositoryStatus{
16651665
ObservedGeneration: 2,
1666-
Artifact: &sourcev1.Artifact{
1666+
Artifact: &meta.Artifact{
16671667
URL: testServer.URL() + "/does-not-exist",
16681668
},
16691669
Conditions: []metav1.Condition{
@@ -1719,7 +1719,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin
17191719
},
17201720
Status: sourcev1.HelmChartStatus{
17211721
ObservedGeneration: 1,
1722-
Artifact: &sourcev1.Artifact{},
1722+
Artifact: &meta.Artifact{},
17231723
Conditions: []metav1.Condition{
17241724
{
17251725
Type: meta.ReadyCondition,
@@ -1740,7 +1740,7 @@ func TestHelmReleaseReconciler_reconcileReleaseFromOCIRepositorySource(t *testin
17401740
},
17411741
Status: sourcev1.OCIRepositoryStatus{
17421742
ObservedGeneration: 2,
1743-
Artifact: &sourcev1.Artifact{
1743+
Artifact: &meta.Artifact{
17441744
URL: testServer.URL() + "/does-not-exist",
17451745
},
17461746
Conditions: []metav1.Condition{
@@ -3999,7 +3999,7 @@ func Test_isHelmChartReady(t *testing.T) {
39993999
Status: metav1.ConditionTrue,
40004000
},
40014001
},
4002-
Artifact: &sourcev1.Artifact{},
4002+
Artifact: &meta.Artifact{},
40034003
},
40044004
}
40054005

@@ -4089,7 +4089,7 @@ func Test_isOCIRepositoryReady(t *testing.T) {
40894089
Status: metav1.ConditionTrue,
40904090
},
40914091
},
4092-
Artifact: &sourcev1.Artifact{},
4092+
Artifact: &meta.Artifact{},
40934093
},
40944094
}
40954095

@@ -4210,7 +4210,7 @@ func Test_TryMutateChartWithSourceRevision(t *testing.T) {
42104210

42114211
s := &sourcev1.OCIRepository{
42124212
Status: sourcev1.OCIRepositoryStatus{
4213-
Artifact: &sourcev1.Artifact{
4213+
Artifact: &meta.Artifact{
42144214
Revision: tt.revision,
42154215
},
42164216
},

internal/predicates/source_predicate_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import (
2727
"sigs.k8s.io/controller-runtime/pkg/event"
2828

2929
"github.com/fluxcd/pkg/apis/meta"
30-
31-
sourcev1 "github.com/fluxcd/source-controller/api/v1"
3230
)
3331

3432
func TestSourceRevisionChangePredicate_Update(t *testing.T) {
@@ -124,9 +122,9 @@ func (m sourceMock) GetRequeueAfter() time.Duration {
124122
return time.Second * 0
125123
}
126124

127-
func (m *sourceMock) GetArtifact() *sourcev1.Artifact {
125+
func (m *sourceMock) GetArtifact() *meta.Artifact {
128126
if m.revision != "" {
129-
return &sourcev1.Artifact{
127+
return &meta.Artifact{
130128
Revision: m.revision,
131129
}
132130
}

internal/testutil/save_chart.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ import (
2222
"path/filepath"
2323
"strings"
2424

25-
sourcev1 "github.com/fluxcd/source-controller/api/v1"
2625
"github.com/opencontainers/go-digest"
2726
"helm.sh/helm/v3/pkg/chart"
2827
"helm.sh/helm/v3/pkg/chartutil"
2928
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3029
"k8s.io/apimachinery/pkg/util/rand"
30+
31+
"github.com/fluxcd/pkg/apis/meta"
3132
)
3233

3334
// SaveChart saves the given chart to the given directory, and returns the
@@ -61,7 +62,7 @@ func SaveChart(c *chart.Chart, outDir string) (string, error) {
6162
// SaveChartAsArtifact saves the given chart to the given directory, and
6263
// returns an artifact with the chart's metadata. The chart is saved with a
6364
// random suffix to avoid name collisions.
64-
func SaveChartAsArtifact(c *chart.Chart, algo digest.Algorithm, baseURL, outDir string) (*sourcev1.Artifact, error) {
65+
func SaveChartAsArtifact(c *chart.Chart, algo digest.Algorithm, baseURL, outDir string) (*meta.Artifact, error) {
6566
abs, err := SaveChart(c, outDir)
6667
if err != nil {
6768
return nil, err
@@ -85,7 +86,7 @@ func SaveChartAsArtifact(c *chart.Chart, algo digest.Algorithm, baseURL, outDir
8586
}
8687
fileURL := strings.TrimSuffix(baseURL, "/") + "/" + rel
8788

88-
return &sourcev1.Artifact{
89+
return &meta.Artifact{
8990
Path: abs,
9091
URL: fileURL,
9192
Revision: c.Metadata.Version,

0 commit comments

Comments
 (0)