Skip to content

Commit

Permalink
Addressed review comments for adding services to ManagedCluster
Browse files Browse the repository at this point in the history
  • Loading branch information
wahabmk committed Sep 30, 2024
1 parent 24da5a0 commit 32d9ee5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions internal/controller/managedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (r *ManagedClusterReconciler) updateServices(ctx context.Context, mc *hmc.M
tmpl := &hmc.ServiceTemplate{}
tmplRef := types.NamespacedName{Name: svc.Template, Namespace: mc.Namespace}
if err := r.Get(ctx, tmplRef, tmpl); err != nil {
return ctrl.Result{}, fmt.Errorf("failed to get Template (%s)", tmplRef.String())
return ctrl.Result{}, fmt.Errorf("failed to get Template (%s): %w", tmplRef.String(), err)
}

source, err := r.getServiceTemplateSource(ctx, tmpl)
Expand Down Expand Up @@ -416,7 +416,7 @@ func (r *ManagedClusterReconciler) updateServices(ctx context.Context, mc *hmc.M
})
}

if _, _, err := sveltos.ReconcileProfile(ctx, r.Client, l, mc.Namespace, mc.Name,
if _, err := sveltos.ReconcileProfile(ctx, r.Client, l, mc.Namespace, mc.Name,
map[string]string{
hmc.FluxHelmChartNamespaceKey: mc.Namespace,
hmc.FluxHelmChartNameKey: mc.Name,
Expand Down Expand Up @@ -453,9 +453,9 @@ func (r *ManagedClusterReconciler) getServiceTemplateSource(ctx context.Context,
hc := &sourcev1.HelmChart{}
if err := r.Get(ctx, types.NamespacedName{
Namespace: tmpl.Status.ChartRef.Namespace,
Name: tmpl.Spec.Helm.ChartName,
Name: tmpl.Status.ChartRef.Name,
}, hc); err != nil {
return nil, fmt.Errorf("failed to get HelmChart (%s)", tmplRef.String())
return nil, fmt.Errorf("failed to get HelmChart (%s): %w", tmplRef.String(), err)
}

repo := &sourcev1.HelmRepository{}
Expand All @@ -465,7 +465,7 @@ func (r *ManagedClusterReconciler) getServiceTemplateSource(ctx context.Context,
Namespace: hc.Namespace,
Name: hc.Spec.SourceRef.Name,
}, repo); err != nil {
return nil, fmt.Errorf("failed to get HelmRepository (%s)", tmplRef.String())
return nil, fmt.Errorf("failed to get HelmRepository (%s): %w", tmplRef.String(), err)
}

return repo, nil
Expand Down
8 changes: 4 additions & 4 deletions internal/sveltos/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func ReconcileProfile(ctx context.Context,
name string,
matchLabels map[string]string,
opts ReconcileProfileOpts,
) (*sveltosv1beta1.Profile, controllerutil.OperationResult, error) {
) (*sveltosv1beta1.Profile, error) {
cp := &sveltosv1beta1.Profile{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Expand Down Expand Up @@ -120,14 +120,14 @@ func ReconcileProfile(ctx context.Context,
return nil
})
if err != nil {
return nil, operation, err
return nil, err
}

if operation == controllerutil.OperationResultCreated || operation == controllerutil.OperationResultUpdated {
l.Info(fmt.Sprintf("Successfully %s Profile (%s)", string(operation), cp.Name))
l.Info(fmt.Sprintf("Successfully %s Profile (%s/%s)", string(operation), cp.Namespace, cp.Name))
}

return cp, operation, nil
return cp, nil
}

func DeleteProfile(ctx context.Context, cl client.Client, namespace string, name string) error {
Expand Down
6 changes: 3 additions & 3 deletions templates/provider/projectsveltos/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: projectsveltos
repository: https://projectsveltos.github.io/helm-charts
version: 0.38.1
digest: sha256:6fae3801c4b89a99b64a8185d21d6b12ec7cf4f40b15c5555985afa88894f4a8
generated: "2024-09-13T11:52:06.517657-04:00"
version: 0.38.2
digest: sha256:49e61851b4a79742612428f193ae6f450bd3b85959e3f9c3639342064b612058
generated: "2024-09-25T20:27:28.220464-04:00"

0 comments on commit 32d9ee5

Please sign in to comment.