diff --git a/internal/controller/managedcluster_controller.go b/internal/controller/managedcluster_controller.go index de9629b9d..7894e5afa 100644 --- a/internal/controller/managedcluster_controller.go +++ b/internal/controller/managedcluster_controller.go @@ -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 ( @@ -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 / format for non-OCI. + // We don't have a repository name, so we can use / 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 diff --git a/internal/utils/helm.go b/internal/utils/helm.go index 6ed9bfa56..016282055 100644 --- a/internal/utils/helm.go +++ b/internal/utils/helm.go @@ -20,8 +20,8 @@ import ( ) const ( - registryTypeOCI = "oci" - registryTypeDefault = "default" + RegistryTypeOCI = "oci" + RegistryTypeDefault = "default" ) func DetermineDefaultRepositoryType(defaultRegistryURL string) (string, error) { @@ -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) } diff --git a/templates/provider/hmc/templates/rbac/controller/roles.yaml b/templates/provider/hmc/templates/rbac/controller/roles.yaml index 198058ce0..739a355e3 100644 --- a/templates/provider/hmc/templates/rbac/controller/roles.yaml +++ b/templates/provider/hmc/templates/rbac/controller/roles.yaml @@ -182,4 +182,3 @@ rules: verbs: - get - list -