From 5d2fcbef1811763e4690d648bbfd251962a740b4 Mon Sep 17 00:00:00 2001 From: Jiri Tyr Date: Sun, 7 Apr 2024 16:12:59 +0100 Subject: [PATCH] Reverting the last commit Signed-off-by: Jiri Tyr --- pkg/controller/release/observe.go | 4 +-- pkg/controller/release/release.go | 54 ++++++++++++++----------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/pkg/controller/release/observe.go b/pkg/controller/release/observe.go index 366dcc0..21662c3 100644 --- a/pkg/controller/release/observe.go +++ b/pkg/controller/release/observe.go @@ -61,7 +61,7 @@ func generateObservation(in *release.Release) v1beta1.ReleaseObservation { } // isUpToDate checks whether desired spec up to date with the observed state for a given release -func isUpToDate(ctx context.Context, kube client.Client, managementPoliciesEnabled bool, spec *v1beta1.ReleaseSpec, observed *release.Release, s v1beta1.ReleaseStatus) (bool, error) { // nolint:gocyclo +func isUpToDate(ctx context.Context, kube client.Client, spec *v1beta1.ReleaseSpec, observed *release.Release, s v1beta1.ReleaseStatus) (bool, error) { // nolint:gocyclo if observed.Info == nil { return false, errors.New(errReleaseInfoNilInObservedRelease) } @@ -88,7 +88,7 @@ func isUpToDate(ctx context.Context, kube client.Client, managementPoliciesEnabl mp := sets.New[xpv1.ManagementAction](spec.ManagementPolicies...) - if managementPoliciesEnabled && len(mp) != 0 && !mp.HasAny(xpv1.ManagementActionUpdate, xpv1.ManagementActionAll) { + if len(mp) != 0 && !mp.HasAny(xpv1.ManagementActionUpdate, xpv1.ManagementActionAll) { // Treated as up-to-date as we don't update or create the resource return true, nil } diff --git a/pkg/controller/release/release.go b/pkg/controller/release/release.go index af17b04..cf08e12 100644 --- a/pkg/controller/release/release.go +++ b/pkg/controller/release/release.go @@ -94,18 +94,17 @@ func Setup(mgr ctrl.Manager, o controller.Options, timeout time.Duration) error reconcilerOptions := []managed.ReconcilerOption{ managed.WithExternalConnecter(&connector{ - client: mgr.GetClient(), - logger: o.Logger, - usage: resource.NewProviderConfigUsageTracker(mgr.GetClient(), &helmv1beta1.ProviderConfigUsage{}), - managementPoliciesEnabled: o.Features.Enabled(feature.EnableBetaManagementPolicies), - kcfgExtractorFn: resource.CommonCredentialExtractor, - gcpExtractorFn: resource.CommonCredentialExtractor, - gcpInjectorFn: gke.WrapRESTConfig, - azureExtractorFn: resource.CommonCredentialExtractor, - azureInjectorFn: azure.WrapRESTConfig, - newRestConfigFn: clients.NewRESTConfig, - newKubeClientFn: clients.NewKubeClient, - newHelmClientFn: helmClient.NewClient, + client: mgr.GetClient(), + logger: o.Logger, + usage: resource.NewProviderConfigUsageTracker(mgr.GetClient(), &helmv1beta1.ProviderConfigUsage{}), + kcfgExtractorFn: resource.CommonCredentialExtractor, + gcpExtractorFn: resource.CommonCredentialExtractor, + gcpInjectorFn: gke.WrapRESTConfig, + azureExtractorFn: resource.CommonCredentialExtractor, + azureInjectorFn: azure.WrapRESTConfig, + newRestConfigFn: clients.NewRESTConfig, + newKubeClientFn: clients.NewKubeClient, + newHelmClientFn: helmClient.NewClient, }), managed.WithPollInterval(o.PollInterval), managed.WithLogger(o.Logger.WithValues("controller", name)), @@ -131,10 +130,9 @@ func Setup(mgr ctrl.Manager, o controller.Options, timeout time.Duration) error } type connector struct { - logger logging.Logger - client client.Client - usage resource.Tracker - managementPoliciesEnabled bool + logger logging.Logger + client client.Client + usage resource.Tracker kcfgExtractorFn func(ctx context.Context, src xpv1.CredentialsSource, c client.Client, ccs xpv1.CommonCredentialSelectors) ([]byte, error) gcpExtractorFn func(ctx context.Context, src xpv1.CredentialsSource, c client.Client, ccs xpv1.CommonCredentialSelectors) ([]byte, error) @@ -253,22 +251,20 @@ func (c *connector) Connect(ctx context.Context, mg resource.Managed) (managed.E } return &helmExternal{ - logger: l, - localKube: c.client, - kube: k, - helm: h, - patch: newPatcher(), - managementPoliciesEnabled: c.managementPoliciesEnabled, + logger: l, + localKube: c.client, + kube: k, + helm: h, + patch: newPatcher(), }, nil } type helmExternal struct { - logger logging.Logger - localKube client.Client - kube client.Client - helm helmClient.Client - patch Patcher - managementPoliciesEnabled bool + logger logging.Logger + localKube client.Client + kube client.Client + helm helmClient.Client + patch Patcher } func (e *helmExternal) Observe(ctx context.Context, mg resource.Managed) (managed.ExternalObservation, error) { @@ -305,7 +301,7 @@ func (e *helmExternal) Observe(ctx context.Context, mg resource.Managed) (manage return managed.ExternalObservation{ResourceExists: true}, nil } - s, err := isUpToDate(ctx, e.localKube, e.managementPoliciesEnabled, &cr.Spec, rel, cr.Status) + s, err := isUpToDate(ctx, e.localKube, &cr.Spec, rel, cr.Status) if err != nil { return managed.ExternalObservation{}, errors.Wrap(err, errFailedToCheckIfUpToDate) }