@intentius/chant-lexicon-k8s 0.121.1 → 0.123.0
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/integrity.json +3 -3
- package/dist/lint/rules/hardcoded-namespace.d.ts +0 -10
- package/dist/lint/rules/hardcoded-namespace.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/rules/hardcoded-namespace.ts +17 -2
- package/package.json +3 -3
- package/src/lint/rules/hardcoded-namespace.ts +17 -2
package/dist/integrity.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "56813d7035054bfab4ce70fba22c1455d77903dc35b22ead041b6e759c37dc4b",
|
|
5
5
|
"meta.json": "c1831ac15083f5e0e45b29698d7b77f1c01646240fe6de5d6320753188594f69",
|
|
6
6
|
"types/index.d.ts": "5c5340046d090ae9db5553039d923cf92a8b2eb57aa4dc941273ed5bcfb5bc9d",
|
|
7
7
|
"rules/argo-appset-single-project.ts": "afa9f310753aa2d475f35012b13135b2dfaebed2a35d44edbe185ebc07673674",
|
|
8
8
|
"rules/argo-ast.ts": "f57b7d84fef9c9cd326a7cad0dff290914e01299415d64bdab48e2f6eb4181c3",
|
|
9
9
|
"rules/argo-automated-prune.ts": "176ac5441c3ccb7106a194abab3abe22fd8a29f976716761c66c243b72d57b14",
|
|
10
10
|
"rules/flux-source-ref-pin.ts": "f25038eaba7f33ea679b59087d7557f3ffd2d798ea02db6f9f6929e36d470c6e",
|
|
11
|
-
"rules/hardcoded-namespace.ts": "
|
|
11
|
+
"rules/hardcoded-namespace.ts": "8dd82b6be3197285b82f5b92dfe0e25deb8048e16f90e8e5c28ee0d04804e384",
|
|
12
12
|
"rules/latest-image-tag.ts": "9dd961b791b4f424fc4edcdbdce69ad30476dc1cd03f66b8c8e19cb5f8a4082d",
|
|
13
13
|
"rules/missing-resource-limits.ts": "d64b5ed1c7c87d60e38eecfdad7668620222bbaf6ff6f4860adf54e816265bb2",
|
|
14
14
|
"rules/argo-helpers.ts": "ac68a33978b03c0fde7a6e4fa0c9a8907c21d11012d9408b6db64c66cb7ec635",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"skills/chant-k8s-argo.md": "24c9a85b78a2fc5c6657424baac9cc6d6caff6f47605b8146b2c0082133181cf",
|
|
79
79
|
"skills/chant-k8s-flux.md": "9670efc2e9854bd14686b5adeb707396b9030a4dcaee6529b30abf56efe2c50c"
|
|
80
80
|
},
|
|
81
|
-
"composite": "
|
|
81
|
+
"composite": "b16450e1fd1ae50df6b81d3b0784e631cc4f68ad441d1f354bfb0f669b98f589"
|
|
82
82
|
}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
import type { LintRule } from "@intentius/chant/lint/rule";
|
|
2
|
-
/**
|
|
3
|
-
* WK8001: Hardcoded Namespace
|
|
4
|
-
*
|
|
5
|
-
* Detects hardcoded namespace strings in Kubernetes resource constructors.
|
|
6
|
-
* Namespaces should be parameterized or derived from configuration, not
|
|
7
|
-
* hardcoded as string literals.
|
|
8
|
-
*
|
|
9
|
-
* Bad: new Deployment({ metadata: { namespace: "production" } })
|
|
10
|
-
* Good: new Deployment({ metadata: { namespace: config.namespace } })
|
|
11
|
-
*/
|
|
12
2
|
export declare const hardcodedNamespaceRule: LintRule;
|
|
13
3
|
//# sourceMappingURL=hardcoded-namespace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hardcoded-namespace.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/hardcoded-namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"hardcoded-namespace.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/hardcoded-namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,4BAA4B,CAAC;AA2BxF,eAAO,MAAM,sBAAsB,EAAE,QA2CpC,CAAC"}
|
package/dist/manifest.json
CHANGED
|
@@ -4,13 +4,27 @@ import * as ts from "typescript";
|
|
|
4
4
|
/**
|
|
5
5
|
* WK8001: Hardcoded Namespace
|
|
6
6
|
*
|
|
7
|
-
* Detects hardcoded namespace strings in Kubernetes resource
|
|
7
|
+
* Detects hardcoded namespace strings in a Kubernetes resource's `metadata`.
|
|
8
8
|
* Namespaces should be parameterized or derived from configuration, not
|
|
9
9
|
* hardcoded as string literals.
|
|
10
10
|
*
|
|
11
11
|
* Bad: new Deployment({ metadata: { namespace: "production" } })
|
|
12
12
|
* Good: new Deployment({ metadata: { namespace: config.namespace } })
|
|
13
13
|
*/
|
|
14
|
+
/**
|
|
15
|
+
* Only `metadata: { namespace }` is a Kubernetes namespace. Other `namespace`
|
|
16
|
+
* keys are another tool's setting (an OpenTelemetry connector's metric prefix,
|
|
17
|
+
* for one) and a k8s rule has no business flagging them.
|
|
18
|
+
*/
|
|
19
|
+
function isMetadataEntry(node: ts.PropertyAssignment): boolean {
|
|
20
|
+
const owner = node.parent.parent;
|
|
21
|
+
return (
|
|
22
|
+
ts.isPropertyAssignment(owner) &&
|
|
23
|
+
ts.isIdentifier(owner.name) &&
|
|
24
|
+
owner.name.text === "metadata"
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
export const hardcodedNamespaceRule: LintRule = {
|
|
15
29
|
id: "WK8001",
|
|
16
30
|
severity: "warning",
|
|
@@ -28,7 +42,8 @@ export const hardcodedNamespaceRule: LintRule = {
|
|
|
28
42
|
ts.isPropertyAssignment(node) &&
|
|
29
43
|
ts.isIdentifier(node.name) &&
|
|
30
44
|
node.name.text === "namespace" &&
|
|
31
|
-
ts.isStringLiteral(node.initializer)
|
|
45
|
+
ts.isStringLiteral(node.initializer) &&
|
|
46
|
+
isMetadataEntry(node)
|
|
32
47
|
) {
|
|
33
48
|
const value = node.initializer.text;
|
|
34
49
|
// Skip empty strings — those are likely intentional placeholders
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-k8s",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.123.0",
|
|
4
4
|
"description": "Kubernetes lexicon for chant — declarative IaC in TypeScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@types/js-yaml": "^4.0.9"
|
|
79
79
|
},
|
|
80
80
|
"optionalDependencies": {
|
|
81
|
-
"@intentius/chant-k8s-client": "^0.
|
|
81
|
+
"@intentius/chant-k8s-client": "^0.123.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@intentius/chant": "*",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"zod": "^4.3.6",
|
|
89
|
-
"@intentius/chant": "^0.
|
|
89
|
+
"@intentius/chant": "^0.123.0",
|
|
90
90
|
"typescript": "^5.9.3"
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -4,13 +4,27 @@ import * as ts from "typescript";
|
|
|
4
4
|
/**
|
|
5
5
|
* WK8001: Hardcoded Namespace
|
|
6
6
|
*
|
|
7
|
-
* Detects hardcoded namespace strings in Kubernetes resource
|
|
7
|
+
* Detects hardcoded namespace strings in a Kubernetes resource's `metadata`.
|
|
8
8
|
* Namespaces should be parameterized or derived from configuration, not
|
|
9
9
|
* hardcoded as string literals.
|
|
10
10
|
*
|
|
11
11
|
* Bad: new Deployment({ metadata: { namespace: "production" } })
|
|
12
12
|
* Good: new Deployment({ metadata: { namespace: config.namespace } })
|
|
13
13
|
*/
|
|
14
|
+
/**
|
|
15
|
+
* Only `metadata: { namespace }` is a Kubernetes namespace. Other `namespace`
|
|
16
|
+
* keys are another tool's setting (an OpenTelemetry connector's metric prefix,
|
|
17
|
+
* for one) and a k8s rule has no business flagging them.
|
|
18
|
+
*/
|
|
19
|
+
function isMetadataEntry(node: ts.PropertyAssignment): boolean {
|
|
20
|
+
const owner = node.parent.parent;
|
|
21
|
+
return (
|
|
22
|
+
ts.isPropertyAssignment(owner) &&
|
|
23
|
+
ts.isIdentifier(owner.name) &&
|
|
24
|
+
owner.name.text === "metadata"
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
export const hardcodedNamespaceRule: LintRule = {
|
|
15
29
|
id: "WK8001",
|
|
16
30
|
severity: "warning",
|
|
@@ -28,7 +42,8 @@ export const hardcodedNamespaceRule: LintRule = {
|
|
|
28
42
|
ts.isPropertyAssignment(node) &&
|
|
29
43
|
ts.isIdentifier(node.name) &&
|
|
30
44
|
node.name.text === "namespace" &&
|
|
31
|
-
ts.isStringLiteral(node.initializer)
|
|
45
|
+
ts.isStringLiteral(node.initializer) &&
|
|
46
|
+
isMetadataEntry(node)
|
|
32
47
|
) {
|
|
33
48
|
const value = node.initializer.text;
|
|
34
49
|
// Skip empty strings — those are likely intentional placeholders
|