diff --git a/api/v1alpha1/addon_types.go b/api/v1alpha1/addon_types.go index 1dad03f3..1bea06ec 100644 --- a/api/v1alpha1/addon_types.go +++ b/api/v1alpha1/addon_types.go @@ -17,11 +17,11 @@ type AddonSpec struct { Kind string `json:"kind"` Enabled bool `json:"enabled"` Namespace string `json:"namespace,omitempty"` - Chart Chart `json:"chart,omitempty"` + Chart ChartInfo `json:"chart,omitempty"` Manifest ManifestInfo `json:"manifest,omitempty"` } -type Chart struct { +type ChartInfo struct { Name string `json:"name"` Repo string `json:"repo"` Version string `json:"version"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 67573609..afac6cdc 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -192,7 +192,7 @@ func (in *BlueprintStatus) DeepCopy() *BlueprintStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Chart) DeepCopyInto(out *Chart) { +func (in *ChartInfo) DeepCopyInto(out *ChartInfo) { *out = *in if in.Set != nil { in, out := &in.Set, &out.Set @@ -203,12 +203,12 @@ func (in *Chart) DeepCopyInto(out *Chart) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Chart. -func (in *Chart) DeepCopy() *Chart { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChartInfo. +func (in *ChartInfo) DeepCopy() *ChartInfo { if in == nil { return nil } - out := new(Chart) + out := new(ChartInfo) in.DeepCopyInto(out) return out } diff --git a/controllers/addon_controller.go b/controllers/addon_controller.go index bc6ee648..d754daa5 100644 --- a/controllers/addon_controller.go +++ b/controllers/addon_controller.go @@ -16,6 +16,11 @@ import ( "github.com/mirantis/boundless-operator/pkg/manifest" ) +const ( + typeManifest = "manifest" + typeChart = "chart" +) + // AddonReconciler reconciles a Addon object type AddonReconciler struct { client.Client @@ -56,7 +61,7 @@ func (r *AddonReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl } switch instance.Spec.Kind { - case "chart": + case typeChart: chart := helm.Chart{ Name: instance.Spec.Chart.Name, Repo: instance.Spec.Chart.Repo, @@ -103,11 +108,11 @@ func (r *AddonReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl } logger.Info("Creating Addon HelmChart resource", "Name", chart.Name, "Version", chart.Version) - if err2 := hc.CreateHelmChart(chart, instance.Spec.Namespace); err2 != nil { + if err := hc.CreateHelmChart(chart, instance.Spec.Namespace); err != nil { logger.Error(err, "failed to install addon", "Name", chart.Name, "Version", chart.Version) - return ctrl.Result{Requeue: true}, err2 + return ctrl.Result{Requeue: true}, err } - case "manifest": + case typeManifest: mc := manifest.NewManifestController(r.Client, logger) err = mc.CreateManifest(instance.Spec.Namespace, instance.Spec.Name, instance.Spec.Manifest.URL) if err != nil { diff --git a/controllers/blueprint_controller.go b/controllers/blueprint_controller.go index b322b084..9cdc88ef 100644 --- a/controllers/blueprint_controller.go +++ b/controllers/blueprint_controller.go @@ -232,7 +232,7 @@ func addonResource(spec *boundlessv1alpha1.AddonSpec) *boundlessv1alpha1.Addon { Name: spec.Name, Namespace: spec.Namespace, Kind: spec.Kind, - Chart: boundlessv1alpha1.Chart{ + Chart: boundlessv1alpha1.ChartInfo{ Name: spec.Chart.Name, Repo: spec.Chart.Repo, Version: spec.Chart.Version,