Skip to content

Commit a4f2b45

Browse files
committed
fix: move syncPerdio into reconciler
Signed-off-by: dntosas <ntosas@gmail.com>
1 parent 89d83d3 commit a4f2b45

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ linters:
77
- godox
88
- lll
99
- depguard
10-
- mnd
10+
- mnd

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test: envtest ## Run go tests against code.
4646
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -v -mod=vendor `go list ./...` -coverprofile cover.out
4747

4848
.PHONY: ci
49-
ci: fmt vet lint test ## Run go fmt/vet/lint/tests against the code.
49+
ci: fmt vet test ## Run go fmt/vet/lint/tests against the code.
5050

5151
.PHONY: modsync
5252
modsync: ## Run go mod tidy && vendor.

charts/capi2argo-cluster-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v2
2-
appVersion: 1.4.1
2+
appVersion: 1.4.2
33
description: Capi-2-Argo Cluster Operator (CACO) converts ClusterAPI Cluster credentials into ArgoCD Cluster definitions and keep them synchronized.
44
home: https://github.com/dntosas/capi2argo-cluster-operator
55
keywords:
@@ -11,7 +11,7 @@ maintainers:
1111
name: capi2argo-cluster-operator
1212
sources:
1313
- https://github.com/dntosas/capi2argo-cluster-operator
14-
version: 1.4.1
14+
version: 1.4.2
1515
dependencies:
1616
- name: common
1717
repository: "https://charts.bitnami.com/bitnami"

charts/capi2argo-cluster-operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ replicaCount: 1
1212
image:
1313
registry: ghcr.io
1414
repository: dntosas/capi2argo-cluster-operator
15-
tag: v1.4.1
15+
tag: v1.4.2
1616
pullPolicy: Always
1717
pullSecrets: []
1818

controllers/capi2argo_reconciler.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
goErr "errors"
77
"os"
88
"strconv"
9+
"time"
910

1011
"slices"
1112
"strings"
@@ -44,8 +45,9 @@ func init() {
4445
// Capi2Argo reconciles a Secret object.
4546
type Capi2Argo struct {
4647
client.Client
47-
Log logr.Logger
48-
Scheme *runtime.Scheme
48+
Log logr.Logger
49+
Scheme *runtime.Scheme
50+
SyncPeriod time.Duration
4951
}
5052

5153
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete
@@ -288,7 +290,7 @@ func (r *Capi2Argo) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resul
288290

289291
log.Info("ArgoSecret is in-sync with CapiCluster, skipping...")
290292

291-
return ctrl.Result{}, nil
293+
return ctrl.Result{RequeueAfter: r.SyncPeriod}, nil
292294
}
293295

294296
return ctrl.Result{}, nil

controllers/capi_cluster.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
)
1010

1111
// CapiClusterSecretType represents the CAPI managed secret type.
12+
//
13+
//nolint:gosec
1214
const CapiClusterSecretType corev1.SecretType = "cluster.x-k8s.io/secret"
1315

1416
// CapiCluster is an one-on-one representation of KubeConfig fields.

main.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3434
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3535
ctrl "sigs.k8s.io/controller-runtime"
36-
"sigs.k8s.io/controller-runtime/pkg/cache"
3736
"sigs.k8s.io/controller-runtime/pkg/healthz"
3837
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3938
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
@@ -45,10 +44,10 @@ var (
4544
setupLog = ctrl.Log.WithName("setup")
4645
)
4746

47+
// +kubebuilder:scaffold:scheme
4848
func init() {
4949
utilruntime.Must(clusterv1.AddToScheme(scheme))
5050
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
51-
//+kubebuilder:scaffold:scheme
5251
}
5352

5453
func main() {
@@ -86,9 +85,6 @@ func main() {
8685
HealthProbeBindAddress: probeAddr,
8786
LeaderElection: enableLeaderElection,
8887
LeaderElectionID: "37cf8926.capi-cluster.x-argoproj.io",
89-
Cache: cache.Options{
90-
SyncPeriod: &syncDuration,
91-
},
9288
Metrics: server.Options{
9389
BindAddress: metricsAddr,
9490
},
@@ -111,9 +107,10 @@ func main() {
111107
}
112108

113109
if err = (&controllers.Capi2Argo{
114-
Client: mgr.GetClient(),
115-
Log: ctrl.Log.WithName("capi2argo"),
116-
Scheme: mgr.GetScheme(),
110+
Client: mgr.GetClient(),
111+
Log: ctrl.Log.WithName("capi2argo"),
112+
Scheme: mgr.GetScheme(),
113+
SyncPeriod: syncDuration,
117114
}).SetupWithManager(mgr); err != nil {
118115
setupLog.Error(err, "unable to create controller", "controller", "Capi2Argo")
119116
os.Exit(1)

0 commit comments

Comments
 (0)