@intentius/chant-lexicon-gcp 0.0.18 → 0.0.24

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.
Files changed (68) hide show
  1. package/dist/integrity.json +12 -8
  2. package/dist/manifest.json +1 -1
  3. package/dist/meta.json +18141 -0
  4. package/dist/rules/schema-registry.ts +91 -0
  5. package/dist/rules/wgc101.ts +1 -1
  6. package/dist/rules/wgc401.ts +59 -0
  7. package/dist/rules/wgc402.ts +54 -0
  8. package/dist/rules/wgc403.ts +84 -0
  9. package/dist/skills/{chant-gke.md → chant-gcp-gke.md} +1 -1
  10. package/dist/skills/chant-gcp-patterns.md +3 -2
  11. package/dist/skills/chant-gcp-security.md +3 -2
  12. package/dist/skills/chant-gcp.md +363 -28
  13. package/package.json +20 -2
  14. package/src/codegen/docs.test.ts +16 -0
  15. package/src/codegen/generate.test.ts +18 -0
  16. package/src/codegen/generate.ts +11 -0
  17. package/src/codegen/package.test.ts +16 -0
  18. package/src/composites/cloud-function.ts +23 -15
  19. package/src/composites/cloud-run-service.ts +20 -13
  20. package/src/composites/cloud-sql-instance.ts +18 -14
  21. package/src/composites/composites.test.ts +94 -62
  22. package/src/composites/gcs-bucket.ts +13 -9
  23. package/src/composites/gke-cluster.ts +91 -16
  24. package/src/composites/index.ts +11 -11
  25. package/src/composites/managed-certificate.ts +19 -15
  26. package/src/composites/private-service.ts +23 -15
  27. package/src/composites/pubsub-pipeline.ts +30 -18
  28. package/src/composites/secure-project.ts +42 -27
  29. package/src/composites/vpc-network.ts +42 -35
  30. package/src/generated/lexicon-gcp.json +18141 -0
  31. package/src/import/import-fixtures.test.ts +98 -0
  32. package/src/index.ts +11 -11
  33. package/src/lint/post-synth/gcp-helpers.test.ts +166 -0
  34. package/src/lint/post-synth/post-synth.test.ts +132 -1
  35. package/src/lint/post-synth/schema-registry.ts +91 -0
  36. package/src/lint/post-synth/wgc101.test.ts +40 -0
  37. package/src/lint/post-synth/wgc101.ts +1 -1
  38. package/src/lint/post-synth/wgc102.test.ts +38 -0
  39. package/src/lint/post-synth/wgc103.test.ts +38 -0
  40. package/src/lint/post-synth/wgc104.test.ts +37 -0
  41. package/src/lint/post-synth/wgc105.test.ts +46 -0
  42. package/src/lint/post-synth/wgc106.test.ts +38 -0
  43. package/src/lint/post-synth/wgc107.test.ts +38 -0
  44. package/src/lint/post-synth/wgc108.test.ts +42 -0
  45. package/src/lint/post-synth/wgc109.test.ts +46 -0
  46. package/src/lint/post-synth/wgc110.test.ts +37 -0
  47. package/src/lint/post-synth/wgc111.test.ts +46 -0
  48. package/src/lint/post-synth/wgc112.test.ts +48 -0
  49. package/src/lint/post-synth/wgc113.test.ts +36 -0
  50. package/src/lint/post-synth/wgc201.test.ts +38 -0
  51. package/src/lint/post-synth/wgc202.test.ts +38 -0
  52. package/src/lint/post-synth/wgc203.test.ts +45 -0
  53. package/src/lint/post-synth/wgc204.test.ts +42 -0
  54. package/src/lint/post-synth/wgc301.test.ts +39 -0
  55. package/src/lint/post-synth/wgc302.test.ts +36 -0
  56. package/src/lint/post-synth/wgc303.test.ts +37 -0
  57. package/src/lint/post-synth/wgc401.test.ts +46 -0
  58. package/src/lint/post-synth/wgc401.ts +59 -0
  59. package/src/lint/post-synth/wgc402.test.ts +40 -0
  60. package/src/lint/post-synth/wgc402.ts +54 -0
  61. package/src/lint/post-synth/wgc403.test.ts +59 -0
  62. package/src/lint/post-synth/wgc403.ts +84 -0
  63. package/src/plugin.test.ts +4 -1
  64. package/src/plugin.ts +258 -177
  65. package/src/skills/{chant-gke.md → chant-gcp-gke.md} +1 -1
  66. package/src/skills/chant-gcp-patterns.md +3 -2
  67. package/src/skills/chant-gcp-security.md +3 -2
  68. package/src/skills/chant-gcp.md +363 -28
@@ -2,6 +2,9 @@
2
2
  * VpcNetwork composite — ComputeNetwork + ComputeSubnetwork + ComputeFirewall + ComputeRouterNAT.
3
3
  */
4
4
 
5
+ import { Composite, mergeDefaults } from "@intentius/chant";
6
+ import { VPCNetwork, Subnetwork, Firewall, Router, RouterNAT } from "../generated";
7
+
5
8
  export interface VpcSubnet {
6
9
  /** Subnet name suffix. */
7
10
  name: string;
@@ -32,14 +35,12 @@ export interface VpcNetworkProps {
32
35
  labels?: Record<string, string>;
33
36
  /** Namespace for all resources. */
34
37
  namespace?: string;
35
- }
36
-
37
- export interface VpcNetworkResult {
38
- network: Record<string, unknown>;
39
- subnets: Record<string, unknown>[];
40
- firewalls: Record<string, unknown>[];
41
- router?: Record<string, unknown>;
42
- routerNat?: Record<string, unknown>;
38
+ /** Per-member defaults for customizing individual resources. */
39
+ defaults?: {
40
+ network?: Partial<ConstructorParameters<typeof VPCNetwork>[0]>;
41
+ router?: Partial<ConstructorParameters<typeof Router>[0]>;
42
+ routerNat?: Partial<ConstructorParameters<typeof RouterNAT>[0]>;
43
+ };
43
44
  }
44
45
 
45
46
  /**
@@ -60,7 +61,7 @@ export interface VpcNetworkResult {
60
61
  * });
61
62
  * ```
62
63
  */
63
- export function VpcNetwork(props: VpcNetworkProps): VpcNetworkResult {
64
+ export const VpcNetwork = Composite<VpcNetworkProps>((props) => {
64
65
  const {
65
66
  name,
66
67
  autoCreateSubnetworks = false,
@@ -71,6 +72,7 @@ export function VpcNetwork(props: VpcNetworkProps): VpcNetworkResult {
71
72
  allowIapSsh = false,
72
73
  labels: extraLabels = {},
73
74
  namespace,
75
+ defaults: defs,
74
76
  } = props;
75
77
 
76
78
  const commonLabels: Record<string, string> = {
@@ -79,7 +81,7 @@ export function VpcNetwork(props: VpcNetworkProps): VpcNetworkResult {
79
81
  ...extraLabels,
80
82
  };
81
83
 
82
- const network: Record<string, unknown> = {
84
+ const network = new VPCNetwork(mergeDefaults({
83
85
  metadata: {
84
86
  name,
85
87
  ...(namespace && { namespace }),
@@ -87,58 +89,63 @@ export function VpcNetwork(props: VpcNetworkProps): VpcNetworkResult {
87
89
  },
88
90
  autoCreateSubnetworks,
89
91
  routingMode: "REGIONAL",
90
- };
92
+ } as Record<string, unknown>, defs?.network));
91
93
 
92
- const subnets: Record<string, unknown>[] = subnetDefs.map((sub) => ({
93
- metadata: {
94
- name: `${name}-${sub.name}`,
95
- ...(namespace && { namespace }),
96
- labels: { ...commonLabels, "app.kubernetes.io/component": "subnet" },
97
- },
98
- networkRef: { name },
99
- ipCidrRange: sub.ipCidrRange,
100
- region: sub.region,
101
- privateIpGoogleAccess: sub.privateIpGoogleAccess ?? true,
102
- }));
94
+ // Spread subnets into named members (subnet_<name>) for Composite validation.
95
+ const subnetEntries: Record<string, any> = {};
96
+ for (const sub of subnetDefs) {
97
+ subnetEntries[`subnet_${sub.name}`] = new Subnetwork({
98
+ metadata: {
99
+ name: `${name}-${sub.name}`,
100
+ ...(namespace && { namespace }),
101
+ labels: { ...commonLabels, "app.kubernetes.io/component": "subnet" },
102
+ },
103
+ networkRef: { name },
104
+ ipCidrRange: sub.ipCidrRange,
105
+ region: sub.region,
106
+ privateIpGoogleAccess: sub.privateIpGoogleAccess ?? true,
107
+ } as Record<string, unknown>);
108
+ }
103
109
 
104
- const firewalls: Record<string, unknown>[] = [];
110
+ // Spread firewalls into named members for Composite validation.
111
+ const firewallEntries: Record<string, any> = {};
105
112
 
106
113
  if (allowInternalTraffic) {
107
- firewalls.push({
114
+ firewallEntries.firewallAllowInternal = new Firewall({
108
115
  metadata: {
109
116
  name: `${name}-allow-internal`,
110
117
  ...(namespace && { namespace }),
111
118
  labels: { ...commonLabels, "app.kubernetes.io/component": "firewall" },
112
119
  },
113
120
  networkRef: { name },
114
- allowed: [
121
+ allow: [
115
122
  { protocol: "tcp", ports: ["0-65535"] },
116
123
  { protocol: "udp", ports: ["0-65535"] },
117
124
  { protocol: "icmp" },
118
125
  ],
119
126
  sourceRanges: subnetDefs.map((s) => s.ipCidrRange),
120
- });
127
+ } as Record<string, unknown>);
121
128
  }
122
129
 
123
130
  if (allowIapSsh) {
124
- firewalls.push({
131
+ firewallEntries.firewallAllowIapSsh = new Firewall({
125
132
  metadata: {
126
133
  name: `${name}-allow-iap-ssh`,
127
134
  ...(namespace && { namespace }),
128
135
  labels: { ...commonLabels, "app.kubernetes.io/component": "firewall" },
129
136
  },
130
137
  networkRef: { name },
131
- allowed: [{ protocol: "tcp", ports: ["22"] }],
138
+ allow: [{ protocol: "tcp", ports: ["22"] }],
132
139
  sourceRanges: ["35.235.240.0/20"], // IAP IP range
133
- });
140
+ } as Record<string, unknown>);
134
141
  }
135
142
 
136
- const result: VpcNetworkResult = { network, subnets, firewalls };
143
+ const result: Record<string, any> = { network, ...subnetEntries, ...firewallEntries };
137
144
 
138
145
  if (enableNat && natRegion) {
139
146
  const routerName = `${name}-router`;
140
147
 
141
- result.router = {
148
+ result.router = new Router(mergeDefaults({
142
149
  metadata: {
143
150
  name: routerName,
144
151
  ...(namespace && { namespace }),
@@ -146,9 +153,9 @@ export function VpcNetwork(props: VpcNetworkProps): VpcNetworkResult {
146
153
  },
147
154
  networkRef: { name },
148
155
  region: natRegion,
149
- };
156
+ } as Record<string, unknown>, defs?.router));
150
157
 
151
- result.routerNat = {
158
+ result.routerNat = new RouterNAT(mergeDefaults({
152
159
  metadata: {
153
160
  name: `${name}-nat`,
154
161
  ...(namespace && { namespace }),
@@ -158,8 +165,8 @@ export function VpcNetwork(props: VpcNetworkProps): VpcNetworkResult {
158
165
  region: natRegion,
159
166
  natIpAllocateOption: "AUTO_ONLY",
160
167
  sourceSubnetworkIpRangesToNat: "ALL_SUBNETWORKS_ALL_IP_RANGES",
161
- };
168
+ } as Record<string, unknown>, defs?.routerNat));
162
169
  }
163
170
 
164
171
  return result;
165
- }
172
+ }, "VpcNetwork");