Skip to content

Commit

Permalink
add public controller interface
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Julian <me@joejulian.name>
  • Loading branch information
joejulian committed Sep 5, 2023
1 parent dcec690 commit 8d2c303
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions controller/helmrelease_controller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Copyright 2020 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controller

import (
"context"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
kuberecorder "k8s.io/client-go/tools/record"
"sigs.k8s.io/cli-utils/pkg/kstatus/polling"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

internalController "github.com/fluxcd/helm-controller/internal/controller"
runtimeClient "github.com/fluxcd/pkg/runtime/client"
helper "github.com/fluxcd/pkg/runtime/controller"
)

type HelmReleaseReconciler struct {
client.Client
helper.Metrics

Config *rest.Config
Scheme *runtime.Scheme
EventRecorder kuberecorder.EventRecorder
DefaultServiceAccount string
NoCrossNamespaceRef bool
ClientOpts runtimeClient.Options
KubeConfigOpts runtimeClient.KubeConfigOptions
StatusPoller *polling.StatusPoller
PollingOpts polling.Options
ControllerName string

helmReleaseReconciler *internalController.HelmReleaseReconciler
}

type HelmReleaseReconcilerOptions internalController.HelmReleaseReconcilerOptions

func (r *HelmReleaseReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opts HelmReleaseReconcilerOptions) error {
r.helmReleaseReconciler = &internalController.HelmReleaseReconciler{
Client: r.Client,
Metrics: r.Metrics,
Config: r.Config,
Scheme: r.Scheme,
EventRecorder: r.EventRecorder,
DefaultServiceAccount: r.DefaultServiceAccount,
NoCrossNamespaceRef: r.NoCrossNamespaceRef,
ClientOpts: r.ClientOpts,
KubeConfigOpts: r.KubeConfigOpts,
StatusPoller: r.StatusPoller,
PollingOpts: r.PollingOpts,
ControllerName: r.ControllerName,
}
o := internalController.HelmReleaseReconcilerOptions{
HTTPRetry: opts.HTTPRetry,
DependencyRequeueInterval: opts.DependencyRequeueInterval,
RateLimiter: opts.RateLimiter,
}
return r.helmReleaseReconciler.SetupWithManager(ctx, mgr, o)
}

0 comments on commit 8d2c303

Please sign in to comment.