Skip to content

Commit e1ad2f9

Browse files
authored
⚠️ Feature: Adding the option to pull from a private repository (#58)
Merging feature to pull from public and private repositories
2 parents 085d72d + 890e589 commit e1ad2f9

21 files changed

+429
-234
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ _artifacts
4040
tmp/
4141

4242
# Release Files
43-
out/
43+
out/
44+
45+
*-cdk8sappproxy.yaml
46+
hack/ssh_known_hosts

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ RUN --mount=type=secret,id=netrc,required=false,target=/root/.netrc \
5050
# Copy the sources
5151
COPY ./ ./
5252

53+
# Known Hosts
54+
RUN ./hack/update-ssh-known-hosts.sh
55+
5356
# Cache the go build into the Go’s compiler cache folder so we take benefits of compiler caching across docker build calls
5457
RUN --mount=type=secret,id=netrc,required=false,target=/root/.netrc \
5558
--mount=type=cache,target=/root/.cache/go-build \
@@ -77,8 +80,8 @@ ARG ARCH
7780
# Set shell with pipefail option for better error handling
7881
SHELL ["/bin/sh", "-o", "pipefail", "-c"]
7982

80-
RUN apk add --no-cache ca-certificates=20250619-r0 curl=8.12.1-r0 nodejs=20.15.1-r0 npm=10.9.1-r0 \
81-
&& npm install -g cdk8s-cli@2.200.152 \
83+
RUN apk add --no-cache ca-certificates=20250911-r0 curl=8.14.1-r2 nodejs=22.16.0-r2 npm=11.3.0-r1 \
84+
&& npm install -g cdk8s-cli@2.202.3 \
8285
&& curl -fsSL -o go1.25.0.linux-${ARCH}.tar.gz https://go.dev/dl/go1.25.0.linux-${ARCH}.tar.gz \
8386
&& tar -C /usr/local -xzf go1.25.0.linux-${ARCH}.tar.gz \
8487
&& rm go1.25.0.linux-${ARCH}.tar.gz \
@@ -90,6 +93,7 @@ ENV GOROOT=/usr/local/go
9093

9194
WORKDIR /
9295
COPY --from=builder /workspace/manager .
96+
COPY --from=builder /workspace/hack/ssh_known_hosts /etc/ssh/ssh_known_hosts
9397

9498
# Create non-root user
9599
RUN adduser -u 65532 -D -h /home/nonroot -s /bin/sh nonroot

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export GO111MODULE=on
4444

4545
DOCKERFILE_CONTAINER_IMAGE ?= docker.io/docker/dockerfile:1.4
4646
DEPLOYMENT_BASE_IMAGE ?= alpine
47-
DEPLOYMENT_BASE_IMAGE_TAG ?= 3.20
47+
DEPLOYMENT_BASE_IMAGE_TAG ?= 3.22.2
4848
BUILD_CONTAINER_ADDITIONAL_ARGS ?=
4949

5050
#
@@ -220,7 +220,7 @@ CAPI_KIND_CLUSTER_NAME ?= capi-test
220220
# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
221221

222222
#TAG ?= dev
223-
TAG ?= v1.0.0-alpha.8
223+
TAG ?= v1.0.0-alpha.9-28
224224
ARCH ?= $(shell go env GOARCH)
225225
ALL_ARCH = amd64 arm64 #ppc64le s390 arm
226226

api/v1alpha1/cdk8sappproxy_types.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,28 @@ import (
2424
// GitRepositorySpec defines the desired state of a Git repository source.
2525
type GitRepositorySpec struct {
2626
// URL is the git repository URL.
27+
// If the Repository is private,
28+
// the URL needs to be provided in the form of '[email protected]:...'
2729
// +kubebuilder:validation:Required
2830
URL string `json:"url"`
2931

3032
// Reference is the git reference (branch, tag, or commit).
3133
// +kubebuilder:validation:Required
3234
Reference string `json:"reference"`
3335

34-
// ReferencePollInterval polls the defined git repository for changes.
35-
// Defaults to 5 min.
36-
// +kubebuilder:validation:optional
37-
ReferencePollInterval *metav1.Duration `json:"referencePollInterval,omitempty"`
38-
3936
// Path is the path within the repository where the cdk8s application is located.
4037
// Defaults to the root of the repository.
4138
// +kubebuilder:validation:Required
4239
Path string `json:"path"`
40+
41+
// SecretRef references to a secret with the
42+
// needed token, used to pull from a private repository.
43+
// +kubebuilder:validation:optional
44+
SecretRef string `json:"secretRef,omitempty"`
45+
46+
// SecretKey is the key within the SecretRef secret.
47+
// +kubebuilder:validation:optional
48+
SecretKey string `json:"secretKey,omitempty"`
4349
}
4450

4551
// Cdk8sAppProxySpec defines the desired state of Cdk8sAppProxy.

api/v1alpha1/cdk8sappproxy_webook.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ package v1alpha1
1818

1919
import (
2020
"fmt"
21-
"time"
2221

23-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2422
"k8s.io/apimachinery/pkg/runtime"
2523
ctrl "sigs.k8s.io/controller-runtime"
2624
logf "sigs.k8s.io/controller-runtime/pkg/log"
@@ -51,12 +49,6 @@ func (c *Cdk8sAppProxy) Default() {
5149
c.Spec.GitRepository.Reference = "main"
5250
}
5351

54-
if c.Spec.GitRepository != nil && c.Spec.GitRepository.ReferencePollInterval == nil {
55-
c.Spec.GitRepository.ReferencePollInterval = &metav1.Duration{
56-
Duration: 5 * time.Minute,
57-
}
58-
}
59-
6052
// Set the default path if not specified
6153
if c.Spec.GitRepository != nil && c.Spec.GitRepository.Path == "" {
6254
c.Spec.GitRepository.Path = "."

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 7 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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,19 @@ spec:
114114
reference:
115115
description: Reference is the git reference (branch, tag, or commit).
116116
type: string
117-
referencePollInterval:
117+
secretKey:
118+
description: SecretKey is the key within the SecretRef secret.
119+
type: string
120+
secretRef:
118121
description: |-
119-
ReferencePollInterval polls the defined git repository for changes.
120-
Defaults to 5 min.
122+
SecretRef references to a secret with the
123+
needed token, used to pull from a private repository.
121124
type: string
122125
url:
123-
description: URL is the git repository URL.
126+
description: |-
127+
URL is the git repository URL.
128+
If the Repository is private,
129+
the URL needs to be provided in the form of '[email protected]:...'
124130
type: string
125131
required:
126132
- path

config/default/manager_image_patch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ spec:
77
template:
88
spec:
99
containers:
10-
- image: ghcr.io/eitco/cluster-api-addon-provider-cdk8s/cluster-api-cdk8s-controller:v1.0.0-alpha.8
10+
- image: ghcr.io/eitco/cluster-api-addon-provider-cdk8s/cluster-api-cdk8s-controller:v1.0.0-alpha.9-28
1111
name: manager

config/default/manager_image_patch.yaml-e

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ spec:
77
template:
88
spec:
99
containers:
10-
- image: ghcr.io/eitco/cluster-api-addon-provider-cdk8s/cluster-api-cdk8s-controller-arm64:v1.0.0-alpha.8
10+
- image: ghcr.io/eitco/cluster-api-addon-provider-cdk8s/cluster-api-cdk8s-controller:v1.0.0-alpha.9-28
1111
name: manager

config/default/manager_pull_policy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ spec:
88
spec:
99
containers:
1010
- name: manager
11-
imagePullPolicy: Always
11+
imagePullPolicy: IfNotPresent

0 commit comments

Comments
 (0)