Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshisharma84 committed Nov 9, 2023
1 parent 7a3fcf5 commit ddc449a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
8 changes: 4 additions & 4 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions controllers/addon_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion controllers/blueprint_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ddc449a

Please sign in to comment.