@intentius/chant-lexicon-gcp 0.0.15
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 +36 -0
- package/dist/manifest.json +12 -0
- package/dist/meta.json +10919 -0
- package/dist/rules/gcp-helpers.ts +117 -0
- package/dist/rules/hardcoded-project.ts +58 -0
- package/dist/rules/hardcoded-region.ts +56 -0
- package/dist/rules/public-iam.ts +43 -0
- package/dist/rules/wgc101.ts +56 -0
- package/dist/rules/wgc102.ts +35 -0
- package/dist/rules/wgc103.ts +45 -0
- package/dist/rules/wgc104.ts +42 -0
- package/dist/rules/wgc105.ts +46 -0
- package/dist/rules/wgc106.ts +36 -0
- package/dist/rules/wgc107.ts +39 -0
- package/dist/rules/wgc108.ts +41 -0
- package/dist/rules/wgc109.ts +39 -0
- package/dist/rules/wgc110.ts +38 -0
- package/dist/rules/wgc111.ts +54 -0
- package/dist/rules/wgc112.ts +56 -0
- package/dist/rules/wgc113.ts +42 -0
- package/dist/rules/wgc201.ts +36 -0
- package/dist/rules/wgc202.ts +39 -0
- package/dist/rules/wgc203.ts +44 -0
- package/dist/rules/wgc204.ts +39 -0
- package/dist/rules/wgc301.ts +34 -0
- package/dist/rules/wgc302.ts +34 -0
- package/dist/rules/wgc303.ts +37 -0
- package/dist/skills/chant-gcp-patterns.md +367 -0
- package/dist/skills/chant-gcp-security.md +276 -0
- package/dist/skills/chant-gcp.md +108 -0
- package/dist/types/index.d.ts +26529 -0
- package/package.json +35 -0
- package/src/actions/index.ts +52 -0
- package/src/codegen/docs-cli.ts +7 -0
- package/src/codegen/docs.ts +820 -0
- package/src/codegen/generate-cli.ts +24 -0
- package/src/codegen/generate.ts +252 -0
- package/src/codegen/naming.test.ts +49 -0
- package/src/codegen/naming.ts +132 -0
- package/src/codegen/package.ts +66 -0
- package/src/composites/cloud-function.ts +117 -0
- package/src/composites/cloud-run-service.ts +124 -0
- package/src/composites/cloud-sql-instance.ts +126 -0
- package/src/composites/composites.test.ts +432 -0
- package/src/composites/gcs-bucket.ts +111 -0
- package/src/composites/gke-cluster.ts +125 -0
- package/src/composites/index.ts +20 -0
- package/src/composites/managed-certificate.ts +79 -0
- package/src/composites/private-service.ts +95 -0
- package/src/composites/pubsub-pipeline.ts +102 -0
- package/src/composites/secure-project.ts +128 -0
- package/src/composites/vpc-network.ts +165 -0
- package/src/coverage.test.ts +27 -0
- package/src/coverage.ts +51 -0
- package/src/default-labels.test.ts +111 -0
- package/src/default-labels.ts +93 -0
- package/src/generated/index.d.ts +26529 -0
- package/src/generated/index.ts +1723 -0
- package/src/generated/lexicon-gcp.json +10919 -0
- package/src/generated/runtime.ts +4 -0
- package/src/import/generator.test.ts +125 -0
- package/src/import/generator.ts +82 -0
- package/src/import/parser.test.ts +167 -0
- package/src/import/parser.ts +80 -0
- package/src/import/roundtrip.test.ts +66 -0
- package/src/index.ts +54 -0
- package/src/lint/post-synth/gcp-helpers.ts +117 -0
- package/src/lint/post-synth/index.ts +20 -0
- package/src/lint/post-synth/post-synth.test.ts +693 -0
- package/src/lint/post-synth/wgc101.ts +56 -0
- package/src/lint/post-synth/wgc102.ts +35 -0
- package/src/lint/post-synth/wgc103.ts +45 -0
- package/src/lint/post-synth/wgc104.ts +42 -0
- package/src/lint/post-synth/wgc105.ts +46 -0
- package/src/lint/post-synth/wgc106.ts +36 -0
- package/src/lint/post-synth/wgc107.ts +39 -0
- package/src/lint/post-synth/wgc108.ts +41 -0
- package/src/lint/post-synth/wgc109.ts +39 -0
- package/src/lint/post-synth/wgc110.ts +38 -0
- package/src/lint/post-synth/wgc111.ts +54 -0
- package/src/lint/post-synth/wgc112.ts +56 -0
- package/src/lint/post-synth/wgc113.ts +42 -0
- package/src/lint/post-synth/wgc201.ts +36 -0
- package/src/lint/post-synth/wgc202.ts +39 -0
- package/src/lint/post-synth/wgc203.ts +44 -0
- package/src/lint/post-synth/wgc204.ts +39 -0
- package/src/lint/post-synth/wgc301.ts +34 -0
- package/src/lint/post-synth/wgc302.ts +34 -0
- package/src/lint/post-synth/wgc303.ts +37 -0
- package/src/lint/rules/hardcoded-project.ts +58 -0
- package/src/lint/rules/hardcoded-region.ts +56 -0
- package/src/lint/rules/index.ts +3 -0
- package/src/lint/rules/public-iam.ts +43 -0
- package/src/lint/rules/rules.test.ts +63 -0
- package/src/lsp/completions.test.ts +67 -0
- package/src/lsp/completions.ts +17 -0
- package/src/lsp/hover.test.ts +66 -0
- package/src/lsp/hover.ts +54 -0
- package/src/package-cli.ts +24 -0
- package/src/plugin.test.ts +250 -0
- package/src/plugin.ts +405 -0
- package/src/pseudo.test.ts +40 -0
- package/src/pseudo.ts +19 -0
- package/src/serializer.test.ts +250 -0
- package/src/serializer.ts +232 -0
- package/src/skills/chant-gcp-patterns.md +367 -0
- package/src/skills/chant-gcp-security.md +276 -0
- package/src/skills/chant-gcp.md +108 -0
- package/src/spec/fetch.test.ts +16 -0
- package/src/spec/fetch.ts +121 -0
- package/src/spec/parse.test.ts +163 -0
- package/src/spec/parse.ts +432 -0
- package/src/testdata/compute-instance.yaml +93 -0
- package/src/testdata/iam-policy-member.yaml +66 -0
- package/src/testdata/manifests/compute-instance.yaml +18 -0
- package/src/testdata/manifests/full-app.yaml +34 -0
- package/src/testdata/manifests/storage-bucket.yaml +12 -0
- package/src/testdata/storage-bucket.yaml +100 -0
- package/src/validate-cli.ts +13 -0
- package/src/validate.test.ts +38 -0
- package/src/validate.ts +30 -0
- package/src/variables.ts +15 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
apiVersion: apiextensions.k8s.io/v1
|
|
2
|
+
kind: CustomResourceDefinition
|
|
3
|
+
metadata:
|
|
4
|
+
name: storagebuckets.storage.cnrm.cloud.google.com
|
|
5
|
+
spec:
|
|
6
|
+
group: storage.cnrm.cloud.google.com
|
|
7
|
+
names:
|
|
8
|
+
kind: StorageBucket
|
|
9
|
+
plural: storagebuckets
|
|
10
|
+
singular: storagebucket
|
|
11
|
+
versions:
|
|
12
|
+
- name: v1beta1
|
|
13
|
+
served: true
|
|
14
|
+
storage: true
|
|
15
|
+
schema:
|
|
16
|
+
openAPIV3Schema:
|
|
17
|
+
type: object
|
|
18
|
+
properties:
|
|
19
|
+
apiVersion:
|
|
20
|
+
type: string
|
|
21
|
+
kind:
|
|
22
|
+
type: string
|
|
23
|
+
metadata:
|
|
24
|
+
type: object
|
|
25
|
+
spec:
|
|
26
|
+
type: object
|
|
27
|
+
required:
|
|
28
|
+
- location
|
|
29
|
+
properties:
|
|
30
|
+
location:
|
|
31
|
+
type: string
|
|
32
|
+
description: The GCS location.
|
|
33
|
+
storageClass:
|
|
34
|
+
type: string
|
|
35
|
+
description: The Storage Class of the new bucket.
|
|
36
|
+
enum:
|
|
37
|
+
- STANDARD
|
|
38
|
+
- NEARLINE
|
|
39
|
+
- COLDLINE
|
|
40
|
+
- ARCHIVE
|
|
41
|
+
uniformBucketLevelAccess:
|
|
42
|
+
type: boolean
|
|
43
|
+
description: Enables uniform bucket-level access on a bucket.
|
|
44
|
+
versioning:
|
|
45
|
+
type: object
|
|
46
|
+
properties:
|
|
47
|
+
enabled:
|
|
48
|
+
type: boolean
|
|
49
|
+
encryption:
|
|
50
|
+
type: object
|
|
51
|
+
properties:
|
|
52
|
+
defaultKmsKeyName:
|
|
53
|
+
type: string
|
|
54
|
+
lifecycleRule:
|
|
55
|
+
type: array
|
|
56
|
+
items:
|
|
57
|
+
type: object
|
|
58
|
+
properties:
|
|
59
|
+
action:
|
|
60
|
+
type: object
|
|
61
|
+
properties:
|
|
62
|
+
type:
|
|
63
|
+
type: string
|
|
64
|
+
storageClass:
|
|
65
|
+
type: string
|
|
66
|
+
condition:
|
|
67
|
+
type: object
|
|
68
|
+
properties:
|
|
69
|
+
age:
|
|
70
|
+
type: integer
|
|
71
|
+
isLive:
|
|
72
|
+
type: boolean
|
|
73
|
+
cors:
|
|
74
|
+
type: array
|
|
75
|
+
items:
|
|
76
|
+
type: object
|
|
77
|
+
properties:
|
|
78
|
+
origin:
|
|
79
|
+
type: array
|
|
80
|
+
items:
|
|
81
|
+
type: string
|
|
82
|
+
method:
|
|
83
|
+
type: array
|
|
84
|
+
items:
|
|
85
|
+
type: string
|
|
86
|
+
responseHeader:
|
|
87
|
+
type: array
|
|
88
|
+
items:
|
|
89
|
+
type: string
|
|
90
|
+
maxAgeSeconds:
|
|
91
|
+
type: integer
|
|
92
|
+
resourceID:
|
|
93
|
+
type: string
|
|
94
|
+
status:
|
|
95
|
+
type: object
|
|
96
|
+
properties:
|
|
97
|
+
selfLink:
|
|
98
|
+
type: string
|
|
99
|
+
url:
|
|
100
|
+
type: string
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { validate } from "./validate";
|
|
3
|
+
import { printValidationResult } from "@intentius/chant/codegen/validate";
|
|
4
|
+
|
|
5
|
+
async function main() {
|
|
6
|
+
const result = await validate();
|
|
7
|
+
printValidationResult(result);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
main().catch((err) => {
|
|
11
|
+
console.error(err);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, test, expect } from "bun:test";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { join, dirname } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
const pkgDir = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
7
|
+
const hasGenerated = existsSync(join(pkgDir, "src", "generated", "lexicon-gcp.json"));
|
|
8
|
+
|
|
9
|
+
describe("validate", () => {
|
|
10
|
+
test("validate function exists and is exported", async () => {
|
|
11
|
+
const mod = await import("./validate");
|
|
12
|
+
expect(typeof mod.validate).toBe("function");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("REQUIRED_NAMES covers core resource types", async () => {
|
|
16
|
+
const mod = await import("./validate");
|
|
17
|
+
expect(mod.validate).toBeDefined();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test.skipIf(!hasGenerated)("validate succeeds with generated artifacts", async () => {
|
|
21
|
+
const { validate } = await import("./validate");
|
|
22
|
+
const result = await validate();
|
|
23
|
+
expect(result).toBeDefined();
|
|
24
|
+
expect(result.checks).toBeDefined();
|
|
25
|
+
expect(Array.isArray(result.checks)).toBe(true);
|
|
26
|
+
}, 60_000);
|
|
27
|
+
|
|
28
|
+
test("handles missing generated files", async () => {
|
|
29
|
+
const { validate } = await import("./validate");
|
|
30
|
+
if (!hasGenerated) {
|
|
31
|
+
try {
|
|
32
|
+
await validate();
|
|
33
|
+
} catch {
|
|
34
|
+
// Expected — no generated files
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
package/src/validate.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate generated lexicon-gcp artifacts.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { dirname } from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { validateLexiconArtifacts, type ValidateResult } from "@intentius/chant/codegen/validate";
|
|
8
|
+
|
|
9
|
+
export type { ValidateCheck, ValidateResult } from "@intentius/chant/codegen/validate";
|
|
10
|
+
|
|
11
|
+
const REQUIRED_NAMES = [
|
|
12
|
+
"ComputeInstance", "StorageBucket", "GKECluster", "SQLInstance",
|
|
13
|
+
"GCPServiceAccount", "IAMPolicyMember", "CloudRunService", "PubSubTopic",
|
|
14
|
+
"VPCNetwork",
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export async function validate(opts?: { basePath?: string }): Promise<ValidateResult> {
|
|
18
|
+
const basePath = opts?.basePath ?? dirname(dirname(fileURLToPath(import.meta.url)));
|
|
19
|
+
|
|
20
|
+
return validateLexiconArtifacts({
|
|
21
|
+
lexiconJsonFilename: "lexicon-gcp.json",
|
|
22
|
+
requiredNames: REQUIRED_NAMES,
|
|
23
|
+
basePath,
|
|
24
|
+
coverageThresholds: {
|
|
25
|
+
minPropertyPct: 0,
|
|
26
|
+
minLifecyclePct: 0,
|
|
27
|
+
minAttrPct: 1,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
package/src/variables.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Well-known Config Connector annotation keys.
|
|
3
|
+
*/
|
|
4
|
+
export const GcpAnnotations = {
|
|
5
|
+
/** Bind a resource to a specific GCP project. */
|
|
6
|
+
ProjectId: "cnrm.cloud.google.com/project-id",
|
|
7
|
+
/** Control what happens when a resource is deleted from K8s. */
|
|
8
|
+
DeletionPolicy: "cnrm.cloud.google.com/deletion-policy",
|
|
9
|
+
/** Whether to merge observed spec back into the resource. */
|
|
10
|
+
StateIntoSpec: "cnrm.cloud.google.com/state-into-spec",
|
|
11
|
+
/** Strategy when another controller manages the same resource. */
|
|
12
|
+
ManagementConflictPolicy: "cnrm.cloud.google.com/management-conflict-prevention-policy",
|
|
13
|
+
/** Disable dependent resource reconciliation. */
|
|
14
|
+
SkipDependentResources: "cnrm.cloud.google.com/skip-dependent-resources",
|
|
15
|
+
} as const;
|