Skip to content

Commit d2f54dd

Browse files
authored
Merge pull request #1018 from fluxcd/meta-artifact
apis: Add `Artifact` type to `meta` package
2 parents 7201e2c + 9adb480 commit d2f54dd

2 files changed

Lines changed: 105 additions & 0 deletions

File tree

apis/meta/artifact.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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 meta
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// Artifact represents the output of a Source reconciliation.
24+
type Artifact struct {
25+
// Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
26+
// +required
27+
// +kubebuilder:validation:Pattern="^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$"
28+
Digest string `json:"digest,omitempty"`
29+
30+
// Path is the relative file path of the Artifact. It can be used to locate
31+
// the file in the root of the Artifact storage on the local file system of
32+
// the controller managing the Source.
33+
// +required
34+
Path string `json:"path"`
35+
36+
// URL is the HTTP address of the Artifact as exposed by the controller
37+
// managing the Source. It can be used to retrieve the Artifact for
38+
// consumption, e.g. by another controller applying the Artifact contents.
39+
// +required
40+
URL string `json:"url"`
41+
42+
// Revision is a human-readable identifier traceable in the origin source
43+
// system. It can be a Git commit SHA, Git tag, a Helm chart version, etc.
44+
// +required
45+
Revision string `json:"revision"`
46+
47+
// LastUpdateTime is the timestamp corresponding to the last update of the
48+
// Artifact.
49+
// +required
50+
LastUpdateTime metav1.Time `json:"lastUpdateTime"`
51+
52+
// Size is the number of bytes in the file.
53+
// +optional
54+
Size *int64 `json:"size,omitempty"`
55+
56+
// Metadata holds upstream information such as OCI annotations.
57+
// +optional
58+
Metadata map[string]string `json:"metadata,omitempty"`
59+
}
60+
61+
// HasRevision returns if the given revision matches the current Revision of
62+
// the Artifact.
63+
func (in *Artifact) HasRevision(revision string) bool {
64+
if in == nil {
65+
return false
66+
}
67+
return in.Revision == revision
68+
}
69+
70+
// HasDigest returns if the given digest matches the current Digest of the
71+
// Artifact.
72+
func (in *Artifact) HasDigest(digest string) bool {
73+
if in == nil {
74+
return false
75+
}
76+
return in.Digest == digest
77+
}

apis/meta/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)