Skip to content

Commit

Permalink
Set Profile.Spec.HelmCharts fields based on default or oci source reg…
Browse files Browse the repository at this point in the history
…istry
  • Loading branch information
wahabmk committed Sep 30, 2024
1 parent 32d9ee5 commit b00ae13
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
20 changes: 15 additions & 5 deletions internal/controller/managedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
hmc "github.com/Mirantis/hmc/api/v1alpha1"
"github.com/Mirantis/hmc/internal/helm"
"github.com/Mirantis/hmc/internal/telemetry"
"github.com/Mirantis/hmc/internal/utils"
)

const (
Expand Down Expand Up @@ -396,12 +397,21 @@ func (r *ManagedClusterReconciler) updateServices(ctx context.Context, mc *hmc.M
}

opts = append(opts, sveltos.HelmChartOpts{
RepositoryURL: source.Spec.URL,
RepositoryURL: source.Spec.URL,
// We don't have repository name so chart name becomes repository name.
RepositoryName: tmpl.Spec.Helm.ChartName,
ChartName: tmpl.Spec.Helm.ChartName,
ChartVersion: tmpl.Spec.Helm.ChartVersion,
ReleaseName: svc.Name,
Values: svc.Values,
ChartName: func() string {
if source.Spec.Type == utils.RegistryTypeOCI {
return tmpl.Spec.Helm.ChartName
}
// Sveltos accepts ChartName in <repository>/<chart> format for non-OCI.
// We don't have a repository name, so we can use <chart>/<chart> instead.
// See: https://projectsveltos.github.io/sveltos/addons/helm_charts/.
return fmt.Sprintf("%s/%s", tmpl.Spec.Helm.ChartName, tmpl.Spec.Helm.ChartName)
}(),
ChartVersion: tmpl.Spec.Helm.ChartVersion,
ReleaseName: svc.Name,
Values: svc.Values,
ReleaseNamespace: func() string {
if svc.Namespace != "" {
return svc.Namespace
Expand Down
8 changes: 4 additions & 4 deletions internal/utils/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
)

const (
registryTypeOCI = "oci"
registryTypeDefault = "default"
RegistryTypeOCI = "oci"
RegistryTypeDefault = "default"
)

func DetermineDefaultRepositoryType(defaultRegistryURL string) (string, error) {
Expand All @@ -32,9 +32,9 @@ func DetermineDefaultRepositoryType(defaultRegistryURL string) (string, error) {

switch parsedRegistryURL.Scheme {
case "oci":
return registryTypeOCI, nil
return RegistryTypeOCI, nil
case "http", "https":
return registryTypeDefault, nil
return RegistryTypeDefault, nil
default:
return "", fmt.Errorf("invalid default registry URL scheme: %s must be 'oci://', 'http://', or 'https://'", parsedRegistryURL.Scheme)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,3 @@ rules:
verbs:
- get
- list

0 comments on commit b00ae13

Please sign in to comment.