Skip to content

Commit

Permalink
add image digests to freight; let promotion mechanisms optionally use…
Browse files Browse the repository at this point in the history
… them (#1239)

Signed-off-by: Kent <[email protected]>
  • Loading branch information
krancour authored Dec 8, 2023
1 parent 54ae87b commit bf276c5
Show file tree
Hide file tree
Showing 23 changed files with 1,129 additions and 668 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/freight_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (f *Freight) UpdateID() {
for _, image := range f.Images {
artifacts = append(
artifacts,
fmt.Sprintf("%s:%s", image.RepoURL, image.Tag),
fmt.Sprintf("%s@%s", image.RepoURL, image.Digest),
)
}
for _, chart := range f.Charts {
Expand Down
59 changes: 48 additions & 11 deletions api/v1alpha1/stage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:validation:Enum={Image,Tag}
// +kubebuilder:validation:Enum={ImageAndTag,Tag,ImageAndDigest,Digest}
type ImageUpdateValueType string

const (
ImageUpdateValueTypeImage ImageUpdateValueType = "Image"
ImageUpdateValueTypeTag ImageUpdateValueType = "Tag"
ImageUpdateValueTypeImageAndTag ImageUpdateValueType = "ImageAndTag"
ImageUpdateValueTypeTag ImageUpdateValueType = "Tag"
ImageUpdateValueTypeImageAndDigest ImageUpdateValueType = "ImageAndDigest"
ImageUpdateValueTypeDigest ImageUpdateValueType = "Digest"
)

type HealthState string
Expand Down Expand Up @@ -195,6 +197,11 @@ type KustomizeImageUpdate struct {
//+kubebuilder:validation:MinLength=1
//+kubebuilder:validation:Pattern=^[\w-\.]+(/[\w-\.]+)*$
Path string `json:"path"`
// UseDigest specifies whether the image's digest should be used instead of
// its tag.
//
//+kubebuilder:validation:Optional
UseDigest bool `json:"useDigest"`
}

// HelmPromotionMechanism describes how to use Helm to incorporate Freight into
Expand Down Expand Up @@ -228,9 +235,16 @@ type HelmImageUpdate struct {
//+kubebuilder:validation:MinLength=1
Key string `json:"key"`
// Value specifies the new value for the specified key in the specified Helm
// values file. Valid values are "Image", which replaces the value of the
// specified key with the entire <image name>:<tag>, or "Tag" which replaces
// the value of the specified with just the new tag. This is a required field.
// values file. Valid values are:
//
// - ImageAndTag: Replaces the value of the specified key with
// <image name>:<tag>
// - Tag: Replaces the value of the specified key with just the new tag
// - ImageAndDigest: Replaces the value of the specified key with
// <image name>@<digest>
// - Digest: Replaces the value of the specified key with just the new digest.
//
// This is a required field.
Value ImageUpdateValueType `json:"value"`
}

Expand Down Expand Up @@ -324,7 +338,7 @@ type ArgoCDKustomize struct {
// Argo CD Application's Kustomize parameters.
//
//+kubebuilder:validation:MinItems=1
Images []string `json:"images"`
Images []ArgoCDKustomizeImageUpdate `json:"images"`
}

// ArgoCDHelm describes updates to an Argo CD Application source's Helm-specific
Expand All @@ -337,6 +351,20 @@ type ArgoCDHelm struct {
Images []ArgoCDHelmImageUpdate `json:"images"`
}

// ArgoCDKustomizeImageUpdate describes how a specific image version can be
// incorporated into an Argo CD Application's Kustomize parameters.
type ArgoCDKustomizeImageUpdate struct {
// Image specifies a container image (without tag). This is a required field.
//
//+kubebuilder:validation:MinLength=1
Image string `json:"image"`
// UseDigest specifies whether the image's digest should be used instead of
// its tag.
//
//+kubebuilder:validation:Optional
UseDigest bool `json:"useDigest"`
}

// ArgoCDHelmImageUpdate describes how a specific image version can be
// incorporated into an Argo CD Application's Helm parameters.
type ArgoCDHelmImageUpdate struct {
Expand All @@ -350,10 +378,16 @@ type ArgoCDHelmImageUpdate struct {
//+kubebuilder:validation:MinLength=1
Key string `json:"key"`
// Value specifies the new value for the specified key in the Argo CD
// Application's Helm parameters. Valid values are "Image", which replaces the
// value of the specified key with the entire <image name>:<tag>, or "Tag"
// which replaces the value of the specified with just the new tag. This is a
// required field.
// Application's Helm parameters. Valid values are:
//
// - ImageAndTag: Replaces the value of the specified key with
// <image name>:<tag>
// - Tag: Replaces the value of the specified key with just the new tag
// - ImageAndDigest: Replaces the value of the specified key with
// <image name>@<digest>
// - Digest: Replaces the value of the specified key with just the new digest.
//
// This is a required field.
Value ImageUpdateValueType `json:"value"`
}

Expand Down Expand Up @@ -452,6 +486,9 @@ type Image struct {
// Tag identifies a specific version of the image in the repository specified
// by RepoURL.
Tag string `json:"tag,omitempty"`
// Digest identifies a specific version of the image in the repository
// specified by RepoURL. This is a more precise identifier than Tag.
Digest string `json:"digest,omitempty"`
}

// Chart describes a specific version of a Helm chart.
Expand Down
9 changes: 8 additions & 1 deletion api/v1alpha1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ message ArgoCDHelmImageUpdate {
}

message ArgoCDKustomize {
repeated string images = 1 [json_name = "images"];
repeated ArgoCDKustomizeImageUpdate images = 1 [json_name = "images"];
}

message ArgoCDKustomizeImageUpdate {
string image = 1 [json_name = "image"];
bool use_digest = 2 [json_name = "useDigest"];
}

message ArgoCDSourceUpdate {
Expand Down Expand Up @@ -118,6 +123,7 @@ message HelmPromotionMechanism {
message Image {
string repo_url = 1 [json_name = "repoURL"];
string tag = 2 [json_name = "tag"];
string digest = 3 [json_name = "digest"];
}

message ImageSubscription {
Expand All @@ -132,6 +138,7 @@ message ImageSubscription {
message KustomizeImageUpdate {
string image = 1 [json_name = "image"];
string path = 2 [json_name = "path"];
bool use_digest = 3 [json_name = "useDigest"];
}

message KustomizePromotionMechanism {
Expand Down
17 changes: 16 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions charts/kargo/crds/kargo.akuity.io_freights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ spec:
items:
description: Image describes a specific version of a container image.
properties:
digest:
description: Digest identifies a specific version of the image in
the repository specified by RepoURL. This is a more precise identifier
than Tag.
type: string
gitRepoURL:
description: GitRepoURL specifies the URL of a Git repository that
contains the source code for the image repository referenced by
Expand Down
79 changes: 63 additions & 16 deletions charts/kargo/crds/kargo.akuity.io_stages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,23 @@ spec:
minLength: 1
type: string
value:
description: Value specifies the new value
description: "Value specifies the new value
for the specified key in the Argo CD Application's
Helm parameters. Valid values are "Image",
which replaces the value of the specified
key with the entire <image name>:<tag>,
or "Tag" which replaces the value of the
specified with just the new tag. This
is a required field.
Helm parameters. Valid values are: \n
- ImageAndTag: Replaces the value of the
specified key with <image name>:<tag>
- Tag: Replaces the value of the specified
key with just the new tag - ImageAndDigest:
Replaces the value of the specified key
with <image name>@<digest> - Digest: Replaces
the value of the specified key with just
the new digest. \n This is a required
field."
enum:
- Image
- ImageAndTag
- Tag
- ImageAndDigest
- Digest
type: string
required:
- image
Expand All @@ -156,7 +162,24 @@ spec:
versions can be incorporated into an Argo CD
Application's Kustomize parameters.
items:
type: string
description: ArgoCDKustomizeImageUpdate describes
how a specific image version can be incorporated
into an Argo CD Application's Kustomize parameters.
properties:
image:
description: Image specifies a container
image (without tag). This is a required
field.
minLength: 1
type: string
useDigest:
description: UseDigest specifies whether
the image's digest should be used instead
of its tag.
type: boolean
required:
- image
type: object
minItems: 1
type: array
required:
Expand Down Expand Up @@ -253,16 +276,21 @@ spec:
minLength: 1
type: string
value:
description: Value specifies the new value for
description: "Value specifies the new value for
the specified key in the specified Helm values
file. Valid values are "Image", which replaces
the value of the specified key with the entire
<image name>:<tag>, or "Tag" which replaces
the value of the specified with just the new
tag. This is a required field.
file. Valid values are: \n - ImageAndTag: Replaces
the value of the specified key with <image name>:<tag>
- Tag: Replaces the value of the specified key
with just the new tag - ImageAndDigest: Replaces
the value of the specified key with <image name>@<digest>
- Digest: Replaces the value of the specified
key with just the new digest. \n This is a required
field."
enum:
- Image
- ImageAndTag
- Tag
- ImageAndDigest
- Digest
type: string
valuesFilePath:
description: ValuesFilePath specifies a path to
Expand Down Expand Up @@ -304,6 +332,10 @@ spec:
minLength: 1
pattern: ^[\w-\.]+(/[\w-\.]+)*$
type: string
useDigest:
description: UseDigest specifies whether the image's
digest should be used instead of its tag.
type: boolean
required:
- image
- path
Expand Down Expand Up @@ -454,6 +486,11 @@ spec:
description: Image describes a specific version of a container
image.
properties:
digest:
description: Digest identifies a specific version of the
image in the repository specified by RepoURL. This is
a more precise identifier than Tag.
type: string
gitRepoURL:
description: GitRepoURL specifies the URL of a Git repository
that contains the source code for the image repository
Expand Down Expand Up @@ -546,6 +583,11 @@ spec:
description: Image describes a specific version of a container
image.
properties:
digest:
description: Digest identifies a specific version of
the image in the repository specified by RepoURL.
This is a more precise identifier than Tag.
type: string
gitRepoURL:
description: GitRepoURL specifies the URL of a Git repository
that contains the source code for the image repository
Expand Down Expand Up @@ -706,6 +748,11 @@ spec:
description: Image describes a specific version of a container
image.
properties:
digest:
description: Digest identifies a specific version of the
image in the repository specified by RepoURL. This is
a more precise identifier than Tag.
type: string
gitRepoURL:
description: GitRepoURL specifies the URL of a Git repository
that contains the source code for the image repository
Expand Down
Loading

0 comments on commit bf276c5

Please sign in to comment.