@intentius/chant-lexicon-cpln 0.53.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/README.md +85 -0
- package/dist/api.d.ts +77 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/codegen/docs-cli.d.ts +3 -0
- package/dist/codegen/docs-cli.d.ts.map +1 -0
- package/dist/codegen/docs.d.ts +17 -0
- package/dist/codegen/docs.d.ts.map +1 -0
- package/dist/codegen/generate-cli.d.ts +6 -0
- package/dist/codegen/generate-cli.d.ts.map +1 -0
- package/dist/codegen/generate-lexicon.d.ts +36 -0
- package/dist/codegen/generate-lexicon.d.ts.map +1 -0
- package/dist/codegen/generate-typescript.d.ts +11 -0
- package/dist/codegen/generate-typescript.d.ts.map +1 -0
- package/dist/codegen/generate.d.ts +15 -0
- package/dist/codegen/generate.d.ts.map +1 -0
- package/dist/codegen/naming.d.ts +30 -0
- package/dist/codegen/naming.d.ts.map +1 -0
- package/dist/codegen/package.d.ts +17 -0
- package/dist/codegen/package.d.ts.map +1 -0
- package/dist/composites/cron-job.d.ts +60 -0
- package/dist/composites/cron-job.d.ts.map +1 -0
- package/dist/composites/gvc-environment.d.ts +47 -0
- package/dist/composites/gvc-environment.d.ts.map +1 -0
- package/dist/composites/index.d.ts +13 -0
- package/dist/composites/index.d.ts.map +1 -0
- package/dist/composites/public-domain.d.ts +68 -0
- package/dist/composites/public-domain.d.ts.map +1 -0
- package/dist/composites/secret-access.d.ts +78 -0
- package/dist/composites/secret-access.d.ts.map +1 -0
- package/dist/composites/serverless-service.d.ts +78 -0
- package/dist/composites/serverless-service.d.ts.map +1 -0
- package/dist/composites/stateful-service.d.ts +79 -0
- package/dist/composites/stateful-service.d.ts.map +1 -0
- package/dist/coverage.d.ts +59 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/describe-resources.d.ts +71 -0
- package/dist/describe-resources.d.ts.map +1 -0
- package/dist/detect.d.ts +14 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/entity-props.d.ts +34 -0
- package/dist/entity-props.d.ts.map +1 -0
- package/dist/generated/index.d.ts +151 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/runtime.d.ts +5 -0
- package/dist/generated/runtime.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/init-templates.d.ts +16 -0
- package/dist/init-templates.d.ts.map +1 -0
- package/dist/integrity.json +35 -0
- package/dist/kinds.d.ts +70 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/lint/audit-catalog.d.ts +19 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl010-unrestricted-outbound.d.ts +12 -0
- package/dist/lint/post-synth/cpl010-unrestricted-outbound.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl011-internal-firewall-scope.d.ts +11 -0
- package/dist/lint/post-synth/cpl011-internal-firewall-scope.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl012-no-literal-credential-env.d.ts +11 -0
- package/dist/lint/post-synth/cpl012-no-literal-credential-env.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl013-qualified-identity-principal.d.ts +11 -0
- package/dist/lint/post-synth/cpl013-qualified-identity-principal.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl014-qualified-secret-ref.d.ts +14 -0
- package/dist/lint/post-synth/cpl014-qualified-secret-ref.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl020-serverless-single-port.d.ts +10 -0
- package/dist/lint/post-synth/cpl020-serverless-single-port.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl021-cron-job-shape.d.ts +11 -0
- package/dist/lint/post-synth/cpl021-cron-job-shape.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl022-container-ports.d.ts +10 -0
- package/dist/lint/post-synth/cpl022-container-ports.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl023-container-resources.d.ts +12 -0
- package/dist/lint/post-synth/cpl023-container-resources.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl024-probe-handler.d.ts +10 -0
- package/dist/lint/post-synth/cpl024-probe-handler.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl025-autoscaling-shape.d.ts +11 -0
- package/dist/lint/post-synth/cpl025-autoscaling-shape.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl026-scale-to-zero.d.ts +11 -0
- package/dist/lint/post-synth/cpl026-scale-to-zero.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl027-capacity-ai-conflict.d.ts +13 -0
- package/dist/lint/post-synth/cpl027-capacity-ai-conflict.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl028-volume-set.d.ts +3 -0
- package/dist/lint/post-synth/cpl028-volume-set.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl029-link-targets.d.ts +3 -0
- package/dist/lint/post-synth/cpl029-link-targets.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl030-domain-routing.d.ts +3 -0
- package/dist/lint/post-synth/cpl030-domain-routing.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl040-pinned-image.d.ts +11 -0
- package/dist/lint/post-synth/cpl040-pinned-image.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl041-image-reference-form.d.ts +12 -0
- package/dist/lint/post-synth/cpl041-image-reference-form.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl042-gvc-placement.d.ts +10 -0
- package/dist/lint/post-synth/cpl042-gvc-placement.d.ts.map +1 -0
- package/dist/lint/post-synth/cpl043-policy-scope.d.ts +16 -0
- package/dist/lint/post-synth/cpl043-policy-scope.d.ts.map +1 -0
- package/dist/lint/post-synth/helpers.d.ts +45 -0
- package/dist/lint/post-synth/helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts +3 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -0
- package/dist/lint/rules/cpl001-no-secret-literals.d.ts +3 -0
- package/dist/lint/rules/cpl001-no-secret-literals.d.ts.map +1 -0
- package/dist/lint/rules/cpl002-prefer-resource-reference.d.ts +3 -0
- package/dist/lint/rules/cpl002-prefer-resource-reference.d.ts.map +1 -0
- package/dist/lint/rules/index.d.ts +6 -0
- package/dist/lint/rules/index.d.ts.map +1 -0
- package/dist/lsp/completions.d.ts +7 -0
- package/dist/lsp/completions.d.ts.map +1 -0
- package/dist/lsp/hover.d.ts +4 -0
- package/dist/lsp/hover.d.ts.map +1 -0
- package/dist/manifest.json +6 -0
- package/dist/meta.json +2110 -0
- package/dist/okf/index.md +39 -0
- package/dist/okf/rules/CPL001.md +22 -0
- package/dist/okf/rules/CPL002.md +22 -0
- package/dist/okf/rules/CPL010.md +15 -0
- package/dist/okf/rules/CPL011.md +15 -0
- package/dist/okf/rules/CPL012.md +15 -0
- package/dist/okf/rules/CPL013.md +15 -0
- package/dist/okf/rules/CPL014.md +16 -0
- package/dist/okf/rules/CPL020.md +11 -0
- package/dist/okf/rules/CPL021.md +15 -0
- package/dist/okf/rules/CPL022.md +15 -0
- package/dist/okf/rules/CPL023.md +15 -0
- package/dist/okf/rules/CPL024.md +15 -0
- package/dist/okf/rules/CPL025.md +15 -0
- package/dist/okf/rules/CPL026.md +15 -0
- package/dist/okf/rules/CPL027.md +15 -0
- package/dist/okf/rules/CPL028.md +15 -0
- package/dist/okf/rules/CPL029.md +15 -0
- package/dist/okf/rules/CPL030.md +16 -0
- package/dist/okf/rules/CPL040.md +15 -0
- package/dist/okf/rules/CPL041.md +15 -0
- package/dist/okf/rules/CPL042.md +11 -0
- package/dist/okf/rules/CPL043.md +15 -0
- package/dist/okf/types/Domain.md +22 -0
- package/dist/okf/types/Gvc.md +21 -0
- package/dist/okf/types/Identity.md +29 -0
- package/dist/okf/types/IpSet.md +21 -0
- package/dist/okf/types/Policy.md +28 -0
- package/dist/okf/types/Secret.md +23 -0
- package/dist/okf/types/VolumeSet.md +22 -0
- package/dist/okf/types/Workload.md +38 -0
- package/dist/ownership.d.ts +23 -0
- package/dist/ownership.d.ts.map +1 -0
- package/dist/package-cli.d.ts +3 -0
- package/dist/package-cli.d.ts.map +1 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/reference-catalog.d.ts +24 -0
- package/dist/reference-catalog.d.ts.map +1 -0
- package/dist/rules/cpl001-no-secret-literals.ts +83 -0
- package/dist/rules/cpl002-prefer-resource-reference.ts +71 -0
- package/dist/rules/cpl010-unrestricted-outbound.ts +41 -0
- package/dist/rules/cpl011-internal-firewall-scope.ts +38 -0
- package/dist/rules/cpl012-no-literal-credential-env.ts +58 -0
- package/dist/rules/cpl013-qualified-identity-principal.ts +45 -0
- package/dist/rules/cpl014-qualified-secret-ref.ts +54 -0
- package/dist/rules/cpl020-serverless-single-port.ts +58 -0
- package/dist/rules/cpl021-cron-job-shape.ts +64 -0
- package/dist/rules/cpl022-container-ports.ts +64 -0
- package/dist/rules/cpl023-container-resources.ts +87 -0
- package/dist/rules/cpl024-probe-handler.ts +51 -0
- package/dist/rules/cpl025-autoscaling-shape.ts +100 -0
- package/dist/rules/cpl026-scale-to-zero.ts +67 -0
- package/dist/rules/cpl027-capacity-ai-conflict.ts +78 -0
- package/dist/rules/cpl028-volume-set.ts +183 -0
- package/dist/rules/cpl029-link-targets.ts +155 -0
- package/dist/rules/cpl030-domain-routing.ts +137 -0
- package/dist/rules/cpl040-pinned-image.ts +48 -0
- package/dist/rules/cpl041-image-reference-form.ts +60 -0
- package/dist/rules/cpl042-gvc-placement.ts +57 -0
- package/dist/rules/cpl043-policy-scope.ts +0 -0
- package/dist/rules/helpers.ts +114 -0
- package/dist/serializer.d.ts +69 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/skills/chant-cpln-secrets.md +110 -0
- package/dist/skills/chant-cpln-workloads.md +78 -0
- package/dist/skills/chant-cpln.md +103 -0
- package/dist/spec/fetch.d.ts +43 -0
- package/dist/spec/fetch.d.ts.map +1 -0
- package/dist/spec/parse.d.ts +79 -0
- package/dist/spec/parse.d.ts.map +1 -0
- package/dist/spec/snapshot-cli.d.ts +18 -0
- package/dist/spec/snapshot-cli.d.ts.map +1 -0
- package/dist/types/index.d.ts +1649 -0
- package/dist/validate-cli.d.ts +3 -0
- package/dist/validate-cli.d.ts.map +1 -0
- package/dist/validate.d.ts +26 -0
- package/dist/validate.d.ts.map +1 -0
- package/package.json +74 -0
- package/src/api.ts +134 -0
- package/src/codegen/docs-cli.ts +7 -0
- package/src/codegen/docs.ts +94 -0
- package/src/codegen/generate-cli.ts +34 -0
- package/src/codegen/generate-lexicon.ts +88 -0
- package/src/codegen/generate-typescript.ts +71 -0
- package/src/codegen/generate.ts +110 -0
- package/src/codegen/naming.ts +61 -0
- package/src/codegen/package.ts +35 -0
- package/src/composites/composites.test.ts +252 -0
- package/src/composites/cron-job.ts +124 -0
- package/src/composites/gvc-environment.ts +104 -0
- package/src/composites/index.ts +17 -0
- package/src/composites/public-domain.ts +144 -0
- package/src/composites/secret-access.ts +136 -0
- package/src/composites/serverless-service.ts +143 -0
- package/src/composites/stateful-service.ts +179 -0
- package/src/coverage.ts +149 -0
- package/src/describe-resources.test.ts +252 -0
- package/src/describe-resources.ts +310 -0
- package/src/detect.ts +58 -0
- package/src/entity-props.ts +98 -0
- package/src/generated/index.d.ts +1649 -0
- package/src/generated/index.ts +156 -0
- package/src/generated/lexicon-cpln.json +2110 -0
- package/src/generated/runtime.ts +4 -0
- package/src/index.ts +31 -0
- package/src/init-templates.ts +131 -0
- package/src/kinds.ts +173 -0
- package/src/lint/audit-catalog.ts +230 -0
- package/src/lint/post-synth/cpl010-unrestricted-outbound.ts +41 -0
- package/src/lint/post-synth/cpl011-internal-firewall-scope.ts +38 -0
- package/src/lint/post-synth/cpl012-no-literal-credential-env.ts +58 -0
- package/src/lint/post-synth/cpl013-qualified-identity-principal.ts +45 -0
- package/src/lint/post-synth/cpl014-qualified-secret-ref.ts +54 -0
- package/src/lint/post-synth/cpl020-serverless-single-port.ts +58 -0
- package/src/lint/post-synth/cpl021-cron-job-shape.ts +64 -0
- package/src/lint/post-synth/cpl022-container-ports.ts +64 -0
- package/src/lint/post-synth/cpl023-container-resources.ts +87 -0
- package/src/lint/post-synth/cpl024-probe-handler.ts +51 -0
- package/src/lint/post-synth/cpl025-autoscaling-shape.ts +100 -0
- package/src/lint/post-synth/cpl026-scale-to-zero.ts +67 -0
- package/src/lint/post-synth/cpl027-capacity-ai-conflict.ts +78 -0
- package/src/lint/post-synth/cpl028-volume-set.ts +183 -0
- package/src/lint/post-synth/cpl029-link-targets.ts +155 -0
- package/src/lint/post-synth/cpl030-domain-routing.ts +137 -0
- package/src/lint/post-synth/cpl040-pinned-image.ts +48 -0
- package/src/lint/post-synth/cpl041-image-reference-form.ts +60 -0
- package/src/lint/post-synth/cpl042-gvc-placement.ts +57 -0
- package/src/lint/post-synth/cpl043-policy-scope.ts +0 -0
- package/src/lint/post-synth/helpers.ts +114 -0
- package/src/lint/post-synth/index.ts +45 -0
- package/src/lint/post-synth/post-synth.test.ts +737 -0
- package/src/lint/rules/cpl001-no-secret-literals.ts +83 -0
- package/src/lint/rules/cpl002-prefer-resource-reference.ts +71 -0
- package/src/lint/rules/index.ts +9 -0
- package/src/lint/rules/rules.test.ts +108 -0
- package/src/lsp/completions.test.ts +44 -0
- package/src/lsp/completions.ts +27 -0
- package/src/lsp/hover.test.ts +53 -0
- package/src/lsp/hover.ts +130 -0
- package/src/ownership.ts +28 -0
- package/src/package-cli.ts +25 -0
- package/src/plugin.test.ts +131 -0
- package/src/plugin.ts +187 -0
- package/src/reference-catalog.ts +110 -0
- package/src/serializer.test.ts +233 -0
- package/src/serializer.ts +253 -0
- package/src/skills/chant-cpln-secrets.md +110 -0
- package/src/skills/chant-cpln-workloads.md +78 -0
- package/src/skills/chant-cpln.md +103 -0
- package/src/spec/cpln-openapi.snapshot.json +10651 -0
- package/src/spec/fetch.ts +77 -0
- package/src/spec/parse.ts +451 -0
- package/src/spec/snapshot-cli.ts +71 -0
- package/src/validate-cli.ts +8 -0
- package/src/validate.ts +102 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
2
|
+
import { readArray, readPath, readString } from "../../entity-props";
|
|
3
|
+
import { GVC, entitiesOfType } from "./helpers";
|
|
4
|
+
|
|
5
|
+
/** Location links look like `/org/ORG/location/aws-us-east-1` or `//location/aws-us-east-1`. */
|
|
6
|
+
const LOCATION_LINK = /\/location\/((aws|gcp|azure)-[a-z0-9-]+|[a-z0-9-]+)$/;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* CPL042: a GVC with nowhere to run.
|
|
10
|
+
*
|
|
11
|
+
* Placement is a GVC-level decision, and a GVC with neither `locationLinks` nor
|
|
12
|
+
* a `locationQuery` accepts workloads and schedules them nowhere. The workloads
|
|
13
|
+
* apply cleanly and never become ready.
|
|
14
|
+
*/
|
|
15
|
+
export const gvcPlacementCheck: PostSynthCheck = {
|
|
16
|
+
id: "CPL042",
|
|
17
|
+
description: "A GVC must declare where its workloads run",
|
|
18
|
+
|
|
19
|
+
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
20
|
+
const diagnostics: PostSynthDiagnostic[] = [];
|
|
21
|
+
|
|
22
|
+
for (const [entityName, entity] of entitiesOfType(ctx.entities, GVC)) {
|
|
23
|
+
const name = readString(entity, "name") ?? entityName;
|
|
24
|
+
const links = readArray(entity, "spec", "staticPlacement", "locationLinks");
|
|
25
|
+
const query = readPath(entity, "spec", "staticPlacement", "locationQuery");
|
|
26
|
+
|
|
27
|
+
if (links.length === 0 && query === undefined) {
|
|
28
|
+
diagnostics.push({
|
|
29
|
+
checkId: "CPL042",
|
|
30
|
+
severity: "error",
|
|
31
|
+
message:
|
|
32
|
+
`GVC "${name}" declares no placement. Set spec.staticPlacement.locationLinks (or a ` +
|
|
33
|
+
`locationQuery) — without one, its workloads apply cleanly and are scheduled nowhere.`,
|
|
34
|
+
entity: entityName,
|
|
35
|
+
lexicon: "cpln",
|
|
36
|
+
});
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
for (const link of links) {
|
|
41
|
+
if (typeof link !== "string") continue;
|
|
42
|
+
if (LOCATION_LINK.test(link)) continue;
|
|
43
|
+
diagnostics.push({
|
|
44
|
+
checkId: "CPL042",
|
|
45
|
+
severity: "warning",
|
|
46
|
+
message:
|
|
47
|
+
`GVC "${name}" has location link "${link}", which does not look like a location. Expected ` +
|
|
48
|
+
`/org/<org>/location/<provider>-<region>, e.g. /org/acme/location/aws-us-east-1.`,
|
|
49
|
+
entity: entityName,
|
|
50
|
+
lexicon: "cpln",
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return diagnostics;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared reading and parsing for the CPL post-synth checks.
|
|
3
|
+
*
|
|
4
|
+
* Each check lives in its own file named for its id, so `CPL027` is greppable
|
|
5
|
+
* to one place. What they have in common lands here rather than being repeated
|
|
6
|
+
* or, worse, drifting: the workload-type default, the port enumeration that has
|
|
7
|
+
* to span both `port` and `ports`, and the quantity parsers.
|
|
8
|
+
*
|
|
9
|
+
* Named `helpers.ts` deliberately — the completeness checker's post-synth count
|
|
10
|
+
* excludes that filename, so a support module is not miscounted as a check.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
14
|
+
import { readArray, readNumber, readPath, readString } from "../../entity-props";
|
|
15
|
+
import { kindByName } from "../../kinds";
|
|
16
|
+
|
|
17
|
+
export const WORKLOAD = kindByName("workload")!.typeName;
|
|
18
|
+
export const GVC = kindByName("gvc")!.typeName;
|
|
19
|
+
export const POLICY = kindByName("policy")!.typeName;
|
|
20
|
+
export const DOMAIN = kindByName("domain")!.typeName;
|
|
21
|
+
export const VOLUMESET = kindByName("volumeset")!.typeName;
|
|
22
|
+
|
|
23
|
+
/** Control Plane defaults an unset workload type to `serverless`. */
|
|
24
|
+
export function workloadType(entity: unknown): string {
|
|
25
|
+
return readString(entity, "spec", "type") ?? "serverless";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The autoscaling block from `defaultOptions`. */
|
|
29
|
+
export function autoscalingOf(entity: unknown): unknown {
|
|
30
|
+
return readPath(entity, "spec", "defaultOptions", "autoscaling");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Every port a workload's containers expose, across both `port` and `ports`. */
|
|
34
|
+
export function exposedPorts(entity: unknown): number[] {
|
|
35
|
+
const ports: number[] = [];
|
|
36
|
+
for (const container of readArray(entity, "spec", "containers")) {
|
|
37
|
+
const single = readNumber(container, "port");
|
|
38
|
+
if (single !== undefined) ports.push(single);
|
|
39
|
+
for (const port of readArray(container, "ports")) {
|
|
40
|
+
const number = readNumber(port, "number");
|
|
41
|
+
if (number !== undefined) ports.push(number);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return ports;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Parse a CPU quantity (`"50m"`, `"1"`, `"1.5"`) to millicores. */
|
|
48
|
+
export function parseCpuMillicores(value: string | undefined): number | undefined {
|
|
49
|
+
if (!value) return undefined;
|
|
50
|
+
const match = /^(\d+(?:\.\d+)?)(m?)$/.exec(value.trim());
|
|
51
|
+
if (!match) return undefined;
|
|
52
|
+
const amount = Number(match[1]);
|
|
53
|
+
return match[2] === "m" ? amount : amount * 1000;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Parse a memory quantity (`"128Mi"`, `"1Gi"`, `"512M"`) to MiB. */
|
|
57
|
+
export function parseMemoryMib(value: string | undefined): number | undefined {
|
|
58
|
+
if (!value) return undefined;
|
|
59
|
+
const match = /^(\d+(?:\.\d+)?)(Ki|Mi|Gi|Ti|K|M|G|T)?$/.exec(value.trim());
|
|
60
|
+
if (!match) return undefined;
|
|
61
|
+
const amount = Number(match[1]);
|
|
62
|
+
const factors: Record<string, number> = {
|
|
63
|
+
Ki: 1 / 1024,
|
|
64
|
+
Mi: 1,
|
|
65
|
+
Gi: 1024,
|
|
66
|
+
Ti: 1024 * 1024,
|
|
67
|
+
// Decimal suffixes, converted to MiB so one comparison covers both families.
|
|
68
|
+
K: 1000 / (1024 * 1024),
|
|
69
|
+
M: 1_000_000 / (1024 * 1024),
|
|
70
|
+
G: 1_000_000_000 / (1024 * 1024),
|
|
71
|
+
T: 1_000_000_000_000 / (1024 * 1024),
|
|
72
|
+
};
|
|
73
|
+
const suffix = match[2];
|
|
74
|
+
if (!suffix) return amount / (1024 * 1024); // bare bytes
|
|
75
|
+
return amount * factors[suffix];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The tag of an image reference, or undefined when untagged.
|
|
80
|
+
*
|
|
81
|
+
* A colon in a registry host's port (`registry:5000/app`) is not a tag, so only
|
|
82
|
+
* a colon after the last slash counts.
|
|
83
|
+
*/
|
|
84
|
+
export function imageTag(image: string): string | undefined {
|
|
85
|
+
const lastSlash = image.lastIndexOf("/");
|
|
86
|
+
const colon = image.indexOf(":", lastSlash + 1);
|
|
87
|
+
return colon === -1 ? undefined : image.slice(colon + 1);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface ParsedLink {
|
|
91
|
+
kind: string;
|
|
92
|
+
name: string;
|
|
93
|
+
gvc?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** `//gvc/prod/identity/api` → kind `identity`, name `api`, gvc `prod`. */
|
|
97
|
+
const GVC_SCOPED_LINK = /^\/\/gvc\/([^/]+)\/([a-z]+)\/([^/]+)$/;
|
|
98
|
+
/** `//secret/db-password` → kind `secret`, name `db-password`. */
|
|
99
|
+
const ORG_SCOPED_LINK = /^\/\/([a-z]+)\/([^/]+)$/;
|
|
100
|
+
|
|
101
|
+
/** Parse a Control Plane link, or return undefined if it is not one. */
|
|
102
|
+
export function parseLink(value: string): ParsedLink | undefined {
|
|
103
|
+
const scoped = GVC_SCOPED_LINK.exec(value);
|
|
104
|
+
if (scoped) return { gvc: scoped[1], kind: scoped[2], name: scoped[3] };
|
|
105
|
+
|
|
106
|
+
const org = ORG_SCOPED_LINK.exec(value);
|
|
107
|
+
if (org) return { kind: org[1], name: org[2] };
|
|
108
|
+
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Iterate entities of one type. Re-exported so checks import one module. */
|
|
113
|
+
export { entitiesOfType } from "../../entity-props";
|
|
114
|
+
export type { Declarable };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Code generated by chant generate. DO NOT EDIT.
|
|
2
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
3
|
+
import { unrestrictedOutboundCheck } from "./cpl010-unrestricted-outbound";
|
|
4
|
+
import { internalFirewallScopeCheck } from "./cpl011-internal-firewall-scope";
|
|
5
|
+
import { noLiteralCredentialEnvCheck } from "./cpl012-no-literal-credential-env";
|
|
6
|
+
import { qualifiedIdentityPrincipalCheck } from "./cpl013-qualified-identity-principal";
|
|
7
|
+
import { qualifiedSecretRefCheck } from "./cpl014-qualified-secret-ref";
|
|
8
|
+
import { serverlessSinglePortCheck } from "./cpl020-serverless-single-port";
|
|
9
|
+
import { cronJobShapeCheck } from "./cpl021-cron-job-shape";
|
|
10
|
+
import { containerPortsCheck } from "./cpl022-container-ports";
|
|
11
|
+
import { containerResourcesCheck } from "./cpl023-container-resources";
|
|
12
|
+
import { probeHandlerCheck } from "./cpl024-probe-handler";
|
|
13
|
+
import { autoscalingShapeCheck } from "./cpl025-autoscaling-shape";
|
|
14
|
+
import { scaleToZeroCheck } from "./cpl026-scale-to-zero";
|
|
15
|
+
import { capacityAiConflictCheck } from "./cpl027-capacity-ai-conflict";
|
|
16
|
+
import { volumeSetCheck } from "./cpl028-volume-set";
|
|
17
|
+
import { linkTargetsCheck } from "./cpl029-link-targets";
|
|
18
|
+
import { domainRoutingCheck } from "./cpl030-domain-routing";
|
|
19
|
+
import { pinnedImageCheck } from "./cpl040-pinned-image";
|
|
20
|
+
import { imageReferenceFormCheck } from "./cpl041-image-reference-form";
|
|
21
|
+
import { gvcPlacementCheck } from "./cpl042-gvc-placement";
|
|
22
|
+
import { policyScopeCheck } from "./cpl043-policy-scope";
|
|
23
|
+
|
|
24
|
+
export const postSynthChecks: PostSynthCheck[] = [
|
|
25
|
+
unrestrictedOutboundCheck,
|
|
26
|
+
internalFirewallScopeCheck,
|
|
27
|
+
noLiteralCredentialEnvCheck,
|
|
28
|
+
qualifiedIdentityPrincipalCheck,
|
|
29
|
+
qualifiedSecretRefCheck,
|
|
30
|
+
serverlessSinglePortCheck,
|
|
31
|
+
cronJobShapeCheck,
|
|
32
|
+
containerPortsCheck,
|
|
33
|
+
containerResourcesCheck,
|
|
34
|
+
probeHandlerCheck,
|
|
35
|
+
autoscalingShapeCheck,
|
|
36
|
+
scaleToZeroCheck,
|
|
37
|
+
capacityAiConflictCheck,
|
|
38
|
+
volumeSetCheck,
|
|
39
|
+
linkTargetsCheck,
|
|
40
|
+
domainRoutingCheck,
|
|
41
|
+
pinnedImageCheck,
|
|
42
|
+
imageReferenceFormCheck,
|
|
43
|
+
gvcPlacementCheck,
|
|
44
|
+
policyScopeCheck,
|
|
45
|
+
];
|