Skip to content

Commit c8358d0

Browse files
authored
Merge pull request #1881 from fluxcd/external-artifact
[RFC-0012] Implement ExternalArtifact API
2 parents 46516fd + ba87b2a commit c8358d0

Some content is hidden

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

47 files changed

+1059
-576
lines changed

PROJECT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ resources:
4343
- group: source
4444
kind: OCIRepository
4545
version: v1
46+
- group: source
47+
kind: ExternalArtifact
48+
version: v1
4649
version: "2"

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.0
44

55
require (
66
github.com/fluxcd/pkg/apis/acl v0.9.0
7-
github.com/fluxcd/pkg/apis/meta v1.20.0
7+
github.com/fluxcd/pkg/apis/meta v1.21.0
88
k8s.io/apimachinery v0.34.0
99
sigs.k8s.io/controller-runtime v0.22.0
1010
)

api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/fluxcd/pkg/apis/acl v0.9.0 h1:wBpgsKT+jcyZEcM//OmZr9RiF8klL3ebrDp2u2ThsnA=
66
github.com/fluxcd/pkg/apis/acl v0.9.0/go.mod h1:TttNS+gocsGLwnvmgVi3/Yscwqrjc17+vhgYfqkfrV4=
7-
github.com/fluxcd/pkg/apis/meta v1.20.0 h1:l9h0kWoDZTcYV0WJkFMgDXq6Q4tSojrJ+bHpFJSsaW0=
8-
github.com/fluxcd/pkg/apis/meta v1.20.0/go.mod h1:XUAEUgT4gkWDAEN79E141tmL+v4SV50tVZ/Ojpc/ueg=
7+
github.com/fluxcd/pkg/apis/meta v1.21.0 h1:R+bN02chcs0HUmyVDQhqe/FHmYLjipVDMLnyYfNX850=
8+
github.com/fluxcd/pkg/apis/meta v1.21.0/go.mod h1:XUAEUgT4gkWDAEN79E141tmL+v4SV50tVZ/Ojpc/ueg=
99
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
1010
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
1111
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=

api/v1/artifact_types.go

Lines changed: 0 additions & 93 deletions
This file was deleted.

api/v1/bucket_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ type BucketStatus struct {
209209

210210
// Artifact represents the last successful Bucket reconciliation.
211211
// +optional
212-
Artifact *Artifact `json:"artifact,omitempty"`
212+
Artifact *meta.Artifact `json:"artifact,omitempty"`
213213

214214
// ObservedIgnore is the observed exclusion patterns used for constructing
215215
// the source artifact.
@@ -245,7 +245,7 @@ func (in *Bucket) GetRequeueAfter() time.Duration {
245245
}
246246

247247
// GetArtifact returns the latest artifact from the source if present in the status sub-resource.
248-
func (in *Bucket) GetArtifact() *Artifact {
248+
func (in *Bucket) GetArtifact() *meta.Artifact {
249249
return in.Status.Artifact
250250
}
251251

api/v1/externalartifact_types.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
Copyright 2025 The Flux authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
22+
"github.com/fluxcd/pkg/apis/meta"
23+
)
24+
25+
// ExternalArtifactSpec defines the desired state of ExternalArtifact
26+
type ExternalArtifactSpec struct {
27+
// SourceRef points to the Kubernetes custom resource for
28+
// which the artifact is generated.
29+
// +optional
30+
SourceRef *meta.NamespacedObjectKindReference `json:"sourceRef,omitempty"`
31+
}
32+
33+
// ExternalArtifactStatus defines the observed state of ExternalArtifact
34+
type ExternalArtifactStatus struct {
35+
// Artifact represents the output of an ExternalArtifact reconciliation.
36+
// +optional
37+
Artifact *meta.Artifact `json:"artifact,omitempty"`
38+
39+
// Conditions holds the conditions for the ExternalArtifact.
40+
// +optional
41+
Conditions []metav1.Condition `json:"conditions,omitempty"`
42+
}
43+
44+
// +kubebuilder:object:root=true
45+
// +kubebuilder:subresource:status
46+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
47+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
48+
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
49+
// +kubebuilder:printcolumn:name="Source",type="string",JSONPath=".spec.sourceRef.name",description=""
50+
51+
// ExternalArtifact is the Schema for the external artifacts API
52+
type ExternalArtifact struct {
53+
metav1.TypeMeta `json:",inline"`
54+
metav1.ObjectMeta `json:"metadata,omitempty"`
55+
56+
Spec ExternalArtifactSpec `json:"spec,omitempty"`
57+
Status ExternalArtifactStatus `json:"status,omitempty"`
58+
}
59+
60+
// ExternalArtifactList contains a list of ExternalArtifact
61+
// +kubebuilder:object:root=true
62+
type ExternalArtifactList struct {
63+
metav1.TypeMeta `json:",inline"`
64+
metav1.ListMeta `json:"metadata,omitempty"`
65+
Items []ExternalArtifact `json:"items"`
66+
}
67+
68+
func init() {
69+
SchemeBuilder.Register(&ExternalArtifact{}, &ExternalArtifactList{})
70+
}

api/v1/gitrepository_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,12 @@ type GitRepositoryStatus struct {
256256

257257
// Artifact represents the last successful GitRepository reconciliation.
258258
// +optional
259-
Artifact *Artifact `json:"artifact,omitempty"`
259+
Artifact *meta.Artifact `json:"artifact,omitempty"`
260260

261261
// IncludedArtifacts contains a list of the last successfully included
262262
// Artifacts as instructed by GitRepositorySpec.Include.
263263
// +optional
264-
IncludedArtifacts []*Artifact `json:"includedArtifacts,omitempty"`
264+
IncludedArtifacts []*meta.Artifact `json:"includedArtifacts,omitempty"`
265265

266266
// ObservedIgnore is the observed exclusion patterns used for constructing
267267
// the source artifact.
@@ -319,7 +319,7 @@ func (in GitRepository) GetRequeueAfter() time.Duration {
319319

320320
// GetArtifact returns the latest Artifact from the GitRepository if present in
321321
// the status sub-resource.
322-
func (in *GitRepository) GetArtifact() *Artifact {
322+
func (in *GitRepository) GetArtifact() *meta.Artifact {
323323
return in.Status.Artifact
324324
}
325325

api/v1/helmchart_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ type HelmChartStatus struct {
149149

150150
// Artifact represents the output of the last successful reconciliation.
151151
// +optional
152-
Artifact *Artifact `json:"artifact,omitempty"`
152+
Artifact *meta.Artifact `json:"artifact,omitempty"`
153153

154154
meta.ReconcileRequestStatus `json:",inline"`
155155
}
@@ -182,7 +182,7 @@ func (in HelmChart) GetRequeueAfter() time.Duration {
182182

183183
// GetArtifact returns the latest artifact from the source if present in the
184184
// status sub-resource.
185-
func (in *HelmChart) GetArtifact() *Artifact {
185+
func (in *HelmChart) GetArtifact() *meta.Artifact {
186186
return in.Status.Artifact
187187
}
188188

api/v1/helmrepository_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ type HelmRepositoryStatus struct {
150150

151151
// Artifact represents the last successful HelmRepository reconciliation.
152152
// +optional
153-
Artifact *Artifact `json:"artifact,omitempty"`
153+
Artifact *meta.Artifact `json:"artifact,omitempty"`
154154

155155
meta.ReconcileRequestStatus `json:",inline"`
156156
}
@@ -191,7 +191,7 @@ func (in HelmRepository) GetTimeout() time.Duration {
191191

192192
// GetArtifact returns the latest artifact from the source if present in the
193193
// status sub-resource.
194-
func (in *HelmRepository) GetArtifact() *Artifact {
194+
func (in *HelmRepository) GetArtifact() *meta.Artifact {
195195
return in.Status.Artifact
196196
}
197197

api/v1/ocirepository_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ type OCIRepositoryStatus struct {
200200

201201
// Artifact represents the output of the last successful OCI Repository sync.
202202
// +optional
203-
Artifact *Artifact `json:"artifact,omitempty"`
203+
Artifact *meta.Artifact `json:"artifact,omitempty"`
204204

205205
// ObservedIgnore is the observed exclusion patterns used for constructing
206206
// the source artifact.
@@ -241,7 +241,7 @@ func (in OCIRepository) GetRequeueAfter() time.Duration {
241241

242242
// GetArtifact returns the latest Artifact from the OCIRepository if present in
243243
// the status sub-resource.
244-
func (in *OCIRepository) GetArtifact() *Artifact {
244+
func (in *OCIRepository) GetArtifact() *meta.Artifact {
245245
return in.Status.Artifact
246246
}
247247

0 commit comments

Comments
 (0)