pepr 0.49.0-nightly.4 → 0.49.0-nightly.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/deploy.d.ts.map +1 -1
- package/dist/cli/docs/cli.helper.d.ts +4 -0
- package/dist/cli/docs/cli.helper.d.ts.map +1 -1
- package/dist/cli/init/templates.d.ts +11 -0
- package/dist/cli/init/templates.d.ts.map +1 -1
- package/dist/cli.js +61 -22
- package/dist/controller.js +1 -1
- package/dist/lib/assets/assets.d.ts.map +1 -1
- package/dist/lib/assets/ignoredNamespaces.d.ts +2 -0
- package/dist/lib/assets/ignoredNamespaces.d.ts.map +1 -0
- package/dist/lib/assets/webhooks.d.ts +0 -1
- package/dist/lib/assets/webhooks.d.ts.map +1 -1
- package/dist/lib/assets/yaml/overridesFile.d.ts.map +1 -1
- package/dist/lib/core/module.d.ts.map +1 -1
- package/dist/lib/helpers.d.ts +1 -1
- package/dist/lib/helpers.d.ts.map +1 -1
- package/dist/lib/processors/mutate-processor.d.ts.map +1 -1
- package/dist/lib/processors/validate-processor.d.ts.map +1 -1
- package/dist/lib/types.d.ts +8 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib.js +20 -17
- package/dist/lib.js.map +4 -4
- package/dist/sdk/sdk.d.ts +2 -0
- package/dist/sdk/sdk.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/cli/build.ts +1 -1
- package/src/cli/deploy.ts +12 -2
- package/src/cli/format.ts +1 -1
- package/src/cli/init/templates.ts +12 -0
- package/src/lib/assets/assets.ts +7 -0
- package/src/lib/assets/ignoredNamespaces.ts +17 -0
- package/src/lib/assets/webhooks.ts +6 -17
- package/src/lib/assets/yaml/overridesFile.ts +6 -2
- package/src/lib/controller/createHooks.ts +1 -1
- package/src/lib/core/module.ts +3 -1
- package/src/lib/helpers.ts +16 -6
- package/src/lib/processors/mutate-processor.ts +6 -2
- package/src/lib/processors/validate-processor.ts +6 -2
- package/src/lib/types.ts +8 -0
- package/src/sdk/sdk.ts +10 -7
- package/src/templates/package.json +10 -0
package/dist/sdk/sdk.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export declare function getOwnerRefFrom(customResource: GenericKind, blockOwnerD
|
|
|
38
38
|
*
|
|
39
39
|
* @param name the name of the resource to sanitize
|
|
40
40
|
* @returns the sanitized resource name
|
|
41
|
+
*
|
|
42
|
+
* https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
|
|
41
43
|
*/
|
|
42
44
|
export declare function sanitizeResourceName(name: string): string;
|
|
43
45
|
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/sdk/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk/sdk.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAO,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,EACpE,aAAa,CAAC,EAAE,YAAY,GAAG,gBAAgB,GAAG,qBAAqB,GACtE,WAAW,EAAE,CAef;AAED;;;;;;;;;GASG;AAEH,wBAAsB,UAAU,CAC9B,EAAE,EAAE,WAAW,EACf,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAC9B,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,cAAc,EAAE,WAAW,EAC3B,kBAAkB,CAAC,EAAE,OAAO,EAC5B,UAAU,CAAC,EAAE,OAAO,GACnB,gBAAgB,EAAE,CAcpB;AAED
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk/sdk.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAO,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,EACpE,aAAa,CAAC,EAAE,YAAY,GAAG,gBAAgB,GAAG,qBAAqB,GACtE,WAAW,EAAE,CAef;AAED;;;;;;;;;GASG;AAEH,wBAAsB,UAAU,CAC9B,EAAE,EAAE,WAAW,EACf,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAC9B,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,cAAc,EAAE,WAAW,EAC3B,kBAAkB,CAAC,EAAE,OAAO,EAC5B,UAAU,CAAC,EAAE,OAAO,GACnB,gBAAgB,EAAE,CAcpB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAazD"}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"!dist/**/*.test.d.ts*",
|
|
18
18
|
"!src/cli/docs/**"
|
|
19
19
|
],
|
|
20
|
-
"version": "0.49.0-nightly.
|
|
20
|
+
"version": "0.49.0-nightly.6",
|
|
21
21
|
"main": "dist/lib.js",
|
|
22
22
|
"types": "dist/lib.d.ts",
|
|
23
23
|
"scripts": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"set:version": "node scripts/set-version.js",
|
|
31
31
|
"test": "npm run test:unit && npm run test:journey && npm run test:journey-wasm",
|
|
32
32
|
"test:artifacts": "npm run build && jest src/build-artifact.test.ts",
|
|
33
|
+
"test:docs": "jest --verbose src/cli/docs/*.test.ts",
|
|
33
34
|
"test:integration": "npm run test:integration:prep && npm run test:integration:run",
|
|
34
35
|
"test:integration:prep": "./integration/prep.sh",
|
|
35
36
|
"test:integration:run": "jest --maxWorkers=4 integration",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts",
|
|
44
45
|
"test:journey:unicorn": "npm run test:journey:k3d && npm run test:journey:image:unicorn && npm run test:journey:run",
|
|
45
46
|
"test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts",
|
|
46
|
-
"test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage --testPathIgnorePatterns
|
|
47
|
+
"test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage --testPathIgnorePatterns=\"build-artifact.test.ts|src/cli/docs/.*\\.test\\.ts\"",
|
|
47
48
|
"format:check": "eslint src && prettier --config .prettierrc src --check",
|
|
48
49
|
"format:fix": "eslint src --fix && prettier --config .prettierrc src --write",
|
|
49
50
|
"prepare": "if [ \"$NODE_ENV\" != 'production' ]; then husky; fi"
|
package/src/cli/build.ts
CHANGED
|
@@ -71,7 +71,7 @@ export default function (program: RootCmd): void {
|
|
|
71
71
|
.option("-e, --entry-point [file]", "Specify the entry point file to build with.", peprTS)
|
|
72
72
|
.option(
|
|
73
73
|
"-n, --no-embed",
|
|
74
|
-
"Disables embedding of deployment files into output module.
|
|
74
|
+
"Disables embedding of deployment files into output module. Useful when creating library modules intended solely for reuse/distribution via NPM.",
|
|
75
75
|
)
|
|
76
76
|
.addOption(
|
|
77
77
|
new Option(
|
package/src/cli/deploy.ts
CHANGED
|
@@ -11,7 +11,8 @@ import { deployImagePullSecret, deployWebhook } from "../lib/assets/deploy";
|
|
|
11
11
|
import { namespaceDeploymentsReady } from "../lib/deploymentChecks";
|
|
12
12
|
import { sanitizeName } from "./init/utils";
|
|
13
13
|
import { validateCapabilityNames } from "../lib/helpers";
|
|
14
|
-
|
|
14
|
+
import { namespaceComplianceValidator } from "../lib/helpers";
|
|
15
|
+
import { loadCapabilities } from "../lib/assets/loader";
|
|
15
16
|
export interface ImagePullSecretDetails {
|
|
16
17
|
pullSecret?: string;
|
|
17
18
|
dockerServer?: string;
|
|
@@ -106,7 +107,16 @@ async function buildAndDeployModule(image: string, force: boolean): Promise<void
|
|
|
106
107
|
[],
|
|
107
108
|
);
|
|
108
109
|
webhook.image = image ?? webhook.image;
|
|
109
|
-
|
|
110
|
+
const capabilities = await loadCapabilities(webhook.path);
|
|
111
|
+
for (const capability of capabilities) {
|
|
112
|
+
namespaceComplianceValidator(capability, webhook.alwaysIgnore?.namespaces);
|
|
113
|
+
namespaceComplianceValidator(
|
|
114
|
+
capability,
|
|
115
|
+
webhook.config.admission?.alwaysIgnore?.namespaces,
|
|
116
|
+
false,
|
|
117
|
+
);
|
|
118
|
+
namespaceComplianceValidator(capability, webhook.config.watch?.alwaysIgnore?.namespaces, true);
|
|
119
|
+
}
|
|
110
120
|
try {
|
|
111
121
|
await webhook.deploy(deployWebhook, force, builtModule.cfg.pepr.webhookTimeout ?? 10);
|
|
112
122
|
|
package/src/cli/format.ts
CHANGED
|
@@ -10,7 +10,7 @@ export default function (program: RootCmd): void {
|
|
|
10
10
|
program
|
|
11
11
|
.command("format")
|
|
12
12
|
.description("Lint and format this Pepr module")
|
|
13
|
-
.option("-v, --validate-only", "Do not modify files, only validate formatting")
|
|
13
|
+
.option("-v, --validate-only", "Do not modify files, only validate formatting.")
|
|
14
14
|
.action(async opts => {
|
|
15
15
|
const success = await peprFormat(opts.validateOnly);
|
|
16
16
|
|
|
@@ -33,6 +33,8 @@ export type peprPackageJSON = {
|
|
|
33
33
|
webhookTimeout: number;
|
|
34
34
|
customLabels: CustomLabels;
|
|
35
35
|
alwaysIgnore: { namespaces: string[] };
|
|
36
|
+
admission: { alwaysIgnore: { namespaces: string[] } };
|
|
37
|
+
watch: { alwaysIgnore: { namespaces: string[] } };
|
|
36
38
|
includedFiles: string[];
|
|
37
39
|
env: object;
|
|
38
40
|
rbac?: PolicyRule[];
|
|
@@ -79,6 +81,16 @@ export function genPkgJSON(opts: InitOptions, pgkVerOverride?: string): peprPack
|
|
|
79
81
|
alwaysIgnore: {
|
|
80
82
|
namespaces: [],
|
|
81
83
|
},
|
|
84
|
+
admission: {
|
|
85
|
+
alwaysIgnore: {
|
|
86
|
+
namespaces: [],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
watch: {
|
|
90
|
+
alwaysIgnore: {
|
|
91
|
+
namespaces: [],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
82
94
|
includedFiles: [],
|
|
83
95
|
env: pgkVerOverride ? testEnv : {},
|
|
84
96
|
},
|
package/src/lib/assets/assets.ts
CHANGED
|
@@ -101,7 +101,14 @@ export class Assets {
|
|
|
101
101
|
this.capabilities = await loadCapabilities(this.path);
|
|
102
102
|
// give error if namespaces are not respected
|
|
103
103
|
for (const capability of this.capabilities) {
|
|
104
|
+
// until deployment, Pepr does not distinguish between watch and admission
|
|
104
105
|
namespaceComplianceValidator(capability, this.alwaysIgnore?.namespaces);
|
|
106
|
+
namespaceComplianceValidator(
|
|
107
|
+
capability,
|
|
108
|
+
this.config.admission?.alwaysIgnore?.namespaces,
|
|
109
|
+
false,
|
|
110
|
+
);
|
|
111
|
+
namespaceComplianceValidator(capability, this.config.watch?.alwaysIgnore?.namespaces, true);
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
const code = await fs.readFile(this.path);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors
|
|
3
|
+
|
|
4
|
+
export function resolveIgnoreNamespaces(ignoredNSConfig: string[] = []): string[] {
|
|
5
|
+
const ignoredNSEnv = process.env.PEPR_ADDITIONAL_IGNORED_NAMESPACES;
|
|
6
|
+
if (!ignoredNSEnv) {
|
|
7
|
+
return ignoredNSConfig;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const namespaces = ignoredNSEnv.split(",").map(ns => ns.trim());
|
|
11
|
+
|
|
12
|
+
// add alwaysIgnore.namespaces to the list
|
|
13
|
+
if (ignoredNSConfig) {
|
|
14
|
+
namespaces.push(...ignoredNSConfig);
|
|
15
|
+
}
|
|
16
|
+
return namespaces.filter(ns => ns.length > 0);
|
|
17
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "@kubernetes/client-node";
|
|
9
9
|
import { kind } from "kubernetes-fluent-client";
|
|
10
10
|
import { concat, equals, uniqWith } from "ramda";
|
|
11
|
-
|
|
11
|
+
import { resolveIgnoreNamespaces } from "./ignoredNamespaces";
|
|
12
12
|
import { Assets } from "./assets";
|
|
13
13
|
import { Event, WebhookType } from "../enums";
|
|
14
14
|
import { Binding } from "../types";
|
|
@@ -42,21 +42,6 @@ export const validateRule = (
|
|
|
42
42
|
return ruleObject;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
export function resolveIgnoreNamespaces(ignoredNSConfig: string[] = []): string[] {
|
|
46
|
-
const ignoredNSEnv = process.env.PEPR_ADDITIONAL_IGNORED_NAMESPACES;
|
|
47
|
-
if (!ignoredNSEnv) {
|
|
48
|
-
return ignoredNSConfig;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const namespaces = ignoredNSEnv.split(",").map(ns => ns.trim());
|
|
52
|
-
|
|
53
|
-
// add alwaysIgnore.namespaces to the list
|
|
54
|
-
if (ignoredNSConfig) {
|
|
55
|
-
namespaces.push(...ignoredNSConfig);
|
|
56
|
-
}
|
|
57
|
-
return namespaces.filter(ns => ns.length > 0);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
45
|
export async function generateWebhookRules(
|
|
61
46
|
assets: Assets,
|
|
62
47
|
isMutateWebhook: boolean,
|
|
@@ -84,7 +69,11 @@ export async function webhookConfigGenerator(
|
|
|
84
69
|
const { name, tls, config, apiPath, host } = assets;
|
|
85
70
|
const ignoreNS = concat(
|
|
86
71
|
peprIgnoreNamespaces,
|
|
87
|
-
resolveIgnoreNamespaces(
|
|
72
|
+
resolveIgnoreNamespaces(
|
|
73
|
+
config?.alwaysIgnore?.namespaces?.length
|
|
74
|
+
? config?.alwaysIgnore?.namespaces
|
|
75
|
+
: config?.admission?.alwaysIgnore?.namespaces,
|
|
76
|
+
),
|
|
88
77
|
);
|
|
89
78
|
|
|
90
79
|
// Add any namespaces to ignore
|
|
@@ -3,7 +3,7 @@ import { CapabilityExport, ModuleConfig } from "../../types";
|
|
|
3
3
|
import { dumpYaml } from "@kubernetes/client-node";
|
|
4
4
|
import { clusterRole } from "../rbac";
|
|
5
5
|
import { promises as fs } from "fs";
|
|
6
|
-
|
|
6
|
+
import { resolveIgnoreNamespaces } from "../ignoredNamespaces";
|
|
7
7
|
export type ChartOverrides = {
|
|
8
8
|
apiPath: string;
|
|
9
9
|
capabilities: CapabilityExport[];
|
|
@@ -23,7 +23,11 @@ export async function overridesFile(
|
|
|
23
23
|
|
|
24
24
|
const overrides = {
|
|
25
25
|
imagePullSecrets,
|
|
26
|
-
additionalIgnoredNamespaces:
|
|
26
|
+
additionalIgnoredNamespaces: resolveIgnoreNamespaces(
|
|
27
|
+
config?.alwaysIgnore?.namespaces?.length
|
|
28
|
+
? config?.alwaysIgnore?.namespaces
|
|
29
|
+
: config?.admission?.alwaysIgnore?.namespaces,
|
|
30
|
+
),
|
|
27
31
|
rbac: rbacOverrides,
|
|
28
32
|
secrets: {
|
|
29
33
|
apiPath: Buffer.from(apiPath).toString("base64"),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ControllerHooks } from ".";
|
|
2
|
-
import { resolveIgnoreNamespaces } from "../assets/
|
|
2
|
+
import { resolveIgnoreNamespaces } from "../assets/ignoredNamespaces";
|
|
3
3
|
import { Capability } from "../core/capability";
|
|
4
4
|
import { isWatchMode, isDevMode } from "../core/envChecks";
|
|
5
5
|
import { setupWatch } from "../processors/watch-processor";
|
package/src/lib/core/module.ts
CHANGED
|
@@ -60,7 +60,9 @@ export class PeprModule {
|
|
|
60
60
|
const controllerHooks = createControllerHooks(
|
|
61
61
|
opts,
|
|
62
62
|
capabilities,
|
|
63
|
-
pepr?.alwaysIgnore?.namespaces
|
|
63
|
+
pepr?.alwaysIgnore?.namespaces?.length
|
|
64
|
+
? pepr.alwaysIgnore.namespaces
|
|
65
|
+
: config?.watch?.alwaysIgnore?.namespaces,
|
|
64
66
|
);
|
|
65
67
|
|
|
66
68
|
this.#controller = new Controller(config, capabilities, controllerHooks);
|
package/src/lib/helpers.ts
CHANGED
|
@@ -138,20 +138,30 @@ export function generateWatchNamespaceError(
|
|
|
138
138
|
export function namespaceComplianceValidator(
|
|
139
139
|
capability: CapabilityExport,
|
|
140
140
|
ignoredNamespaces?: string[],
|
|
141
|
+
watch?: boolean,
|
|
141
142
|
): void {
|
|
142
143
|
const { namespaces: capabilityNamespaces, bindings, name } = capability;
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
|
|
145
|
+
const shouldInclude = (binding: Binding): boolean => {
|
|
146
|
+
if (watch === true) return !!binding.isWatch;
|
|
147
|
+
if (watch === false) return !!binding.isMutate;
|
|
148
|
+
return true;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const bindingNamespaces: string[] = bindings.flatMap(binding =>
|
|
152
|
+
shouldInclude(binding) ? binding.filters.namespaces || [] : [],
|
|
145
153
|
);
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
|
|
155
|
+
const bindingRegexNamespaces: string[] = bindings.flatMap(binding =>
|
|
156
|
+
shouldInclude(binding) ? binding.filters.regexNamespaces || [] : [],
|
|
148
157
|
);
|
|
149
158
|
|
|
150
159
|
const namespaceError = generateWatchNamespaceError(
|
|
151
|
-
ignoredNamespaces
|
|
160
|
+
ignoredNamespaces ?? [],
|
|
152
161
|
bindingNamespaces,
|
|
153
|
-
capabilityNamespaces
|
|
162
|
+
capabilityNamespaces ?? [],
|
|
154
163
|
);
|
|
164
|
+
|
|
155
165
|
if (namespaceError !== "") {
|
|
156
166
|
throw new Error(
|
|
157
167
|
`Error in ${name} capability. A binding violates namespace rules. Please check ignoredNamespaces and capability namespaces: ${namespaceError}`,
|
|
@@ -13,7 +13,7 @@ import { ModuleConfig } from "../types";
|
|
|
13
13
|
import { PeprMutateRequest } from "../mutate-request";
|
|
14
14
|
import { base64Encode } from "../utils";
|
|
15
15
|
import { OnError } from "../../cli/init/enums";
|
|
16
|
-
import { resolveIgnoreNamespaces } from "../assets/
|
|
16
|
+
import { resolveIgnoreNamespaces } from "../assets/ignoredNamespaces";
|
|
17
17
|
import { Operation } from "fast-json-patch";
|
|
18
18
|
import { WebhookType } from "../enums";
|
|
19
19
|
|
|
@@ -149,7 +149,11 @@ export async function mutateProcessor(
|
|
|
149
149
|
bind.binding,
|
|
150
150
|
bind.req,
|
|
151
151
|
bind.namespaces,
|
|
152
|
-
resolveIgnoreNamespaces(
|
|
152
|
+
resolveIgnoreNamespaces(
|
|
153
|
+
bind?.config?.alwaysIgnore?.namespaces?.length
|
|
154
|
+
? bind.config?.alwaysIgnore?.namespaces
|
|
155
|
+
: bind.config?.admission?.alwaysIgnore?.namespaces,
|
|
156
|
+
),
|
|
153
157
|
);
|
|
154
158
|
if (shouldSkip !== "") {
|
|
155
159
|
Log.debug(shouldSkip);
|
|
@@ -10,7 +10,7 @@ import Log from "../telemetry/logger";
|
|
|
10
10
|
import { convertFromBase64Map } from "../utils";
|
|
11
11
|
import { PeprValidateRequest } from "../validate-request";
|
|
12
12
|
import { ModuleConfig } from "../types";
|
|
13
|
-
import { resolveIgnoreNamespaces } from "../assets/
|
|
13
|
+
import { resolveIgnoreNamespaces } from "../assets/ignoredNamespaces";
|
|
14
14
|
import { MeasureWebhookTimeout } from "../telemetry/webhookTimeouts";
|
|
15
15
|
import { WebhookType } from "../enums";
|
|
16
16
|
import { AdmissionRequest } from "../common-types";
|
|
@@ -95,7 +95,11 @@ export async function validateProcessor(
|
|
|
95
95
|
binding,
|
|
96
96
|
req,
|
|
97
97
|
namespaces,
|
|
98
|
-
resolveIgnoreNamespaces(
|
|
98
|
+
resolveIgnoreNamespaces(
|
|
99
|
+
config?.alwaysIgnore?.namespaces?.length
|
|
100
|
+
? config?.alwaysIgnore?.namespaces
|
|
101
|
+
: config?.admission?.alwaysIgnore?.namespaces,
|
|
102
|
+
),
|
|
99
103
|
);
|
|
100
104
|
if (shouldSkip !== "") {
|
|
101
105
|
Log.debug(shouldSkip);
|
package/src/lib/types.ts
CHANGED
|
@@ -292,6 +292,14 @@ export type ModuleConfig = {
|
|
|
292
292
|
uuid: string;
|
|
293
293
|
/** Configure global exclusions that will never be processed by Pepr. */
|
|
294
294
|
alwaysIgnore: WebhookIgnore;
|
|
295
|
+
/** admission specific ignore */
|
|
296
|
+
admission?: {
|
|
297
|
+
alwaysIgnore: WebhookIgnore;
|
|
298
|
+
};
|
|
299
|
+
/** watch specific ignore */
|
|
300
|
+
watch?: {
|
|
301
|
+
alwaysIgnore: WebhookIgnore;
|
|
302
|
+
};
|
|
295
303
|
} & Partial<ModuleConfigOptions>;
|
|
296
304
|
|
|
297
305
|
export type PackageJSON = {
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -109,17 +109,20 @@ export function getOwnerRefFrom(
|
|
|
109
109
|
*
|
|
110
110
|
* @param name the name of the resource to sanitize
|
|
111
111
|
* @returns the sanitized resource name
|
|
112
|
+
*
|
|
113
|
+
* https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
|
|
112
114
|
*/
|
|
113
115
|
export function sanitizeResourceName(name: string): string {
|
|
114
116
|
return (
|
|
115
117
|
name
|
|
116
|
-
// The name must be lowercase
|
|
117
118
|
.toLowerCase()
|
|
118
|
-
// Replace
|
|
119
|
-
.replace(/[^a-z0-9]+/g, "-")
|
|
120
|
-
//
|
|
121
|
-
.slice(0,
|
|
122
|
-
// Remove leading
|
|
123
|
-
.replace(/^[^a-
|
|
119
|
+
// Replace invalid characters (anything not a-z, 0-9, or '-') with '-'
|
|
120
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
121
|
+
// Trim to 63 characters (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#rfc-1035-label-names)
|
|
122
|
+
.slice(0, 63)
|
|
123
|
+
// Remove leading non-alphanumeric characters
|
|
124
|
+
.replace(/^[^a-z0-9]+/, "")
|
|
125
|
+
// Remove trailing non-alphanumeric characters
|
|
126
|
+
.replace(/[^a-z0-9]+$/, "")
|
|
124
127
|
);
|
|
125
128
|
}
|