Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 7507d0b

Browse files
committed
cleanup
1 parent fcbcf9a commit 7507d0b

11 files changed

+58
-56
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ RUN apt-get update && \
8080
apt-get install -y --no-install-recommends ca-certificates=20240203~22.04.1 curl=7.81.0-1ubuntu1.20 && \
8181
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
8282
apt-get install -y nodejs=18.19.1-1nodesource1 && \
83-
npm install -g [email protected].99 && \
83+
npm install -g [email protected].108 && \
8484
curl -fsSL -o go1.24.4.linux-amd64.tar.gz https://go.dev/dl/go1.24.4.linux-amd64.tar.gz && \
8585
tar -C /usr/local -xzf go1.24.4.linux-amd64.tar.gz && \
8686
rm go1.24.4.linux-amd64.tar.gz && \

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ CAPI_KIND_CLUSTER_NAME ?= capi-test
231231
# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
232232

233233
# Next release is: v0.3.2
234-
TAG ?= v0.3.2-preview.21
234+
TAG ?= v0.3.2-preview.22
235235
ARCH ?= $(shell go env GOARCH)
236236
ALL_ARCH = amd64 arm arm64
237237

api/v1alpha1/cdk8sappproxy_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ type GitRepositorySpec struct {
3232
// +kubebuilder:validation:Required
3333
Reference string `json:"reference"`
3434

35-
// ReferencePollInterval
35+
// ReferencePollInterval polls the defined git repository for changes.
36+
// Defaults to 5 min.
3637
// +kubebuilder:validation:optional
3738
ReferencePollInterval *metav1.Duration `json:"referencePollInterval,omitempty"`
3839

api/v1alpha1/cdk8sappproxy_webook.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package v1alpha1
22

33
import (
44
"fmt"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
"time"
57

68
"k8s.io/apimachinery/pkg/runtime"
79
ctrl "sigs.k8s.io/controller-runtime"
@@ -33,6 +35,12 @@ func (c *Cdk8sAppProxy) Default() {
3335
c.Spec.GitRepository.Reference = "main"
3436
}
3537

38+
if c.Spec.GitRepository != nil && c.Spec.GitRepository.ReferencePollInterval == nil {
39+
c.Spec.GitRepository.ReferencePollInterval = &metav1.Duration{
40+
Duration: 5 * time.Minute,
41+
}
42+
}
43+
3644
// Set the default path if not specified
3745
if c.Spec.GitRepository != nil && c.Spec.GitRepository.Path == "" {
3846
c.Spec.GitRepository.Path = "."

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/addons.cluster.x-k8s.io_cdk8sappproxies.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ spec:
128128
reference:
129129
description: Reference is the git reference (branch, tag, or commit).
130130
type: string
131+
referencePollInterval:
132+
description: |-
133+
ReferencePollInterval polls the defined git repository for changes.
134+
Defaults to 5 min.
135+
type: string
131136
url:
132137
description: URL is the git repository URL.
133138
type: string
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package cdk8sappproxy
22

3-
import "time"
4-
53
// Finalizer is the finalizer used by the cdk8sappproxy controller.
64
const (
75
Finalizer = "cdk8sappproxy.addons.cluster.x-k8s.io/finalizer"
@@ -17,10 +15,3 @@ const (
1715
OperationApply = "apply"
1816
OperationNpmInstall = "npmInstall"
1917
)
20-
21-
// gitPollInterval is the interval at which the cdk8sappproxy controller polls the git repository for changes.
22-
const (
23-
gitPollInterval = 1 * time.Minute
24-
consecutiveErrors = 0
25-
maxConsecutiveErrors = 5
26-
)

controllers/cdk8sappproxy/cdk8sappproxy_git_operator.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,27 @@ func (r *Reconciler) cloneGitRepository(ctx context.Context, cdk8sAppProxy *addo
9696
return nil
9797
}
9898

99+
func getPollInterval(c *addonsv1alpha1.Cdk8sAppProxy) time.Duration {
100+
if c.Spec.GitRepository != nil && c.Spec.GitRepository.ReferencePollInterval != nil {
101+
return c.Spec.GitRepository.ReferencePollInterval.Duration
102+
}
103+
return 5 * time.Minute // default
104+
}
105+
99106
// pollGitRepository periodically checks the remote git repository for changes.
100107
func (r *Reconciler) pollGitRepository(ctx context.Context, proxyName types.NamespacedName) {
101108
logger := log.FromContext(ctx).WithValues("cdk8sappproxy", proxyName.String(), "goroutine", "pollGitRepository")
102109

103-
ticker := time.NewTicker(gitPollInterval)
110+
cdk8sAppProxy := &addonsv1alpha1.Cdk8sAppProxy{}
111+
err := r.Get(ctx, proxyName, cdk8sAppProxy)
112+
if err != nil {
113+
logger.Error(err, "Failed to get cdk8sAppProxy")
114+
115+
return
116+
}
117+
pollInterval := getPollInterval(cdk8sAppProxy)
118+
119+
ticker := time.NewTicker(pollInterval)
104120
defer ticker.Stop()
105121

106122
for {

examples/cdk8sappproxy_sample-go.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ spec:
77
gitRepository:
88
url: "https://github.com/PatrickLaabs/cluster-api-addon-provider-cdk8s"
99
reference: "main"
10+
referencePollInterval: '5'
1011
path: "examples/cdk8s-sample-deployment"
1112
# authSecretRef:
1213
# name: git-credentials

examples/cdk8sappproxy_sample-typescript.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
apiVersion: addons.cluster.x-k8s.io/v1alpha1
22
kind: Cdk8sAppProxy
33
metadata:
4-
name: cdk8s-sample-app-go
4+
name: cdk8s-sample-app-typescript
55
namespace: default
66
spec:
77
gitRepository:
88
url: "https://github.com/PatrickLaabs/cluster-api-addon-provider-cdk8s"
99
reference: "main"
10-
path: "examples/cdk8s-sample-deployment"
10+
referencePollInterval: '5'
11+
path: "examples/cdk8s-sample-deployment-typescript"
1112
# authSecretRef:
1213
# name: git-credentials
1314
clusterSelector: {}

0 commit comments

Comments
 (0)