@@ -16,6 +16,8 @@ package v1alpha1
1616
1717import "strings"
1818
19+ // Image represents a container image asset along with metadata such as OS,
20+ // architecture, and registry information.
1921type Image struct {
2022 // +kubebuilder:validation:Required
2123 // The asset name
@@ -42,10 +44,14 @@ type Image struct {
4244 ImageDigest string `json:"imageDigest,omitempty"`
4345}
4446
47+ // VersionedImage returns the full URI of the Image, including registry,
48+ // repository, and tag or digest.
4549func (i Image ) VersionedImage () string {
4650 return i .URI
4751}
4852
53+ // Image returns the repository URI of the Image, excluding the tag or digest
54+ // if one is present.
4955func (i Image ) Image () string {
5056 lastInd := strings .LastIndex (i .URI , ":" )
5157 if lastInd == - 1 {
@@ -54,6 +60,7 @@ func (i Image) Image() string {
5460 return i .URI [:lastInd ]
5561}
5662
63+ // Tag returns the tag portion of the Image's URI if present, otherwise an empty string.
5764func (i Image ) Tag () string {
5865 lastInd := strings .LastIndex (i .URI , ":" )
5966 if lastInd == - 1 || lastInd == len (i .URI )- 1 {
@@ -62,6 +69,8 @@ func (i Image) Tag() string {
6269 return i .URI [lastInd + 1 :]
6370}
6471
72+ // ChartName constructs a typical Helm chart artifact name (with ".tgz")
73+ // from the Image's name by replacing the last colon with a hyphen.
6574func (i Image ) ChartName () string {
6675 lastInd := strings .LastIndex (i .Image (), "/" )
6776 if lastInd == - 1 {
@@ -73,6 +82,7 @@ func (i Image) ChartName() string {
7382 return chart
7483}
7584
85+ // Registry returns the registry portion of the Image URI (the substring before the first slash).
7686func (i * Image ) Registry () string {
7787 result := strings .Split (i .URI , "/" )
7888 if len (result ) < 1 {
@@ -81,6 +91,7 @@ func (i *Image) Registry() string {
8191 return result [0 ]
8292}
8393
94+ // Repository returns the repository name (between the registry and the tag/digest).
8495func (i * Image ) Repository () string {
8596 rol := strings .TrimPrefix (i .URI , i .Registry ()+ "/" )
8697 result := strings .Split (rol , "@" )
@@ -94,6 +105,7 @@ func (i *Image) Repository() string {
94105 return result [0 ]
95106}
96107
108+ // Digest returns the SHA digest portion (after '@') of the Image URI, if present.
97109func (i * Image ) Digest () string {
98110 rol := strings .TrimPrefix (i .URI , i .Registry ()+ "/" )
99111 result := strings .Split (rol , "@" )
@@ -103,6 +115,7 @@ func (i *Image) Digest() string {
103115 return result [1 ]
104116}
105117
118+ // Version returns the tag portion (after ':') of the Image URI, if present, or empty if the URI uses digests.
106119func (i * Image ) Version () string {
107120 rol := strings .TrimPrefix (i .URI , i .Registry ()+ "/" )
108121 result := strings .Split (rol , "@" )
@@ -116,6 +129,8 @@ func (i *Image) Version() string {
116129 return ""
117130}
118131
132+ // Archive represents an archive asset (e.g. tarball) along with its OS/architecture metadata,
133+ // and checksums for file integrity.
119134type Archive struct {
120135 // +kubebuilder:validation:Required
121136 // The asset name
@@ -138,14 +153,18 @@ type Archive struct {
138153 // +kubebuilder:validation:Required
139154 // The URI where the asset is located
140155 URI string `json:"uri,omitempty"`
156+
141157 // +kubebuilder:validation:Required
142158 // The sha512 of the asset, only applies for 'file' store
143159 SHA512 string `json:"sha512,omitempty"`
160+
144161 // +kubebuilder:validation:Required
145162 // The sha256 of the asset, only applies for 'file' store
146163 SHA256 string `json:"sha256,omitempty"`
147164}
148165
166+ // Manifest represents a reference to a manifest, typically containing
167+ // further resource definitions or configurations.
149168type Manifest struct {
150169 // +kubebuilder:validation:Required
151170 // URI points to the manifest yaml file
0 commit comments