@intentius/chant 0.124.97 → 0.124.98
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/audit/core.d.ts +29 -0
- package/dist/audit/core.d.ts.map +1 -1
- package/dist/audit/core.js +48 -11
- package/dist/audit/identity.d.ts +27 -0
- package/dist/audit/identity.d.ts.map +1 -0
- package/dist/audit/identity.js +36 -0
- package/dist/audit/report-html.d.ts +3 -1
- package/dist/audit/report-html.d.ts.map +1 -1
- package/dist/audit/report-html.js +1 -1
- package/dist/audit/report-model.d.ts +16 -0
- package/dist/audit/report-model.d.ts.map +1 -1
- package/dist/audit/report-model.js +5 -1
- package/dist/ci-agent.d.ts +17 -0
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +32 -0
- package/dist/ci-comment-allow.d.ts +88 -0
- package/dist/ci-comment-allow.d.ts.map +1 -0
- package/dist/ci-comment-allow.js +178 -0
- package/dist/ci-comment-commands.d.ts +12 -0
- package/dist/ci-comment-commands.d.ts.map +1 -1
- package/dist/ci-comment-commands.js +22 -0
- package/dist/ci-control.d.ts +6 -1
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +6 -1
- package/dist/ci-product.d.ts +3 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +3 -0
- package/dist/cli/commands/audit.d.ts +3 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +23 -6
- package/dist/cli/commands/import.d.ts +8 -1
- package/dist/cli/commands/import.d.ts.map +1 -1
- package/dist/cli/commands/import.js +31 -6
- package/dist/cli/handlers/agent.d.ts.map +1 -1
- package/dist/cli/handlers/agent.js +12 -2
- package/dist/cli/handlers/pr-comment.d.ts +6 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
- package/dist/cli/handlers/pr-comment.js +12 -0
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +53 -6
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +29 -6
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +23 -0
- package/dist/cli/registry.d.ts +8 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cloud-lister/mask.d.ts +30 -1
- package/dist/cloud-lister/mask.d.ts.map +1 -1
- package/dist/cloud-lister/mask.js +66 -3
- package/dist/components/driver.d.ts +8 -1
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +1 -0
- package/dist/components/product-pipeline.d.ts +23 -1
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +40 -7
- package/dist/components/product-plan.d.ts +20 -0
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +11 -1
- package/dist/control/applied.d.ts +8 -1
- package/dist/control/applied.d.ts.map +1 -1
- package/dist/control/applied.js +18 -2
- package/dist/control/dispatch.d.ts +52 -0
- package/dist/control/dispatch.d.ts.map +1 -1
- package/dist/control/dispatch.js +140 -4
- package/dist/control/train.d.ts +198 -0
- package/dist/control/train.d.ts.map +1 -0
- package/dist/control/train.js +294 -0
- package/dist/deep-observation.js +2 -2
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +11 -0
- package/dist/graph-detail.d.ts +9 -0
- package/dist/graph-detail.d.ts.map +1 -1
- package/dist/graph-detail.js +38 -13
- package/dist/graph-refs.d.ts +233 -3
- package/dist/graph-refs.d.ts.map +1 -1
- package/dist/graph-refs.js +106 -15
- package/dist/lint/post-synth.d.ts +22 -0
- package/dist/lint/post-synth.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.d.ts +12 -0
- package/dist/lint/rules/declarable-naming-convention.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.js +38 -8
- package/dist/lint/rules/imported-source.d.ts +20 -0
- package/dist/lint/rules/imported-source.d.ts.map +1 -0
- package/dist/lint/rules/imported-source.js +27 -0
- package/dist/lint/rules/no-unused-declarable.d.ts.map +1 -1
- package/dist/lint/rules/no-unused-declarable.js +3 -0
- package/dist/op/gate.d.ts +2 -0
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +8 -1
- package/dist/pr-forge-reads.d.ts +17 -0
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +55 -0
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +9 -1
- package/dist/repo-path.d.ts +29 -0
- package/dist/repo-path.d.ts.map +1 -0
- package/dist/repo-path.js +81 -0
- package/dist/sensitive-key.d.ts +23 -0
- package/dist/sensitive-key.d.ts.map +1 -1
- package/dist/sensitive-key.js +37 -0
- package/dist/terraform/hcl2json.d.ts +7 -0
- package/dist/terraform/hcl2json.d.ts.map +1 -1
- package/dist/terraform/hcl2json.js +7 -0
- package/dist/wave-runtime.mjs +352 -345
- package/dist/workspace/catalog-edges.d.ts +147 -0
- package/dist/workspace/catalog-edges.d.ts.map +1 -0
- package/dist/workspace/catalog-edges.js +461 -0
- package/dist/workspace/compose-graph.d.ts +73 -3
- package/dist/workspace/compose-graph.d.ts.map +1 -1
- package/dist/workspace/declaration.d.ts +2 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +1 -0
- package/dist/workspace/declaration.schema.json +6 -0
- package/dist/workspace/discover.d.ts +134 -0
- package/dist/workspace/discover.d.ts.map +1 -0
- package/dist/workspace/discover.js +372 -0
- package/dist/workspace/graph-cli.d.ts +20 -0
- package/dist/workspace/graph-cli.d.ts.map +1 -1
- package/dist/workspace/graph-cli.js +178 -20
- package/dist/workspace/graph.schema.json +195 -2
- package/dist/workspace/release-train.d.ts +214 -3
- package/dist/workspace/release-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +552 -16
- package/dist/workspace/repo-ref.d.ts +14 -0
- package/dist/workspace/repo-ref.d.ts.map +1 -1
- package/dist/workspace/repo-ref.js +26 -1
- package/dist/workspace/workspace-gates.d.ts +24 -0
- package/dist/workspace/workspace-gates.d.ts.map +1 -1
- package/dist/workspace/workspace-gates.js +29 -5
- package/dist/workspace/workspace-ledger.d.ts +31 -5
- package/dist/workspace/workspace-ledger.d.ts.map +1 -1
- package/dist/workspace/workspace-ledger.js +2 -1
- package/dist/workspace/workspace-run.d.ts +14 -0
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -2
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +33 -8
- package/package.json +1 -1
- package/src/audit/core.test.ts +64 -1
- package/src/audit/core.ts +75 -10
- package/src/audit/identity.test.ts +31 -0
- package/src/audit/identity.ts +43 -0
- package/src/audit/report-html.ts +4 -2
- package/src/audit/report-model.ts +21 -1
- package/src/ci-agent.test.ts +32 -0
- package/src/ci-agent.ts +42 -0
- package/src/ci-comment-allow.test.ts +380 -0
- package/src/ci-comment-allow.ts +184 -0
- package/src/ci-comment-commands.ts +25 -0
- package/src/ci-control.ts +42 -0
- package/src/ci-product.ts +3 -0
- package/src/cli/commands/audit-parser-notice.test.ts +74 -0
- package/src/cli/commands/audit.test.ts +12 -0
- package/src/cli/commands/audit.ts +25 -7
- package/src/cli/commands/import-layout.test.ts +2 -1
- package/src/cli/commands/import.ts +29 -6
- package/src/cli/handlers/agent.ts +13 -2
- package/src/cli/handlers/pr-comment.ts +12 -0
- package/src/cli/handlers/promote.test.ts +68 -0
- package/src/cli/handlers/promote.ts +52 -6
- package/src/cli/main.test.ts +5 -0
- package/src/cli/main.ts +29 -6
- package/src/cli/parse-args.ts +18 -0
- package/src/cli/registry.ts +8 -0
- package/src/cloud-lister/kubernetes.k3d.e2e.test.ts +104 -0
- package/src/cloud-lister/mask-references.test.ts +132 -0
- package/src/cloud-lister/mask.ts +68 -3
- package/src/components/driver.ts +9 -1
- package/src/components/product-pipeline.ts +57 -7
- package/src/components/product-plan.ts +27 -2
- package/src/control/applied.ts +33 -3
- package/src/control/dispatch.ts +156 -5
- package/src/control/train.test.ts +215 -0
- package/src/control/train.ts +413 -0
- package/src/deep-observation.ts +2 -2
- package/src/floor-table.data.ts +6 -0
- package/src/graph-detail.ts +37 -12
- package/src/graph-refs.test.ts +45 -1
- package/src/graph-refs.ts +321 -14
- package/src/lint/post-synth.ts +20 -0
- package/src/lint/rules/declarable-naming-convention.test.ts +35 -1
- package/src/lint/rules/declarable-naming-convention.ts +35 -8
- package/src/lint/rules/imported-source.test.ts +22 -0
- package/src/lint/rules/imported-source.ts +31 -0
- package/src/lint/rules/no-unused-declarable.test.ts +16 -0
- package/src/lint/rules/no-unused-declarable.ts +7 -0
- package/src/op/gate.ts +10 -2
- package/src/pr-forge-reads.ts +62 -0
- package/src/release-floors.ts +13 -1
- package/src/repo-path.test.ts +72 -0
- package/src/repo-path.ts +103 -0
- package/src/sensitive-key.ts +38 -0
- package/src/terraform/hcl2json.ts +8 -0
- package/src/workspace/application-set.e2e.test.ts +405 -0
- package/src/workspace/catalog-edges.ts +507 -0
- package/src/workspace/ci-green-workflow.test.ts +2 -2
- package/src/workspace/cluster-join.e2e.test.ts +150 -0
- package/src/workspace/compose-graph.ts +74 -5
- package/src/workspace/declaration.schema.json +6 -0
- package/src/workspace/declaration.ts +3 -0
- package/src/workspace/discover.e2e.test.ts +122 -0
- package/src/workspace/discover.test.ts +225 -0
- package/src/workspace/discover.ts +406 -0
- package/src/workspace/external-secret-catalog.e2e.test.ts +98 -0
- package/src/workspace/external-secret-catalog.test.ts +142 -0
- package/src/workspace/graph-cli.ts +207 -21
- package/src/workspace/graph-contract.test.ts +92 -0
- package/src/workspace/graph.schema.json +195 -2
- package/src/workspace/helm-references.e2e.test.ts +135 -0
- package/src/workspace/identity-annotation-catalog.e2e.test.ts +91 -0
- package/src/workspace/identity-annotation-catalog.test.ts +139 -0
- package/src/workspace/release-train-repos.test.ts +304 -0
- package/src/workspace/release-train.test.ts +296 -0
- package/src/workspace/release-train.ts +631 -16
- package/src/workspace/repo-ref.ts +26 -1
- package/src/workspace/runs-on.test.ts +45 -0
- package/src/workspace/workspace-gates.ts +48 -5
- package/src/workspace/workspace-ledger.ts +28 -5
- package/src/workspace/workspace-run.test.ts +1 -1
- package/src/workspace/workspace-run.ts +2 -2
- package/src/yaml.test.ts +96 -8
- package/src/yaml.ts +36 -8
|
@@ -101,12 +101,22 @@
|
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
"dangling": {
|
|
104
|
-
"description": "Added in contract 1 by #3922. The members' references whose target is no node of their graph (#3910): a job `needs` a job no workflow declares, a `uses:` names another repository's workflow, a GitLab `include:` names a file chant did not generate. Each member's `ir.dangling` entry with `from` prefixed by its member and a `member` field,
|
|
104
|
+
"description": "Added in contract 1 by #3922. The members' references whose target is no node of their graph (#3910): a job `needs` a job no workflow declares, a `uses:` names another repository's workflow, a GitLab `include:` names a file chant did not generate. Each member's `ir.dangling` entry with `from` prefixed by its member and a `member` field, then (#5097) each reference the reference catalog found no node for, with its `rule`. Sorted by `from`, `path` and `value`. Absent when there is none.",
|
|
105
105
|
"type": "array",
|
|
106
106
|
"items": {
|
|
107
107
|
"$ref": "#/$defs/dangling"
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
+
"ambiguous": {
|
|
111
|
+
"description": "Added in contract 1 by #5097, written by chant 0.124.98 and newer. References the reference catalog matched to more than one node: no edge is drawn, and every candidate is listed. Sorted by `from`, `rule` and `value`. Absent when there are none.",
|
|
112
|
+
"type": "array",
|
|
113
|
+
"items": {
|
|
114
|
+
"$ref": "#/$defs/ambiguous"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"catalog": {
|
|
118
|
+
"$ref": "#/$defs/catalog"
|
|
119
|
+
},
|
|
110
120
|
"groups": {
|
|
111
121
|
"type": "object",
|
|
112
122
|
"required": [
|
|
@@ -272,9 +282,46 @@
|
|
|
272
282
|
"plantable": {
|
|
273
283
|
"description": "Added in contract 1 by #3146. Whether a host such as a studio's planter can plant the workspace as one box: exactly one member's box block declares services, read from the declaration at the revision read. Not a check: a records-only or infra workspace is valid and simply not plantable.",
|
|
274
284
|
"$ref": "#/$defs/plantable"
|
|
285
|
+
},
|
|
286
|
+
"discovered": {
|
|
287
|
+
"type": "array",
|
|
288
|
+
"description": "Added in contract 1 by #5095. Present only for chant workspace graph <dir> --discover when <dir> holds no declaration: every directory a kind's probe claims, sorted by dir, with what became of it. Absent for a declared read.",
|
|
289
|
+
"items": { "$ref": "#/$defs/discoveredDir" }
|
|
275
290
|
}
|
|
276
291
|
}
|
|
277
292
|
},
|
|
293
|
+
"discoveredDir": {
|
|
294
|
+
"type": "object",
|
|
295
|
+
"description": "Added in contract 1 by #5095. One directory a kind's probe claims in a discovered read.",
|
|
296
|
+
"additionalProperties": false,
|
|
297
|
+
"required": ["dir", "member", "kind", "source", "probe", "outcome", "claims", "note"],
|
|
298
|
+
"properties": {
|
|
299
|
+
"dir": { "type": "string", "description": "The directory, relative to <dir> with / separators; \".\" for <dir> itself." },
|
|
300
|
+
"member": { "type": ["string", "null"], "description": "The member's name when outcome is member, else null. It depends on dir alone, by the rule the workspace graph page gives." },
|
|
301
|
+
"kind": { "type": ["string", "null"], "description": "The kind the precedence order picks; null for a tie." },
|
|
302
|
+
"source": { "type": ["string", "null"], "description": "Where that kind comes from: builtin, or the package that supplies it; null for a tie." },
|
|
303
|
+
"probe": { "type": ["object", "null"], "description": "That kind's probe, as its kinds file states it; null for a tie." },
|
|
304
|
+
"outcome": {
|
|
305
|
+
"enum": ["member", "tie", "module", "inside-member"],
|
|
306
|
+
"description": "member: read as the member named in member. tie: two or more kinds share the highest precedence, and it is not read. module: a .tf file under <dir> calls it through a local source, so it is read with each root that calls it. inside-member: it sits inside another member's directory, and members don't nest except inside the root member \".\"."
|
|
307
|
+
},
|
|
308
|
+
"claims": {
|
|
309
|
+
"type": "array",
|
|
310
|
+
"description": "Every kind whose probe claims the directory, highest precedence first.",
|
|
311
|
+
"items": {
|
|
312
|
+
"type": "object",
|
|
313
|
+
"additionalProperties": false,
|
|
314
|
+
"required": ["kind", "precedence", "source"],
|
|
315
|
+
"properties": {
|
|
316
|
+
"kind": { "type": "string" },
|
|
317
|
+
"precedence": { "type": "number" },
|
|
318
|
+
"source": { "type": "string" }
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
"note": { "type": ["string", "null"], "description": "Why the directory is not a member, in one line; null for a member." }
|
|
323
|
+
}
|
|
324
|
+
},
|
|
278
325
|
"member": {
|
|
279
326
|
"type": "object",
|
|
280
327
|
"required": [
|
|
@@ -590,6 +637,28 @@
|
|
|
590
637
|
}
|
|
591
638
|
}
|
|
592
639
|
},
|
|
640
|
+
"generatedBy": {
|
|
641
|
+
"type": "object",
|
|
642
|
+
"description": "Added in contract 1 by #5102. On a node the reference catalog generated from another, an Application an ApplicationSet's list or clusters generator yields: the generating node's id, the rule, the generator, the parameters it was made with (flattened to a.b.c keys) and, for a clusters generator, the cluster Secret it was made for. Its id is the generating node's id, a slash and its name. Since #5094 a node read from a file a generated node names (a generated Application's Helm values file, or an object under its extraObjects) has generatedBy too, naming that generated node, the generate rule and generator \"file\", with empty params.",
|
|
643
|
+
"required": ["node", "rule", "generator", "params"],
|
|
644
|
+
"properties": {
|
|
645
|
+
"node": { "type": "string" },
|
|
646
|
+
"rule": { "type": "string" },
|
|
647
|
+
"generator": { "type": "string" },
|
|
648
|
+
"params": { "type": "object", "additionalProperties": { "type": "string" } },
|
|
649
|
+
"cluster": { "type": "string" }
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
"expansion": {
|
|
653
|
+
"type": "object",
|
|
654
|
+
"description": "Added in contract 1 by #5102. On a node a catalog rule generates nodes from, an ApplicationSet: the rule, how many nodes it generated, and one line for each thing it did not expand, such as another generator, templatePatch or a template function it does not read.",
|
|
655
|
+
"required": ["rule", "generated", "notExpanded"],
|
|
656
|
+
"properties": {
|
|
657
|
+
"rule": { "type": "string" },
|
|
658
|
+
"generated": { "type": "integer", "minimum": 0 },
|
|
659
|
+
"notExpanded": { "type": "array", "items": { "type": "string" } }
|
|
660
|
+
}
|
|
661
|
+
},
|
|
593
662
|
"facts": {
|
|
594
663
|
"type": "object",
|
|
595
664
|
"description": "Added in contract 1 by #4529, written by chant 0.124.54 and newer. What an ownership engine observed about the node: ownership, markers, ownedBy, cloudIds, recordVersions and observedAt, each optional, in the shape of EngineFacts (packages/core/src/graph-schema/graph.schema.json). Set on a Pulumi member on plunge from its checked-in engine-graph.json. Never read for a decision."
|
|
@@ -655,8 +724,21 @@
|
|
|
655
724
|
"enum": ["block", "instance", "property"],
|
|
656
725
|
"description": "Added in contract 1 by #4529, written by chant 0.124.54 and newer. What the edge joins: two blocks, two instances, or a property of one instance to another. A Pulumi member's dependencies and parent edges are instance; a plunge member's property edges are property. Absent when the source does not say."
|
|
657
726
|
},
|
|
727
|
+
"origin": {
|
|
728
|
+
"enum": ["declared", "observed", "derived"],
|
|
729
|
+
"description": "Where the edge came from, as on a member's IR: `derived` for an edge a reference catalog rule drew. Added in contract 1 by #5097, written by chant 0.124.98 and newer. The composed graph draws derived edges between members too. Absent reads as `declared` on a source read and `observed` on a live one."
|
|
730
|
+
},
|
|
731
|
+
"rule": {
|
|
732
|
+
"type": "string",
|
|
733
|
+
"description": "With `origin: \"derived\"`: the rule that drew the edge, `<lexicon>:<holder kind>:<path>`. `catalog.rules` describes it."
|
|
734
|
+
},
|
|
735
|
+
"relation": {
|
|
736
|
+
"enum": ["reference", "containment"],
|
|
737
|
+
"description": "`reference` (the default when absent) or `containment`: the holder sits inside the target, and is in `groups.byContainer` too."
|
|
738
|
+
},
|
|
658
739
|
"member": {
|
|
659
|
-
"type": "string"
|
|
740
|
+
"type": "string",
|
|
741
|
+
"description": "The member the edge was read in. For a derived edge, the holder's member; the edge's ends carry their own."
|
|
660
742
|
}
|
|
661
743
|
}
|
|
662
744
|
},
|
|
@@ -695,6 +777,117 @@
|
|
|
695
777
|
"nested": {
|
|
696
778
|
"type": "string",
|
|
697
779
|
"description": "For a member of kind `workspace`: the nested workspace's member the reference was read through, as on a node."
|
|
780
|
+
},
|
|
781
|
+
"rule": {
|
|
782
|
+
"type": "string",
|
|
783
|
+
"description": "Added in contract 1 by #5097, written by chant 0.124.98 and newer. For a reference the reference catalog read: the rule that read it, as on an edge. Absent on a member's own dangling references."
|
|
784
|
+
},
|
|
785
|
+
"targetKind": {
|
|
786
|
+
"type": "string",
|
|
787
|
+
"description": "Added in contract 1 by #5097, written by chant 0.124.98 and newer. The kind the rule looks for, when it names one."
|
|
788
|
+
},
|
|
789
|
+
"through": {
|
|
790
|
+
"type": "string",
|
|
791
|
+
"description": "Added in contract 1 by #5098. For a reference read through another node, the id of that node: the store a key is read from, or (#5102) the ApplicationSet that generated the Application whose path is missing."
|
|
792
|
+
},
|
|
793
|
+
"cluster": {
|
|
794
|
+
"type": "string",
|
|
795
|
+
"description": "Added in contract 1 by #5102. For a path a generated Application names: the cluster Secret it was generated for."
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
"ambiguous": {
|
|
800
|
+
"type": "object",
|
|
801
|
+
"required": ["from", "member", "rule", "path", "value", "candidates"],
|
|
802
|
+
"properties": {
|
|
803
|
+
"from": {
|
|
804
|
+
"type": "string",
|
|
805
|
+
"description": "The node holding the reference."
|
|
806
|
+
},
|
|
807
|
+
"member": {
|
|
808
|
+
"type": "string",
|
|
809
|
+
"description": "The holder's member."
|
|
810
|
+
},
|
|
811
|
+
"rule": {
|
|
812
|
+
"type": "string",
|
|
813
|
+
"description": "The rule that read the reference, as on an edge."
|
|
814
|
+
},
|
|
815
|
+
"path": {
|
|
816
|
+
"type": "string"
|
|
817
|
+
},
|
|
818
|
+
"value": {
|
|
819
|
+
"type": "string"
|
|
820
|
+
},
|
|
821
|
+
"candidates": {
|
|
822
|
+
"type": "array",
|
|
823
|
+
"items": {
|
|
824
|
+
"type": "string"
|
|
825
|
+
},
|
|
826
|
+
"description": "Every node the value matched, sorted. At `--detail` 0 and 1, the nodes they are drawn as."
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
"catalog": {
|
|
831
|
+
"description": "Added in contract 1 by #5097, written by chant 0.124.98 and newer. What the reference catalog pass read. Absent with `--live`, where each member's own chant runs its catalog.",
|
|
832
|
+
"type": "object",
|
|
833
|
+
"required": ["lexicons", "members", "rules"],
|
|
834
|
+
"properties": {
|
|
835
|
+
"lexicons": {
|
|
836
|
+
"type": "array",
|
|
837
|
+
"items": {
|
|
838
|
+
"type": "string"
|
|
839
|
+
},
|
|
840
|
+
"description": "The lexicons whose reference catalog ran, sorted. A lexicon of the graph that is not listed has no catalog, or did not load, and its nodes hold no derived references."
|
|
841
|
+
},
|
|
842
|
+
"members": {
|
|
843
|
+
"type": "array",
|
|
844
|
+
"items": {
|
|
845
|
+
"type": "string"
|
|
846
|
+
},
|
|
847
|
+
"description": "The members whose nodes the pass read, sorted."
|
|
848
|
+
},
|
|
849
|
+
"rules": {
|
|
850
|
+
"type": "object",
|
|
851
|
+
"description": "Every rule an edge, a dangling entry or an ambiguous entry names, by rule id.",
|
|
852
|
+
"additionalProperties": {
|
|
853
|
+
"type": "object",
|
|
854
|
+
"required": ["lexicon", "from", "path", "relation", "targetKinds"],
|
|
855
|
+
"properties": {
|
|
856
|
+
"lexicon": {
|
|
857
|
+
"type": "string"
|
|
858
|
+
},
|
|
859
|
+
"from": {
|
|
860
|
+
"type": "string",
|
|
861
|
+
"description": "The holder kind the rule reads."
|
|
862
|
+
},
|
|
863
|
+
"path": {
|
|
864
|
+
"type": "string",
|
|
865
|
+
"description": "The attribute path, with `[]` for each element of a list and `[\"key\"]` for a key that holds dots or slashes."
|
|
866
|
+
},
|
|
867
|
+
"relation": {
|
|
868
|
+
"enum": ["reference", "containment"]
|
|
869
|
+
},
|
|
870
|
+
"targetKinds": {
|
|
871
|
+
"type": "array",
|
|
872
|
+
"items": {
|
|
873
|
+
"type": "string"
|
|
874
|
+
},
|
|
875
|
+
"description": "The kinds the target can be. One id can stand for several rules, one per kind. Empty when the rule takes any kind."
|
|
876
|
+
},
|
|
877
|
+
"label": {
|
|
878
|
+
"type": "string",
|
|
879
|
+
"description": "The rule's human-facing name for the relation, such as `runs as`."
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
},
|
|
884
|
+
"nonLiteral": {
|
|
885
|
+
"type": "object",
|
|
886
|
+
"additionalProperties": {
|
|
887
|
+
"type": "integer",
|
|
888
|
+
"minimum": 1
|
|
889
|
+
},
|
|
890
|
+
"description": "By node id: arguments the pass did not read because their value is not literal, such as a terraform interpolation. Absent when there are none."
|
|
698
891
|
}
|
|
699
892
|
}
|
|
700
893
|
},
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helm charts and values files on `chant workspace graph --discover` (#5100),
|
|
3
|
+
* read as data: a kustomization's `helmCharts`, a Terraform `helm_release` and
|
|
4
|
+
* an Argo CD Application name one chart, and each values file they name is a
|
|
5
|
+
* node. The read runs with no `kustomize`, `kubectl`, `helm` or `terraform` on
|
|
6
|
+
* PATH, and with no network.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { dirname } from "node:path";
|
|
10
|
+
import { afterAll, beforeAll, describe, expect, test } from "vitest";
|
|
11
|
+
import { cleanScratch, contract, scratchDir, writeFiles } from "./__fixtures__/contract-repo";
|
|
12
|
+
import { CACHE_DIR_ENV } from "./graph-cache";
|
|
13
|
+
import { workspaceGraph, type GraphDocument } from "./graph-cli";
|
|
14
|
+
import schema from "./graph.schema.json";
|
|
15
|
+
|
|
16
|
+
const TIMEOUT = 240_000;
|
|
17
|
+
const { expectValid } = contract(schema);
|
|
18
|
+
|
|
19
|
+
let cacheBefore: string | undefined;
|
|
20
|
+
let pathBefore: string | undefined;
|
|
21
|
+
beforeAll(() => {
|
|
22
|
+
cacheBefore = process.env[CACHE_DIR_ENV];
|
|
23
|
+
process.env[CACHE_DIR_ENV] = scratchDir("chant-helm-cache-");
|
|
24
|
+
// Only node's own directory and the system tools: none of the four binaries the read could use.
|
|
25
|
+
pathBefore = process.env.PATH;
|
|
26
|
+
process.env.PATH = [dirname(process.execPath), "/usr/bin", "/bin"].join(":");
|
|
27
|
+
});
|
|
28
|
+
afterAll(() => {
|
|
29
|
+
if (cacheBefore === undefined) delete process.env[CACHE_DIR_ENV];
|
|
30
|
+
else process.env[CACHE_DIR_ENV] = cacheBefore;
|
|
31
|
+
process.env.PATH = pathBefore;
|
|
32
|
+
cleanScratch();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const KUSTOMIZATION =
|
|
36
|
+
"apiVersion: kustomize.config.k8s.io/v1beta1\nkind: Kustomization\nhelmCharts:\n - name: datadog\n repo: https://helm.datadoghq.com\n version: 3.244.0\n releaseName: datadog\n valuesFile: values.yaml\n";
|
|
37
|
+
|
|
38
|
+
const DD = {
|
|
39
|
+
"k8s/dd/kustomization.yaml": KUSTOMIZATION,
|
|
40
|
+
"k8s/dd/values.yaml": "datadog:\n site: datadoghq.com\nextraObjects:\n - apiVersion: external-secrets.io/v1beta1\n kind: SecretStore\n metadata:\n name: dd-store\n",
|
|
41
|
+
"tf/main.tf": 'resource "helm_release" "datadog" {\n name = "datadog"\n repository = "https://helm.datadoghq.com/"\n chart = "datadog"\n version = "3.244.0"\n}\n',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const MORE = {
|
|
45
|
+
...DD,
|
|
46
|
+
"k8s/gone/kustomization.yaml":
|
|
47
|
+
"apiVersion: kustomize.config.k8s.io/v1beta1\nkind: Kustomization\nhelmCharts:\n - name: redis\n repo: https://charts.example.com\n version: 1.0.0\n valuesFile: missing.yaml\n",
|
|
48
|
+
"argo/app.yaml":
|
|
49
|
+
"apiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n name: dd\n namespace: argocd\nspec:\n project: default\n sources:\n - repoURL: https://helm.datadoghq.com\n chart: datadog\n targetRevision: 3.244.0\n helm:\n valueFiles:\n - $values/k8s/dd/values.yaml\n - repoURL: https://example.com/repo.git\n targetRevision: main\n ref: values\n destination:\n server: https://kubernetes.default.svc\n namespace: dd\n",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function result(doc: GraphDocument): Extract<GraphDocument, { nodes: unknown }> {
|
|
53
|
+
if ("error" in doc) throw new Error(`${doc.error.code}: ${doc.error.message}`);
|
|
54
|
+
return doc;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function read(files: Record<string, string>, detail?: number) {
|
|
58
|
+
const root = scratchDir("chant-helm-fx-");
|
|
59
|
+
writeFiles(root, files);
|
|
60
|
+
const { doc } = await workspaceGraph({ cwd: root, discover: true, noCache: false, catalog: true, ...(detail ? { args: { detail } as never } : {}) });
|
|
61
|
+
const g = result(doc);
|
|
62
|
+
expectValid(g);
|
|
63
|
+
return g;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
describe("helm charts and values files as data (#5100)", () => {
|
|
67
|
+
test(
|
|
68
|
+
"a kustomization and a helm_release that name one chart: one chart node, one values node, an edge to the chart from each",
|
|
69
|
+
async () => {
|
|
70
|
+
const g = await read(DD, 3);
|
|
71
|
+
const charts = g.nodes.filter((n) => n.kind === "Helm::ChartRef");
|
|
72
|
+
expect(charts.map((c) => c.attrs)).toEqual([{ repo: "https://helm.datadoghq.com", chart: "datadog", version: "3.244.0" }]);
|
|
73
|
+
const values = g.nodes.filter((n) => n.kind === "Helm::Values");
|
|
74
|
+
expect(values.map((v) => v.attrs.path)).toEqual(["k8s/dd/values.yaml"]);
|
|
75
|
+
expect(values[0].attrs.values).toMatchObject({ datadog: { site: "datadoghq.com" } });
|
|
76
|
+
|
|
77
|
+
const toChart = g.edges.filter((e) => e.to === charts[0].id).map((e) => [e.from, e.rule]);
|
|
78
|
+
expect(toChart).toEqual([
|
|
79
|
+
["k8s-dd/k8s-dd/kustomizationK8sDd", "helm:K8s::Kustomize::Kustomization:helmReferences.charts"],
|
|
80
|
+
["k8s-dd/k8s-dd/values/k8s/dd/values.yaml", "helm:Helm::Values:charts"],
|
|
81
|
+
["tf/tf/helm_release.datadog", "helm:helm_release:chart"],
|
|
82
|
+
]);
|
|
83
|
+
expect(g.edges.filter((e) => e.to === values[0].id).map((e) => e.from)).toEqual(["k8s-dd/k8s-dd/kustomizationK8sDd"]);
|
|
84
|
+
expect(g.dangling ?? []).toEqual([]);
|
|
85
|
+
// What a values file's extraObjects creates is a node of the member.
|
|
86
|
+
expect(g.nodes.filter((n) => n.kind === "K8s::ExternalSecrets::SecretStore").map((n) => n.id)).toEqual(["k8s-dd/k8s-dd/secretStoreDdStore"]);
|
|
87
|
+
},
|
|
88
|
+
TIMEOUT,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
test(
|
|
92
|
+
"an Argo CD source joins the same chart, its $values file is read from the workspace, and a values file that does not exist is dangling with its path",
|
|
93
|
+
async () => {
|
|
94
|
+
const g = await read(MORE);
|
|
95
|
+
const charts = g.nodes.filter((n) => n.kind === "Helm::ChartRef");
|
|
96
|
+
expect(charts.map((c) => c.attrs.chart).sort()).toEqual(["datadog", "redis"]);
|
|
97
|
+
const datadog = charts.find((c) => c.attrs.chart === "datadog")!;
|
|
98
|
+
const holders = g.edges.filter((e) => e.to === datadog.id).map((e) => e.from.split("/")[0]);
|
|
99
|
+
expect(holders.sort()).toEqual(["argo", "argo", "k8s-dd", "k8s-dd", "tf"]);
|
|
100
|
+
|
|
101
|
+
// One values node for each member that reads the file, and each holder reaches the one in its own member.
|
|
102
|
+
const values = g.nodes.filter((n) => n.kind === "Helm::Values");
|
|
103
|
+
expect(values.map((v) => v.id).sort()).toEqual(["argo/argo/values/k8s/dd/values.yaml", "k8s-dd/k8s-dd/values/k8s/dd/values.yaml"]);
|
|
104
|
+
expect(g.ambiguous ?? []).toEqual([]);
|
|
105
|
+
expect(g.edges.filter((e) => values.some((v) => v.id === e.to)).map((e) => [e.from, e.to].map((id) => id.split("/")[0]))).toEqual([
|
|
106
|
+
["argo", "argo"],
|
|
107
|
+
["k8s-dd", "k8s-dd"],
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
const missing = g.dangling ?? [];
|
|
111
|
+
expect(missing.map((d) => [d.from, d.value, d.targetKind])).toEqual([["k8s-gone/k8s-gone/kustomizationK8sGone", "k8s/gone/missing.yaml", "Helm::Values"]]);
|
|
112
|
+
},
|
|
113
|
+
TIMEOUT,
|
|
114
|
+
);
|
|
115
|
+
test(
|
|
116
|
+
"an Application in a namespace reaches both its destination cluster Secret in that namespace and the values file in its own member",
|
|
117
|
+
async () => {
|
|
118
|
+
const g = await read({
|
|
119
|
+
"argo/clusters.yaml":
|
|
120
|
+
"apiVersion: v1\nkind: Secret\nmetadata:\n name: cluster-prod\n namespace: argocd\n labels:\n argocd.argoproj.io/secret-type: cluster\nstringData:\n name: prod\n server: https://10.0.0.1\n",
|
|
121
|
+
"argo/app.yaml":
|
|
122
|
+
"apiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n name: dd\n namespace: argocd\nspec:\n project: default\n sources:\n - repoURL: https://helm.datadoghq.com\n chart: datadog\n targetRevision: 3.244.0\n helm:\n valueFiles:\n - $values/k8s/dd/values.yaml\n - repoURL: https://example.com/repo.git\n ref: values\n destination:\n name: prod\n namespace: dd\n",
|
|
123
|
+
"k8s/dd/values.yaml": "datadog:\n site: datadoghq.com\n",
|
|
124
|
+
});
|
|
125
|
+
const from = "argo/argo/applicationDd";
|
|
126
|
+
const to = g.edges.filter((e) => e.from === from).map((e) => [e.to, e.rule]);
|
|
127
|
+
expect(to).toContainEqual(["argo/argo/secretClusterProd", "k8s:K8s::Argo::Application:spec.destination.name"]);
|
|
128
|
+
expect(to).toContainEqual(["argo/argo/values/k8s/dd/values.yaml", "k8s:K8s::Argo::Application:helmReferences.valuesFiles[]"]);
|
|
129
|
+
// Nothing names a cluster resource or a Namespace here, so those two references dangle; the values file does not.
|
|
130
|
+
expect((g.dangling ?? []).map((d) => d.targetKind).sort()).toEqual(["K8s::Core::Namespace", "azurerm_kubernetes_cluster"]);
|
|
131
|
+
expect(g.ambiguous ?? []).toEqual([]);
|
|
132
|
+
},
|
|
133
|
+
TIMEOUT,
|
|
134
|
+
);
|
|
135
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A ServiceAccount to its cloud identity, and a Workload Identity binding back
|
|
3
|
+
* to the ServiceAccount, through `chant workspace graph --discover` end to end
|
|
4
|
+
* (#5099): a manifests member `k8s` and a terraform member `tf`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { afterAll, beforeAll, describe, expect, test } from "vitest";
|
|
8
|
+
import { cleanScratch, scratchDir, writeFiles } from "./__fixtures__/contract-repo";
|
|
9
|
+
import { CACHE_DIR_ENV } from "./graph-cache";
|
|
10
|
+
import { workspaceGraph, type GraphDocument } from "./graph-cli";
|
|
11
|
+
|
|
12
|
+
const TIMEOUT = 240_000;
|
|
13
|
+
|
|
14
|
+
let cacheBefore: string | undefined;
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
cacheBefore = process.env[CACHE_DIR_ENV];
|
|
17
|
+
process.env[CACHE_DIR_ENV] = scratchDir("chant-id-cache-");
|
|
18
|
+
});
|
|
19
|
+
afterAll(() => {
|
|
20
|
+
if (cacheBefore === undefined) delete process.env[CACHE_DIR_ENV];
|
|
21
|
+
else process.env[CACHE_DIR_ENV] = cacheBefore;
|
|
22
|
+
cleanScratch();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const serviceAccount = (name: string, key: string, value: string) =>
|
|
26
|
+
`apiVersion: v1\nkind: ServiceAccount\nmetadata:\n name: ${name}\n namespace: ci\n annotations:\n ${key}: ${value}\n`;
|
|
27
|
+
|
|
28
|
+
const FX = {
|
|
29
|
+
"k8s/sa.yaml": [
|
|
30
|
+
serviceAccount("runner", "iam.gke.io/gcp-service-account", "runner@demo-proj.iam.gserviceaccount.com"),
|
|
31
|
+
serviceAccount("builder", "eks.amazonaws.com/role-arn", "arn:aws:iam::111122223333:role/ci-runner"),
|
|
32
|
+
serviceAccount("ghost", "iam.gke.io/gcp-service-account", "ghost@demo-proj.iam.gserviceaccount.com"),
|
|
33
|
+
].join("---\n"),
|
|
34
|
+
"tf/main.tf": [
|
|
35
|
+
'resource "google_service_account" "runner" {',
|
|
36
|
+
' account_id = "runner"',
|
|
37
|
+
' project = "demo-proj"',
|
|
38
|
+
"}",
|
|
39
|
+
"",
|
|
40
|
+
'resource "google_service_account" "elsewhere" {',
|
|
41
|
+
' account_id = "runner"',
|
|
42
|
+
' project = "other-proj"',
|
|
43
|
+
"}",
|
|
44
|
+
"",
|
|
45
|
+
'resource "google_service_account_iam_member" "runner" {',
|
|
46
|
+
" service_account_id = google_service_account.runner.name",
|
|
47
|
+
' role = "roles/iam.workloadIdentityUser"',
|
|
48
|
+
' member = "serviceAccount:demo-proj.svc.id.goog[ci/runner]"',
|
|
49
|
+
"}",
|
|
50
|
+
"",
|
|
51
|
+
'resource "aws_iam_role" "ci_runner" {',
|
|
52
|
+
' name = "ci-runner"',
|
|
53
|
+
" assume_role_policy = \"{}\"",
|
|
54
|
+
"}",
|
|
55
|
+
"",
|
|
56
|
+
].join("\n"),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
function result(doc: GraphDocument): Extract<GraphDocument, { nodes: unknown }> {
|
|
60
|
+
if ("error" in doc) throw new Error(`${doc.error.code}: ${doc.error.message}`);
|
|
61
|
+
return doc;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe("workspace graph: cloud identity rules (#5099)", () => {
|
|
65
|
+
test(
|
|
66
|
+
"draws ServiceAccount to account and role, binding to ServiceAccount, joins only the account of the project, and lists the account that is not there",
|
|
67
|
+
async () => {
|
|
68
|
+
const root = scratchDir("chant-id-fx-");
|
|
69
|
+
writeFiles(root, FX);
|
|
70
|
+
const { doc, failed } = await workspaceGraph({ cwd: root, discover: true, noCache: false, catalog: true });
|
|
71
|
+
const g = result(doc);
|
|
72
|
+
expect(failed).toBe(false);
|
|
73
|
+
|
|
74
|
+
const sa = (name: string) => g.nodes.find((n) => n.kind === "K8s::Core::ServiceAccount" && n.id.toLowerCase().endsWith(name))!.id;
|
|
75
|
+
const res = (address: string) => g.nodes.find((n) => n.id.endsWith(`/${address}`))!.id;
|
|
76
|
+
const derived = g.edges.filter((e) => e.origin === "derived" && (e.rule?.includes("annotations[") || e.rule?.includes("service_account_iam_member")));
|
|
77
|
+
expect(derived.map((e) => `${e.from} -> ${e.to}`).sort()).toEqual(
|
|
78
|
+
[
|
|
79
|
+
`${sa("runner")} -> ${res("google_service_account.runner")}`,
|
|
80
|
+
`${sa("builder")} -> ${res("aws_iam_role.ci_runner")}`,
|
|
81
|
+
`${res("google_service_account_iam_member.runner")} -> ${sa("runner")}`,
|
|
82
|
+
].sort(),
|
|
83
|
+
);
|
|
84
|
+
expect(derived.every((e) => e.relation === "reference" && e.grain === "property")).toBe(true);
|
|
85
|
+
|
|
86
|
+
const dangling = (g.dangling ?? []).filter((d) => d.rule?.includes("annotations["));
|
|
87
|
+
expect(dangling).toEqual([expect.objectContaining({ from: sa("ghost"), value: "ghost@demo-proj.iam.gserviceaccount.com", targetKind: "google_service_account" })]);
|
|
88
|
+
},
|
|
89
|
+
TIMEOUT,
|
|
90
|
+
);
|
|
91
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #5099: a ServiceAccount's Workload Identity or IRSA annotation to the cloud
|
|
3
|
+
* identity, and a Workload Identity binding back to the ServiceAccount, over
|
|
4
|
+
* a composed workspace graph with the k8s and terraform catalogs together.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { EKS_ANNOTATION, GKE_ANNOTATION, k8sReferenceCatalog } from "../../../../lexicons/k8s/src/reference-catalog";
|
|
8
|
+
import { TERRAFORM_REFERENCE_CATALOG } from "../../../../lexicons/terraform/src/behaviour/reference-catalog";
|
|
9
|
+
import { placeCatalogPass, runCatalogPass } from "./catalog-edges";
|
|
10
|
+
import type { ComposedNode, WorkspaceGraph } from "./compose-graph";
|
|
11
|
+
|
|
12
|
+
const SA = "K8s::Core::ServiceAccount";
|
|
13
|
+
const GKE_RULE = `k8s:${SA}:${GKE_ANNOTATION}`;
|
|
14
|
+
const EKS_RULE = `k8s:${SA}:${EKS_ANNOTATION}`;
|
|
15
|
+
const MEMBER_RULE = "terraform:google_service_account_iam_member:member";
|
|
16
|
+
const BINDING_RULE = "terraform:google_service_account_iam_binding:members[]";
|
|
17
|
+
|
|
18
|
+
const sa = (name: string, namespace: string, annotations?: Record<string, string>, member = "k8s"): ComposedNode => ({
|
|
19
|
+
id: `${member}/sa-${namespace}-${name}`,
|
|
20
|
+
kind: SA,
|
|
21
|
+
lexicon: "k8s",
|
|
22
|
+
member,
|
|
23
|
+
attrs: { metadata: { name, namespace, ...(annotations ? { annotations } : {}) } },
|
|
24
|
+
});
|
|
25
|
+
const tf = (address: string, body: Record<string, unknown>, member = "tf"): ComposedNode => ({
|
|
26
|
+
id: `${member}/r/${address}`,
|
|
27
|
+
kind: "Terraform::Resource",
|
|
28
|
+
lexicon: "terraform",
|
|
29
|
+
member,
|
|
30
|
+
attrs: { address, type: address.split(".")[0], name: address.split(".")[1], body, source: "main.tf" },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const gsa = (address: string, accountId: string, project: string) => tf(address, { account_id: accountId, project });
|
|
34
|
+
const runner = sa("runner", "ci", { "iam.gke.io/gcp-service-account": "runner@demo-proj.iam.gserviceaccount.com" });
|
|
35
|
+
const binding = (member: string, address = "google_service_account_iam_member.runner", role = "roles/iam.workloadIdentityUser") =>
|
|
36
|
+
tf(address, { service_account_id: "projects/demo-proj/serviceAccounts/runner@demo-proj.iam.gserviceaccount.com", role, member });
|
|
37
|
+
|
|
38
|
+
const pass = (nodes: ComposedNode[]) =>
|
|
39
|
+
runCatalogPass(nodes, [
|
|
40
|
+
{ lexicon: "k8s", catalog: k8sReferenceCatalog },
|
|
41
|
+
{ lexicon: "terraform", catalog: TERRAFORM_REFERENCE_CATALOG },
|
|
42
|
+
]);
|
|
43
|
+
// A Namespace declared nowhere is dangling under the containment rule; these tests read the identity rules.
|
|
44
|
+
const identityDangling = (out: ReturnType<typeof pass>) => out.dangling.filter((d) => d.rule !== undefined && !d.rule.endsWith("metadata.namespace"));
|
|
45
|
+
const refEdges = (out: ReturnType<typeof pass>) =>
|
|
46
|
+
out.edges.filter((e) => e.relation === "reference").map((e) => `${e.from} -> ${e.to} [${e.viaAttr}] ${e.rule}`);
|
|
47
|
+
|
|
48
|
+
describe("Workload Identity annotation (#5099)", () => {
|
|
49
|
+
it("draws ServiceAccount to account and binding to ServiceAccount", () => {
|
|
50
|
+
const out = pass([runner, gsa("google_service_account.runner", "runner", "demo-proj"), binding("serviceAccount:demo-proj.svc.id.goog[ci/runner]")]);
|
|
51
|
+
expect(refEdges(out)).toEqual([
|
|
52
|
+
`k8s/sa-ci-runner -> tf/r/google_service_account.runner [iam.gke.io/gcp-service-account] ${GKE_RULE}`,
|
|
53
|
+
`tf/r/google_service_account_iam_member.runner -> k8s/sa-ci-runner [workload identity member] ${MEMBER_RULE}`,
|
|
54
|
+
]);
|
|
55
|
+
expect(identityDangling(out)).toEqual([]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("joins only the account in the annotation's project", () => {
|
|
59
|
+
const out = pass([runner, gsa("google_service_account.a", "runner", "other-proj"), gsa("google_service_account.b", "runner", "demo-proj")]);
|
|
60
|
+
expect(refEdges(out)).toEqual([`k8s/sa-ci-runner -> tf/r/google_service_account.b [iam.gke.io/gcp-service-account] ${GKE_RULE}`]);
|
|
61
|
+
expect(out.ambiguous).toEqual([]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("reports two accounts of one id in one project as ambiguous, with both candidates", () => {
|
|
65
|
+
const out = pass([runner, gsa("google_service_account.a", "runner", "demo-proj"), gsa("google_service_account.b", "runner", "demo-proj")]);
|
|
66
|
+
expect(refEdges(out)).toEqual([]);
|
|
67
|
+
expect(out.ambiguous).toEqual([expect.objectContaining({ rule: GKE_RULE, candidates: ["tf/r/google_service_account.a", "tf/r/google_service_account.b"] })]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("lists an annotation that names an account not in the graph as dangling", () => {
|
|
71
|
+
const out = pass([runner, gsa("google_service_account.other", "other", "demo-proj")]);
|
|
72
|
+
expect(refEdges(out)).toEqual([]);
|
|
73
|
+
expect(identityDangling(out)).toEqual([
|
|
74
|
+
expect.objectContaining({ from: "k8s/sa-ci-runner", value: "runner@demo-proj.iam.gserviceaccount.com", rule: GKE_RULE, targetKind: "google_service_account" }),
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("gives an account whose project is a variable no edge, and counts the argument", () => {
|
|
79
|
+
const account = tf("google_service_account.runner", { account_id: "runner", project: "${var.project}" });
|
|
80
|
+
const out = pass([runner, account]);
|
|
81
|
+
expect(refEdges(out)).toEqual([]);
|
|
82
|
+
expect(out.nonLiteral).toEqual({ "tf/r/google_service_account.runner": 1 });
|
|
83
|
+
expect(identityDangling(out).map((d) => d.value)).toEqual(["runner@demo-proj.iam.gserviceaccount.com"]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("reads a binding's members list, and only for roles/iam.workloadIdentityUser", () => {
|
|
87
|
+
const list = tf("google_service_account_iam_binding.runner", { role: "roles/iam.workloadIdentityUser", members: ["serviceAccount:demo-proj.svc.id.goog[ci/runner]", "user:a@example.com"] });
|
|
88
|
+
expect(refEdges(pass([runner, list])).map((e) => e.split(" ").slice(0, 3).join(" "))).toEqual(["tf/r/google_service_account_iam_binding.runner -> k8s/sa-ci-runner"]);
|
|
89
|
+
expect(refEdges(pass([runner, binding("serviceAccount:demo-proj.svc.id.goog[ci/runner]", "google_service_account_iam_member.x", "roles/iam.serviceAccountUser")]))).toEqual([]);
|
|
90
|
+
expect(BINDING_RULE).toContain("members[]");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("joins a binding to the ServiceAccount of that name in that namespace only, and reports none for a cluster that is not in the workspace", () => {
|
|
94
|
+
const elsewhere = sa("runner", "other", undefined);
|
|
95
|
+
const edges = refEdges(pass([runner, elsewhere, binding("serviceAccount:demo-proj.svc.id.goog[ci/runner]")])).filter((e) => e.includes(MEMBER_RULE));
|
|
96
|
+
expect(edges.map((e) => e.split(" ")[2])).toEqual(["k8s/sa-ci-runner"]);
|
|
97
|
+
const out = pass([binding("serviceAccount:demo-proj.svc.id.goog[ci/runner]")]);
|
|
98
|
+
expect(refEdges(out)).toEqual([]);
|
|
99
|
+
expect(identityDangling(out)).toEqual([]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("gives a binding whose member is built from a local no edge, and counts it", () => {
|
|
103
|
+
const out = pass([runner, binding("serviceAccount:${local.pool}[ci/runner]")]);
|
|
104
|
+
expect(refEdges(out)).toEqual([]);
|
|
105
|
+
expect(out.nonLiteral).toEqual({ "tf/r/google_service_account_iam_member.runner": 1 });
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe("IRSA annotation (#5099)", () => {
|
|
110
|
+
const irsa = (arn: string) => sa("runner", "ci", { "eks.amazonaws.com/role-arn": arn });
|
|
111
|
+
const role = (name: string, extra: Record<string, unknown> = {}) => tf(`aws_iam_role.${name.replace(/-/g, "_")}`, { name, assume_role_policy: "{}", ...extra });
|
|
112
|
+
|
|
113
|
+
it("draws ServiceAccount to aws_iam_role by the role name in the ARN", () => {
|
|
114
|
+
const out = pass([irsa("arn:aws:iam::111122223333:role/ci-runner"), role("ci-runner")]);
|
|
115
|
+
expect(refEdges(out)).toEqual([`k8s/sa-ci-runner -> tf/r/aws_iam_role.ci_runner [eks.amazonaws.com/role-arn] ${EKS_RULE}`]);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("requires the role's path and, when its arn is literal, its account to agree", () => {
|
|
119
|
+
const arn = "arn:aws:iam::111122223333:role/service-role/ci-runner";
|
|
120
|
+
expect(refEdges(pass([irsa(arn), role("ci-runner", { path: "/service-role/" })]))).toHaveLength(1);
|
|
121
|
+
expect(refEdges(pass([irsa(arn), role("ci-runner", { path: "/other/" })]))).toHaveLength(0);
|
|
122
|
+
expect(refEdges(pass([irsa(arn), role("ci-runner", { path: "/service-role/", arn: "arn:aws:iam::999999999999:role/service-role/ci-runner" })]))).toHaveLength(0);
|
|
123
|
+
expect(refEdges(pass([irsa(arn), role("ci-runner", { path: "/service-role/", arn: "arn:aws:iam::111122223333:role/service-role/ci-runner" })]))).toHaveLength(1);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("lists a role not in the graph as dangling, and a malformed value too", () => {
|
|
127
|
+
const out = pass([irsa("arn:aws:iam::111122223333:role/missing"), sa("b", "ci", { "eks.amazonaws.com/role-arn": "not-an-arn" })]);
|
|
128
|
+
expect(identityDangling(out).map((d) => d.value).sort()).toEqual(["arn:aws:iam::111122223333:role/missing", "not-an-arn"]);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("placed rules", () => {
|
|
133
|
+
it("names the annotation rules with their quoted-key ids and target kinds", () => {
|
|
134
|
+
const graph = { version: 1, workspace: { name: "w", root: "." }, members: [], nodes: [], edges: [], groups: { byMember: {} }, exports: [], imports: [], links: [], collectors: [], records: [] } as unknown as WorkspaceGraph;
|
|
135
|
+
placeCatalogPass(graph, pass([runner, gsa("google_service_account.runner", "runner", "demo-proj"), binding("serviceAccount:demo-proj.svc.id.goog[ci/runner]")]));
|
|
136
|
+
expect(graph.catalog?.rules[GKE_RULE]).toMatchObject({ from: SA, path: GKE_ANNOTATION, targetKinds: ["google_service_account"], label: "acts as" });
|
|
137
|
+
expect(graph.catalog?.rules[MEMBER_RULE]).toMatchObject({ targetKinds: [SA] });
|
|
138
|
+
});
|
|
139
|
+
});
|