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

Commit e92ef61

Browse files
committed
Change secretgen for default templating
- Change based on option scdf.registry.secret.ref if add default reg-creds secret ref or one with user defined which should allow secretgen-controller to do its dance while allowing user to define its own secret ref. - Relates #4731
1 parent ecbf847 commit e92ef61

File tree

7 files changed

+34
-2
lines changed

7 files changed

+34
-2
lines changed

src/carvel/config/binder/_ytt_lib/kafka/kafka-broker-ss.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ spec:
3030
env: #@ kafka_broker_container_env()
3131
#@ if has_image_pull_secrets():
3232
imagePullSecrets: #@ image_pull_secrets()
33+
#@ else:
34+
imagePullSecrets: [{name: reg-creds}]
3335
#@ end

src/carvel/config/binder/_ytt_lib/rabbitmq/rabbitmq-deployment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ spec:
4141
- containerPort: 5672
4242
#@ if has_image_pull_secrets():
4343
imagePullSecrets: #@ image_pull_secrets()
44+
#@ else:
45+
imagePullSecrets: [{name: reg-creds}]
4446
#@ end
4547
volumes:
4648
- name: rabbitmq-config-volume

src/carvel/config/dataflow-deployment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ spec:
5858
serviceAccountName: scdf-sa
5959
#@ if has_image_pull_secrets():
6060
imagePullSecrets: #@ image_pull_secrets()
61+
#@ else:
62+
imagePullSecrets: [{name: reg-creds}]
6163
#@ end
6264
volumes:
6365
- name: config

src/carvel/config/db/_ytt_lib/mysql/mysql-deployment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ spec:
5252
- "--ignore-db-dir=lost+found"
5353
#@ if has_image_pull_secrets():
5454
imagePullSecrets: #@ image_pull_secrets()
55+
#@ else:
56+
imagePullSecrets: [{name: reg-creds}]
5557
#@ end
5658
volumes:
5759
- name: data

src/carvel/config/db/_ytt_lib/postgres/postgres-deployment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ spec:
4040
name: #@ name()
4141
#@ if has_image_pull_secrets():
4242
imagePullSecrets: #@ image_pull_secrets()
43+
#@ else:
44+
imagePullSecrets: [{name: reg-creds}]
4345
#@ end
4446
volumes:
4547
- name: data

src/carvel/config/skipper-deployment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ spec:
6363
serviceAccountName: scdf-sa
6464
#@ if has_image_pull_secrets():
6565
imagePullSecrets: #@ image_pull_secrets()
66+
#@ else:
67+
imagePullSecrets: [{name: reg-creds}]
6668
#@ end
6769
volumes:
6870
- name: config

src/carvel/test/secrets.test.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,26 @@ describe('secrets', () => {
1515
});
1616
expect(result.success, result.stderr).toBeTruthy();
1717
const yaml = result.stdout;
18+
19+
// gh-4731
20+
// on default we need to have pod image pull secret
21+
// to ref to reg-creds which is basically no-op having
22+
// dump empty secret which is valid in terms of k8s
23+
// validation but just having nothing.
1824
const pods = findPodSpecsWithImagePullSecrets(yaml);
19-
expect(pods).toHaveLength(0);
25+
expect(pods).toHaveLength(5);
26+
27+
// all default pull secrets need to ref to reg-creds
28+
const refs = pods.flatMap(p => p.imagePullSecrets?.[0].name);
29+
expect(refs).toHaveLength(5);
30+
expect(refs.every(r => r === 'reg-creds')).toBeTrue();
2031

2132
const secret = findSecret(yaml, 'reg-creds');
2233
expect(secret).toBeTruthy();
2334
});
2435

2536
it('should add carvel secretgen on default 2', async () => {
37+
// see above test for as this is just same with different setup
2638
const result = await execYtt({
2739
files: ['config'],
2840
dataValueYamls: [
@@ -33,8 +45,14 @@ describe('secrets', () => {
3345
});
3446
expect(result.success, result.stderr).toBeTruthy();
3547
const yaml = result.stdout;
48+
3649
const pods = findPodSpecsWithImagePullSecrets(yaml);
37-
expect(pods).toHaveLength(0);
50+
expect(pods).toHaveLength(5);
51+
52+
// all default pull secrets need to ref to reg-creds
53+
const refs = pods.flatMap(p => p.imagePullSecrets?.[0].name);
54+
expect(refs).toHaveLength(5);
55+
expect(refs.every(r => r === 'reg-creds')).toBeTrue();
3856

3957
const secret = findSecret(yaml, 'reg-creds');
4058
expect(secret).toBeTruthy();
@@ -52,9 +70,11 @@ describe('secrets', () => {
5270
});
5371
expect(result.success, result.stderr).toBeTruthy();
5472
const yaml = result.stdout;
73+
5574
const pods = findPodSpecsWithImagePullSecrets(yaml);
5675
expect(pods).toHaveLength(5);
5776

77+
// should just have fakeref and not any other defaults
5878
const refs = pods.flatMap(p => p.imagePullSecrets?.[0].name);
5979
expect(refs).toHaveLength(5);
6080
expect(refs.every(r => r === 'fakeref')).toBeTrue();

0 commit comments

Comments
 (0)