Skip to content

Commit

Permalink
Merge watches for hybrid and helm
Browse files Browse the repository at this point in the history
This PR makes the following changes:
1. Allow passing label selectors in watches
2. Remove legacy watches
  • Loading branch information
varshaprasad96 committed Dec 14, 2021
1 parent 1cdcd7f commit 3bf8620
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 497 deletions.
27 changes: 4 additions & 23 deletions internal/cmd/helm-operator/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ import (
"strings"

"github.com/operator-framework/helm-operator-plugins/internal/flags"
watches "github.com/operator-framework/helm-operator-plugins/internal/legacy/watches"
"github.com/operator-framework/helm-operator-plugins/internal/metrics"
"github.com/operator-framework/helm-operator-plugins/internal/version"
"github.com/operator-framework/helm-operator-plugins/pkg/annotation"
helmmgr "github.com/operator-framework/helm-operator-plugins/pkg/manager"
"github.com/operator-framework/helm-operator-plugins/pkg/reconciler"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"github.com/operator-framework/helm-operator-plugins/pkg/watches"

"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -179,18 +177,11 @@ func run(cmd *cobra.Command, f *flags.Flags) {

for _, w := range ws {

// TODO: remove this after modifying watches of hybrid lib.
cl, err := getChart(w)
if err != nil {
log.Error(err, "Unable to read chart")
os.Exit(1)
}

r, err := reconciler.New(
reconciler.WithChart(*cl),
reconciler.WithChart(*w.Chart),
reconciler.WithGroupVersionKind(w.GroupVersionKind),
reconciler.WithOverrideValues(w.OverrideValues),
reconciler.WithSelector(w.Selector),
reconciler.WithSelector(*w.Selector),
reconciler.SkipDependentWatches(*w.WatchDependentResources),
reconciler.WithMaxConcurrentReconciles(f.MaxConcurrentReconciles),
reconciler.WithReconcilePeriod(f.ReconcilePeriod),
Expand All @@ -207,7 +198,7 @@ func run(cmd *cobra.Command, f *flags.Flags) {
log.Error(err, "unable to create controller", "Helm")
os.Exit(1)
}
log.Info("configured watch", "gvk", w.GroupVersionKind, "chartDir", w.ChartDir, "maxConcurrentReconciles", f.MaxConcurrentReconciles, "reconcilePeriod", f.ReconcilePeriod)
log.Info("configured watch", "gvk", w.GroupVersionKind, "chartDir", w.ChartPath, "maxConcurrentReconciles", f.MaxConcurrentReconciles, "reconcilePeriod", f.ReconcilePeriod)
}

log.Info("starting manager")
Expand Down Expand Up @@ -239,13 +230,3 @@ func exitIfUnsupported(options manager.Options) {
os.Exit(1)
}
}

// getChart returns the chart from the chartDir passed to the watches file.
func getChart(w watches.Watch) (*chart.Chart, error) {
c, err := loader.LoadDir(w.ChartDir)
if err != nil {
return nil, fmt.Errorf("failed to load chart dir: %w", err)
}

return c, nil
}
1 change: 1 addition & 0 deletions internal/cmd/hybrid-operator/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func run(cmd *cobra.Command, f *flags.Flags) {
reconciler.WithChart(*w.Chart),
reconciler.WithGroupVersionKind(w.GroupVersionKind),
reconciler.WithOverrideValues(w.OverrideValues),
reconciler.WithSelector(*w.Selector),
reconciler.SkipDependentWatches(w.WatchDependentResources != nil && !*w.WatchDependentResources),
reconciler.WithMaxConcurrentReconciles(maxConcurrentReconciles),
reconciler.WithReconcilePeriod(reconcilePeriod),
Expand Down
159 changes: 0 additions & 159 deletions internal/legacy/watches/watches.go

This file was deleted.

Loading

0 comments on commit 3bf8620

Please sign in to comment.