Skip to content

Commit f6bc044

Browse files
authored
fix: update mtls attribute in workload configuration (#306)
1 parent e5596f8 commit f6bc044

7 files changed

Lines changed: 95 additions & 53 deletions

File tree

package-lock.json

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

packages/config/src/configProcessor/helpers/azion.config.example.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,12 @@ const config: AzionConfig = {
532532
},
533533
},
534534
mtls: {
535-
verification: 'enforce' as WorkloadMTLSVerification,
536-
certificate: 67890,
537-
crl: [1, 2, 3],
535+
enabled: true,
536+
config: {
537+
verification: 'enforce' as WorkloadMTLSVerification,
538+
certificate: 67890,
539+
crl: [1, 2, 3],
540+
},
538541
},
539542
deployments: [
540543
{

packages/config/src/configProcessor/helpers/schema.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -987,22 +987,31 @@ const azionConfigSchema = {
987987
mtls: {
988988
type: 'object',
989989
properties: {
990-
verification: {
991-
type: 'string',
992-
enum: WORKLOAD_MTLS_VERIFICATION,
993-
default: 'enforce',
990+
enabled: {
991+
type: 'boolean',
992+
default: false,
994993
},
995-
certificate: {
996-
type: ['integer', 'null'],
997-
minimum: 1,
998-
},
999-
crl: {
1000-
type: ['array', 'null'],
1001-
items: { type: 'integer' },
1002-
maxItems: 100,
994+
config: {
995+
type: 'object',
996+
properties: {
997+
verification: {
998+
type: 'string',
999+
enum: WORKLOAD_MTLS_VERIFICATION,
1000+
default: 'enforce',
1001+
},
1002+
certificate: {
1003+
type: ['integer', 'null'],
1004+
minimum: 1,
1005+
},
1006+
crl: {
1007+
type: ['array', 'null'],
1008+
items: { type: 'integer' },
1009+
maxItems: 100,
1010+
},
1011+
},
1012+
additionalProperties: false,
10031013
},
10041014
},
1005-
required: ['verification'],
10061015
additionalProperties: false,
10071016
},
10081017
deployments: {

packages/config/src/configProcessor/helpers/schemaManifest.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,22 +1309,31 @@ const schemaWorkloadManifest = {
13091309
mtls: {
13101310
type: 'object',
13111311
properties: {
1312-
verification: {
1313-
type: 'string',
1314-
enum: WORKLOAD_MTLS_VERIFICATION,
1315-
default: 'enforce',
1316-
},
1317-
certificate: {
1318-
type: ['integer', 'null'],
1319-
minimum: 1,
1312+
enabled: {
1313+
type: 'boolean',
1314+
default: false,
13201315
},
1321-
crl: {
1322-
type: ['array', 'null'],
1323-
items: { type: 'integer' },
1324-
maxItems: 100,
1316+
config: {
1317+
type: 'object',
1318+
properties: {
1319+
verification: {
1320+
type: 'string',
1321+
enum: WORKLOAD_MTLS_VERIFICATION,
1322+
default: 'enforce',
1323+
},
1324+
certificate: {
1325+
type: ['integer', 'null'],
1326+
minimum: 1,
1327+
},
1328+
crl: {
1329+
type: ['array', 'null'],
1330+
items: { type: 'integer' },
1331+
maxItems: 100,
1332+
},
1333+
},
1334+
additionalProperties: false,
13251335
},
13261336
},
1327-
required: ['verification'],
13281337
additionalProperties: false,
13291338
},
13301339
},

packages/config/src/configProcessor/processStrategy/implementations/workloadProcessConfigStrategy.test.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ describe('WorkloadProcessConfigStrategy', () => {
8181
},
8282
},
8383
mtls: {
84-
verification: 'permissive',
85-
certificate: 456,
86-
crl: [789],
84+
enabled: true,
85+
config: {
86+
verification: 'permissive',
87+
certificate: 456,
88+
crl: [789],
89+
},
8790
},
8891
},
8992
],
@@ -112,9 +115,12 @@ describe('WorkloadProcessConfigStrategy', () => {
112115
},
113116
},
114117
mtls: {
115-
verification: 'permissive',
116-
certificate: 456,
117-
crl: [789],
118+
enabled: true,
119+
config: {
120+
verification: 'permissive',
121+
certificate: 456,
122+
crl: [789],
123+
},
118124
},
119125
}),
120126
]);
@@ -232,9 +238,12 @@ describe('WorkloadProcessConfigStrategy', () => {
232238
},
233239
},
234240
mtls: {
235-
verification: 'permissive',
236-
certificate: 456,
237-
crl: [789],
241+
enabled: true,
242+
config: {
243+
verification: 'permissive',
244+
certificate: 456,
245+
crl: [789],
246+
},
238247
},
239248
},
240249
],
@@ -264,9 +273,12 @@ describe('WorkloadProcessConfigStrategy', () => {
264273
},
265274
},
266275
mtls: {
267-
verification: 'permissive',
268-
certificate: 456,
269-
crl: [789],
276+
enabled: true,
277+
config: {
278+
verification: 'permissive',
279+
certificate: 456,
280+
crl: [789],
281+
},
270282
},
271283
}),
272284
],
@@ -352,7 +364,7 @@ describe('WorkloadProcessConfigStrategy', () => {
352364
};
353365

354366
const result = strategy.transformToConfig(payload) as {
355-
workloads: Array<{ mtls?: { verification: string; certificate?: number | null; crl?: number[] | null } }>;
367+
workloads: Array<{ mtls?: { enabled?: false; config?: { verification: string; certificate?: number | null; crl?: number[] | null } } }>;
356368
};
357369

358370
expect(result.workloads[0].mtls).toBeUndefined();

packages/config/src/configProcessor/processStrategy/implementations/workloadProcessConfigStrategy.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ class WorkloadProcessConfigStrategy extends ProcessConfigStrategy {
3333
},
3434
mtls: workload.mtls
3535
? {
36-
verification: workload.mtls.verification || 'enforce',
37-
certificate: workload.mtls.certificate,
38-
crl: workload.mtls.crl,
36+
enabled: workload.mtls.enabled || false,
37+
config: {
38+
verification: workload.mtls.config.verification || 'enforce',
39+
certificate: workload.mtls.config.certificate,
40+
crl: workload.mtls.config.crl,
41+
},
3942
}
4043
: undefined,
4144
}));
@@ -68,9 +71,12 @@ class WorkloadProcessConfigStrategy extends ProcessConfigStrategy {
6871
},
6972
mtls: workload.mtls
7073
? {
71-
verification: workload.mtls.verification,
72-
certificate: workload.mtls.certificate,
73-
crl: workload.mtls.crl,
74+
enabled: workload.mtls.enabled || false,
75+
config: {
76+
verification: workload.mtls.config.verification || 'enforce',
77+
certificate: workload.mtls.config.certificate,
78+
crl: workload.mtls.config.crl,
79+
},
7480
}
7581
: undefined,
7682
}));

packages/config/src/types.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,12 @@ export type AzionWorkloadProtocols = {
776776
};
777777

778778
export type AzionWorkloadMTLS = {
779-
verification: WorkloadMTLSVerification;
780-
certificate?: number | null;
781-
crl?: number[] | null;
779+
enabled: boolean;
780+
config: {
781+
verification: WorkloadMTLSVerification;
782+
certificate?: number | null;
783+
crl?: number[] | null;
784+
};
782785
};
783786

784787
/**

0 commit comments

Comments
 (0)