Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge watches for hybrid and helm #143

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if w.Selector is nil does this fail with a nil pointer exception?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since its optional, nope. If selector is nil, we won't have predicate created to filter resources

func parsePredicateSelector(selector metav1.LabelSelector) (ctrlpredicate.Predicate, error) {

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