@intentius/chant-lexicon-terraform 0.124.54 → 0.124.56
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 +7 -4
- package/dist/ci-setup.d.ts +11 -0
- package/dist/ci-setup.d.ts.map +1 -0
- package/dist/ci-setup.js +41 -0
- package/dist/components/capability-plugin.d.ts +40 -6
- package/dist/components/capability-plugin.d.ts.map +1 -1
- package/dist/components/capability-plugin.js +174 -30
- package/dist/components/compose-group.d.ts +1 -1
- package/dist/components/compose-group.d.ts.map +1 -1
- package/dist/components/compose-group.js +1 -1
- package/dist/components/release-inputs.d.ts +29 -0
- package/dist/components/release-inputs.d.ts.map +1 -0
- package/dist/components/release-inputs.js +57 -0
- package/dist/components/trace-facts.d.ts +16 -0
- package/dist/components/trace-facts.d.ts.map +1 -0
- package/dist/components/trace-facts.js +19 -0
- package/dist/cone.d.ts +53 -0
- package/dist/cone.d.ts.map +1 -0
- package/dist/cone.js +119 -0
- package/dist/cost-hold.d.ts +27 -0
- package/dist/cost-hold.d.ts.map +1 -0
- package/dist/cost-hold.js +21 -0
- package/dist/drift-rows.d.ts +61 -0
- package/dist/drift-rows.d.ts.map +1 -0
- package/dist/drift-rows.js +108 -0
- package/dist/exit-codes.d.ts +55 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +48 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/integrity.json +7 -4
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/audit-catalog.js +27 -3
- package/dist/lint/audit-lineage.d.ts +14 -2
- package/dist/lint/audit-lineage.d.ts.map +1 -1
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/post-synth/index.js +4 -0
- package/dist/lint/post-synth/record-store.d.ts +54 -0
- package/dist/lint/post-synth/record-store.d.ts.map +1 -0
- package/dist/lint/post-synth/record-store.js +104 -0
- package/dist/lint/post-synth/tf001.d.ts +2 -2
- package/dist/lint/post-synth/tf001.js +2 -2
- package/dist/lint/post-synth/tf024.d.ts +35 -11
- package/dist/lint/post-synth/tf024.d.ts.map +1 -1
- package/dist/lint/post-synth/tf024.js +92 -20
- package/dist/lint/post-synth/tf046.d.ts +64 -0
- package/dist/lint/post-synth/tf046.d.ts.map +1 -0
- package/dist/lint/post-synth/tf046.js +175 -0
- package/dist/lint/post-synth/tf047.d.ts +36 -0
- package/dist/lint/post-synth/tf047.d.ts.map +1 -0
- package/dist/lint/post-synth/tf047.js +94 -0
- package/dist/lock-rows.d.ts +36 -0
- package/dist/lock-rows.d.ts.map +1 -0
- package/dist/lock-rows.js +60 -0
- package/dist/lock-timeout.d.ts +22 -0
- package/dist/lock-timeout.d.ts.map +1 -0
- package/dist/lock-timeout.js +32 -0
- package/dist/manifest.json +1 -1
- package/dist/module-catalog/index.d.ts +69 -0
- package/dist/module-catalog/index.d.ts.map +1 -0
- package/dist/module-catalog/index.js +110 -0
- package/dist/module-catalog/refresh-cli.d.ts +4 -0
- package/dist/module-catalog/refresh-cli.d.ts.map +1 -0
- package/dist/module-catalog/refresh-cli.js +64 -0
- package/dist/module-catalog/static-tier.d.ts +6 -0
- package/dist/module-catalog/static-tier.d.ts.map +1 -0
- package/dist/module-catalog/static-tier.js +1650 -0
- package/dist/module-catalog/types.d.ts +65 -0
- package/dist/module-catalog/types.d.ts.map +1 -0
- package/dist/module-catalog/types.js +33 -0
- package/dist/okf/index.md +3 -1
- package/dist/okf/rules/TF024.md +2 -2
- package/dist/okf/rules/TF046.md +11 -0
- package/dist/okf/rules/TF047.md +11 -0
- package/dist/op/activities/terraform.d.ts +29 -0
- package/dist/op/activities/terraform.d.ts.map +1 -1
- package/dist/op/activities/terraform.js +19 -4
- package/dist/pin/consumers.d.ts +35 -0
- package/dist/pin/consumers.d.ts.map +1 -0
- package/dist/pin/consumers.js +70 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +5 -0
- package/dist/registry/address.d.ts +63 -0
- package/dist/registry/address.d.ts.map +1 -0
- package/dist/registry/address.js +65 -0
- package/dist/registry/catalog-read.d.ts +14 -0
- package/dist/registry/catalog-read.d.ts.map +1 -0
- package/dist/registry/catalog-read.js +58 -0
- package/dist/registry/deprecated.d.ts +37 -0
- package/dist/registry/deprecated.d.ts.map +1 -0
- package/dist/registry/deprecated.js +43 -0
- package/dist/registry/docs.d.ts +96 -0
- package/dist/registry/docs.d.ts.map +1 -0
- package/dist/registry/docs.js +210 -0
- package/dist/registry/edge/edge.d.ts +46 -0
- package/dist/registry/edge/edge.d.ts.map +1 -0
- package/dist/registry/edge/edge.js +194 -0
- package/dist/registry/edge/index.d.ts +11 -0
- package/dist/registry/edge/index.d.ts.map +1 -0
- package/dist/registry/edge/index.js +10 -0
- package/dist/registry/edge/lambda-edge.d.ts +76 -0
- package/dist/registry/edge/lambda-edge.d.ts.map +1 -0
- package/dist/registry/edge/lambda-edge.js +95 -0
- package/dist/registry/edge/sigv4-web.d.ts +33 -0
- package/dist/registry/edge/sigv4-web.d.ts.map +1 -0
- package/dist/registry/edge/sigv4-web.js +56 -0
- package/dist/registry/edge/token-source.d.ts +73 -0
- package/dist/registry/edge/token-source.d.ts.map +1 -0
- package/dist/registry/edge/token-source.js +115 -0
- package/dist/registry/edge/worker.d.ts +45 -0
- package/dist/registry/edge/worker.d.ts.map +1 -0
- package/dist/registry/edge/worker.js +26 -0
- package/dist/registry/handler.d.ts +25 -0
- package/dist/registry/handler.d.ts.map +1 -0
- package/dist/registry/handler.js +75 -0
- package/dist/registry/headers-file.d.ts +21 -0
- package/dist/registry/headers-file.d.ts.map +1 -0
- package/dist/registry/headers-file.js +57 -0
- package/dist/registry/index.d.ts +31 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +30 -0
- package/dist/registry/mirror-paths.d.ts +9 -0
- package/dist/registry/mirror-paths.d.ts.map +1 -0
- package/dist/registry/mirror-paths.js +8 -0
- package/dist/registry/mirror.d.ts +130 -0
- package/dist/registry/mirror.d.ts.map +1 -0
- package/dist/registry/mirror.js +319 -0
- package/dist/registry/proxies.d.ts +73 -0
- package/dist/registry/proxies.d.ts.map +1 -0
- package/dist/registry/proxies.js +111 -0
- package/dist/registry/reader.d.ts +57 -0
- package/dist/registry/reader.d.ts.map +1 -0
- package/dist/registry/reader.js +198 -0
- package/dist/registry/semver.d.ts +16 -0
- package/dist/registry/semver.d.ts.map +1 -0
- package/dist/registry/semver.js +24 -0
- package/dist/registry/serve.d.ts +24 -0
- package/dist/registry/serve.d.ts.map +1 -0
- package/dist/registry/serve.js +64 -0
- package/dist/registry/source-forms.d.ts +79 -0
- package/dist/registry/source-forms.d.ts.map +1 -0
- package/dist/registry/source-forms.js +202 -0
- package/dist/registry/targets/artifactory.d.ts +28 -0
- package/dist/registry/targets/artifactory.d.ts.map +1 -0
- package/dist/registry/targets/artifactory.js +206 -0
- package/dist/registry/targets/fake-artifactory.d.ts +30 -0
- package/dist/registry/targets/fake-artifactory.d.ts.map +1 -0
- package/dist/registry/targets/fake-artifactory.js +142 -0
- package/dist/registry/targets/fake-gitlab.d.ts +39 -0
- package/dist/registry/targets/fake-gitlab.d.ts.map +1 -0
- package/dist/registry/targets/fake-gitlab.js +136 -0
- package/dist/registry/targets/fake-hcp.d.ts +50 -0
- package/dist/registry/targets/fake-hcp.d.ts.map +1 -0
- package/dist/registry/targets/fake-hcp.js +202 -0
- package/dist/registry/targets/fake-http.d.ts +31 -0
- package/dist/registry/targets/fake-http.d.ts.map +1 -0
- package/dist/registry/targets/fake-http.js +87 -0
- package/dist/registry/targets/fake-nexus.d.ts +27 -0
- package/dist/registry/targets/fake-nexus.d.ts.map +1 -0
- package/dist/registry/targets/fake-nexus.js +137 -0
- package/dist/registry/targets/gitlab.d.ts +53 -0
- package/dist/registry/targets/gitlab.d.ts.map +1 -0
- package/dist/registry/targets/gitlab.js +187 -0
- package/dist/registry/targets/hcp.d.ts +29 -0
- package/dist/registry/targets/hcp.d.ts.map +1 -0
- package/dist/registry/targets/hcp.js +310 -0
- package/dist/registry/targets/hosted.d.ts +62 -0
- package/dist/registry/targets/hosted.d.ts.map +1 -0
- package/dist/registry/targets/hosted.js +74 -0
- package/dist/registry/targets/index.d.ts +18 -0
- package/dist/registry/targets/index.d.ts.map +1 -0
- package/dist/registry/targets/index.js +17 -0
- package/dist/registry/targets/module-target.d.ts +68 -0
- package/dist/registry/targets/module-target.d.ts.map +1 -0
- package/dist/registry/targets/module-target.js +63 -0
- package/dist/registry/targets/nexus.d.ts +43 -0
- package/dist/registry/targets/nexus.d.ts.map +1 -0
- package/dist/registry/targets/nexus.js +250 -0
- package/dist/registry/targets/zip.d.ts +55 -0
- package/dist/registry/targets/zip.d.ts.map +1 -0
- package/dist/registry/targets/zip.js +278 -0
- package/dist/registry/writer.d.ts +101 -0
- package/dist/registry/writer.d.ts.map +1 -0
- package/dist/registry/writer.js +109 -0
- package/dist/rules/record-store.ts +122 -0
- package/dist/rules/tf001.ts +2 -2
- package/dist/rules/tf024.ts +105 -22
- package/dist/rules/tf046.ts +204 -0
- package/dist/rules/tf047.ts +114 -0
- package/dist/state/azure-blob.d.ts +8 -67
- package/dist/state/azure-blob.d.ts.map +1 -1
- package/dist/state/azure-blob.js +6 -199
- package/dist/state/gcs.d.ts +7 -61
- package/dist/state/gcs.d.ts.map +1 -1
- package/dist/state/gcs.js +5 -222
- package/dist/state/object-store.d.ts +4 -33
- package/dist/state/object-store.d.ts.map +1 -1
- package/dist/state/object-store.js +4 -17
- package/dist/state/s3.d.ts +11 -58
- package/dist/state/s3.d.ts.map +1 -1
- package/dist/state/s3.js +10 -161
- package/dist/state/store.js +2 -2
- package/dist/state-ops.d.ts +255 -0
- package/dist/state-ops.d.ts.map +1 -0
- package/dist/state-ops.js +305 -0
- package/dist/state-reads.d.ts +57 -0
- package/dist/state-reads.d.ts.map +1 -0
- package/dist/state-reads.js +104 -0
- package/dist/used-sources.d.ts +54 -0
- package/dist/used-sources.d.ts.map +1 -0
- package/dist/used-sources.js +157 -0
- package/package.json +19 -3
- package/src/__fixtures__/drift-record/README.md +5 -0
- package/src/__fixtures__/drift-rows/live-root-plan.json +70 -0
- package/src/__fixtures__/drift-rows/refresh-plan.json +61 -0
- package/src/__fixtures__/used-sources/root/extra.tofu +1 -0
- package/src/__fixtures__/used-sources/root/main.tf +31 -0
- package/src/__fixtures__/used-sources/root/modules/net/main.tf +14 -0
- package/src/__fixtures__/used-sources/root/modules/net/versions.tf.json +7 -0
- package/src/__fixtures__/used-sources/unit/terragrunt.hcl +3 -0
- package/src/ci-setup.ts +42 -0
- package/src/components/capability-plugin.test.ts +26 -14
- package/src/components/capability-plugin.ts +185 -31
- package/src/components/compose-group.ts +1 -1
- package/src/components/pr-loop-compose.tofu.e2e.test.ts +1 -1
- package/src/components/pr-loop.tofu.test.ts +1 -1
- package/src/components/release-inputs.ts +69 -0
- package/src/components/trace-facts.test.ts +21 -0
- package/src/components/trace-facts.ts +27 -0
- package/src/cone.ts +138 -0
- package/src/cost-hold.ts +29 -0
- package/src/describe-resources.engine-facts.test.ts +2 -3
- package/src/drift-rows.test.ts +135 -0
- package/src/drift-rows.ts +137 -0
- package/src/exit-codes.test.ts +23 -0
- package/src/exit-codes.ts +59 -0
- package/src/index.ts +3 -0
- package/src/lint/audit-catalog.ts +29 -3
- package/src/lint/audit-lineage.ts +14 -2
- package/src/lint/post-synth/fixtures/TF024/live-with-record-store/main.tf +18 -0
- package/src/lint/post-synth/fixtures/TF024/sidecar-with-backend/estate.chdf.hcl +1 -0
- package/src/lint/post-synth/fixtures/TF024/sidecar-with-backend/main.tf +10 -0
- package/src/lint/post-synth/fixtures/TF046/azurerm-no-resource-group/main.tf +15 -0
- package/src/lint/post-synth/fixtures/TF046/backend-config-only/main.tf +14 -0
- package/src/lint/post-synth/fixtures/TF046/derived-s3/backend.tf +7 -0
- package/src/lint/post-synth/fixtures/TF046/derived-s3/main.tf +9 -0
- package/src/lint/post-synth/fixtures/TF046/explicit-local/main.tf +16 -0
- package/src/lint/post-synth/fixtures/TF046/explicit-s3-beside-local-backend/main.tf +15 -0
- package/src/lint/post-synth/fixtures/TF046/implied-local/main.tf +9 -0
- package/src/lint/post-synth/fixtures/TF046/sidecar-implied/estate.chdf.hcl +1 -0
- package/src/lint/post-synth/fixtures/TF046/sidecar-implied/main.tf +5 -0
- package/src/lint/post-synth/fixtures/TF047/clear/main.tf +12 -0
- package/src/lint/post-synth/fixtures/TF047/refused/main.tf +12 -0
- package/src/lint/post-synth/fixtures/TF047/unknown-module/main.tf +12 -0
- package/src/lint/post-synth/fixtures/TF047/unknown-version/main.tf +12 -0
- package/src/lint/post-synth/index.ts +4 -0
- package/src/lint/post-synth/record-store.ts +122 -0
- package/src/lint/post-synth/tf001.ts +2 -2
- package/src/lint/post-synth/tf024.test.ts +26 -5
- package/src/lint/post-synth/tf024.ts +105 -22
- package/src/lint/post-synth/tf046.test.ts +137 -0
- package/src/lint/post-synth/tf046.ts +204 -0
- package/src/lint/post-synth/tf047.test.ts +56 -0
- package/src/lint/post-synth/tf047.ts +114 -0
- package/src/lock-rows.test.ts +70 -0
- package/src/lock-rows.ts +82 -0
- package/src/lock-timeout.ts +34 -0
- package/src/module-catalog/index.test.ts +93 -0
- package/src/module-catalog/index.ts +159 -0
- package/src/module-catalog/refresh-cli.ts +68 -0
- package/src/module-catalog/static-tier.ts +1659 -0
- package/src/module-catalog/types.ts +88 -0
- package/src/op/activities/terraform.ts +46 -5
- package/src/op-wave-step.test.ts +109 -0
- package/src/pin/__fixtures__/consumers/live/dev/main.tf +4 -0
- package/src/pin/__fixtures__/consumers/live/prod/main.tf +21 -0
- package/src/pin/__fixtures__/consumers/units/vpc/terragrunt.hcl +7 -0
- package/src/pin/consumers.test.ts +57 -0
- package/src/pin/consumers.ts +95 -0
- package/src/plugin.ts +6 -0
- package/src/registry/__fixtures__/docs/documented/.terraform-docs.yml +3 -0
- package/src/registry/__fixtures__/docs/documented/README.md +1 -0
- package/src/registry/__fixtures__/docs/documented/main.tf +8 -0
- package/src/registry/__fixtures__/docs/json/main.tf.json +14 -0
- package/src/registry/__fixtures__/docs/vpc/README.md +3 -0
- package/src/registry/__fixtures__/docs/vpc/examples/complete/main.tf +5 -0
- package/src/registry/__fixtures__/docs/vpc/examples/simple/README.md +1 -0
- package/src/registry/__fixtures__/docs/vpc/examples/simple/main.tf +4 -0
- package/src/registry/__fixtures__/docs/vpc/main.tf +14 -0
- package/src/registry/__fixtures__/docs/vpc/outputs.tf +9 -0
- package/src/registry/__fixtures__/docs/vpc/variables.tf +16 -0
- package/src/registry/__fixtures__/proxied-root/main.tf +12 -0
- package/src/registry/address.ts +100 -0
- package/src/registry/catalog-read.ts +56 -0
- package/src/registry/deprecated.test.ts +139 -0
- package/src/registry/deprecated.ts +76 -0
- package/src/registry/docs.test.ts +140 -0
- package/src/registry/docs.ts +299 -0
- package/src/registry/edge/bundle.test.ts +50 -0
- package/src/registry/edge/edge.test.ts +176 -0
- package/src/registry/edge/edge.ts +211 -0
- package/src/registry/edge/index.ts +10 -0
- package/src/registry/edge/lambda-edge.ts +127 -0
- package/src/registry/edge/sigv4-web.ts +79 -0
- package/src/registry/edge/token-source.test.ts +258 -0
- package/src/registry/edge/token-source.ts +169 -0
- package/src/registry/edge/worker.ts +61 -0
- package/src/registry/handler.ts +89 -0
- package/src/registry/headers-file.ts +61 -0
- package/src/registry/index.ts +31 -0
- package/src/registry/mirror-paths.ts +10 -0
- package/src/registry/mirror.test.ts +198 -0
- package/src/registry/mirror.ts +395 -0
- package/src/registry/proxies.test.ts +153 -0
- package/src/registry/proxies.ts +132 -0
- package/src/registry/reader.ts +225 -0
- package/src/registry/registry.test.ts +262 -0
- package/src/registry/semver.ts +34 -0
- package/src/registry/serve.ts +82 -0
- package/src/registry/source-forms.test.ts +87 -0
- package/src/registry/source-forms.ts +216 -0
- package/src/registry/targets/artifactory.test.ts +248 -0
- package/src/registry/targets/artifactory.ts +257 -0
- package/src/registry/targets/fake-artifactory.ts +158 -0
- package/src/registry/targets/fake-gitlab.ts +161 -0
- package/src/registry/targets/fake-hcp.ts +233 -0
- package/src/registry/targets/fake-http.ts +97 -0
- package/src/registry/targets/fake-nexus.ts +152 -0
- package/src/registry/targets/gitlab.test.ts +208 -0
- package/src/registry/targets/gitlab.ts +223 -0
- package/src/registry/targets/hcp.test.ts +230 -0
- package/src/registry/targets/hcp.ts +360 -0
- package/src/registry/targets/hosted.ts +117 -0
- package/src/registry/targets/index.ts +17 -0
- package/src/registry/targets/module-target.ts +131 -0
- package/src/registry/targets/nexus.test.ts +220 -0
- package/src/registry/targets/nexus.ts +314 -0
- package/src/registry/targets/zip.test.ts +65 -0
- package/src/registry/targets/zip.ts +287 -0
- package/src/registry/writer.ts +155 -0
- package/src/state/azure-blob.ts +6 -221
- package/src/state/gcs.ts +5 -252
- package/src/state/object-store.ts +4 -32
- package/src/state/s3.ts +10 -182
- package/src/state/store.ts +2 -2
- package/src/state-ops.test.ts +182 -0
- package/src/state-ops.ts +462 -0
- package/src/state-reads.ts +116 -0
- package/src/used-sources.test.ts +75 -0
- package/src/used-sources.ts +204 -0
package/dist/rules/tf024.ts
CHANGED
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TF024: a live root declares a `backend` or `cloud` block.
|
|
3
3
|
*
|
|
4
|
-
* choudoufu
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* choudoufu used to refuse this pair at `init` (#1170). Since
|
|
5
|
+
* INTENTIUS/choudoufu#2213 it accepts both and ignores them with a warning
|
|
6
|
+
* (`internal/configs/module.go`, `ignoreStateStoreUnderLive`), because
|
|
7
|
+
* Terragrunt's `remote_state` and Atmos's `backend.tf.json` write a backend
|
|
8
|
+
* beside the live block on every run. What each block still does:
|
|
9
|
+
*
|
|
10
|
+
* - `backend "<type>"`: no state is read or written there, and
|
|
11
|
+
* `init -migrate-state` is refused. choudoufu keeps the block as
|
|
12
|
+
* `IgnoredBackend`: an apply publishes the estate's non-sensitive outputs
|
|
13
|
+
* to the location it names, so `terraform_remote_state` readers keep
|
|
14
|
+
* working, and when the live declaration has no `record_store` the record
|
|
15
|
+
* store is derived from the backend's bucket, s3 to s3, gcs to gcs, azurerm
|
|
16
|
+
* to azurerm (INTENTIUS/choudoufu#2293), when the bucket is a literal in
|
|
17
|
+
* the configuration. An explicit `record_store` always wins. The resolution
|
|
18
|
+
* is shared with TF046 in `./record-store.ts`.
|
|
19
|
+
* - `cloud {}`: dropped entirely. Nothing is published to it and no store is
|
|
20
|
+
* derived from it.
|
|
21
|
+
*
|
|
22
|
+
* So the backend case is reported as `info` (the block is doing a job the
|
|
23
|
+
* author may want, and is the derivation source the maintainer ruled for),
|
|
24
|
+
* and the cloud case as `warning` (the block does nothing at all). Neither
|
|
25
|
+
* fails a build at default severity. The guard against a CI root that ends
|
|
26
|
+
* up on the local store is TF046 (chant#4561).
|
|
27
|
+
*
|
|
28
|
+
* The live marker is the root's `mode`, stamped from either a `live` block or
|
|
29
|
+
* an `estate.chdf.hcl` sidecar (`hcl/parse.ts`), so a sidecar estate is
|
|
30
|
+
* covered. A `record_store` is read from whichever `Terraform::Live` entity
|
|
31
|
+
* carries it: the `live` block, or the sidecar's top level.
|
|
11
32
|
*
|
|
12
33
|
* TF001 is the equivalent check for a stock root (no remote backend is
|
|
13
|
-
* configured); it
|
|
14
|
-
*
|
|
15
|
-
* at most one of them.
|
|
34
|
+
* configured); it does not fire on a live root. A root is flagged by at most
|
|
35
|
+
* one of them.
|
|
16
36
|
*
|
|
17
37
|
* Scope: root modules only (#2112). A child module's backend or cloud block
|
|
18
38
|
* is TF015's finding, whatever binary the root runs.
|
|
@@ -26,17 +46,74 @@ import type {
|
|
|
26
46
|
PostSynthDiagnostic,
|
|
27
47
|
} from "@intentius/chant/lint/post-synth";
|
|
28
48
|
import { isResourceDeclarable } from "@intentius/chant/declarable";
|
|
29
|
-
import { TERRAFORM_TYPE, type BlockBody } from "../../hcl/parse";
|
|
30
|
-
import { hasBlock } from "./tf001";
|
|
49
|
+
import { LIVE_TYPE, TERRAFORM_TYPE, type BlockBody } from "../../hcl/parse";
|
|
50
|
+
import { backendTypes, hasBlock } from "./tf001";
|
|
31
51
|
import { isRootScoped } from "./scope";
|
|
52
|
+
import { DERIVABLE_BACKENDS, resolveRecordStore, type ResolvedRecordStore } from "./record-store";
|
|
53
|
+
|
|
54
|
+
export { DERIVABLE_BACKENDS } from "./record-store";
|
|
55
|
+
|
|
56
|
+
const bodyOf = (props: { body?: unknown }): BlockBody =>
|
|
57
|
+
(typeof props.body === "object" && props.body !== null ? props.body : {}) as BlockBody;
|
|
58
|
+
|
|
59
|
+
/** Each root's live declarations (its `live` block and its sidecar), keyed by root. */
|
|
60
|
+
export function liveBodiesByRoot(ctx: PostSynthContext): Map<string, BlockBody[]> {
|
|
61
|
+
const roots = new Map<string, BlockBody[]>();
|
|
62
|
+
for (const entity of ctx.entities.values()) {
|
|
63
|
+
if (entity.entityType !== LIVE_TYPE) continue;
|
|
64
|
+
if (!isResourceDeclarable(entity) || !isRootScoped(entity)) continue;
|
|
65
|
+
const props = entity.props as { root?: unknown; body?: unknown };
|
|
66
|
+
const root = typeof props.root === "string" ? props.root : "";
|
|
67
|
+
const list = roots.get(root) ?? [];
|
|
68
|
+
list.push(bodyOf(props));
|
|
69
|
+
roots.set(root, list);
|
|
70
|
+
}
|
|
71
|
+
return roots;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function backendMessage(root: string, type: string, store: ResolvedRecordStore): string {
|
|
75
|
+
const label = type ? `backend "${type}"` : "backend";
|
|
76
|
+
const head =
|
|
77
|
+
`Root module "${root}" runs choudoufu with a declared estate and also declares a ${label} block. ` +
|
|
78
|
+
"choudoufu ignores it with a warning: no state is read or written there and `init -migrate-state` " +
|
|
79
|
+
"is refused. An apply publishes the estate's non-sensitive outputs to the location it names, so " +
|
|
80
|
+
"terraform_remote_state readers keep working.";
|
|
81
|
+
if (store.source === "record_store") {
|
|
82
|
+
return `${head} Records go to the record_store the live declaration names, which wins over the backend.`;
|
|
83
|
+
}
|
|
84
|
+
if (store.source === "backend") {
|
|
85
|
+
return (
|
|
86
|
+
`${head} With no record_store declared, choudoufu derives the record store from this backend's ` +
|
|
87
|
+
"bucket and prints it on every init and plan (INTENTIUS/choudoufu#2293). Declare record_store to " +
|
|
88
|
+
"put records somewhere else."
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const why = DERIVABLE_BACKENDS.has(type) && store.note
|
|
92
|
+
? `No record store is derived from it: ${store.note}.`
|
|
93
|
+
: `No record store is derived from a ${type ? `"${type}"` : "backend of unknown type"} (only s3, gcs and azurerm are).`;
|
|
94
|
+
return (
|
|
95
|
+
`${head} ${why} No record_store is declared, so records stay in the local ` +
|
|
96
|
+
"store. Declare record_store if more than one machine runs this root (TF046 guards this in CI)."
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function cloudMessage(root: string): string {
|
|
101
|
+
return (
|
|
102
|
+
`Root module "${root}" runs choudoufu with a declared estate and also declares a cloud block. ` +
|
|
103
|
+
"choudoufu ignores it entirely: no state is read or written there, no outputs are published to it, " +
|
|
104
|
+
"and no record store is derived from it. Remove it, or use a backend block if " +
|
|
105
|
+
"terraform_remote_state readers need this estate's outputs."
|
|
106
|
+
);
|
|
107
|
+
}
|
|
32
108
|
|
|
33
109
|
export const tf024: PostSynthCheck = {
|
|
34
110
|
id: "TF024",
|
|
35
|
-
description: "Live root declares a backend or cloud block, which choudoufu
|
|
111
|
+
description: "Live root declares a backend or cloud block, which choudoufu ignores",
|
|
36
112
|
|
|
37
113
|
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
38
114
|
const diagnostics: PostSynthDiagnostic[] = [];
|
|
39
115
|
const flagged = new Set<string>();
|
|
116
|
+
let liveBodies: Map<string, BlockBody[]> | undefined;
|
|
40
117
|
|
|
41
118
|
for (const [name, entity] of ctx.entities) {
|
|
42
119
|
if (entity.entityType !== TERRAFORM_TYPE) continue;
|
|
@@ -46,20 +123,26 @@ export const tf024: PostSynthCheck = {
|
|
|
46
123
|
const root = typeof props.root === "string" ? props.root : "";
|
|
47
124
|
if (flagged.has(root)) continue;
|
|
48
125
|
|
|
49
|
-
const body = (
|
|
50
|
-
const hasBackend = hasBlock(body, "backend");
|
|
126
|
+
const body = bodyOf(props);
|
|
51
127
|
const hasCloud = hasBlock(body, "cloud");
|
|
128
|
+
const hasBackend = hasBlock(body, "backend");
|
|
52
129
|
if (!hasBackend && !hasCloud) continue;
|
|
53
|
-
|
|
54
130
|
flagged.add(root);
|
|
55
|
-
|
|
131
|
+
|
|
132
|
+
// A cloud block does nothing at all, so it is the one worth a warning
|
|
133
|
+
// when a (malformed) root somehow carries both.
|
|
134
|
+
if (hasCloud) {
|
|
135
|
+
diagnostics.push({ checkId: "TF024", severity: "warning", message: cloudMessage(root), entity: name, lexicon: "terraform" });
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
liveBodies ??= liveBodiesByRoot(ctx);
|
|
140
|
+
const type = backendTypes(body)[0] ?? "";
|
|
141
|
+
const store = resolveRecordStore([body], liveBodies.get(root) ?? []);
|
|
56
142
|
diagnostics.push({
|
|
57
143
|
checkId: "TF024",
|
|
58
|
-
severity: "
|
|
59
|
-
message:
|
|
60
|
-
`Root module "${root}" runs choudoufu with a declared estate and also declares a ` +
|
|
61
|
-
`${blockKind} block. choudoufu refuses this at init: "Both a ${blockKind} and a live ` +
|
|
62
|
-
`configuration are present." Remove the ${blockKind} block; a live root keeps no state to store.`,
|
|
144
|
+
severity: "info",
|
|
145
|
+
message: backendMessage(root, type, store),
|
|
63
146
|
entity: name,
|
|
64
147
|
lexicon: "terraform",
|
|
65
148
|
});
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TF046: a live root's record store is local, and the lint runs in CI.
|
|
3
|
+
*
|
|
4
|
+
* A live root keeps its records (what binds a record-backed resource to the
|
|
5
|
+
* estate) in a record store. With nothing to say otherwise that store is a
|
|
6
|
+
* directory beside the module (choudoufu `live/STORAGE.md`), and on a CI
|
|
7
|
+
* runner the directory is empty on every run: an ordinary resource still binds
|
|
8
|
+
* by its marker, but a record-backed one is proposed for create again.
|
|
9
|
+
*
|
|
10
|
+
* "Local" is what choudoufu resolves, read here through `./record-store.ts`,
|
|
11
|
+
* the same resolution TF024 names in its message (INTENTIUS/choudoufu#2293):
|
|
12
|
+
*
|
|
13
|
+
* - an explicit `record_store "local"` fires;
|
|
14
|
+
* - an explicit `record_store` of any other kind is quiet, whatever backend
|
|
15
|
+
* sits beside it;
|
|
16
|
+
* - with no `record_store`, an ignored `backend "s3"`, `"gcs"` or `"azurerm"`
|
|
17
|
+
* block that names its bucket as a literal gives a derived store and is
|
|
18
|
+
* quiet;
|
|
19
|
+
* - with no `record_store` and no backend, or a backend with no counterpart
|
|
20
|
+
* (`local`, `consul`, `http`), or one whose bucket comes only from
|
|
21
|
+
* `-backend-config`, the store is implied local and the rule fires, naming
|
|
22
|
+
* the reason choudoufu would print.
|
|
23
|
+
*
|
|
24
|
+
* A root that is also a Terragrunt unit with a `remote_state`, a `generate`
|
|
25
|
+
* block that writes a backend, or an `include` of a parent config gets its
|
|
26
|
+
* backend file at run time, so what chant reads is not what choudoufu sees.
|
|
27
|
+
* The rule stays quiet there rather than guess; TF044 still reports a
|
|
28
|
+
* Terragrunt `backend = "local"`.
|
|
29
|
+
*
|
|
30
|
+
* CI is read from the environment chant runs in: `CI` set to anything but
|
|
31
|
+
* `false` or `0`, or `GITHUB_ACTIONS`, `GITLAB_CI`, `FORGEJO_ACTIONS`,
|
|
32
|
+
* `GITEA_ACTIONS` or `TF_BUILD` (Azure Pipelines) set to `true`. Outside CI the
|
|
33
|
+
* local store is a reasonable choice for one person or a demo, and the rule
|
|
34
|
+
* says nothing.
|
|
35
|
+
*
|
|
36
|
+
* Opt-outs, for emulator and test lanes that use the local store on purpose:
|
|
37
|
+
* `CHANT_ALLOW_LOCAL_RECORD_STORE=1` in the lane's environment, or
|
|
38
|
+
* `# chant-ignore-block: TF046` above the `terraform` block holding `live`
|
|
39
|
+
* for one root, or
|
|
40
|
+
* `lint.rules: { TF046: "off" }` for a whole project.
|
|
41
|
+
*
|
|
42
|
+
* The rule is `report-only` in the audit catalog, so it is off under the
|
|
43
|
+
* `recommended` preset: terragucci switches it on and holds the product
|
|
44
|
+
* wording (chant#4561 placement).
|
|
45
|
+
*
|
|
46
|
+
* One diagnostic per root. It fires from the `terraform` block that holds the
|
|
47
|
+
* `live` block, since suppression comments anchor on top-level blocks only,
|
|
48
|
+
* and from the sidecar's `Terraform::Live` entity for a sidecar estate, where
|
|
49
|
+
* `# chant-ignore-file: TF046` in `estate.chdf.hcl` suppresses it.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
import type {
|
|
53
|
+
PostSynthCheck,
|
|
54
|
+
PostSynthContext,
|
|
55
|
+
PostSynthDiagnostic,
|
|
56
|
+
} from "@intentius/chant/lint/post-synth";
|
|
57
|
+
import { isResourceDeclarable, type ResourceDeclarable } from "@intentius/chant/declarable";
|
|
58
|
+
import {
|
|
59
|
+
LIVE_TYPE,
|
|
60
|
+
TERRAFORM_TYPE,
|
|
61
|
+
TERRAGRUNT_CONFIG_TYPE,
|
|
62
|
+
TERRAGRUNT_GENERATE_TYPE,
|
|
63
|
+
TERRAGRUNT_REMOTE_STATE_TYPE,
|
|
64
|
+
type BlockBody,
|
|
65
|
+
} from "../../hcl/parse";
|
|
66
|
+
import { isRootScoped } from "./scope";
|
|
67
|
+
import { resolveRecordStore, type ResolvedRecordStore } from "./record-store";
|
|
68
|
+
|
|
69
|
+
/** The environment variable an emulator or test lane sets to keep the local store without a finding. */
|
|
70
|
+
export const ALLOW_LOCAL_RECORD_STORE_ENV = "CHANT_ALLOW_LOCAL_RECORD_STORE";
|
|
71
|
+
|
|
72
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
73
|
+
|
|
74
|
+
const truthy = (v: string | undefined): boolean => v !== undefined && v !== "" && v !== "0" && v.toLowerCase() !== "false";
|
|
75
|
+
|
|
76
|
+
/** Whether the environment is a CI job. */
|
|
77
|
+
export function isCiEnvironment(env: Env): boolean {
|
|
78
|
+
if (truthy(env.CI)) return true;
|
|
79
|
+
for (const name of ["GITHUB_ACTIONS", "GITLAB_CI", "FORGEJO_ACTIONS", "GITEA_ACTIONS", "TF_BUILD"]) {
|
|
80
|
+
if (env[name]?.toLowerCase() === "true") return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const bodyOf = (entity: ResourceDeclarable): BlockBody => {
|
|
86
|
+
const props = entity.props as { body?: unknown };
|
|
87
|
+
return (typeof props.body === "object" && props.body !== null ? props.body : {}) as BlockBody;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const rootOf = (entity: ResourceDeclarable): string => {
|
|
91
|
+
const root = (entity.props as { root?: unknown }).root;
|
|
92
|
+
return typeof root === "string" ? root : "";
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
interface LiveRoot {
|
|
96
|
+
/** Entity key the finding anchors on: the live declaration's entity, until a `terraform` block holding it is seen. */
|
|
97
|
+
anchor: string;
|
|
98
|
+
liveBodies: BlockBody[];
|
|
99
|
+
terraformBodies: BlockBody[];
|
|
100
|
+
/** A Terragrunt unit whose backend file is written at run time. */
|
|
101
|
+
runtimeBackend: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Whether a Terragrunt block in this root writes a backend file at run time. */
|
|
105
|
+
function writesRuntimeBackend(entity: ResourceDeclarable): boolean {
|
|
106
|
+
const body = bodyOf(entity);
|
|
107
|
+
switch (entity.entityType) {
|
|
108
|
+
case TERRAGRUNT_REMOTE_STATE_TYPE:
|
|
109
|
+
return body.backend !== "local";
|
|
110
|
+
case TERRAGRUNT_GENERATE_TYPE: {
|
|
111
|
+
const contents = typeof body.contents === "string" ? body.contents : "";
|
|
112
|
+
return /\bbackend\s+"(?!local")/.test(contents);
|
|
113
|
+
}
|
|
114
|
+
case TERRAGRUNT_CONFIG_TYPE:
|
|
115
|
+
return Array.isArray(body.includes) && body.includes.length > 0;
|
|
116
|
+
default:
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function liveRoots(ctx: PostSynthContext): Map<string, LiveRoot> {
|
|
122
|
+
const roots = new Map<string, LiveRoot>();
|
|
123
|
+
const terraform = new Map<string, BlockBody[]>();
|
|
124
|
+
/** Per root, the key of the first `terraform` block that holds a `live` block. */
|
|
125
|
+
const holder = new Map<string, string>();
|
|
126
|
+
const runtime = new Set<string>();
|
|
127
|
+
|
|
128
|
+
for (const [key, entity] of ctx.entities) {
|
|
129
|
+
if (!isResourceDeclarable(entity) || !isRootScoped(entity)) continue;
|
|
130
|
+
const root = rootOf(entity);
|
|
131
|
+
if (entity.entityType === TERRAFORM_TYPE) {
|
|
132
|
+
const list = terraform.get(root) ?? [];
|
|
133
|
+
const body = bodyOf(entity);
|
|
134
|
+
list.push(body);
|
|
135
|
+
terraform.set(root, list);
|
|
136
|
+
if (body.live !== undefined && !holder.has(root)) holder.set(root, key);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (entity.entityType === LIVE_TYPE) {
|
|
140
|
+
if ((entity.props as { mode?: unknown }).mode !== "live") continue;
|
|
141
|
+
const found = roots.get(root);
|
|
142
|
+
if (found) found.liveBodies.push(bodyOf(entity));
|
|
143
|
+
else roots.set(root, { anchor: key, liveBodies: [bodyOf(entity)], terraformBodies: [], runtimeBackend: false });
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (writesRuntimeBackend(entity)) runtime.add(root);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
for (const [root, live] of roots) {
|
|
150
|
+
live.terraformBodies = terraform.get(root) ?? [];
|
|
151
|
+
live.anchor = holder.get(root) ?? live.anchor;
|
|
152
|
+
live.runtimeBackend = runtime.has(root);
|
|
153
|
+
}
|
|
154
|
+
return roots;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function message(root: string, store: ResolvedRecordStore): string {
|
|
158
|
+
const why =
|
|
159
|
+
store.source === "record_store"
|
|
160
|
+
? 'Its live declaration names record_store "local", a directory beside the module.'
|
|
161
|
+
: store.note
|
|
162
|
+
? `It declares no record_store, and no store is derived from its backend: ${store.note}.`
|
|
163
|
+
: store.backend
|
|
164
|
+
? `It declares no record_store, and its backend "${store.backend}" block keeps state on local disk, so choudoufu uses the local store.`
|
|
165
|
+
: "It declares no record_store and has no backend block to derive one from, so choudoufu uses the local store.";
|
|
166
|
+
return (
|
|
167
|
+
`Live root "${root}" keeps its records in the local store, and this is a CI run. ${why} ` +
|
|
168
|
+
"A CI runner starts with an empty directory every run, so each record-backed resource is proposed " +
|
|
169
|
+
"for create again. Keep or add a backend \"s3\", \"gcs\" or \"azurerm\" block with a literal bucket " +
|
|
170
|
+
"(choudoufu derives the store from it), or declare a record_store in the live block or " +
|
|
171
|
+
`estate.chdf.hcl. A lane that uses the local store on purpose sets ${ALLOW_LOCAL_RECORD_STORE_ENV}=1.`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* TF046 against an explicit environment. `tf046.check` passes `process.env`;
|
|
177
|
+
* tests pass their own.
|
|
178
|
+
*/
|
|
179
|
+
export function checkLocalRecordStore(ctx: PostSynthContext, env: Env): PostSynthDiagnostic[] {
|
|
180
|
+
if (!isCiEnvironment(env) || truthy(env[ALLOW_LOCAL_RECORD_STORE_ENV])) return [];
|
|
181
|
+
const diagnostics: PostSynthDiagnostic[] = [];
|
|
182
|
+
for (const [root, live] of liveRoots(ctx)) {
|
|
183
|
+
if (live.runtimeBackend) continue;
|
|
184
|
+
const store = resolveRecordStore(live.terraformBodies, live.liveBodies);
|
|
185
|
+
if (store.kind !== "local") continue;
|
|
186
|
+
diagnostics.push({
|
|
187
|
+
checkId: "TF046",
|
|
188
|
+
severity: "error",
|
|
189
|
+
message: message(root, store),
|
|
190
|
+
entity: live.anchor,
|
|
191
|
+
lexicon: "terraform",
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return diagnostics;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export const tf046: PostSynthCheck = {
|
|
198
|
+
id: "TF046",
|
|
199
|
+
description: "Live root resolves to the local record store in a CI run",
|
|
200
|
+
|
|
201
|
+
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
202
|
+
return checkLocalRecordStore(ctx, process.env);
|
|
203
|
+
},
|
|
204
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TF047: a live root pins a registry module version the known-module catalog
|
|
3
|
+
* has no row for, or one whose row carries refusals.
|
|
4
|
+
*
|
|
5
|
+
* The catalog is choudoufu's module compatibility table, vendored in
|
|
6
|
+
* `../../module-catalog/` (chant#4560, choudoufu#2292). It has one static
|
|
7
|
+
* row per terraform-aws-modules example at one tag, measured offline in the
|
|
8
|
+
* onboarded form. A module call on a root whose binary is choudoufu (the
|
|
9
|
+
* root's `mode` is `live`) with an exact `version` is looked up there:
|
|
10
|
+
*
|
|
11
|
+
* - no row for the module, or none at the pinned version: `info`, naming the
|
|
12
|
+
* versions the static tier did measure;
|
|
13
|
+
* - at least one example at that version refused: `warning`, with each
|
|
14
|
+
* refusal ID, its site count, the examples that carry it and its
|
|
15
|
+
* `live/LIMITATIONS.md` link;
|
|
16
|
+
* - every example clear: quiet.
|
|
17
|
+
*
|
|
18
|
+
* Every message names the tier. The catalog holds the static tier only, and
|
|
19
|
+
* no figure here counts a gauntlet run (choudoufu#2292 ruling: two tiers,
|
|
20
|
+
* never mixed).
|
|
21
|
+
*
|
|
22
|
+
* A stock root (`mode: "state"`) is skipped: the table measures choudoufu.
|
|
23
|
+
* A range is TF039's finding and a missing `version` TF004's, so both are
|
|
24
|
+
* skipped here. A `//subdir` source is looked up by its module repository.
|
|
25
|
+
*
|
|
26
|
+
* Off by default: `report-only` in the audit catalog, as TF039 is.
|
|
27
|
+
* terragucci turns it on and holds the product wording (terragucci#1286).
|
|
28
|
+
*
|
|
29
|
+
* Scope: root and child modules of a live root alike.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import type {
|
|
33
|
+
PostSynthCheck,
|
|
34
|
+
PostSynthContext,
|
|
35
|
+
PostSynthDiagnostic,
|
|
36
|
+
} from "@intentius/chant/lint/post-synth";
|
|
37
|
+
import { isResourceDeclarable } from "@intentius/chant/declarable";
|
|
38
|
+
import { MODULE_TYPE, type BlockBody } from "../../hcl/parse";
|
|
39
|
+
import { classifyModuleSource, isExactVersionConstraint } from "./module-source";
|
|
40
|
+
import {
|
|
41
|
+
MODULE_CATALOG_SOURCE,
|
|
42
|
+
MODULE_COMPATIBILITY_PAGE,
|
|
43
|
+
moduleCompatibility,
|
|
44
|
+
type ModuleCompatibility,
|
|
45
|
+
} from "../../module-catalog";
|
|
46
|
+
|
|
47
|
+
const tierNote = (): string =>
|
|
48
|
+
`static tier of choudoufu's module table, measured ${MODULE_CATALOG_SOURCE.date} with hashicorp/aws ${MODULE_CATALOG_SOURCE.awsProvider}`;
|
|
49
|
+
|
|
50
|
+
/** The TF047 message for one module call, or undefined when the call is clear. */
|
|
51
|
+
export function catalogMessage(address: string, c: ModuleCompatibility): string | undefined {
|
|
52
|
+
const pin = `${c.module} ${c.version}`;
|
|
53
|
+
switch (c.status) {
|
|
54
|
+
case "clear":
|
|
55
|
+
return undefined;
|
|
56
|
+
case "unknown-module":
|
|
57
|
+
return (
|
|
58
|
+
`Module "${address}" pins ${pin}, and the ${tierNote()} has no row for this module. ` +
|
|
59
|
+
`Run \`choudoufu live-check\` on the root to see whether it plans. The table: ${MODULE_COMPATIBILITY_PAGE}`
|
|
60
|
+
);
|
|
61
|
+
case "unknown-version":
|
|
62
|
+
return (
|
|
63
|
+
`Module "${address}" pins ${pin}, and the ${tierNote()} has no row at this version. ` +
|
|
64
|
+
`It measured ${c.measuredVersions.join(", ")}. ` +
|
|
65
|
+
`Run \`choudoufu live-check\` on the root, or pin a measured version. The table: ${MODULE_COMPATIBILITY_PAGE}`
|
|
66
|
+
);
|
|
67
|
+
case "refused": {
|
|
68
|
+
const ids = c.refusals
|
|
69
|
+
.map((r) => `${r.id} (${r.sites} site${r.sites === 1 ? "" : "s"} in ${r.examples.join(", ")}; ${r.docsUrl})`)
|
|
70
|
+
.join("; ");
|
|
71
|
+
return (
|
|
72
|
+
`Module "${address}" pins ${pin}. In the ${tierNote()}, ${c.refusedExamples} of ${c.examples} ` +
|
|
73
|
+
`examples at this version are refused: ${ids}. ` +
|
|
74
|
+
"A call that uses the same features is refused the same way; `choudoufu live-check` names each site in this root."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const tf047: PostSynthCheck = {
|
|
81
|
+
id: "TF047",
|
|
82
|
+
description: "Live root pins a module version the known-module catalog has no row for, or one with refusals",
|
|
83
|
+
|
|
84
|
+
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
85
|
+
const diagnostics: PostSynthDiagnostic[] = [];
|
|
86
|
+
|
|
87
|
+
for (const [key, entity] of ctx.entities) {
|
|
88
|
+
if (entity.entityType !== MODULE_TYPE || !isResourceDeclarable(entity)) continue;
|
|
89
|
+
const props = entity.props as { address?: unknown; body?: unknown; mode?: unknown };
|
|
90
|
+
if (props.mode !== "live") continue;
|
|
91
|
+
const body = (typeof props.body === "object" && props.body !== null ? props.body : {}) as BlockBody;
|
|
92
|
+
const source = typeof body.source === "string" ? body.source : undefined;
|
|
93
|
+
if (source === undefined || classifyModuleSource(source).kind !== "registry") continue;
|
|
94
|
+
const version = body.version;
|
|
95
|
+
if (typeof version !== "string" || !isExactVersionConstraint(version)) continue;
|
|
96
|
+
|
|
97
|
+
const compat = moduleCompatibility(source, version);
|
|
98
|
+
if (compat === undefined) continue;
|
|
99
|
+
const address = typeof props.address === "string" ? props.address : key;
|
|
100
|
+
const message = catalogMessage(address, compat);
|
|
101
|
+
if (message === undefined) continue;
|
|
102
|
+
|
|
103
|
+
diagnostics.push({
|
|
104
|
+
checkId: "TF047",
|
|
105
|
+
severity: compat.status === "refused" ? "warning" : "info",
|
|
106
|
+
message,
|
|
107
|
+
entity: key,
|
|
108
|
+
lexicon: "terraform",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return diagnostics;
|
|
113
|
+
},
|
|
114
|
+
};
|
|
@@ -1,68 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/** The account's blob endpoint, no trailing slash: https://<account>.blob.core.windows.net, or an emulator's http://host:10000/<account>. */
|
|
10
|
-
endpoint: string;
|
|
11
|
-
}
|
|
12
|
-
/** The job's federated identity: an Entra app or managed identity that trusts the forge's token. */
|
|
13
|
-
export interface AzureOidc {
|
|
14
|
-
tenantId: string;
|
|
15
|
-
clientId: string;
|
|
16
|
-
tokenFile: string;
|
|
17
|
-
/** Entra ID's address, https://host, no path. */
|
|
18
|
-
authority: string;
|
|
19
|
-
}
|
|
20
|
-
export type AzureTarget = AzureLocation & ({
|
|
21
|
-
accountKey: string;
|
|
22
|
-
} | {
|
|
23
|
-
oidc: AzureOidc;
|
|
24
|
-
} | {
|
|
25
|
-
sas: string;
|
|
26
|
-
});
|
|
27
|
-
/** A blob's properties, as a HEAD answers them: never its body. */
|
|
28
|
-
export interface BlobHead {
|
|
29
|
-
exists: boolean;
|
|
30
|
-
etag?: string;
|
|
31
|
-
/** x-ms-lease-state: `leased` while a lease holds it. */
|
|
32
|
-
leaseState?: string;
|
|
33
|
-
/** Its metadata, by name without the x-ms-meta- prefix. */
|
|
34
|
-
metadata: Record<string, string>;
|
|
35
|
-
}
|
|
36
|
-
/** The Shared Key Authorization header for a request. */
|
|
37
|
-
export declare function sharedKey(account: string, accountKey: string, method: string, rawUrl: string, headers: Record<string, string>): string;
|
|
38
|
-
export declare class AzureBlobClient {
|
|
39
|
-
readonly target: AzureTarget;
|
|
40
|
-
private readonly fetchFn;
|
|
41
|
-
private readonly readToken;
|
|
42
|
-
private token?;
|
|
43
|
-
constructor(target: AzureTarget, fetchFn?: StoreFetch, readToken?: (file: string) => string);
|
|
44
|
-
private where;
|
|
45
|
-
private blobUrl;
|
|
46
|
-
/** The storage token for the OIDC identity: once per client, again a minute before it expires. */
|
|
47
|
-
private bearer;
|
|
48
|
-
/** The headers for one request, signed or with the bearer token. */
|
|
49
|
-
private headers;
|
|
50
|
-
get(key: string): Promise<string | undefined>;
|
|
51
|
-
/** A blob's properties and metadata, from a HEAD. */
|
|
52
|
-
head(key: string): Promise<BlobHead>;
|
|
53
|
-
/** Take a snapshot of a blob: its id, the time Azure gives it. */
|
|
54
|
-
snapshot(key: string): Promise<string>;
|
|
55
|
-
/** Write a block blob with metadata, under a lease when one holds it; with `ifNoneMatch`, only when there is none (false when one was there). */
|
|
56
|
-
putBlob(key: string, body: string, contentType: string, options?: {
|
|
57
|
-
leaseId?: string;
|
|
58
|
-
metadata?: Record<string, string>;
|
|
59
|
-
ifNoneMatch?: boolean;
|
|
60
|
-
}): Promise<boolean>;
|
|
61
|
-
/** Delete a blob. One that is not there is deleted already. */
|
|
62
|
-
remove(key: string): Promise<void>;
|
|
63
|
-
/** A blob lease: acquire one that never expires with the id given (false when one holds it), or release it. */
|
|
64
|
-
lease(key: string, action: "acquire" | "release", id: string): Promise<boolean>;
|
|
65
|
-
/** Set a blob's metadata, all of it, under its lease when one holds it. */
|
|
66
|
-
setMetadata(key: string, metadata: Record<string, string>, leaseId?: string): Promise<void>;
|
|
67
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The Azure Blob Storage client an azurerm backend's state uses: chant
|
|
3
|
+
* core's (#4554, `@intentius/chant/object-store`): a blob's properties and
|
|
4
|
+
* metadata, a snapshot, a block blob put, and the blob lease the backend
|
|
5
|
+
* locks a state with, signed with Shared Key, a SAS, or an Entra token for
|
|
6
|
+
* the job's OIDC identity.
|
|
7
|
+
*/
|
|
8
|
+
export { AZURE_AUTHORITY, AZURE_VERSION, AzureBlobClient, sharedKey, type AzureLocation, type AzureOidc, type AzureTarget, type BlobHead } from "@intentius/chant/object-store";
|
|
68
9
|
//# sourceMappingURL=azure-blob.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-blob.d.ts","sourceRoot":"","sources":["../../src/state/azure-blob.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"azure-blob.d.ts","sourceRoot":"","sources":["../../src/state/azure-blob.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,+BAA+B,CAAC"}
|