Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: play nicer with helm #1450

Merged
merged 7 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion api/v1alpha1/freight_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1alpha1
import (
"crypto/sha1"
"fmt"
"path"
"sort"
"strings"

Expand Down Expand Up @@ -62,7 +63,12 @@ func (f *Freight) UpdateID() {
for _, chart := range f.Charts {
artifacts = append(
artifacts,
fmt.Sprintf("%s/%s:%s", chart.RegistryURL, chart.Name, chart.Version),
fmt.Sprintf(
"%s:%s",
// path.Join accounts for the possibility that chart.Name is empty
path.Join(chart.RepoURL, chart.Name),
chart.Version,
),
)
}
sort.Strings(artifacts)
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/freight_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ func TestFreightUpdateID(t *testing.T) {
},
Charts: []Chart{
{
RegistryURL: "fake-chart-registry",
Name: "fake-chart",
Version: "fake-chart-version",
RepoURL: "fake-chart-repo",
Name: "fake-chart",
Version: "fake-chart-version",
},
},
}
Expand Down
52 changes: 35 additions & 17 deletions api/v1alpha1/stage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,22 @@ type HelmImageUpdate struct {
// HelmChartDependencyUpdate describes how a specific Helm chart that is used
// as a subchart of an umbrella chart can be updated.
type HelmChartDependencyUpdate struct {
// RegistryURL along with Name identify a subchart of the umbrella chart at
// ChartPath whose version should be updated.
// Repository along with Name identifies a subchart of the umbrella chart at
// ChartPath whose version should be updated. The values of both fields should
// exactly match the values of the fields of the same names in a dependency
// expressed in the Chart.yaml of the umbrella chart at ChartPath. i.e. Do not
// match the values of these two fields to your Warehouse; match them to the
// Chart.yaml. This is a required field.
//
//+kubebuilder:validation:MinLength=1
//+kubebuilder:validation:Pattern=`^(((https?)|(oci))://)([\w\d\.\-]+)(:[\d]+)?(/.*)*$`
RegistryURL string `json:"registryURL"`
// Name along with RegistryURL identify a subchart of the umbrella chart at
// ChartPath whose version should be updated.
Repository string `json:"repository"`
// Name along with Repository identifies a subchart of the umbrella chart at
// ChartPath whose version should be updated. The values of both fields should
// exactly match the values of the fields of the same names in a dependency
// expressed in the Chart.yaml of the umbrella chart at ChartPath. i.e. Do not
// match the values of these two fields to your Warehouse; match them to the
// Chart.yaml. This is a required field.
//
//+kubebuilder:validation:MinLength=1
Name string `json:"name"`
Expand Down Expand Up @@ -397,19 +405,24 @@ func (a *ArgoCDAppUpdate) AppNamespaceOrDefault() string {
// ArgoCDSourceUpdate describes updates that should be applied to one of an Argo
// CD Application resource's sources.
type ArgoCDSourceUpdate struct {
// RepoURL identifies which of the Argo CD Application's sources this update
// is intended for. Note: As of Argo CD 2.6, Application's can use multiple
// sources.
// RepoURL along with the Chart field identifies which of an Argo CD
// Application's sources this update is intended for. Note: As of Argo CD 2.6,
// Applications can use multiple sources. When the source to be updated
// references a Helm chart repository, the values of the RepoURL and Chart
// fields should exactly match the values of the fields of the same names in
// the source. i.e. Do not match the values of these two fields to your
// Warehouse; match them to the Application source you wish to update. This is
// a required field.
//
//+kubebuilder:validation:MinLength=1
RepoURL string `json:"repoURL"`
// Chart specifies a chart within a Helm chart registry if RepoURL points to a
// Helm chart registry. Application sources that point directly at a chart do
// so through a combination of their own RepoURL (registry) and Chart fields,
// so BOTH of those are used as criteria in selecting an Application source to
// update. This field MUST always be used when RepoURL points at a Helm chart
// registry. This field MUST never be used when RepoURL points at a Git
// repository.
// Chart along with the RepoURL field identifies which of an Argo CD
// Application's sources this update is intended for. Note: As of Argo CD 2.6,
// Applications can use multiple sources. When the source to be updated
// references a Helm chart repository, the values of the RepoURL and Chart
// fields should exactly match the values of the fields of the same names in
// the source. i.e. Do not match the values of these two fields to your
// Warehouse; match them to the Application source you wish to update.
//
//+kubebuilder:validation:Optional
Chart string `json:"chart,omitempty"`
Expand Down Expand Up @@ -592,8 +605,13 @@ type Image struct {

// Chart describes a specific version of a Helm chart.
type Chart struct {
// RepoURL specifies the remote registry in which this chart is located.
RegistryURL string `json:"registryURL,omitempty"`
// RepoURL specifies the URL of a Helm chart repository. Classic chart
// repositories (using HTTP/S) can contain differently named charts. When this
// field points to such a repository, the Name field will specify the name of
// the chart within the repository. In the case of a repository within an OCI
// registry, the URL implicitly points to a specific chart and the Name field
// will be empty.
RepoURL string `json:"repoURL,omitempty"`
// Name specifies the name of the chart.
Name string `json:"name,omitempty"`
// Version specifies a particular version of the chart.
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ message KargoRenderPromotionMechanism {
}

message Chart {
string registry_url = 1 [json_name = "registryURL"];
string repo_url = 1 [json_name = "repoURL"];
string name = 2 [json_name = "name"];
string version = 3 [json_name = "version"];
}

message ChartSubscription {
string registry_url = 1 [json_name = "registryURL"];
string repo_url = 1 [json_name = "repoURL"];
optional string name = 2 [json_name = "name"];
optional string semver_constraint = 3 [json_name = "semverConstraint"];
}
Expand Down Expand Up @@ -109,7 +109,7 @@ message ArgoCDAppSyncStatus {
}

message HelmChartDependencyUpdate {
string registry_url = 1 [json_name = "registryURL"];
string repository = 1 [json_name = "repositoryURL"];
string name = 2 [json_name = "name"];
string chart_path = 3 [json_name = "chartPath"];
}
Expand Down
22 changes: 14 additions & 8 deletions api/v1alpha1/warehouse_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,23 @@ type ImageSubscription struct {

// ChartSubscription defines a subscription to a Helm chart repository.
type ChartSubscription struct {
// RegistryURL specifies the URL of a Helm chart registry. It may be a classic
// chart registry (using HTTP/S) OR an OCI registry. This field is required.
// RepoURL specifies the URL of a Helm chart repository. It may be a classic
// chart repository (using HTTP/S) OR a repository within an OCI registry.
// Classic chart repositories can contain differently named charts. When this
// field points to such a repository, the Name field MUST also be used
// to specify the name of the desired chart within that repository. In the
// case of a repository within an OCI registry, the URL implicitly points to
// a specific chart and the Name field MUST NOT be used. The RepoURL field is
// required.
//
//+kubebuilder:validation:MinLength=1
//+kubebuilder:validation:Pattern=`^(((https?)|(oci))://)([\w\d\.\-]+)(:[\d]+)?(/.*)*$`
RegistryURL string `json:"registryURL"`
// Name specifies a Helm chart to subscribe to within the Helm chart registry
// specified by the RegistryURL field. This field is required.
//
//+kubebuilder:validation:MinLength=1
Name string `json:"name"`
RepoURL string `json:"repoURL"`
// Name specifies the name of a Helm chart to subscribe to within a classic
// chart repository specified by the RepoURL field. This field is required
// when the RepoURL field points to a classic chart repository and MUST
// otherwise be empty.
Name string `json:"name,omitempty"`
// SemverConstraint specifies constraints on what new chart versions are
// permissible. This field is optional. When left unspecified, there will be
// no constraints, which means the latest version of the chart will always be
Expand Down
10 changes: 7 additions & 3 deletions charts/kargo/crds/kargo.akuity.io_freights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ spec:
name:
description: Name specifies the name of the chart.
type: string
registryURL:
description: RepoURL specifies the remote registry in which this
chart is located.
repoURL:
description: RepoURL specifies the URL of a Helm chart repository.
Classic chart repositories (using HTTP/S) can contain differently
named charts. When this field points to such a repository, the
Name field will specify the name of the chart within the repository.
In the case of a repository within an OCI registry, the URL implicitly
points to a specific chart and the Name field will be empty.
type: string
version:
description: Version specifies a particular version of the chart.
Expand Down
94 changes: 65 additions & 29 deletions charts/kargo/crds/kargo.akuity.io_stages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ spec:
sources.
properties:
chart:
description: Chart specifies a chart within a Helm
chart registry if RepoURL points to a Helm chart
registry. Application sources that point directly
at a chart do so through a combination of their
own RepoURL (registry) and Chart fields, so BOTH
of those are used as criteria in selecting an Application
source to update. This field MUST always be used
when RepoURL points at a Helm chart registry. This
field MUST never be used when RepoURL points at
a Git repository.
description: 'Chart along with the RepoURL field identifies
which of an Argo CD Application''s sources this
update is intended for. Note: As of Argo CD 2.6,
Applications can use multiple sources. When the
source to be updated references a Helm chart repository,
the values of the RepoURL and Chart fields should
exactly match the values of the fields of the same
names in the source. i.e. Do not match the values
of these two fields to your Warehouse; match them
to the Application source you wish to update.'
type: string
helm:
description: Helm describes updates to the source's
Expand Down Expand Up @@ -189,10 +189,17 @@ spec:
- images
type: object
repoURL:
description: 'RepoURL identifies which of the Argo
CD Application''s sources this update is intended
for. Note: As of Argo CD 2.6, Application''s can
use multiple sources.'
description: 'RepoURL along with the Chart field identifies
which of an Argo CD Application''s sources this
update is intended for. Note: As of Argo CD 2.6,
Applications can use multiple sources. When the
source to be updated references a Helm chart repository,
the values of the RepoURL and Chart fields should
exactly match the values of the fields of the same
names in the source. i.e. Do not match the values
of these two fields to your Warehouse; match them
to the Application source you wish to update. This
is a required field.'
minLength: 1
type: string
updateTargetRevision:
Expand Down Expand Up @@ -240,22 +247,34 @@ spec:
pattern: ^[\w-\.]+(/[\w-\.]+)*$
type: string
name:
description: Name along with RegistryURL identify
description: Name along with Repository identifies
a subchart of the umbrella chart at ChartPath
whose version should be updated.
whose version should be updated. The values
of both fields should exactly match the values
of the fields of the same names in a dependency
expressed in the Chart.yaml of the umbrella
chart at ChartPath. i.e. Do not match the values
of these two fields to your Warehouse; match
them to the Chart.yaml. This is a required field.
minLength: 1
type: string
registryURL:
description: RegistryURL along with Name identify
repository:
description: Repository along with Name identifies
a subchart of the umbrella chart at ChartPath
whose version should be updated.
whose version should be updated. The values
of both fields should exactly match the values
of the fields of the same names in a dependency
expressed in the Chart.yaml of the umbrella
chart at ChartPath. i.e. Do not match the values
of these two fields to your Warehouse; match
them to the Chart.yaml. This is a required field.
minLength: 1
pattern: ^(((https?)|(oci))://)([\w\d\.\-]+)(:[\d]+)?(/.*)*$
type: string
required:
- chartPath
- name
- registryURL
- repository
type: object
type: array
images:
Expand Down Expand Up @@ -524,9 +543,14 @@ spec:
name:
description: Name specifies the name of the chart.
type: string
registryURL:
description: RepoURL specifies the remote registry in which
this chart is located.
repoURL:
description: RepoURL specifies the URL of a Helm chart repository.
Classic chart repositories (using HTTP/S) can contain
differently named charts. When this field points to such
a repository, the Name field will specify the name of
the chart within the repository. In the case of a repository
within an OCI registry, the URL implicitly points to a
specific chart and the Name field will be empty.
type: string
version:
description: Version specifies a particular version of the
Expand Down Expand Up @@ -659,9 +683,15 @@ spec:
name:
description: Name specifies the name of the chart.
type: string
registryURL:
description: RepoURL specifies the remote registry in
which this chart is located.
repoURL:
description: RepoURL specifies the URL of a Helm chart
repository. Classic chart repositories (using HTTP/S)
can contain differently named charts. When this field
points to such a repository, the Name field will specify
the name of the chart within the repository. In the
case of a repository within an OCI registry, the URL
implicitly points to a specific chart and the Name
field will be empty.
type: string
version:
description: Version specifies a particular version
Expand Down Expand Up @@ -864,9 +894,15 @@ spec:
name:
description: Name specifies the name of the chart.
type: string
registryURL:
description: RepoURL specifies the remote registry in
which this chart is located.
repoURL:
description: RepoURL specifies the URL of a Helm chart
repository. Classic chart repositories (using HTTP/S)
can contain differently named charts. When this field
points to such a repository, the Name field will specify
the name of the chart within the repository. In the
case of a repository within an OCI registry, the URL
implicitly points to a specific chart and the Name field
will be empty.
type: string
version:
description: Version specifies a particular version of
Expand Down
Loading
Loading