diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 5c55ce789..90cd85c00 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -461,7 +461,7 @@ func (in *ManagedClusterServiceSpec) DeepCopyInto(out *ManagedClusterServiceSpec *out = *in if in.Values != nil { in, out := &in.Values, &out.Values - *out = new(v1.JSON) + *out = new(apiextensionsv1.JSON) (*in).DeepCopyInto(*out) } } diff --git a/internal/controller/managedcluster_controller.go b/internal/controller/managedcluster_controller.go index de9629b9d..c366053fd 100644 --- a/internal/controller/managedcluster_controller.go +++ b/internal/controller/managedcluster_controller.go @@ -38,17 +38,20 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/dynamic" "k8s.io/client-go/rest" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" 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 +399,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 -