@intentius/chant-lexicon-terraform 0.124.97 → 0.124.99
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/__fixtures__/capabilities/chant.config.d.ts +0 -1
- package/dist/__fixtures__/effective-topology/chant.config.d.ts +0 -1
- package/dist/__fixtures__/kind-type/chant.config.d.ts +0 -1
- package/dist/__fixtures__/pr-loop/estate.component.d.ts +0 -1
- package/dist/__fixtures__/report/generate.d.ts +0 -1
- package/dist/__fixtures__/search-roots/chant.config.d.ts +0 -1
- package/dist/__fixtures__/sensitive-default/chant.config.d.ts +0 -1
- package/dist/__fixtures__/terragrunt/affected-cases.d.ts +0 -1
- package/dist/__fixtures__/terragrunt/record.d.ts +0 -1
- package/dist/action-ops.d.ts +0 -1
- package/dist/applied-state.d.ts +0 -1
- package/dist/backend-config.d.ts +0 -1
- package/dist/behaviour/index.d.ts +0 -1
- package/dist/behaviour/kinds.d.ts +0 -1
- package/dist/behaviour/predict.d.ts +0 -1
- package/dist/behaviour/reference-catalog.d.ts +42 -7
- package/dist/behaviour/reference-catalog.js +169 -8
- package/dist/behaviour/request.d.ts +0 -1
- package/dist/capabilities/adapter.d.ts +0 -1
- package/dist/capabilities/mapping.json +164 -164
- package/dist/change-set.d.ts +0 -1
- package/dist/changed-roots.d.ts +0 -1
- package/dist/chant-floors.d.ts +0 -1
- package/dist/ci-setup.d.ts +0 -1
- package/dist/codegen/docs-cli.d.ts +0 -1
- package/dist/codegen/docs.d.ts +0 -1
- package/dist/codegen/generate-cli.d.ts +0 -1
- package/dist/codegen/generate.d.ts +0 -1
- package/dist/codegen/package.d.ts +0 -1
- package/dist/commands.d.ts +0 -1
- package/dist/components/capability-plugin.d.ts +0 -1
- package/dist/components/compose-group.d.ts +0 -1
- package/dist/components/placeholder-preview.d.ts +0 -1
- package/dist/components/release-inputs.d.ts +0 -1
- package/dist/components/trace-facts.d.ts +0 -1
- package/dist/compose/apply-events.d.ts +0 -1
- package/dist/compose/estate.d.ts +0 -1
- package/dist/compose/hcl.d.ts +0 -1
- package/dist/compose/module-address.d.ts +0 -1
- package/dist/compose/root.d.ts +0 -1
- package/dist/compose/run.d.ts +0 -1
- package/dist/compose/slice.d.ts +0 -1
- package/dist/compose/state-address.d.ts +0 -1
- package/dist/compose/state-merge.d.ts +0 -1
- package/dist/compose.d.ts +0 -1
- package/dist/composites/terraform-adopt-op.d.ts +0 -1
- package/dist/composites/terraform-apply-op.d.ts +0 -1
- package/dist/composites/terraform-pin-rollout-op.d.ts +0 -1
- package/dist/composites/terraform-watch-op.d.ts +0 -1
- package/dist/cone.d.ts +0 -1
- package/dist/config.d.ts +0 -1
- package/dist/cost-hold.d.ts +0 -1
- package/dist/describe-resources.d.ts +0 -1
- package/dist/describe-resources.js +1 -1
- package/dist/drift-read.d.ts +0 -1
- package/dist/drift-record.d.ts +0 -1
- package/dist/drift-rows.d.ts +0 -1
- package/dist/engine-runner.d.ts +0 -1
- package/dist/engine-timings.d.ts +0 -1
- package/dist/estate-migration.d.ts +0 -1
- package/dist/exit-codes.d.ts +0 -1
- package/dist/generated/index.d.ts +0 -1
- package/dist/hcl/descend.d.ts +0 -1
- package/dist/hcl/edges.d.ts +0 -1
- package/dist/hcl/evaluate.d.ts +150 -0
- package/dist/hcl/evaluate.js +940 -0
- package/dist/hcl/files.d.ts +0 -1
- package/dist/hcl/instances.d.ts +11 -2
- package/dist/hcl/instances.js +89 -3
- package/dist/hcl/jsonencode.d.ts +0 -1
- package/dist/hcl/marker.d.ts +0 -1
- package/dist/hcl/parse.d.ts +23 -2
- package/dist/hcl/parse.js +9 -3
- package/dist/hcl/redact.d.ts +5 -2
- package/dist/hcl/redact.js +7 -3
- package/dist/hcl/references.d.ts +12 -2
- package/dist/hcl/references.js +33 -16
- package/dist/hcl/roots.d.ts +0 -1
- package/dist/hcl/suppressions.d.ts +0 -1
- package/dist/hcl/value.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/init-turn.d.ts +0 -1
- package/dist/integrity.json +6 -6
- package/dist/lint/audit-catalog.d.ts +0 -1
- package/dist/lint/audit-lineage.d.ts +0 -1
- package/dist/lint/post-synth/blocks.d.ts +0 -1
- package/dist/lint/post-synth/fixtures/load.d.ts +0 -1
- package/dist/lint/post-synth/flat-attributes.d.ts +0 -1
- package/dist/lint/post-synth/index.d.ts +0 -1
- package/dist/lint/post-synth/module-source.d.ts +0 -1
- package/dist/lint/post-synth/record-store.d.ts +0 -1
- package/dist/lint/post-synth/scope.d.ts +0 -1
- package/dist/lint/post-synth/terragrunt.d.ts +0 -1
- package/dist/lint/post-synth/tf001.d.ts +4 -2
- package/dist/lint/post-synth/tf001.js +20 -8
- package/dist/lint/post-synth/tf002.d.ts +11 -6
- package/dist/lint/post-synth/tf002.js +42 -8
- package/dist/lint/post-synth/tf003.d.ts +0 -1
- package/dist/lint/post-synth/tf004.d.ts +0 -1
- package/dist/lint/post-synth/tf005.d.ts +0 -1
- package/dist/lint/post-synth/tf006.d.ts +7 -4
- package/dist/lint/post-synth/tf006.js +9 -3
- package/dist/lint/post-synth/tf007.d.ts +0 -1
- package/dist/lint/post-synth/tf008.d.ts +0 -1
- package/dist/lint/post-synth/tf009.d.ts +0 -1
- package/dist/lint/post-synth/tf010.d.ts +0 -1
- package/dist/lint/post-synth/tf011.d.ts +0 -1
- package/dist/lint/post-synth/tf012.d.ts +0 -1
- package/dist/lint/post-synth/tf013.d.ts +0 -1
- package/dist/lint/post-synth/tf014.d.ts +0 -1
- package/dist/lint/post-synth/tf015.d.ts +0 -1
- package/dist/lint/post-synth/tf016.d.ts +0 -1
- package/dist/lint/post-synth/tf017.d.ts +0 -1
- package/dist/lint/post-synth/tf018.d.ts +0 -1
- package/dist/lint/post-synth/tf019.d.ts +0 -1
- package/dist/lint/post-synth/tf020.d.ts +0 -1
- package/dist/lint/post-synth/tf021.d.ts +0 -1
- package/dist/lint/post-synth/tf022.d.ts +6 -1
- package/dist/lint/post-synth/tf022.js +18 -1
- package/dist/lint/post-synth/tf024.d.ts +0 -1
- package/dist/lint/post-synth/tf025.d.ts +0 -1
- package/dist/lint/post-synth/tf026.d.ts +0 -1
- package/dist/lint/post-synth/tf027.d.ts +0 -1
- package/dist/lint/post-synth/tf028.d.ts +0 -1
- package/dist/lint/post-synth/tf029.d.ts +0 -1
- package/dist/lint/post-synth/tf030.d.ts +0 -1
- package/dist/lint/post-synth/tf031.d.ts +0 -1
- package/dist/lint/post-synth/tf032.d.ts +0 -1
- package/dist/lint/post-synth/tf033.d.ts +0 -1
- package/dist/lint/post-synth/tf034.d.ts +0 -1
- package/dist/lint/post-synth/tf035.d.ts +0 -1
- package/dist/lint/post-synth/tf036.d.ts +0 -1
- package/dist/lint/post-synth/tf037.d.ts +0 -1
- package/dist/lint/post-synth/tf038.d.ts +0 -1
- package/dist/lint/post-synth/tf039.d.ts +0 -1
- package/dist/lint/post-synth/tf040.d.ts +0 -1
- package/dist/lint/post-synth/tf041.d.ts +0 -1
- package/dist/lint/post-synth/tf042.d.ts +0 -1
- package/dist/lint/post-synth/tf043.d.ts +0 -1
- package/dist/lint/post-synth/tf044.d.ts +0 -1
- package/dist/lint/post-synth/tf045.d.ts +0 -1
- package/dist/lint/post-synth/tf046.d.ts +0 -1
- package/dist/lint/post-synth/tf047.d.ts +0 -1
- package/dist/lint/rules/fixtures/load.d.ts +0 -1
- package/dist/lint/rules/index.d.ts +0 -1
- package/dist/lint/rules/plan-before-apply.d.ts +0 -1
- package/dist/lint/secret-shape.d.ts +8 -1
- package/dist/lint/secret-shape.js +76 -0
- package/dist/live-ownership.d.ts +0 -1
- package/dist/live-plan-reasons.d.ts +0 -1
- package/dist/live-roots.d.ts +0 -1
- package/dist/lock-rows.d.ts +0 -1
- package/dist/lock-timeout.d.ts +0 -1
- package/dist/lsp/completions.d.ts +0 -1
- package/dist/lsp/context.d.ts +0 -1
- package/dist/lsp/hover.d.ts +0 -1
- package/dist/lsp/option-keys.d.ts +0 -1
- package/dist/manifest.json +1 -1
- package/dist/migration-history.d.ts +0 -1
- package/dist/module-catalog/index.d.ts +0 -1
- package/dist/module-catalog/refresh-cli.d.ts +0 -1
- package/dist/module-catalog/static-tier.d.ts +0 -1
- package/dist/module-catalog/types.d.ts +0 -1
- package/dist/op/activities/index.d.ts +0 -1
- package/dist/op/activities/live-detect.d.ts +0 -1
- package/dist/op/activities/pin-rollout.d.ts +0 -1
- package/dist/op/activities/terraform.d.ts +0 -1
- package/dist/op/activity-contracts.d.ts +0 -1
- package/dist/op/adoption.d.ts +0 -1
- package/dist/op/builders.d.ts +0 -1
- package/dist/op/command-hook.d.ts +0 -1
- package/dist/op/resolve-root-mode.d.ts +0 -1
- package/dist/package-cli.d.ts +0 -1
- package/dist/pin/consumers.d.ts +0 -1
- package/dist/pin/edit-ts.d.ts +0 -1
- package/dist/pin/edit.d.ts +0 -1
- package/dist/pin/forge.d.ts +0 -1
- package/dist/pin/index.d.ts +0 -1
- package/dist/pin/rollout.d.ts +0 -1
- package/dist/pin/scan.d.ts +0 -1
- package/dist/pin/source.d.ts +0 -1
- package/dist/pin/waves.d.ts +0 -1
- package/dist/plan-digest.d.ts +0 -1
- package/dist/plan-observation.d.ts +0 -1
- package/dist/plan-shape.d.ts +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plugin.js +7 -2
- package/dist/pr-env.d.ts +0 -1
- package/dist/reach.d.ts +0 -1
- package/dist/registry/address.d.ts +0 -1
- package/dist/registry/catalog-read.d.ts +0 -1
- package/dist/registry/deprecated.d.ts +0 -1
- package/dist/registry/docs.d.ts +0 -1
- package/dist/registry/edge/edge.d.ts +0 -1
- package/dist/registry/edge/index.d.ts +0 -1
- package/dist/registry/edge/lambda-edge.d.ts +0 -1
- package/dist/registry/edge/sigv4-web.d.ts +0 -1
- package/dist/registry/edge/token-source.d.ts +0 -1
- package/dist/registry/edge/worker.d.ts +0 -1
- package/dist/registry/handler.d.ts +0 -1
- package/dist/registry/headers-file.d.ts +0 -1
- package/dist/registry/index.d.ts +0 -1
- package/dist/registry/mirror-paths.d.ts +0 -1
- package/dist/registry/mirror.d.ts +0 -1
- package/dist/registry/proxies.d.ts +0 -1
- package/dist/registry/reader.d.ts +0 -1
- package/dist/registry/semver.d.ts +0 -1
- package/dist/registry/serve.d.ts +0 -1
- package/dist/registry/source-forms.d.ts +0 -1
- package/dist/registry/targets/artifactory.d.ts +0 -1
- package/dist/registry/targets/fake-artifactory.d.ts +0 -1
- package/dist/registry/targets/fake-gitlab.d.ts +0 -1
- package/dist/registry/targets/fake-hcp.d.ts +0 -1
- package/dist/registry/targets/fake-http.d.ts +0 -1
- package/dist/registry/targets/fake-nexus.d.ts +0 -1
- package/dist/registry/targets/gitlab.d.ts +0 -1
- package/dist/registry/targets/hcp.d.ts +0 -1
- package/dist/registry/targets/hosted.d.ts +0 -1
- package/dist/registry/targets/index.d.ts +0 -1
- package/dist/registry/targets/module-target.d.ts +0 -1
- package/dist/registry/targets/nexus.d.ts +0 -1
- package/dist/registry/targets/zip.d.ts +0 -1
- package/dist/registry/writer.d.ts +0 -1
- package/dist/report.d.ts +0 -1
- package/dist/rules/tf001.ts +21 -7
- package/dist/rules/tf002.ts +44 -7
- package/dist/rules/tf006.ts +8 -3
- package/dist/rules/tf022.ts +18 -1
- package/dist/serializer.d.ts +0 -1
- package/dist/state/azure-blob.d.ts +0 -1
- package/dist/state/backend.d.ts +0 -1
- package/dist/state/exec.d.ts +0 -1
- package/dist/state/gcs.d.ts +0 -1
- package/dist/state/gitlab.d.ts +0 -1
- package/dist/state/index.d.ts +0 -1
- package/dist/state/locks.d.ts +0 -1
- package/dist/state/object-store.d.ts +0 -1
- package/dist/state/root-states.d.ts +0 -1
- package/dist/state/s3.d.ts +0 -1
- package/dist/state/source.d.ts +0 -1
- package/dist/state/store.d.ts +0 -1
- package/dist/state/versions.d.ts +0 -1
- package/dist/state-migration.d.ts +0 -1
- package/dist/state-ops.d.ts +0 -1
- package/dist/state-ownership.d.ts +0 -1
- package/dist/state-reads.d.ts +0 -1
- package/dist/template/index.d.ts +0 -1
- package/dist/template/render.d.ts +0 -1
- package/dist/terragrunt/affected.d.ts +0 -1
- package/dist/terragrunt/capability.d.ts +0 -1
- package/dist/terragrunt/index.d.ts +0 -1
- package/dist/terragrunt/mocks.d.ts +0 -1
- package/dist/terragrunt/place.d.ts +0 -1
- package/dist/terragrunt/run.d.ts +0 -1
- package/dist/terragrunt/units.d.ts +0 -1
- package/dist/terragrunt/wave.d.ts +0 -1
- package/dist/used-sources.d.ts +0 -1
- package/dist/validate-cli.d.ts +0 -1
- package/dist/validate.d.ts +0 -1
- package/package.json +3 -4
- package/dist/__fixtures__/capabilities/chant.config.d.ts.map +0 -1
- package/dist/__fixtures__/effective-topology/chant.config.d.ts.map +0 -1
- package/dist/__fixtures__/kind-type/chant.config.d.ts.map +0 -1
- package/dist/__fixtures__/pr-loop/estate.component.d.ts.map +0 -1
- package/dist/__fixtures__/report/generate.d.ts.map +0 -1
- package/dist/__fixtures__/search-roots/chant.config.d.ts.map +0 -1
- package/dist/__fixtures__/sensitive-default/chant.config.d.ts.map +0 -1
- package/dist/__fixtures__/terragrunt/affected-cases.d.ts.map +0 -1
- package/dist/__fixtures__/terragrunt/record.d.ts.map +0 -1
- package/dist/action-ops.d.ts.map +0 -1
- package/dist/applied-state.d.ts.map +0 -1
- package/dist/backend-config.d.ts.map +0 -1
- package/dist/behaviour/index.d.ts.map +0 -1
- package/dist/behaviour/kinds.d.ts.map +0 -1
- package/dist/behaviour/predict.d.ts.map +0 -1
- package/dist/behaviour/reference-catalog.d.ts.map +0 -1
- package/dist/behaviour/request.d.ts.map +0 -1
- package/dist/capabilities/adapter.d.ts.map +0 -1
- package/dist/change-set.d.ts.map +0 -1
- package/dist/changed-roots.d.ts.map +0 -1
- package/dist/chant-floors.d.ts.map +0 -1
- package/dist/ci-setup.d.ts.map +0 -1
- package/dist/codegen/docs-cli.d.ts.map +0 -1
- package/dist/codegen/docs.d.ts.map +0 -1
- package/dist/codegen/generate-cli.d.ts.map +0 -1
- package/dist/codegen/generate.d.ts.map +0 -1
- package/dist/codegen/package.d.ts.map +0 -1
- package/dist/commands.d.ts.map +0 -1
- package/dist/components/capability-plugin.d.ts.map +0 -1
- package/dist/components/compose-group.d.ts.map +0 -1
- package/dist/components/placeholder-preview.d.ts.map +0 -1
- package/dist/components/release-inputs.d.ts.map +0 -1
- package/dist/components/trace-facts.d.ts.map +0 -1
- package/dist/compose/apply-events.d.ts.map +0 -1
- package/dist/compose/estate.d.ts.map +0 -1
- package/dist/compose/hcl.d.ts.map +0 -1
- package/dist/compose/module-address.d.ts.map +0 -1
- package/dist/compose/root.d.ts.map +0 -1
- package/dist/compose/run.d.ts.map +0 -1
- package/dist/compose/slice.d.ts.map +0 -1
- package/dist/compose/state-address.d.ts.map +0 -1
- package/dist/compose/state-merge.d.ts.map +0 -1
- package/dist/compose.d.ts.map +0 -1
- package/dist/composites/terraform-adopt-op.d.ts.map +0 -1
- package/dist/composites/terraform-apply-op.d.ts.map +0 -1
- package/dist/composites/terraform-pin-rollout-op.d.ts.map +0 -1
- package/dist/composites/terraform-watch-op.d.ts.map +0 -1
- package/dist/cone.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/cost-hold.d.ts.map +0 -1
- package/dist/describe-resources.d.ts.map +0 -1
- package/dist/drift-read.d.ts.map +0 -1
- package/dist/drift-record.d.ts.map +0 -1
- package/dist/drift-rows.d.ts.map +0 -1
- package/dist/engine-runner.d.ts.map +0 -1
- package/dist/engine-timings.d.ts.map +0 -1
- package/dist/estate-migration.d.ts.map +0 -1
- package/dist/exit-codes.d.ts.map +0 -1
- package/dist/generated/index.d.ts.map +0 -1
- package/dist/hcl/descend.d.ts.map +0 -1
- package/dist/hcl/edges.d.ts.map +0 -1
- package/dist/hcl/files.d.ts.map +0 -1
- package/dist/hcl/instances.d.ts.map +0 -1
- package/dist/hcl/jsonencode.d.ts.map +0 -1
- package/dist/hcl/marker.d.ts.map +0 -1
- package/dist/hcl/parse.d.ts.map +0 -1
- package/dist/hcl/redact.d.ts.map +0 -1
- package/dist/hcl/references.d.ts.map +0 -1
- package/dist/hcl/roots.d.ts.map +0 -1
- package/dist/hcl/suppressions.d.ts.map +0 -1
- package/dist/hcl/value.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init-turn.d.ts.map +0 -1
- package/dist/lint/audit-catalog.d.ts.map +0 -1
- package/dist/lint/audit-lineage.d.ts.map +0 -1
- package/dist/lint/post-synth/blocks.d.ts.map +0 -1
- package/dist/lint/post-synth/fixtures/load.d.ts.map +0 -1
- package/dist/lint/post-synth/flat-attributes.d.ts.map +0 -1
- package/dist/lint/post-synth/index.d.ts.map +0 -1
- package/dist/lint/post-synth/module-source.d.ts.map +0 -1
- package/dist/lint/post-synth/record-store.d.ts.map +0 -1
- package/dist/lint/post-synth/scope.d.ts.map +0 -1
- package/dist/lint/post-synth/terragrunt.d.ts.map +0 -1
- package/dist/lint/post-synth/tf001.d.ts.map +0 -1
- package/dist/lint/post-synth/tf002.d.ts.map +0 -1
- package/dist/lint/post-synth/tf003.d.ts.map +0 -1
- package/dist/lint/post-synth/tf004.d.ts.map +0 -1
- package/dist/lint/post-synth/tf005.d.ts.map +0 -1
- package/dist/lint/post-synth/tf006.d.ts.map +0 -1
- package/dist/lint/post-synth/tf007.d.ts.map +0 -1
- package/dist/lint/post-synth/tf008.d.ts.map +0 -1
- package/dist/lint/post-synth/tf009.d.ts.map +0 -1
- package/dist/lint/post-synth/tf010.d.ts.map +0 -1
- package/dist/lint/post-synth/tf011.d.ts.map +0 -1
- package/dist/lint/post-synth/tf012.d.ts.map +0 -1
- package/dist/lint/post-synth/tf013.d.ts.map +0 -1
- package/dist/lint/post-synth/tf014.d.ts.map +0 -1
- package/dist/lint/post-synth/tf015.d.ts.map +0 -1
- package/dist/lint/post-synth/tf016.d.ts.map +0 -1
- package/dist/lint/post-synth/tf017.d.ts.map +0 -1
- package/dist/lint/post-synth/tf018.d.ts.map +0 -1
- package/dist/lint/post-synth/tf019.d.ts.map +0 -1
- package/dist/lint/post-synth/tf020.d.ts.map +0 -1
- package/dist/lint/post-synth/tf021.d.ts.map +0 -1
- package/dist/lint/post-synth/tf022.d.ts.map +0 -1
- package/dist/lint/post-synth/tf024.d.ts.map +0 -1
- package/dist/lint/post-synth/tf025.d.ts.map +0 -1
- package/dist/lint/post-synth/tf026.d.ts.map +0 -1
- package/dist/lint/post-synth/tf027.d.ts.map +0 -1
- package/dist/lint/post-synth/tf028.d.ts.map +0 -1
- package/dist/lint/post-synth/tf029.d.ts.map +0 -1
- package/dist/lint/post-synth/tf030.d.ts.map +0 -1
- package/dist/lint/post-synth/tf031.d.ts.map +0 -1
- package/dist/lint/post-synth/tf032.d.ts.map +0 -1
- package/dist/lint/post-synth/tf033.d.ts.map +0 -1
- package/dist/lint/post-synth/tf034.d.ts.map +0 -1
- package/dist/lint/post-synth/tf035.d.ts.map +0 -1
- package/dist/lint/post-synth/tf036.d.ts.map +0 -1
- package/dist/lint/post-synth/tf037.d.ts.map +0 -1
- package/dist/lint/post-synth/tf038.d.ts.map +0 -1
- package/dist/lint/post-synth/tf039.d.ts.map +0 -1
- package/dist/lint/post-synth/tf040.d.ts.map +0 -1
- package/dist/lint/post-synth/tf041.d.ts.map +0 -1
- package/dist/lint/post-synth/tf042.d.ts.map +0 -1
- package/dist/lint/post-synth/tf043.d.ts.map +0 -1
- package/dist/lint/post-synth/tf044.d.ts.map +0 -1
- package/dist/lint/post-synth/tf045.d.ts.map +0 -1
- package/dist/lint/post-synth/tf046.d.ts.map +0 -1
- package/dist/lint/post-synth/tf047.d.ts.map +0 -1
- package/dist/lint/rules/fixtures/load.d.ts.map +0 -1
- package/dist/lint/rules/index.d.ts.map +0 -1
- package/dist/lint/rules/plan-before-apply.d.ts.map +0 -1
- package/dist/lint/secret-shape.d.ts.map +0 -1
- package/dist/live-ownership.d.ts.map +0 -1
- package/dist/live-plan-reasons.d.ts.map +0 -1
- package/dist/live-roots.d.ts.map +0 -1
- package/dist/lock-rows.d.ts.map +0 -1
- package/dist/lock-timeout.d.ts.map +0 -1
- package/dist/lsp/completions.d.ts.map +0 -1
- package/dist/lsp/context.d.ts.map +0 -1
- package/dist/lsp/hover.d.ts.map +0 -1
- package/dist/lsp/option-keys.d.ts.map +0 -1
- package/dist/migration-history.d.ts.map +0 -1
- package/dist/module-catalog/index.d.ts.map +0 -1
- package/dist/module-catalog/refresh-cli.d.ts.map +0 -1
- package/dist/module-catalog/static-tier.d.ts.map +0 -1
- package/dist/module-catalog/types.d.ts.map +0 -1
- package/dist/op/activities/index.d.ts.map +0 -1
- package/dist/op/activities/live-detect.d.ts.map +0 -1
- package/dist/op/activities/pin-rollout.d.ts.map +0 -1
- package/dist/op/activities/terraform.d.ts.map +0 -1
- package/dist/op/activity-contracts.d.ts.map +0 -1
- package/dist/op/adoption.d.ts.map +0 -1
- package/dist/op/builders.d.ts.map +0 -1
- package/dist/op/command-hook.d.ts.map +0 -1
- package/dist/op/resolve-root-mode.d.ts.map +0 -1
- package/dist/package-cli.d.ts.map +0 -1
- package/dist/pin/consumers.d.ts.map +0 -1
- package/dist/pin/edit-ts.d.ts.map +0 -1
- package/dist/pin/edit.d.ts.map +0 -1
- package/dist/pin/forge.d.ts.map +0 -1
- package/dist/pin/index.d.ts.map +0 -1
- package/dist/pin/rollout.d.ts.map +0 -1
- package/dist/pin/scan.d.ts.map +0 -1
- package/dist/pin/source.d.ts.map +0 -1
- package/dist/pin/waves.d.ts.map +0 -1
- package/dist/plan-digest.d.ts.map +0 -1
- package/dist/plan-observation.d.ts.map +0 -1
- package/dist/plan-shape.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/pr-env.d.ts.map +0 -1
- package/dist/reach.d.ts.map +0 -1
- package/dist/registry/address.d.ts.map +0 -1
- package/dist/registry/catalog-read.d.ts.map +0 -1
- package/dist/registry/deprecated.d.ts.map +0 -1
- package/dist/registry/docs.d.ts.map +0 -1
- package/dist/registry/edge/edge.d.ts.map +0 -1
- package/dist/registry/edge/index.d.ts.map +0 -1
- package/dist/registry/edge/lambda-edge.d.ts.map +0 -1
- package/dist/registry/edge/sigv4-web.d.ts.map +0 -1
- package/dist/registry/edge/token-source.d.ts.map +0 -1
- package/dist/registry/edge/worker.d.ts.map +0 -1
- package/dist/registry/handler.d.ts.map +0 -1
- package/dist/registry/headers-file.d.ts.map +0 -1
- package/dist/registry/index.d.ts.map +0 -1
- package/dist/registry/mirror-paths.d.ts.map +0 -1
- package/dist/registry/mirror.d.ts.map +0 -1
- package/dist/registry/proxies.d.ts.map +0 -1
- package/dist/registry/reader.d.ts.map +0 -1
- package/dist/registry/semver.d.ts.map +0 -1
- package/dist/registry/serve.d.ts.map +0 -1
- package/dist/registry/source-forms.d.ts.map +0 -1
- package/dist/registry/targets/artifactory.d.ts.map +0 -1
- package/dist/registry/targets/fake-artifactory.d.ts.map +0 -1
- package/dist/registry/targets/fake-gitlab.d.ts.map +0 -1
- package/dist/registry/targets/fake-hcp.d.ts.map +0 -1
- package/dist/registry/targets/fake-http.d.ts.map +0 -1
- package/dist/registry/targets/fake-nexus.d.ts.map +0 -1
- package/dist/registry/targets/gitlab.d.ts.map +0 -1
- package/dist/registry/targets/hcp.d.ts.map +0 -1
- package/dist/registry/targets/hosted.d.ts.map +0 -1
- package/dist/registry/targets/index.d.ts.map +0 -1
- package/dist/registry/targets/module-target.d.ts.map +0 -1
- package/dist/registry/targets/nexus.d.ts.map +0 -1
- package/dist/registry/targets/zip.d.ts.map +0 -1
- package/dist/registry/writer.d.ts.map +0 -1
- package/dist/report.d.ts.map +0 -1
- package/dist/serializer.d.ts.map +0 -1
- package/dist/state/azure-blob.d.ts.map +0 -1
- package/dist/state/backend.d.ts.map +0 -1
- package/dist/state/exec.d.ts.map +0 -1
- package/dist/state/gcs.d.ts.map +0 -1
- package/dist/state/gitlab.d.ts.map +0 -1
- package/dist/state/index.d.ts.map +0 -1
- package/dist/state/locks.d.ts.map +0 -1
- package/dist/state/object-store.d.ts.map +0 -1
- package/dist/state/root-states.d.ts.map +0 -1
- package/dist/state/s3.d.ts.map +0 -1
- package/dist/state/source.d.ts.map +0 -1
- package/dist/state/store.d.ts.map +0 -1
- package/dist/state/versions.d.ts.map +0 -1
- package/dist/state-migration.d.ts.map +0 -1
- package/dist/state-ops.d.ts.map +0 -1
- package/dist/state-ownership.d.ts.map +0 -1
- package/dist/state-reads.d.ts.map +0 -1
- package/dist/template/index.d.ts.map +0 -1
- package/dist/template/render.d.ts.map +0 -1
- package/dist/terragrunt/affected.d.ts.map +0 -1
- package/dist/terragrunt/capability.d.ts.map +0 -1
- package/dist/terragrunt/index.d.ts.map +0 -1
- package/dist/terragrunt/mocks.d.ts.map +0 -1
- package/dist/terragrunt/place.d.ts.map +0 -1
- package/dist/terragrunt/run.d.ts.map +0 -1
- package/dist/terragrunt/units.d.ts.map +0 -1
- package/dist/terragrunt/wave.d.ts.map +0 -1
- package/dist/used-sources.d.ts.map +0 -1
- package/dist/validate-cli.d.ts.map +0 -1
- package/dist/validate.d.ts.map +0 -1
- package/src/__fixtures__/ACCEPTANCE.md +0 -370
- package/src/__fixtures__/capabilities/catalog/main.tf +0 -105
- package/src/__fixtures__/capabilities/chant.config.ts +0 -15
- package/src/__fixtures__/capabilities/findings/main.tf +0 -225
- package/src/__fixtures__/capabilities/ledger/main.tf +0 -265
- package/src/__fixtures__/capabilities/package.json +0 -1
- package/src/__fixtures__/change-set/choudoufu-set-plan.change-set.golden.json +0 -95
- package/src/__fixtures__/change-set/choudoufu-set-plan.json +0 -76
- package/src/__fixtures__/change-set/choudoufu.part.golden.json +0 -173
- package/src/__fixtures__/change-set/choudoufu.plan.json +0 -610
- package/src/__fixtures__/change-set/terraform.import-forget.plan.json +0 -81
- package/src/__fixtures__/change-set/terraform.part.golden.json +0 -173
- package/src/__fixtures__/change-set/terraform.plan.json +0 -589
- package/src/__fixtures__/change-set/tofu.part.golden.json +0 -173
- package/src/__fixtures__/change-set/tofu.plan.json +0 -588
- package/src/__fixtures__/change-set/v1.tf.txt +0 -21
- package/src/__fixtures__/change-set/v2-module-app.tf.txt +0 -4
- package/src/__fixtures__/change-set/v2.tf.txt +0 -21
- package/src/__fixtures__/compose/apply-failed-in-app.jsonl +0 -12
- package/src/__fixtures__/compose/state-app.json +0 -66
- package/src/__fixtures__/compose/state-edge.json +0 -40
- package/src/__fixtures__/compose/state-net.json +0 -58
- package/src/__fixtures__/compose/three-app.plan.json +0 -184
- package/src/__fixtures__/compose/three-composed.plan.json +0 -509
- package/src/__fixtures__/compose/three-edge.plan.json +0 -144
- package/src/__fixtures__/compose/three-net.plan.json +0 -174
- package/src/__fixtures__/compose/unknown-composed.plan.json +0 -228
- package/src/__fixtures__/compose/working-after-apply.json +0 -145
- package/src/__fixtures__/config-blocks/app/main.tf +0 -61
- package/src/__fixtures__/config-blocks/app/modules/network/main.tf +0 -4
- package/src/__fixtures__/config-blocks/app-json/main.tf.json +0 -39
- package/src/__fixtures__/config-files/shadow/main.tf +0 -3
- package/src/__fixtures__/config-files/shadow/main.tofu +0 -3
- package/src/__fixtures__/config-files/shadow/other.tf +0 -3
- package/src/__fixtures__/config-files/tf/main.tf +0 -11
- package/src/__fixtures__/config-files/tf-json/main.tf.json +0 -18
- package/src/__fixtures__/config-files/tofu/main.tofu +0 -11
- package/src/__fixtures__/config-files/tofu-json/main.tofu.json +0 -18
- package/src/__fixtures__/config-files/tofu-only/main.tofu +0 -3
- package/src/__fixtures__/drift-record/README.md +0 -16
- package/src/__fixtures__/drift-record/live-plan-sections.json +0 -27
- package/src/__fixtures__/drift-rows/live-root-plan.json +0 -70
- package/src/__fixtures__/drift-rows/refresh-plan-module.json +0 -48
- package/src/__fixtures__/drift-rows/refresh-plan.json +0 -61
- package/src/__fixtures__/effective-topology/chant.config.ts +0 -11
- package/src/__fixtures__/effective-topology/net/main.tf +0 -176
- package/src/__fixtures__/effective-topology/package.json +0 -6
- package/src/__fixtures__/graph-roots/README.md +0 -21
- package/src/__fixtures__/graph-roots/app/main.tf +0 -41
- package/src/__fixtures__/graph-roots/app/modules/cdn/main.tf +0 -7
- package/src/__fixtures__/graph-roots/network/main.tf +0 -16
- package/src/__fixtures__/instance-forms/app/main.tf +0 -110
- package/src/__fixtures__/instance-forms/app/modules/svc/main.tf +0 -3
- package/src/__fixtures__/instance-vars/app/main.tf +0 -52
- package/src/__fixtures__/instance-vars/app/modules/app/main.tf +0 -12
- package/src/__fixtures__/instance-vars/app/modules/edge/main.tf +0 -3
- package/src/__fixtures__/instance-vars/app/terraform.tfvars +0 -1
- package/src/__fixtures__/kind-type/app/main.tf +0 -35
- package/src/__fixtures__/kind-type/chant.config.ts +0 -11
- package/src/__fixtures__/kind-type/package.json +0 -6
- package/src/__fixtures__/live/main.tf +0 -28
- package/src/__fixtures__/live-adopt/estate.chdf.hcl +0 -6
- package/src/__fixtures__/live-adopt/main.tf +0 -21
- package/src/__fixtures__/live-estate/README.md +0 -104
- package/src/__fixtures__/live-estate/adoptable.tf +0 -13
- package/src/__fixtures__/live-estate/compute.tf +0 -10
- package/src/__fixtures__/live-estate/estate.chdf.hcl +0 -1
- package/src/__fixtures__/live-estate/logs.tf +0 -8
- package/src/__fixtures__/live-estate/network.tf +0 -24
- package/src/__fixtures__/live-estate/rule.tf +0 -11
- package/src/__fixtures__/live-estate/unowned.tf +0 -21
- package/src/__fixtures__/live-estate/versions.tf +0 -31
- package/src/__fixtures__/live-ls.json +0 -98
- package/src/__fixtures__/live-module-keyed/live-graph.json +0 -259
- package/src/__fixtures__/live-module-keyed/live-plan.json +0 -87
- package/src/__fixtures__/live-module-keyed/root/estate.chdf.hcl +0 -1
- package/src/__fixtures__/live-module-keyed/root/main.tf +0 -21
- package/src/__fixtures__/live-module-keyed/root/modules/app/main.tf +0 -17
- package/src/__fixtures__/live-module-keyed/root/modules/edge/main.tf +0 -7
- package/src/__fixtures__/live-module-keyed/root/versions.tf +0 -30
- package/src/__fixtures__/live-module-keyed/show-state.json +0 -146
- package/src/__fixtures__/live-plan-depth/README.md +0 -59
- package/src/__fixtures__/live-plan-depth/live-plan.json +0 -110
- package/src/__fixtures__/live-plan-depth/show-plan-sensitive.json +0 -1
- package/src/__fixtures__/live-plan-depth/show-plan.json +0 -1
- package/src/__fixtures__/live-plan.json +0 -317
- package/src/__fixtures__/live-sidecar/estate.chdf.hcl +0 -3
- package/src/__fixtures__/live-sidecar/main.tf +0 -24
- package/src/__fixtures__/module-tree/README.md +0 -16
- package/src/__fixtures__/module-tree/cycle/main.tf +0 -3
- package/src/__fixtures__/module-tree/cycle/modules/a/main.tf +0 -9
- package/src/__fixtures__/module-tree/cycle/modules/b/main.tf +0 -9
- package/src/__fixtures__/module-tree/missing/main.tf +0 -9
- package/src/__fixtures__/module-tree/outside/root/main.tf +0 -9
- package/src/__fixtures__/module-tree/root/main.tf +0 -28
- package/src/__fixtures__/module-tree/root/modules/cdn/main.tf +0 -15
- package/src/__fixtures__/module-tree/root/modules/cdn/modules/bucket/main.tf +0 -11
- package/src/__fixtures__/module-tree/shared/main.tf +0 -5
- package/src/__fixtures__/no-backend/main.tf +0 -24
- package/src/__fixtures__/pin/choudoufu-live-waves-n5.json +0 -83
- package/src/__fixtures__/pin/largeset-oci-n5/apply-order.txt +0 -5
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e01/estate.chdf.hcl +0 -6
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e01/main.tf +0 -33
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e02/estate.chdf.hcl +0 -6
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e02/main.tf +0 -45
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e03/estate.chdf.hcl +0 -6
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e03/main.tf +0 -47
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e04/estate.chdf.hcl +0 -6
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e04/main.tf +0 -31
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e05/estate.chdf.hcl +0 -6
- package/src/__fixtures__/pin/largeset-oci-n5/estates/e05/main.tf +0 -27
- package/src/__fixtures__/pin/largeset-oci-n5/fixture.json +0 -77
- package/src/__fixtures__/plan-read/main.tf +0 -46
- package/src/__fixtures__/plan-read/next.tfvars +0 -1
- package/src/__fixtures__/plan-read-drift/README.md +0 -33
- package/src/__fixtures__/plan-read-drift/main.tf +0 -63
- package/src/__fixtures__/plan-read-drift/next.tfvars +0 -1
- package/src/__fixtures__/plan-summary/largeset-n5-bump.json +0 -2071
- package/src/__fixtures__/plan-summary/largeset-n5.summary.golden.json +0 -95
- package/src/__fixtures__/plan-summary/largeset-n5.summary.golden.md +0 -22
- package/src/__fixtures__/plan-summary/largeset-n5.summary.golden.txt +0 -12
- package/src/__fixtures__/pr-loop/README.md +0 -50
- package/src/__fixtures__/pr-loop/chant.config.json +0 -13
- package/src/__fixtures__/pr-loop/estate.component.ts +0 -10
- package/src/__fixtures__/pr-loop/roots/a/main.tf +0 -11
- package/src/__fixtures__/pr-loop/roots/app/main.tf +0 -19
- package/src/__fixtures__/pr-loop/roots/b/main.tf +0 -7
- package/src/__fixtures__/pr-loop/roots/dns/main.tf +0 -3
- package/src/__fixtures__/pr-loop/roots/net/main.tf +0 -7
- package/src/__fixtures__/references/main.tf +0 -56
- package/src/__fixtures__/remote-backend/main.tf +0 -34
- package/src/__fixtures__/report/applied.show.json +0 -51
- package/src/__fixtures__/report/generate.ts +0 -63
- package/src/__fixtures__/report/plan.show.json +0 -200
- package/src/__fixtures__/report/tf-apply/change-set.json +0 -170
- package/src/__fixtures__/report/tf-apply/report.json +0 -338
- package/src/__fixtures__/report/tf-plan/change-set.json +0 -170
- package/src/__fixtures__/report/tf-plan/report.json +0 -320
- package/src/__fixtures__/search-roots/chant.config.ts +0 -11
- package/src/__fixtures__/search-roots/net/main.tf +0 -73
- package/src/__fixtures__/search-roots/package.json +0 -6
- package/src/__fixtures__/sensitive-default/chant.config.ts +0 -11
- package/src/__fixtures__/sensitive-default/net/main.tf +0 -38
- package/src/__fixtures__/sensitive-default/package.json +0 -6
- package/src/__fixtures__/show-plan.json +0 -663
- package/src/__fixtures__/show-state.json +0 -68
- package/src/__fixtures__/terragrunt/affected/catalog/units/web/terragrunt.hcl +0 -3
- package/src/__fixtures__/terragrunt/affected/gitignore +0 -3
- package/src/__fixtures__/terragrunt/affected/live/dev/app/terragrunt.hcl +0 -3
- package/src/__fixtures__/terragrunt/affected/live/dev/vpc/terragrunt.hcl +0 -3
- package/src/__fixtures__/terragrunt/affected/live/prod/app/terragrunt.hcl +0 -3
- package/src/__fixtures__/terragrunt/affected/live/stg/terragrunt.stack.hcl +0 -5
- package/src/__fixtures__/terragrunt/affected/modules/app/main.tf +0 -6
- package/src/__fixtures__/terragrunt/affected/modules/app/policy.json +0 -1
- package/src/__fixtures__/terragrunt/affected/modules/net/main.tf +0 -2
- package/src/__fixtures__/terragrunt/affected/modules/thing/main.tf +0 -3
- package/src/__fixtures__/terragrunt/affected/root.hcl +0 -5
- package/src/__fixtures__/terragrunt/affected-cases.ts +0 -126
- package/src/__fixtures__/terragrunt/five-units/catalog/units/thing/terragrunt.hcl +0 -3
- package/src/__fixtures__/terragrunt/five-units/live/dev/app/terragrunt.hcl +0 -13
- package/src/__fixtures__/terragrunt/five-units/live/dev/db/terragrunt.hcl +0 -8
- package/src/__fixtures__/terragrunt/five-units/live/dev/vpc/terragrunt.hcl +0 -3
- package/src/__fixtures__/terragrunt/five-units/live/prod/app/terragrunt.hcl +0 -8
- package/src/__fixtures__/terragrunt/five-units/live/prod/vpc/terragrunt.hcl +0 -3
- package/src/__fixtures__/terragrunt/five-units/modules/thing/main.tf +0 -7
- package/src/__fixtures__/terragrunt/five-units/root.hcl +0 -5
- package/src/__fixtures__/terragrunt/record.ts +0 -56
- package/src/__fixtures__/terragrunt/recorded/affected-find.json +0 -50
- package/src/__fixtures__/terragrunt/recorded/failed-plan-report.json +0 -36
- package/src/__fixtures__/terragrunt/recorded/find.json +0 -67
- package/src/__fixtures__/terragrunt/recorded/version.txt +0 -1
- package/src/__fixtures__/terragrunt/recorded/wave-1/apply-report.json +0 -22
- package/src/__fixtures__/terragrunt/recorded/wave-1/json/live/dev/vpc/tfplan.json +0 -1
- package/src/__fixtures__/terragrunt/recorded/wave-1/json/live/prod/vpc/tfplan.json +0 -1
- package/src/__fixtures__/terragrunt/recorded/wave-1/plan-report.json +0 -22
- package/src/__fixtures__/terragrunt/recorded/wave-2/json/live/dev/db/tfplan.json +0 -1
- package/src/__fixtures__/terragrunt/recorded/wave-2/json/live/prod/app/tfplan.json +0 -1
- package/src/__fixtures__/terragrunt/recorded/wave-2/plan-report.json +0 -22
- package/src/__fixtures__/three-cloud-azure.graph.json +0 -290
- package/src/__fixtures__/used-sources/root/extra.tofu +0 -1
- package/src/__fixtures__/used-sources/root/main.tf +0 -31
- package/src/__fixtures__/used-sources/root/modules/net/main.tf +0 -14
- package/src/__fixtures__/used-sources/root/modules/net/versions.tf.json +0 -7
- package/src/__fixtures__/used-sources/unit/terragrunt.hcl +0 -3
- package/src/__fixtures__/with-backend/main.tf +0 -35
- package/src/__fixtures__/with-module/main.tf +0 -49
- package/src/__fixtures__/with-module/modules/inner/main.tf +0 -5
- package/src/action-ops.test.ts +0 -293
- package/src/action-ops.ts +0 -372
- package/src/applied-state.ts +0 -52
- package/src/backend-config.test.ts +0 -105
- package/src/backend-config.ts +0 -133
- package/src/behaviour/index.ts +0 -32
- package/src/behaviour/kinds.ts +0 -209
- package/src/behaviour/predict.test.ts +0 -549
- package/src/behaviour/predict.ts +0 -391
- package/src/behaviour/reference-catalog.plugin.test.ts +0 -65
- package/src/behaviour/reference-catalog.ts +0 -196
- package/src/behaviour/request.test.ts +0 -359
- package/src/behaviour/request.ts +0 -624
- package/src/capabilities/adapter.ts +0 -32
- package/src/capabilities/mapping.json +0 -166
- package/src/capabilities-workspace.e2e.test.ts +0 -251
- package/src/capabilities.test.ts +0 -264
- package/src/change-set-combined-run.test.ts +0 -157
- package/src/change-set-instances.test.ts +0 -98
- package/src/change-set.test.ts +0 -177
- package/src/change-set.ts +0 -292
- package/src/changed-roots.test.ts +0 -84
- package/src/changed-roots.ts +0 -100
- package/src/chant-floors.ts +0 -32
- package/src/ci-setup.test.ts +0 -20
- package/src/ci-setup.ts +0 -47
- package/src/codegen/docs-cli.ts +0 -4
- package/src/codegen/docs.ts +0 -50
- package/src/codegen/generate-cli.ts +0 -10
- package/src/codegen/generate.ts +0 -68
- package/src/codegen/lint-rules-page.test.ts +0 -45
- package/src/codegen/package.ts +0 -50
- package/src/commands.ts +0 -192
- package/src/components/capability-plugin.test.ts +0 -548
- package/src/components/capability-plugin.ts +0 -921
- package/src/components/change-set-graph.e2e.test.ts +0 -90
- package/src/components/compose-group.test.ts +0 -515
- package/src/components/compose-group.ts +0 -497
- package/src/components/compose-op-wave.test.ts +0 -134
- package/src/components/demo-composed-roots.e2e.test.ts +0 -440
- package/src/components/member-outputs.test.ts +0 -76
- package/src/components/placeholder-preview.test.ts +0 -147
- package/src/components/placeholder-preview.ts +0 -257
- package/src/components/pr-loop-compose.tofu.e2e.test.ts +0 -363
- package/src/components/pr-loop.tofu.test.ts +0 -384
- package/src/components/release-inputs.ts +0 -69
- package/src/components/terraform-apply-command-hook.test.ts +0 -200
- package/src/components/terraform-apply-op-wave.test.ts +0 -295
- package/src/components/terraform-apply-parallel.test.ts +0 -158
- package/src/components/trace-facts.test.ts +0 -21
- package/src/components/trace-facts.ts +0 -27
- package/src/compose/apply-events.test.ts +0 -62
- package/src/compose/apply-events.ts +0 -100
- package/src/compose/estate.choudoufu.e2e.test.ts +0 -112
- package/src/compose/estate.test.ts +0 -421
- package/src/compose/estate.ts +0 -443
- package/src/compose/hcl.ts +0 -311
- package/src/compose/module-address.ts +0 -49
- package/src/compose/root.test.ts +0 -416
- package/src/compose/root.ts +0 -592
- package/src/compose/run.test.ts +0 -440
- package/src/compose/run.tofu.test.ts +0 -176
- package/src/compose/run.ts +0 -527
- package/src/compose/slice.test.ts +0 -184
- package/src/compose/slice.ts +0 -290
- package/src/compose/state-address.ts +0 -157
- package/src/compose/state-merge.test.ts +0 -131
- package/src/compose/state-merge.ts +0 -148
- package/src/compose.test.ts +0 -248
- package/src/compose.ts +0 -628
- package/src/composites/terraform-adopt-op.acceptance.test.ts +0 -244
- package/src/composites/terraform-adopt-op.test.ts +0 -203
- package/src/composites/terraform-adopt-op.ts +0 -225
- package/src/composites/terraform-apply-op.acceptance.test.ts +0 -323
- package/src/composites/terraform-apply-op.test.ts +0 -400
- package/src/composites/terraform-apply-op.ts +0 -291
- package/src/composites/terraform-pin-rollout-op.test.ts +0 -69
- package/src/composites/terraform-pin-rollout-op.ts +0 -60
- package/src/composites/terraform-watch-op.test.ts +0 -338
- package/src/composites/terraform-watch-op.ts +0 -322
- package/src/cone.ts +0 -138
- package/src/config-file-listers.test.ts +0 -265
- package/src/config.ts +0 -213
- package/src/cost-hold.ts +0 -29
- package/src/describe-resources.engine-facts.test.ts +0 -411
- package/src/describe-resources.live-module-keyed.test.ts +0 -290
- package/src/describe-resources.live-plan.test.ts +0 -302
- package/src/describe-resources.live-root-unchanged.test.ts +0 -126
- package/src/describe-resources.live.test.ts +0 -670
- package/src/describe-resources.plan.test.ts +0 -437
- package/src/describe-resources.test.ts +0 -430
- package/src/describe-resources.ts +0 -1996
- package/src/drift-read.ts +0 -284
- package/src/drift-record.test.ts +0 -285
- package/src/drift-record.ts +0 -513
- package/src/drift-rows.test.ts +0 -224
- package/src/drift-rows.ts +0 -208
- package/src/effective-topology.test.ts +0 -134
- package/src/engine-runner.test.ts +0 -347
- package/src/engine-runner.ts +0 -201
- package/src/engine-timings.test.ts +0 -203
- package/src/engine-timings.ts +0 -718
- package/src/estate-migration.test.ts +0 -186
- package/src/estate-migration.ts +0 -563
- package/src/exit-codes.test.ts +0 -23
- package/src/exit-codes.ts +0 -59
- package/src/generated/index.d.ts +0 -2
- package/src/generated/index.ts +0 -4
- package/src/hcl/config-blocks.test.ts +0 -174
- package/src/hcl/descend.test.ts +0 -202
- package/src/hcl/descend.ts +0 -286
- package/src/hcl/edges.test.ts +0 -207
- package/src/hcl/edges.ts +0 -336
- package/src/hcl/files.ts +0 -234
- package/src/hcl/instance-forms.test.ts +0 -94
- package/src/hcl/instances.test.ts +0 -137
- package/src/hcl/instances.ts +0 -422
- package/src/hcl/jsonencode.test.ts +0 -226
- package/src/hcl/jsonencode.ts +0 -454
- package/src/hcl/marker.test.ts +0 -147
- package/src/hcl/marker.ts +0 -235
- package/src/hcl/parse.test.ts +0 -232
- package/src/hcl/parse.ts +0 -787
- package/src/hcl/redact.ts +0 -181
- package/src/hcl/references.test.ts +0 -116
- package/src/hcl/references.ts +0 -172
- package/src/hcl/roots.ts +0 -148
- package/src/hcl/suppressions.test.ts +0 -147
- package/src/hcl/suppressions.ts +0 -216
- package/src/hcl/value.test.ts +0 -73
- package/src/hcl/value.ts +0 -106
- package/src/index.ts +0 -218
- package/src/init-turn.ts +0 -36
- package/src/lint/audit-catalog.ts +0 -584
- package/src/lint/audit-lineage.ts +0 -570
- package/src/lint/audit.test.ts +0 -254
- package/src/lint/post-synth/blocks.ts +0 -109
- package/src/lint/post-synth/estate-2284.test.ts +0 -68
- package/src/lint/post-synth/fixtures/TF001/negative-cloud.tf +0 -28
- package/src/lint/post-synth/fixtures/TF001/negative.tf +0 -30
- package/src/lint/post-synth/fixtures/TF001/positive-local.tf +0 -31
- package/src/lint/post-synth/fixtures/TF001/positive.tf +0 -24
- package/src/lint/post-synth/fixtures/TF002/negative.tf +0 -17
- package/src/lint/post-synth/fixtures/TF002/positive-legacy.tf +0 -10
- package/src/lint/post-synth/fixtures/TF002/positive-no-version.tf +0 -12
- package/src/lint/post-synth/fixtures/TF002/positive.tf +0 -7
- package/src/lint/post-synth/fixtures/TF003/negative.tf +0 -10
- package/src/lint/post-synth/fixtures/TF003/positive.tf +0 -8
- package/src/lint/post-synth/fixtures/TF004/negative-git.tf +0 -3
- package/src/lint/post-synth/fixtures/TF004/negative-local.tf +0 -3
- package/src/lint/post-synth/fixtures/TF004/negative.tf +0 -4
- package/src/lint/post-synth/fixtures/TF004/positive.tf +0 -3
- package/src/lint/post-synth/fixtures/TF005/negative-local.tf +0 -3
- package/src/lint/post-synth/fixtures/TF005/negative-registry.tf +0 -3
- package/src/lint/post-synth/fixtures/TF005/negative-sha.tf +0 -3
- package/src/lint/post-synth/fixtures/TF005/negative.tf +0 -3
- package/src/lint/post-synth/fixtures/TF005/positive-branch.tf +0 -3
- package/src/lint/post-synth/fixtures/TF005/positive-non-semver.tf +0 -3
- package/src/lint/post-synth/fixtures/TF005/positive.tf +0 -3
- package/src/lint/post-synth/fixtures/TF006/negative.tf +0 -5
- package/src/lint/post-synth/fixtures/TF006/positive-empty-default.tf +0 -11
- package/src/lint/post-synth/fixtures/TF006/positive.tf +0 -6
- package/src/lint/post-synth/fixtures/TF007/negative.tf +0 -10
- package/src/lint/post-synth/fixtures/TF007/positive.tf +0 -9
- package/src/lint/post-synth/fixtures/TF008/negative-variable.tf +0 -10
- package/src/lint/post-synth/fixtures/TF008/negative.tf +0 -8
- package/src/lint/post-synth/fixtures/TF008/positive-other-provider.tf +0 -10
- package/src/lint/post-synth/fixtures/TF008/positive.tf +0 -5
- package/src/lint/post-synth/fixtures/TF009/negative.tf +0 -10
- package/src/lint/post-synth/fixtures/TF009/positive.tf +0 -4
- package/src/lint/post-synth/fixtures/TF010/negative.tf +0 -5
- package/src/lint/post-synth/fixtures/TF010/positive.tf +0 -4
- package/src/lint/post-synth/fixtures/TF011/negative.tf +0 -5
- package/src/lint/post-synth/fixtures/TF011/positive-blank.tf +0 -5
- package/src/lint/post-synth/fixtures/TF011/positive.tf +0 -4
- package/src/lint/post-synth/fixtures/TF012/negative.tf +0 -4
- package/src/lint/post-synth/fixtures/TF012/positive.tf +0 -3
- package/src/lint/post-synth/fixtures/TF013/negative.tf +0 -8
- package/src/lint/post-synth/fixtures/TF013/positive-data.tf +0 -8
- package/src/lint/post-synth/fixtures/TF013/positive.tf +0 -8
- package/src/lint/post-synth/fixtures/TF014/negative/main.tf +0 -26
- package/src/lint/post-synth/fixtures/TF014/negative/modules/cdn/main.tf +0 -19
- package/src/lint/post-synth/fixtures/TF014/positive/main.tf +0 -16
- package/src/lint/post-synth/fixtures/TF014/positive/modules/cdn/main.tf +0 -15
- package/src/lint/post-synth/fixtures/TF015/negative/main.tf +0 -13
- package/src/lint/post-synth/fixtures/TF015/negative/modules/cdn/main.tf +0 -16
- package/src/lint/post-synth/fixtures/TF015/positive/main.tf +0 -13
- package/src/lint/post-synth/fixtures/TF015/positive/modules/cdn/main.tf +0 -14
- package/src/lint/post-synth/fixtures/TF016/negative-template.tf +0 -7
- package/src/lint/post-synth/fixtures/TF016/negative.tf +0 -16
- package/src/lint/post-synth/fixtures/TF016/positive-shared-file.tf +0 -12
- package/src/lint/post-synth/fixtures/TF016/positive.tf +0 -13
- package/src/lint/post-synth/fixtures/TF017/negative.tf +0 -4
- package/src/lint/post-synth/fixtures/TF017/positive.tf +0 -5
- package/src/lint/post-synth/fixtures/TF018/negative.tf +0 -9
- package/src/lint/post-synth/fixtures/TF018/positive-data.tf +0 -9
- package/src/lint/post-synth/fixtures/TF018/positive.tf +0 -4
- package/src/lint/post-synth/fixtures/TF019/negative.tf +0 -14
- package/src/lint/post-synth/fixtures/TF019/positive-output.tf +0 -5
- package/src/lint/post-synth/fixtures/TF019/positive.tf +0 -16
- package/src/lint/post-synth/fixtures/TF020/negative.tf +0 -43
- package/src/lint/post-synth/fixtures/TF020/positive.tf +0 -32
- package/src/lint/post-synth/fixtures/TF020/scoped/main.tf +0 -21
- package/src/lint/post-synth/fixtures/TF020/scoped/modules/cdn/main.tf +0 -13
- package/src/lint/post-synth/fixtures/TF021/negative.tf +0 -31
- package/src/lint/post-synth/fixtures/TF021/positive-length.tf +0 -8
- package/src/lint/post-synth/fixtures/TF021/positive.tf +0 -8
- package/src/lint/post-synth/fixtures/TF022/negative-locator.tf +0 -7
- package/src/lint/post-synth/fixtures/TF022/negative.tf +0 -10
- package/src/lint/post-synth/fixtures/TF022/positive-nested.tf +0 -10
- package/src/lint/post-synth/fixtures/TF022/positive.tf +0 -6
- package/src/lint/post-synth/fixtures/TF023/negative/main.tf +0 -15
- package/src/lint/post-synth/fixtures/TF023/positive/main.tf +0 -9
- package/src/lint/post-synth/fixtures/TF023/positive/state.json +0 -24
- package/src/lint/post-synth/fixtures/TF024/live-clean/main.tf +0 -9
- package/src/lint/post-synth/fixtures/TF024/live-with-backend/main.tf +0 -14
- package/src/lint/post-synth/fixtures/TF024/live-with-cloud/main.tf +0 -16
- package/src/lint/post-synth/fixtures/TF024/live-with-record-store/main.tf +0 -18
- package/src/lint/post-synth/fixtures/TF024/sidecar-with-backend/estate.chdf.hcl +0 -1
- package/src/lint/post-synth/fixtures/TF024/sidecar-with-backend/main.tf +0 -10
- package/src/lint/post-synth/fixtures/TF025/live-clean/main.tf +0 -13
- package/src/lint/post-synth/fixtures/TF025/live-with-workspace-ref/main.tf +0 -13
- package/src/lint/post-synth/fixtures/TF026/live-default/main.tf +0 -9
- package/src/lint/post-synth/fixtures/TF026/live-explicit-delete/main.tf +0 -13
- package/src/lint/post-synth/fixtures/TF026/live-keep/main.tf +0 -13
- package/src/lint/post-synth/fixtures/TF027/live-default/main.tf +0 -9
- package/src/lint/post-synth/fixtures/TF027/live-untagged-delete/main.tf +0 -13
- package/src/lint/post-synth/fixtures/TF027/live-untagged-delete-scoped/main.tf +0 -17
- package/src/lint/post-synth/fixtures/TF027/live-untagged-report/main.tf +0 -13
- package/src/lint/post-synth/fixtures/TF028/live/main.tf +0 -9
- package/src/lint/post-synth/fixtures/TF028/stock/main.tf +0 -10
- package/src/lint/post-synth/fixtures/TF029/declared/main.tf +0 -5
- package/src/lint/post-synth/fixtures/TF029/no-declaration/main.tf +0 -5
- package/src/lint/post-synth/fixtures/TF030/negative-rules.tf +0 -45
- package/src/lint/post-synth/fixtures/TF030/negative.tf +0 -55
- package/src/lint/post-synth/fixtures/TF030/not-determined-port.tf +0 -28
- package/src/lint/post-synth/fixtures/TF030/not-determined-standalone.tf +0 -32
- package/src/lint/post-synth/fixtures/TF030/not-determined-vpc-rule.tf +0 -21
- package/src/lint/post-synth/fixtures/TF030/not-determined.tf +0 -39
- package/src/lint/post-synth/fixtures/TF030/positive-ipv6.tf +0 -44
- package/src/lint/post-synth/fixtures/TF030/positive-mixed.tf +0 -36
- package/src/lint/post-synth/fixtures/TF030/positive-standalone.tf +0 -25
- package/src/lint/post-synth/fixtures/TF030/positive.tf +0 -43
- package/src/lint/post-synth/fixtures/TF031/negative.tf +0 -89
- package/src/lint/post-synth/fixtures/TF031/not-determined.tf +0 -139
- package/src/lint/post-synth/fixtures/TF031/positive-data-source.tf +0 -57
- package/src/lint/post-synth/fixtures/TF031/positive-heredoc.tf +0 -149
- package/src/lint/post-synth/fixtures/TF031/positive-jsonencode.tf +0 -115
- package/src/lint/post-synth/fixtures/TF032/negative-heredoc.tf +0 -20
- package/src/lint/post-synth/fixtures/TF032/negative-references.tf +0 -214
- package/src/lint/post-synth/fixtures/TF032/negative.tf +0 -99
- package/src/lint/post-synth/fixtures/TF032/positive-heredoc.tf +0 -22
- package/src/lint/post-synth/fixtures/TF032/positive-sidecar.tf +0 -197
- package/src/lint/post-synth/fixtures/TF032/positive.tf +0 -54
- package/src/lint/post-synth/fixtures/TF033/negative.tf +0 -39
- package/src/lint/post-synth/fixtures/TF033/not-determined-aurora.tf +0 -25
- package/src/lint/post-synth/fixtures/TF033/positive-absent.tf +0 -93
- package/src/lint/post-synth/fixtures/TF033/positive.tf +0 -50
- package/src/lint/post-synth/fixtures/TF034/negative.tf +0 -24
- package/src/lint/post-synth/fixtures/TF034/positive-absent.tf +0 -36
- package/src/lint/post-synth/fixtures/TF034/positive.tf +0 -14
- package/src/lint/post-synth/fixtures/TF035/negative-absent.tf +0 -43
- package/src/lint/post-synth/fixtures/TF035/negative.tf +0 -54
- package/src/lint/post-synth/fixtures/TF035/positive.tf +0 -37
- package/src/lint/post-synth/fixtures/TF036/negative.tf +0 -61
- package/src/lint/post-synth/fixtures/TF036/not-determined.tf +0 -28
- package/src/lint/post-synth/fixtures/TF036/positive.tf +0 -38
- package/src/lint/post-synth/fixtures/TF037/negative-exclusion.tf +0 -63
- package/src/lint/post-synth/fixtures/TF037/negative.tf +0 -27
- package/src/lint/post-synth/fixtures/TF037/not-determined.tf +0 -27
- package/src/lint/post-synth/fixtures/TF037/positive-absent.tf +0 -15
- package/src/lint/post-synth/fixtures/TF037/positive.tf +0 -26
- package/src/lint/post-synth/fixtures/TF038/positive.tf +0 -3
- package/src/lint/post-synth/fixtures/TF039/positive.tf +0 -4
- package/src/lint/post-synth/fixtures/TF041/negative/terragrunt.hcl +0 -12
- package/src/lint/post-synth/fixtures/TF041/positive/terragrunt.hcl +0 -7
- package/src/lint/post-synth/fixtures/TF041/positive-apply/terragrunt.hcl +0 -8
- package/src/lint/post-synth/fixtures/TF042/negative/terragrunt.hcl +0 -13
- package/src/lint/post-synth/fixtures/TF042/positive/terragrunt.hcl +0 -9
- package/src/lint/post-synth/fixtures/TF043/negative/terragrunt.hcl +0 -3
- package/src/lint/post-synth/fixtures/TF043/negative-other/terragrunt.hcl +0 -3
- package/src/lint/post-synth/fixtures/TF043/positive-git/terragrunt.hcl +0 -3
- package/src/lint/post-synth/fixtures/TF043/positive-oci/terragrunt.hcl +0 -3
- package/src/lint/post-synth/fixtures/TF043/positive-tfr/terragrunt.hcl +0 -3
- package/src/lint/post-synth/fixtures/TF044/negative/terragrunt.hcl +0 -9
- package/src/lint/post-synth/fixtures/TF044/positive/terragrunt.hcl +0 -7
- package/src/lint/post-synth/fixtures/TF044/positive-generate/terragrunt.hcl +0 -9
- package/src/lint/post-synth/fixtures/TF045/negative/root.hcl +0 -1
- package/src/lint/post-synth/fixtures/TF045/negative/terragrunt.hcl +0 -3
- package/src/lint/post-synth/fixtures/TF045/positive/root.hcl +0 -9
- package/src/lint/post-synth/fixtures/TF045/positive/terragrunt.hcl +0 -3
- package/src/lint/post-synth/fixtures/TF045/unit-only/terragrunt.hcl +0 -3
- package/src/lint/post-synth/fixtures/TF046/azurerm-no-resource-group/main.tf +0 -15
- package/src/lint/post-synth/fixtures/TF046/backend-config-only/main.tf +0 -14
- package/src/lint/post-synth/fixtures/TF046/derived-s3/backend.tf +0 -7
- package/src/lint/post-synth/fixtures/TF046/derived-s3/main.tf +0 -9
- package/src/lint/post-synth/fixtures/TF046/explicit-local/main.tf +0 -16
- package/src/lint/post-synth/fixtures/TF046/explicit-s3-beside-local-backend/main.tf +0 -15
- package/src/lint/post-synth/fixtures/TF046/implied-local/main.tf +0 -9
- package/src/lint/post-synth/fixtures/TF046/sidecar-implied/estate.chdf.hcl +0 -1
- package/src/lint/post-synth/fixtures/TF046/sidecar-implied/main.tf +0 -5
- package/src/lint/post-synth/fixtures/TF047/clear/main.tf +0 -12
- package/src/lint/post-synth/fixtures/TF047/refused/main.tf +0 -12
- package/src/lint/post-synth/fixtures/TF047/unknown-module/main.tf +0 -12
- package/src/lint/post-synth/fixtures/TF047/unknown-version/main.tf +0 -12
- package/src/lint/post-synth/fixtures/estate-2284/clean/main.tf +0 -132
- package/src/lint/post-synth/fixtures/estate-2284/violating/main.tf +0 -112
- package/src/lint/post-synth/fixtures/load.ts +0 -108
- package/src/lint/post-synth/flat-attributes.ts +0 -146
- package/src/lint/post-synth/index.ts +0 -97
- package/src/lint/post-synth/live-refusals-config-format.test.ts +0 -143
- package/src/lint/post-synth/module-rules.test.ts +0 -153
- package/src/lint/post-synth/module-source.test.ts +0 -116
- package/src/lint/post-synth/module-source.ts +0 -176
- package/src/lint/post-synth/post-synth.test.ts +0 -152
- package/src/lint/post-synth/record-store.ts +0 -122
- package/src/lint/post-synth/scope.ts +0 -107
- package/src/lint/post-synth/single-block.test.ts +0 -265
- package/src/lint/post-synth/suppression.test.ts +0 -110
- package/src/lint/post-synth/terragrunt.ts +0 -76
- package/src/lint/post-synth/tf001.ts +0 -146
- package/src/lint/post-synth/tf002.test.ts +0 -93
- package/src/lint/post-synth/tf002.ts +0 -151
- package/src/lint/post-synth/tf003.test.ts +0 -75
- package/src/lint/post-synth/tf003.ts +0 -71
- package/src/lint/post-synth/tf004.test.ts +0 -47
- package/src/lint/post-synth/tf004.ts +0 -63
- package/src/lint/post-synth/tf005.test.ts +0 -57
- package/src/lint/post-synth/tf005.ts +0 -76
- package/src/lint/post-synth/tf006.ts +0 -53
- package/src/lint/post-synth/tf007.ts +0 -78
- package/src/lint/post-synth/tf008.ts +0 -75
- package/src/lint/post-synth/tf009.ts +0 -59
- package/src/lint/post-synth/tf010.ts +0 -51
- package/src/lint/post-synth/tf011.ts +0 -49
- package/src/lint/post-synth/tf012.ts +0 -47
- package/src/lint/post-synth/tf013.ts +0 -63
- package/src/lint/post-synth/tf014.ts +0 -72
- package/src/lint/post-synth/tf015.ts +0 -72
- package/src/lint/post-synth/tf016.ts +0 -75
- package/src/lint/post-synth/tf017.ts +0 -50
- package/src/lint/post-synth/tf018.ts +0 -72
- package/src/lint/post-synth/tf019.ts +0 -72
- package/src/lint/post-synth/tf020.ts +0 -123
- package/src/lint/post-synth/tf021.ts +0 -126
- package/src/lint/post-synth/tf022.ts +0 -61
- package/src/lint/post-synth/tf024.test.ts +0 -63
- package/src/lint/post-synth/tf024.ts +0 -153
- package/src/lint/post-synth/tf025.test.ts +0 -46
- package/src/lint/post-synth/tf025.ts +0 -101
- package/src/lint/post-synth/tf026.test.ts +0 -56
- package/src/lint/post-synth/tf026.ts +0 -84
- package/src/lint/post-synth/tf027.test.ts +0 -62
- package/src/lint/post-synth/tf027.ts +0 -74
- package/src/lint/post-synth/tf028.test.ts +0 -92
- package/src/lint/post-synth/tf028.ts +0 -96
- package/src/lint/post-synth/tf029.test.ts +0 -72
- package/src/lint/post-synth/tf029.ts +0 -85
- package/src/lint/post-synth/tf030.test.ts +0 -219
- package/src/lint/post-synth/tf030.ts +0 -290
- package/src/lint/post-synth/tf031.test.ts +0 -229
- package/src/lint/post-synth/tf031.ts +0 -370
- package/src/lint/post-synth/tf032.test.ts +0 -127
- package/src/lint/post-synth/tf032.ts +0 -226
- package/src/lint/post-synth/tf033.test.ts +0 -126
- package/src/lint/post-synth/tf033.ts +0 -160
- package/src/lint/post-synth/tf034.test.ts +0 -71
- package/src/lint/post-synth/tf034.ts +0 -63
- package/src/lint/post-synth/tf035.test.ts +0 -68
- package/src/lint/post-synth/tf035.ts +0 -74
- package/src/lint/post-synth/tf036.test.ts +0 -87
- package/src/lint/post-synth/tf036.ts +0 -119
- package/src/lint/post-synth/tf037.test.ts +0 -88
- package/src/lint/post-synth/tf037.ts +0 -101
- package/src/lint/post-synth/tf038.test.ts +0 -51
- package/src/lint/post-synth/tf038.ts +0 -71
- package/src/lint/post-synth/tf039.test.ts +0 -40
- package/src/lint/post-synth/tf039.ts +0 -64
- package/src/lint/post-synth/tf040.test.ts +0 -55
- package/src/lint/post-synth/tf040.ts +0 -76
- package/src/lint/post-synth/tf041.test.ts +0 -50
- package/src/lint/post-synth/tf041.ts +0 -56
- package/src/lint/post-synth/tf042.test.ts +0 -19
- package/src/lint/post-synth/tf042.ts +0 -42
- package/src/lint/post-synth/tf043.test.ts +0 -65
- package/src/lint/post-synth/tf043.ts +0 -49
- package/src/lint/post-synth/tf044.test.ts +0 -27
- package/src/lint/post-synth/tf044.ts +0 -51
- package/src/lint/post-synth/tf045.test.ts +0 -30
- package/src/lint/post-synth/tf045.ts +0 -47
- package/src/lint/post-synth/tf046.test.ts +0 -137
- package/src/lint/post-synth/tf046.ts +0 -204
- package/src/lint/post-synth/tf047.test.ts +0 -56
- package/src/lint/post-synth/tf047.ts +0 -114
- package/src/lint/presets.test.ts +0 -72
- package/src/lint/rules/fixtures/TF101/negative-op.ts +0 -2
- package/src/lint/rules/fixtures/TF101/positive-op.ts +0 -2
- package/src/lint/rules/fixtures/load.ts +0 -53
- package/src/lint/rules/index.ts +0 -7
- package/src/lint/rules/plan-before-apply.test.ts +0 -216
- package/src/lint/rules/plan-before-apply.ts +0 -154
- package/src/lint/secret-shape.test.ts +0 -150
- package/src/lint/secret-shape.ts +0 -159
- package/src/live-ownership.ts +0 -60
- package/src/live-plan-depth.acceptance.e2e.test.ts +0 -193
- package/src/live-plan-reasons.ts +0 -54
- package/src/live-record-store.test.ts +0 -76
- package/src/live-roots.test.ts +0 -80
- package/src/live-roots.ts +0 -347
- package/src/lock-rows.test.ts +0 -78
- package/src/lock-rows.ts +0 -82
- package/src/lock-timeout.ts +0 -34
- package/src/lsp/completions.test.ts +0 -121
- package/src/lsp/completions.ts +0 -101
- package/src/lsp/context.test.ts +0 -152
- package/src/lsp/context.ts +0 -349
- package/src/lsp/hover.test.ts +0 -82
- package/src/lsp/hover.ts +0 -44
- package/src/lsp/option-keys.ts +0 -114
- package/src/migration-history.test.ts +0 -83
- package/src/migration-history.ts +0 -199
- package/src/module-catalog/index.test.ts +0 -93
- package/src/module-catalog/index.ts +0 -162
- package/src/module-catalog/refresh-cli.ts +0 -68
- package/src/module-catalog/static-tier.ts +0 -1659
- package/src/module-catalog/types.ts +0 -88
- package/src/op/activities/choudoufu-plan-set-op.test.ts +0 -111
- package/src/op/activities/choudoufu-waves.test.ts +0 -176
- package/src/op/activities/choudoufu.acceptance.test.ts +0 -127
- package/src/op/activities/choudoufu.test.ts +0 -725
- package/src/op/activities/index.ts +0 -97
- package/src/op/activities/live-detect.test.ts +0 -143
- package/src/op/activities/live-detect.ts +0 -278
- package/src/op/activities/pin-rollout.ts +0 -80
- package/src/op/activities/registry.test.ts +0 -38
- package/src/op/activities/terraform.test.ts +0 -932
- package/src/op/activities/terraform.ts +0 -2484
- package/src/op/activity-contracts.test.ts +0 -151
- package/src/op/activity-contracts.ts +0 -244
- package/src/op/adoption.test.ts +0 -288
- package/src/op/adoption.ts +0 -373
- package/src/op/builders.test.ts +0 -145
- package/src/op/builders.ts +0 -213
- package/src/op/command-hook.ts +0 -237
- package/src/op/resolve-root-mode.test.ts +0 -85
- package/src/op/resolve-root-mode.ts +0 -86
- package/src/op-wave-step.test.ts +0 -109
- package/src/ops-doc-parity.test.ts +0 -147
- package/src/package-cli.ts +0 -21
- package/src/pin/__fixtures__/consumers/live/dev/main.tf +0 -4
- package/src/pin/__fixtures__/consumers/live/prod/main.tf +0 -21
- package/src/pin/__fixtures__/consumers/units/vpc/terragrunt.hcl +0 -7
- package/src/pin/bundle.test.ts +0 -57
- package/src/pin/consumers.test.ts +0 -57
- package/src/pin/consumers.ts +0 -95
- package/src/pin/edit-ts.test.ts +0 -39
- package/src/pin/edit-ts.ts +0 -77
- package/src/pin/edit.test.ts +0 -199
- package/src/pin/edit.ts +0 -187
- package/src/pin/forge.ts +0 -91
- package/src/pin/index.ts +0 -22
- package/src/pin/rollout.test.ts +0 -232
- package/src/pin/rollout.ts +0 -462
- package/src/pin/scan.ts +0 -320
- package/src/pin/source.ts +0 -206
- package/src/pin/waves.test.ts +0 -101
- package/src/pin/waves.ts +0 -125
- package/src/plan-digest.test.ts +0 -89
- package/src/plan-digest.ts +0 -140
- package/src/plan-observation.ts +0 -428
- package/src/plan-read.acceptance.test.ts +0 -184
- package/src/plan-shape.test.ts +0 -148
- package/src/plan-shape.ts +0 -128
- package/src/plan-summary.test.ts +0 -172
- package/src/plugin.test.ts +0 -412
- package/src/plugin.ts +0 -388
- package/src/pr-env.test.ts +0 -132
- package/src/pr-env.ts +0 -312
- package/src/reach.test.ts +0 -72
- package/src/reach.ts +0 -196
- package/src/redact-ir.e2e.test.ts +0 -79
- package/src/redact.test.ts +0 -111
- package/src/registry/__fixtures__/docs/documented/.terraform-docs.yml +0 -3
- package/src/registry/__fixtures__/docs/documented/README.md +0 -1
- package/src/registry/__fixtures__/docs/documented/main.tf +0 -8
- package/src/registry/__fixtures__/docs/json/main.tf.json +0 -14
- package/src/registry/__fixtures__/docs/vpc/README.md +0 -3
- package/src/registry/__fixtures__/docs/vpc/examples/complete/main.tf +0 -5
- package/src/registry/__fixtures__/docs/vpc/examples/simple/README.md +0 -1
- package/src/registry/__fixtures__/docs/vpc/examples/simple/main.tf +0 -4
- package/src/registry/__fixtures__/docs/vpc/main.tf +0 -14
- package/src/registry/__fixtures__/docs/vpc/outputs.tf +0 -9
- package/src/registry/__fixtures__/docs/vpc/variables.tf +0 -16
- package/src/registry/__fixtures__/proxied-root/main.tf +0 -12
- package/src/registry/address.ts +0 -100
- package/src/registry/catalog-read.ts +0 -56
- package/src/registry/deprecated.test.ts +0 -139
- package/src/registry/deprecated.ts +0 -76
- package/src/registry/docs.test.ts +0 -140
- package/src/registry/docs.ts +0 -299
- package/src/registry/edge/bundle.test.ts +0 -50
- package/src/registry/edge/edge.test.ts +0 -176
- package/src/registry/edge/edge.ts +0 -211
- package/src/registry/edge/index.ts +0 -10
- package/src/registry/edge/lambda-edge.ts +0 -127
- package/src/registry/edge/sigv4-web.ts +0 -79
- package/src/registry/edge/token-source.test.ts +0 -258
- package/src/registry/edge/token-source.ts +0 -169
- package/src/registry/edge/worker.ts +0 -61
- package/src/registry/handler.ts +0 -89
- package/src/registry/headers-file.ts +0 -61
- package/src/registry/index.ts +0 -32
- package/src/registry/mirror-paths.ts +0 -10
- package/src/registry/mirror.test.ts +0 -198
- package/src/registry/mirror.ts +0 -395
- package/src/registry/proxies.test.ts +0 -153
- package/src/registry/proxies.ts +0 -132
- package/src/registry/reader.ts +0 -225
- package/src/registry/registry.test.ts +0 -262
- package/src/registry/semver.ts +0 -34
- package/src/registry/serve.ts +0 -82
- package/src/registry/source-forms.test.ts +0 -87
- package/src/registry/source-forms.ts +0 -216
- package/src/registry/targets/artifactory.test.ts +0 -248
- package/src/registry/targets/artifactory.ts +0 -257
- package/src/registry/targets/fake-artifactory.ts +0 -158
- package/src/registry/targets/fake-gitlab.ts +0 -161
- package/src/registry/targets/fake-hcp.ts +0 -233
- package/src/registry/targets/fake-http.ts +0 -97
- package/src/registry/targets/fake-nexus.ts +0 -152
- package/src/registry/targets/gitlab.test.ts +0 -208
- package/src/registry/targets/gitlab.ts +0 -223
- package/src/registry/targets/hcp.test.ts +0 -230
- package/src/registry/targets/hcp.ts +0 -360
- package/src/registry/targets/hosted.ts +0 -117
- package/src/registry/targets/index.ts +0 -17
- package/src/registry/targets/module-target.ts +0 -131
- package/src/registry/targets/nexus.test.ts +0 -220
- package/src/registry/targets/nexus.ts +0 -314
- package/src/registry/targets/zip.test.ts +0 -65
- package/src/registry/targets/zip.ts +0 -287
- package/src/registry/writer.ts +0 -155
- package/src/report.test.ts +0 -423
- package/src/report.ts +0 -752
- package/src/search-build-roots.test.ts +0 -125
- package/src/search-count.test.ts +0 -144
- package/src/search-kind-type.test.ts +0 -136
- package/src/serializer.test.ts +0 -26
- package/src/serializer.ts +0 -26
- package/src/signal-only-root.test.ts +0 -72
- package/src/skills/chant-terraform.md +0 -92
- package/src/state/azure-blob.ts +0 -8
- package/src/state/backend-verdict.test.ts +0 -188
- package/src/state/backend.test.ts +0 -129
- package/src/state/backend.ts +0 -563
- package/src/state/engine-env.test.ts +0 -18
- package/src/state/exec.ts +0 -158
- package/src/state/gcs.ts +0 -7
- package/src/state/gitlab.test.ts +0 -226
- package/src/state/gitlab.ts +0 -331
- package/src/state/index.ts +0 -18
- package/src/state/locks.test.ts +0 -84
- package/src/state/locks.ts +0 -201
- package/src/state/object-store.ts +0 -7
- package/src/state/root-states-floci.e2e.test.ts +0 -66
- package/src/state/root-states.test.ts +0 -462
- package/src/state/root-states.ts +0 -309
- package/src/state/s3.ts +0 -22
- package/src/state/source.ts +0 -289
- package/src/state/store.ts +0 -360
- package/src/state/versions.test.ts +0 -365
- package/src/state/versions.ts +0 -183
- package/src/state-export-unlock.test.ts +0 -230
- package/src/state-migration-backends.test.ts +0 -277
- package/src/state-migration.test.ts +0 -236
- package/src/state-migration.ts +0 -595
- package/src/state-ops.test.ts +0 -182
- package/src/state-ops.ts +0 -469
- package/src/state-ownership.ts +0 -32
- package/src/state-reads.ts +0 -134
- package/src/template/__fixtures__/app-root.golden.tf +0 -25
- package/src/template/index.ts +0 -17
- package/src/template/render.test.ts +0 -230
- package/src/template/render.ts +0 -352
- package/src/terragrunt/affected.acceptance.test.ts +0 -83
- package/src/terragrunt/affected.test.ts +0 -188
- package/src/terragrunt/affected.ts +0 -350
- package/src/terragrunt/capability.test.ts +0 -421
- package/src/terragrunt/capability.ts +0 -446
- package/src/terragrunt/index.ts +0 -15
- package/src/terragrunt/mocks.acceptance.test.ts +0 -105
- package/src/terragrunt/mocks.test.ts +0 -422
- package/src/terragrunt/mocks.ts +0 -399
- package/src/terragrunt/place.test.ts +0 -42
- package/src/terragrunt/place.ts +0 -75
- package/src/terragrunt/run.ts +0 -532
- package/src/terragrunt/terragrunt.acceptance.test.ts +0 -122
- package/src/terragrunt/terragrunt.test.ts +0 -332
- package/src/terragrunt/units.ts +0 -260
- package/src/terragrunt/wave.ts +0 -203
- package/src/used-sources.test.ts +0 -75
- package/src/used-sources.ts +0 -204
- package/src/validate-cli.ts +0 -5
- package/src/validate.ts +0 -37
- package/src/workspace-kinds.test.ts +0 -36
- /package/{src → dist}/generated/lexicon-terraform.json +0 -0
|
@@ -1,1996 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Live observation for declared terraform entities (#2087, #2104).
|
|
3
|
-
*
|
|
4
|
-
* `buildRoots()` turns each configured root module into one entity per HCL
|
|
5
|
-
* block, keyed `<root>/<address>` (`./hcl/parse.ts`). This reader answers the
|
|
6
|
-
* lifecycle question for those entities, and how it answers depends on one
|
|
7
|
-
* fact the parse already recorded on every entity: the root's `mode`.
|
|
8
|
-
*
|
|
9
|
-
* A **stock** root is read with `terraform show -json` over its state, and
|
|
10
|
-
* state membership is the ownership answer. A **live** root, meaning
|
|
11
|
-
* `terraform.binary` is `"choudoufu"` and the root declares an estate
|
|
12
|
-
* (#2103), has no state to show: it is read with `choudoufu live-plan -json`,
|
|
13
|
-
* and the marker on the resource is the ownership answer. The two halves are
|
|
14
|
-
* two adapters over the same `observeEntities` harness, picked per root.
|
|
15
|
-
*
|
|
16
|
-
* ## Which of the two answered is on the wire (#2267)
|
|
17
|
-
*
|
|
18
|
-
* They are different claims. `terraform show -json` says what the last apply
|
|
19
|
-
* recorded; `choudoufu live-plan -json` says what the account holds now. A
|
|
20
|
-
* renderer that paints an observation as drift and cannot tell them apart
|
|
21
|
-
* paints a state read green, which reads as "the account matches" when all it
|
|
22
|
-
* says is "the apply finished". For an estate that has decided state is never
|
|
23
|
-
* the system of record, a state-backed observation is not a weaker answer, it
|
|
24
|
-
* is a different one.
|
|
25
|
-
*
|
|
26
|
-
* So the returned `ObservationResult` carries `sources`, keyed by chant entity
|
|
27
|
-
* name, with one of exactly four values:
|
|
28
|
-
*
|
|
29
|
-
* - `"state"`: this entity's root was read with `terraform show -json`.
|
|
30
|
-
* - `"live"`: this entity's root was read with `choudoufu live-plan -json`.
|
|
31
|
-
* - `"plan"`: this entity's root was read at the plan depth (#4358), a saved
|
|
32
|
-
* plan's `show -json`, which says what the next apply would do. See the
|
|
33
|
-
* plan depth section below.
|
|
34
|
-
* - `"live+plan"`: a live root at the plan depth (#4371), where both reads
|
|
35
|
-
* answered: `live-plan -json` for presence and ownership, the plan read for
|
|
36
|
-
* the attributes. A live root whose plan read failed says `"live"`.
|
|
37
|
-
*
|
|
38
|
-
* Three guarantees a consumer may rely on. Every entity `describeResources`
|
|
39
|
-
* was asked about that belongs to a root has an entry, whatever verdict it
|
|
40
|
-
* came back with: present, absent and not-observed alike, because which read
|
|
41
|
-
* was attempted is a fact independent of what it found. On a root read at the
|
|
42
|
-
* default depth the value equals the declared entity's own `props.mode`
|
|
43
|
-
* (`./hcl/parse.ts`), since one fact decides both, so `props.mode` is also a
|
|
44
|
-
* valid join key for a consumer holding the declared graph and no
|
|
45
|
-
* observation; the plan depth is chosen at read time, so only `sources` says
|
|
46
|
-
* it was used. And a project mixing stock
|
|
47
|
-
* and live roots gets both values in one document, which is why this is a map
|
|
48
|
-
* and not a field on the result as a whole.
|
|
49
|
-
*
|
|
50
|
-
* An entity with no root gets no entry, for the same reason it gets no read.
|
|
51
|
-
*
|
|
52
|
-
* ## The state file is the ownership answer, on a stock root
|
|
53
|
-
*
|
|
54
|
-
* Every other lexicon in chant stamps a tag or a label at synthesis and reads
|
|
55
|
-
* it back off the live resource. Terraform stamps nothing, and there is
|
|
56
|
-
* nowhere to stamp: a resource's provider-side tags are the practitioner's
|
|
57
|
-
* own, and writing chant's marker into them would edit an estate this lexicon
|
|
58
|
-
* promises never to write. What terraform has instead is the thing chant
|
|
59
|
-
* elsewhere refuses to host, a trusted state file that already records
|
|
60
|
-
* exactly which addresses this configuration manages.
|
|
61
|
-
*
|
|
62
|
-
* So the answer here is state membership. An address `terraform show -json`
|
|
63
|
-
* returns is `owned`; anything else is `unknown`. Concretely that makes a
|
|
64
|
-
* declared `module` block `unknown`: the state carries the module's
|
|
65
|
-
* resources, never a row for the block itself, so chant can see the block is
|
|
66
|
-
* live without the state ever saying that block is managed. `unknown` never
|
|
67
|
-
* escalates to a delete, which is the correct posture for a thing chant did
|
|
68
|
-
* not read a verdict for.
|
|
69
|
-
*
|
|
70
|
-
* That places a stock terraform root on the trusted-state-file row of the
|
|
71
|
-
* third axis in docs/src/content/docs/concepts/lifecycle-models.mdx, where
|
|
72
|
-
* chant elsewhere sits on the live-marker row. `docs/pages/observation.mdx`
|
|
73
|
-
* is the reader's version of this paragraph.
|
|
74
|
-
*
|
|
75
|
-
* ## The marker is the ownership answer, on a live root
|
|
76
|
-
*
|
|
77
|
-
* choudoufu keeps no authoritative state file. Every taggable resource it
|
|
78
|
-
* manages carries `tofu-estate` and `tofu-address` tags written in the create
|
|
79
|
-
* call, prior state is rebuilt from the live system each run, and the state
|
|
80
|
-
* file, where one exists at all, is a disposable cache. So a live root is on
|
|
81
|
-
* the live-marker row, the row every other chant lexicon sits in.
|
|
82
|
-
*
|
|
83
|
-
* chant does not re-derive that verdict from the tags. `live-plan -json`
|
|
84
|
-
* (choudoufu issue #788) already splits every declared instance four ways,
|
|
85
|
-
* and those four are the classification:
|
|
86
|
-
*
|
|
87
|
-
* | live-plan section | chant |
|
|
88
|
-
* |---|---|
|
|
89
|
-
* | `bound[]`, `source: "marker"` | present, `owned`; the marker named this estate and this address, and it is surfaced as `ResourceMetadata.marker` |
|
|
90
|
-
* | `bound[]`, any other source | present, `owned` by derivation, record, or cache; noted as such, and no marker is surfaced because none was read |
|
|
91
|
-
* | `unowned[]` with `adopt_*` | present, `unknown`; an adoptable match, carrying the exact two tag values #2105 would write |
|
|
92
|
-
* | `unowned[]` without | present, `foreign`; a live resource is in the way at a declared identity and the plan will not touch it |
|
|
93
|
-
* | `adoptable[]` | present, `unknown`; the same adoptable verdict, for a live resource the sweep content-matched to a declaration that carries no identity of its own (choudoufu #962, chant #2241) |
|
|
94
|
-
* | `omissions[]` | not-observed, `ABSENT` excepted (see below) |
|
|
95
|
-
*
|
|
96
|
-
* The ownership channel this declares is `./live-ownership.ts`'s
|
|
97
|
-
* `TERRAFORM_LIVE_MARKER_KEYS`, and its module doc holds the record of why
|
|
98
|
-
* the keys are declared while the verdicts are set here by hand rather than
|
|
99
|
-
* core's `OwnershipChannel` growing a classifier for them.
|
|
100
|
-
*
|
|
101
|
-
* ### `ABSENT` is absence, and the rest of the omissions are not
|
|
102
|
-
*
|
|
103
|
-
* An omission is choudoufu saying an instance is missing from prior state,
|
|
104
|
-
* with a reason. Most of those reasons are claims of ignorance and become
|
|
105
|
-
* NOT-OBSERVED, which is what the tri-state exists for. One is not:
|
|
106
|
-
* `ABSENT` means "the instance has a usable import identity and the provider
|
|
107
|
-
* reported, normally, that no such object exists", which is exactly chant's
|
|
108
|
-
* OBSERVED-ABSENT, spelled "in neither map". Reporting it as not-observed
|
|
109
|
-
* instead would mean a live root could never propose a create for a resource
|
|
110
|
-
* that genuinely is not there yet, which is the opposite of the honesty the
|
|
111
|
-
* contract is for. `UNOWNED` is the other exception, in the other direction:
|
|
112
|
-
* the `unowned[]` section answers for that address with a real verdict, so
|
|
113
|
-
* the paired omission is never read on its own.
|
|
114
|
-
*
|
|
115
|
-
* ### A block's instances, aggregated
|
|
116
|
-
*
|
|
117
|
-
* chant's entity is the HCL block, `aws_eip.pool`; the document's rows are
|
|
118
|
-
* instances, `aws_eip.pool[0]`. So a block's verdict is the aggregate of its
|
|
119
|
-
* instances, in this precedence: any instance not-observed makes the block
|
|
120
|
-
* not-observed, then foreign, then adoptable, then owned, and a block whose
|
|
121
|
-
* instances are all absent is absent. Partial knowledge is not knowledge,
|
|
122
|
-
* which is the same rule choudoufu applies to its own `INCOMPLETE_BLOCK`.
|
|
123
|
-
* The precedence is core's `TERRAFORM_INSTANCE_ROLLUP` and the rollup is
|
|
124
|
-
* core's `rollupInstances` (`@intentius/chant/instance-nodes`, #4454), the
|
|
125
|
-
* one place it is written.
|
|
126
|
-
*
|
|
127
|
-
* The block's verdict is not the whole answer. A present block also carries
|
|
128
|
-
* each instance's own verdict on `instances`, keyed as Terraform prints it
|
|
129
|
-
* (`[0]`, `["a"]`), which the live graph draws as an instance node under the
|
|
130
|
-
* block node (#4454). The state read does the same with the rows it found.
|
|
131
|
-
*
|
|
132
|
-
* ## What is readable at all
|
|
133
|
-
*
|
|
134
|
-
* `values.root_module.resources[]` (and, recursively, `child_modules[]`)
|
|
135
|
-
* carries `resource` and `data` blocks. A `terraform`, `provider`, `variable`,
|
|
136
|
-
* `output` or `locals` block has no row there and reads `unsupported-kind`.
|
|
137
|
-
* That is honest, not a gap to close by inventing an address for something
|
|
138
|
-
* that has none.
|
|
139
|
-
*
|
|
140
|
-
* A live root reads one block narrower. `live-plan`'s document is prior state
|
|
141
|
-
* for managed resources, so a `data` block has no row in it either and reads
|
|
142
|
-
* `unsupported-kind` there, where the stock reader can answer for it.
|
|
143
|
-
*
|
|
144
|
-
* ## Tri-state (#1089)
|
|
145
|
-
*
|
|
146
|
-
* A root whose `init` or `show` fails, or whose `live-plan` fails, reports
|
|
147
|
-
* EVERY entity declared in that root as not-observed with the mapped reason
|
|
148
|
-
* and the root named, never absent. A failed read must never render as a list
|
|
149
|
-
* of creates. Roots are read independently and merged (`mergeObservations`),
|
|
150
|
-
* so one broken backend does not un-observe a root that answered.
|
|
151
|
-
*
|
|
152
|
-
* ## Beyond the declared estate, on a live root
|
|
153
|
-
*
|
|
154
|
-
* `live-ls -estate -json` lists the whole estate off the Resource Groups
|
|
155
|
-
* Tagging API with no configuration read at all, which is a question a state
|
|
156
|
-
* file cannot answer: what does this estate hold that nothing declares? That
|
|
157
|
-
* is what makes `ambientKinds()`, `observeAmbient()` and `teardownOwned()`
|
|
158
|
-
* implementable on this lexicon for the first time. `-consistent` is always
|
|
159
|
-
* passed, because that index lags a tag write by about a minute
|
|
160
|
-
* (`live-ls`'s own help text) and a listing taken right after an apply can
|
|
161
|
-
* otherwise show a resource under both its old and new estate, or neither.
|
|
162
|
-
*
|
|
163
|
-
* ## The plan depth (#4358)
|
|
164
|
-
*
|
|
165
|
-
* A stock root can be read one depth further: `terraform.observe` (or a
|
|
166
|
-
* root's own `observe`) set to `"plan"`, or `CHANT_TERRAFORM_OBSERVE=plan`,
|
|
167
|
-
* or `depth: "plan"` from a caller. The read is `terraformPlanRead`:
|
|
168
|
-
* `plan -input=false -lock=false -out=<tmp>/plan.tfplan`, then `show -json`,
|
|
169
|
-
* with `<tmp>` under the OS temp directory and removed afterwards, and no
|
|
170
|
-
* `init`. Presence and ownership come from the plan's `prior_state` by the
|
|
171
|
-
* state read's own rule; `./plan-observation.ts` adds the plan's attributes
|
|
172
|
-
* (`planAction`, `planReplacePaths`, `planAfterUnknown`, `planDrift`, ...)
|
|
173
|
-
* to each present block, with sensitive values redacted.
|
|
174
|
-
*
|
|
175
|
-
* It falls back by depth (`planAdapter`): no provider credentials -> the
|
|
176
|
-
* state read; no backend, or a root that needs `init` -> declared only. Each
|
|
177
|
-
* root gets a note saying which read answered. A planned create has no row in
|
|
178
|
-
* `prior_state` and reads absent, as on the state read, so its plan
|
|
179
|
-
* attributes have nowhere to ride.
|
|
180
|
-
*
|
|
181
|
-
* ### On a live root (#4371)
|
|
182
|
-
*
|
|
183
|
-
* `live-plan -json` carries ownership and no attribute values (behold#404),
|
|
184
|
-
* and `choudoufu plan -out` writes a stock plan file (choudoufu #878). So a
|
|
185
|
-
* live root at the plan depth runs both (`livePlanDepthAdapter`):
|
|
186
|
-
* `live-plan -json` first, unchanged, for presence and ownership, then the
|
|
187
|
-
* same `terraformPlanRead` a stock root gets, whose attributes are added to
|
|
188
|
-
* each block `live-plan` bound. A foreign or adoptable block gets none: the
|
|
189
|
-
* plan proposes a create there, which is choudoufu's answer for an instance
|
|
190
|
-
* it does not own, not a fact about the live resource. `sources` reads
|
|
191
|
-
* `"live+plan"`.
|
|
192
|
-
*
|
|
193
|
-
* choudoufu rebuilds prior state from the account on every run, so on a live
|
|
194
|
-
* root out-of-band drift is not in `resource_drift`. It is the planned
|
|
195
|
-
* `update` itself: `planChanges` has the live value as `before` and the
|
|
196
|
-
* declared one as `after`, and `planDrift` stays empty. That is where #2472's
|
|
197
|
-
* property-level drift for a live root comes from.
|
|
198
|
-
*
|
|
199
|
-
* Falling back is one step: if the plan read fails, `live-plan` alone
|
|
200
|
-
* answered, the note says why, and `sources` reads `"live"`. If `live-plan`
|
|
201
|
-
* fails the root is not observed, as at the default depth, and the plan read
|
|
202
|
-
* is not tried, since its attributes would have no present block to ride.
|
|
203
|
-
* The cost is two refreshes of the estate per read, run one after the other
|
|
204
|
-
* so they never share the root's cache file.
|
|
205
|
-
*
|
|
206
|
-
* ## Engine facts on a live root (#4528)
|
|
207
|
-
*
|
|
208
|
-
* After `live-plan -json` answers, the same document is handed to `choudoufu
|
|
209
|
-
* live-graph -json -from-plan=<file>` (choudoufu#2285), which builds the
|
|
210
|
-
* root's graph from the configuration and that file alone: no second live
|
|
211
|
-
* read, so the facts and the verdicts above come from one refresh (choudoufu
|
|
212
|
-
* #1014, the #4520 ruling Q3). `<file>` is the `<root>.live-plan.json`
|
|
213
|
-
* written under {@link TERRAFORM_LIVE_PLAN_DIR_ENV} when the caller asked
|
|
214
|
-
* for it, and otherwise a copy in a temporary directory removed afterwards.
|
|
215
|
-
*
|
|
216
|
-
* The document's node ids are choudoufu's addresses (the ruling's Q2). A
|
|
217
|
-
* block node maps to its entity with {@link entityKeyFor}; an instance node
|
|
218
|
-
* (`instanceOf` set) maps to its block's entity, and its facts go on that
|
|
219
|
-
* block's `instances` entry of the same address, from which core's
|
|
220
|
-
* `observedInstanceNodeId` draws the instance node. Each node's `facts` land
|
|
221
|
-
* on `ResourceMetadata.facts` or `InstanceObservation.facts`, and edges with
|
|
222
|
-
* a grain land on the observation's `edges`, endpoints mapped the same way
|
|
223
|
-
* ({@link readEngineGraph}). Facts are never read for a decision: ownership
|
|
224
|
-
* and the change set keep reading the verdicts above.
|
|
225
|
-
*
|
|
226
|
-
* A choudoufu without the command, older than
|
|
227
|
-
* `MIN_CHOUDOUFU_GRAPH_VERSION`, answers with a usage error: `facts` stay
|
|
228
|
-
* absent, the root gets one note, and the rest of the read is unchanged. Any
|
|
229
|
-
* other failure of the graph read degrades the same way, with its own note.
|
|
230
|
-
*
|
|
231
|
-
* ## Nothing from `values` is surfaced
|
|
232
|
-
*
|
|
233
|
-
* A state row's `values` are the resource's full attribute set, secrets
|
|
234
|
-
* included, and `sensitive_values` describes only what the configuration
|
|
235
|
-
* declared sensitive. So the attributes reported here are the row's identity
|
|
236
|
-
* (address, type, mode, provider, root) and nothing from `values` except the
|
|
237
|
-
* `id`, which is the physical id every observation carries.
|
|
238
|
-
*/
|
|
239
|
-
|
|
240
|
-
import type {
|
|
241
|
-
DescribeResourcesResult,
|
|
242
|
-
ResourceMetadata,
|
|
243
|
-
TeardownCandidate,
|
|
244
|
-
TeardownEnumeration,
|
|
245
|
-
TeardownHole,
|
|
246
|
-
} from "@intentius/chant/lexicon";
|
|
247
|
-
import {
|
|
248
|
-
mergeObservations,
|
|
249
|
-
normalizeObservation,
|
|
250
|
-
observation,
|
|
251
|
-
observeEntities,
|
|
252
|
-
type DeclaredEntity,
|
|
253
|
-
type EntityObservation,
|
|
254
|
-
type ObserverAdapter,
|
|
255
|
-
type RootRead,
|
|
256
|
-
type UnobservedReason,
|
|
257
|
-
} from "@intentius/chant/observation";
|
|
258
|
-
import type { OwnershipMarker } from "@intentius/chant/ownership";
|
|
259
|
-
import {
|
|
260
|
-
observedInstanceNodeId,
|
|
261
|
-
rollupInstances,
|
|
262
|
-
terraformInstancePath,
|
|
263
|
-
TERRAFORM_INSTANCE_ROLLUP,
|
|
264
|
-
type InstanceObservation,
|
|
265
|
-
} from "@intentius/chant/instance-nodes";
|
|
266
|
-
import type { EdgeGrain, EngineFacts } from "@intentius/chant/engine-facts";
|
|
267
|
-
import type { IREdge } from "@intentius/chant/graph-ir";
|
|
268
|
-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
269
|
-
import { tmpdir } from "node:os";
|
|
270
|
-
import { isAbsolute, join } from "node:path";
|
|
271
|
-
import {
|
|
272
|
-
choudoufuLiveGraph,
|
|
273
|
-
choudoufuLiveLs,
|
|
274
|
-
choudoufuLivePlanDocument,
|
|
275
|
-
MIN_CHOUDOUFU_GRAPH_VERSION,
|
|
276
|
-
terraformInit,
|
|
277
|
-
terraformPlanRead,
|
|
278
|
-
terraformShow,
|
|
279
|
-
TerraformPlanReadError,
|
|
280
|
-
} from "./op/activities/terraform";
|
|
281
|
-
import { blockAddressOf, indexPlan, planAttributesFor, plannedAttributesFor, type PlanIndex } from "./plan-observation";
|
|
282
|
-
import type { TerraformObserveDepth } from "./config";
|
|
283
|
-
import { LIVE_PLAN_OMISSION_REASONS, readsAsCredentials } from "./live-plan-reasons";
|
|
284
|
-
import { DATA_TYPE, MODULE_TYPE, RESOURCE_TYPE, callersOfKey } from "./hcl/parse";
|
|
285
|
-
|
|
286
|
-
// The channel keys live in their own module so `plugin.ts` can declare
|
|
287
|
-
// `ownershipChannel` without loading this reader. Re-exported here because
|
|
288
|
-
// this is where they are used.
|
|
289
|
-
export { TERRAFORM_STATE_OWNERSHIP_KEYS } from "./state-ownership";
|
|
290
|
-
export { TERRAFORM_LIVE_MARKER_KEYS } from "./live-ownership";
|
|
291
|
-
export { LIVE_PLAN_OMISSION_REASONS } from "./live-plan-reasons";
|
|
292
|
-
|
|
293
|
-
/** One row out of `values.root_module.resources[]`, at any module depth. */
|
|
294
|
-
export interface StateResourceRow {
|
|
295
|
-
/** Fully qualified terraform address, `module.<name>.` prefixes included. */
|
|
296
|
-
address: string;
|
|
297
|
-
/** `managed` for a `resource` block, `data` for a `data` block. */
|
|
298
|
-
mode?: string;
|
|
299
|
-
/** Resource type, e.g. `null_resource`. */
|
|
300
|
-
type?: string;
|
|
301
|
-
/** Provider that owns the row, e.g. `registry.terraform.io/hashicorp/null`. */
|
|
302
|
-
providerName?: string;
|
|
303
|
-
/** `values.id`, when the row carries a string id. Nothing else from `values` is read. */
|
|
304
|
-
id?: string;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/** What one root's state read produced. */
|
|
308
|
-
export interface StateIndex {
|
|
309
|
-
/** Every resource/data row, keyed by fully qualified address. */
|
|
310
|
-
rows: Map<string, StateResourceRow>;
|
|
311
|
-
/** Every `module.<name>` address the state carries a child module for, at any depth. */
|
|
312
|
-
modules: Set<string>;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function asRecord(value: unknown): Record<string, unknown> {
|
|
316
|
-
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
317
|
-
? (value as Record<string, unknown>)
|
|
318
|
-
: {};
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function asArray(value: unknown): unknown[] {
|
|
322
|
-
return Array.isArray(value) ? value : [];
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
function asString(value: unknown): string | undefined {
|
|
326
|
-
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Index a `terraform show -json` document by address.
|
|
331
|
-
*
|
|
332
|
-
* Terraform already writes fully qualified addresses inside `child_modules`
|
|
333
|
-
* (`module.cdn.null_resource.edge`, as `src/__fixtures__/show-state.json`
|
|
334
|
-
* records), so the module prefix is applied only when a row's own address is
|
|
335
|
-
* missing it. Belt and braces for an older `format_version`, never a second
|
|
336
|
-
* `module.cdn.` on top of the first.
|
|
337
|
-
*/
|
|
338
|
-
export function indexStateResources(showJson: unknown): StateIndex {
|
|
339
|
-
const rows = new Map<string, StateResourceRow>();
|
|
340
|
-
const modules = new Set<string>();
|
|
341
|
-
|
|
342
|
-
const walk = (module: unknown, prefix: string): void => {
|
|
343
|
-
const node = asRecord(module);
|
|
344
|
-
for (const entry of asArray(node.resources)) {
|
|
345
|
-
const row = asRecord(entry);
|
|
346
|
-
const raw = asString(row.address);
|
|
347
|
-
if (!raw) continue;
|
|
348
|
-
const address = prefix && !raw.startsWith(`${prefix}.`) ? `${prefix}.${raw}` : raw;
|
|
349
|
-
rows.set(address, {
|
|
350
|
-
address,
|
|
351
|
-
...(asString(row.mode) ? { mode: asString(row.mode) } : {}),
|
|
352
|
-
...(asString(row.type) ? { type: asString(row.type) } : {}),
|
|
353
|
-
...(asString(row.provider_name) ? { providerName: asString(row.provider_name) } : {}),
|
|
354
|
-
...(asString(asRecord(row.values).id) ? { id: asString(asRecord(row.values).id) } : {}),
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
for (const entry of asArray(node.child_modules)) {
|
|
358
|
-
const child = asRecord(entry);
|
|
359
|
-
const address = asString(child.address) ?? prefix;
|
|
360
|
-
if (address) modules.add(address);
|
|
361
|
-
walk(child, address ?? "");
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
walk(asRecord(asRecord(showJson).values).root_module, "");
|
|
366
|
-
return { rows, modules };
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* The ownership verdict for one declared address: `owned` when the state
|
|
371
|
-
* carries a row for it, `unknown` otherwise. Exported because it is the whole
|
|
372
|
-
* of terraform's ownership channel, and a channel with one rule deserves one
|
|
373
|
-
* function to point at.
|
|
374
|
-
*/
|
|
375
|
-
export function classifyStateOwnership(address: string, index: StateIndex): "owned" | "unknown" {
|
|
376
|
-
return index.rows.has(address) ? "owned" : "unknown";
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* True when `instance` is the module call `address` itself or sits beneath it,
|
|
381
|
-
* at any instance key. `address` is a declared module address with no keys
|
|
382
|
-
* (`module.app`, `module.outer.module.inner`); a state or live-plan address
|
|
383
|
-
* carries them (`module.app[0]`, `module.outer["a"].module.inner[1].aws_eip.x`),
|
|
384
|
-
* so the keys come off before the prefix test (#4513).
|
|
385
|
-
*/
|
|
386
|
-
function underModule(instance: string, address: string): boolean {
|
|
387
|
-
const block = blockAddressOf(instance);
|
|
388
|
-
return block === address || block.startsWith(`${address}.`);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/** True when the state carries at least one resource beneath `module.<name>`. */
|
|
392
|
-
function moduleIsLive(address: string, index: StateIndex): boolean {
|
|
393
|
-
// A keyed call's child_modules[] entries are `module.app[0]`, never
|
|
394
|
-
// `module.app`, and so are its rows' prefixes (#4513).
|
|
395
|
-
for (const module of index.modules) if (underModule(module, address)) return true;
|
|
396
|
-
for (const key of index.rows.keys()) if (underModule(key, address)) return true;
|
|
397
|
-
return false;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/* ─────────────────────────── live roots (#2104) ─────────────────────────── */
|
|
401
|
-
|
|
402
|
-
/** One `bound[]` entry: a declared instance the plan admitted into prior state. */
|
|
403
|
-
export interface LivePlanBoundRow {
|
|
404
|
-
addr: string;
|
|
405
|
-
type?: string;
|
|
406
|
-
/** The import id it bound to, when the resolver produced one. */
|
|
407
|
-
identity?: string;
|
|
408
|
-
/** Which admission path supplied the identity: `marker`, `record`, `derived` or `cache`. */
|
|
409
|
-
source?: string;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/** One `omissions[]` entry: a declared instance the plan could not read, and why. */
|
|
413
|
-
export interface LivePlanOmissionRow {
|
|
414
|
-
addr: string;
|
|
415
|
-
/** choudoufu's own machine-readable code (`ABSENT`, `FAILED`, `UNOWNED`, …). */
|
|
416
|
-
reason: string;
|
|
417
|
-
detail: string;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/** One `unowned[]` entry: a live resource at a declared identity without this estate's marker. */
|
|
421
|
-
export interface LivePlanUnownedRow {
|
|
422
|
-
addr: string;
|
|
423
|
-
type?: string;
|
|
424
|
-
identity?: string;
|
|
425
|
-
/** `tofu_estate`: the marker it does carry, when it carries one. Empty means no marker at all. */
|
|
426
|
-
heldBy?: string;
|
|
427
|
-
/** `adopt_tofu_estate`: present exactly when adoption is this run's to offer. */
|
|
428
|
-
adoptEstate?: string;
|
|
429
|
-
/** `adopt_tofu_address`: the escaped address the adopting tag write would carry. */
|
|
430
|
-
adoptAddress?: string;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* One `adoptable[]` entry: a live resource the estate-wide sweep matched to a
|
|
435
|
-
* declared instance by content rather than by reading a declared identity
|
|
436
|
-
* (choudoufu #962). The declaration names no identity at all, so this is the
|
|
437
|
-
* only row the document has for it and the paired omission says
|
|
438
|
-
* `NEEDS_DISCOVERY`.
|
|
439
|
-
*
|
|
440
|
-
* Same fields as {@link LivePlanUnownedRow} minus `heldBy`, which cannot
|
|
441
|
-
* apply: a row here carries no marker for any estate, or the sweep would have
|
|
442
|
-
* called it foreign instead of unclaimed.
|
|
443
|
-
*/
|
|
444
|
-
export interface LivePlanAdoptableRow {
|
|
445
|
-
addr: string;
|
|
446
|
-
type?: string;
|
|
447
|
-
identity?: string;
|
|
448
|
-
adoptEstate?: string;
|
|
449
|
-
adoptAddress?: string;
|
|
450
|
-
/** `matched[]`: the arguments the declaration and the live resource agreed on exactly. */
|
|
451
|
-
matched?: Array<{ attribute: string; value: string }>;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/** A `live-plan -json` document, indexed by declared instance address. */
|
|
455
|
-
export interface LivePlanIndex {
|
|
456
|
-
/** `estate`: the estate every section was computed against. */
|
|
457
|
-
estate: string;
|
|
458
|
-
bound: Map<string, LivePlanBoundRow>;
|
|
459
|
-
omissions: Map<string, LivePlanOmissionRow>;
|
|
460
|
-
unowned: Map<string, LivePlanUnownedRow>;
|
|
461
|
-
adoptable: Map<string, LivePlanAdoptableRow>;
|
|
462
|
-
/**
|
|
463
|
-
* `swept[]`: the resource types the estate-wide sweep listed in full. Empty
|
|
464
|
-
* on every observation read, which asks for no sweep, so an empty
|
|
465
|
-
* `adoptable` beside it says nothing was asked rather than nothing found.
|
|
466
|
-
*/
|
|
467
|
-
swept: string[];
|
|
468
|
-
/** Every address any section named, so a block can find its own instances. */
|
|
469
|
-
addresses: string[];
|
|
470
|
-
/** `diagnostics[]` summaries, for the observation's run-level notes. */
|
|
471
|
-
diagnostics: string[];
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Index choudoufu issue #788's document. Unknown fields are ignored and a
|
|
476
|
-
* missing section reads as empty: a document from a newer choudoufu must
|
|
477
|
-
* degrade to "this section said nothing", never to a throw.
|
|
478
|
-
*/
|
|
479
|
-
export function indexLivePlan(document: unknown): LivePlanIndex {
|
|
480
|
-
const doc = asRecord(document);
|
|
481
|
-
const index: LivePlanIndex = {
|
|
482
|
-
estate: asString(doc.estate) ?? "",
|
|
483
|
-
bound: new Map(),
|
|
484
|
-
omissions: new Map(),
|
|
485
|
-
unowned: new Map(),
|
|
486
|
-
adoptable: new Map(),
|
|
487
|
-
swept: asArray(doc.swept).filter((t): t is string => typeof t === "string"),
|
|
488
|
-
addresses: [],
|
|
489
|
-
diagnostics: [],
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
for (const entry of asArray(doc.bound)) {
|
|
493
|
-
const row = asRecord(entry);
|
|
494
|
-
const addr = asString(row.addr);
|
|
495
|
-
if (!addr) continue;
|
|
496
|
-
index.bound.set(addr, {
|
|
497
|
-
addr,
|
|
498
|
-
...(asString(row.type) ? { type: asString(row.type) } : {}),
|
|
499
|
-
...(asString(row.identity) ? { identity: asString(row.identity) } : {}),
|
|
500
|
-
...(asString(row.source) ? { source: asString(row.source) } : {}),
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
for (const entry of asArray(doc.omissions)) {
|
|
505
|
-
const row = asRecord(entry);
|
|
506
|
-
const addr = asString(row.addr);
|
|
507
|
-
if (!addr) continue;
|
|
508
|
-
index.omissions.set(addr, {
|
|
509
|
-
addr,
|
|
510
|
-
reason: asString(row.reason) ?? "",
|
|
511
|
-
detail: asString(row.detail) ?? "",
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
for (const entry of asArray(doc.unowned)) {
|
|
516
|
-
const row = asRecord(entry);
|
|
517
|
-
const addr = asString(row.addr);
|
|
518
|
-
if (!addr) continue;
|
|
519
|
-
index.unowned.set(addr, {
|
|
520
|
-
addr,
|
|
521
|
-
...(asString(row.type) ? { type: asString(row.type) } : {}),
|
|
522
|
-
...(asString(row.identity) ? { identity: asString(row.identity) } : {}),
|
|
523
|
-
...(asString(row.tofu_estate) ? { heldBy: asString(row.tofu_estate) } : {}),
|
|
524
|
-
...(asString(row.adopt_tofu_estate) ? { adoptEstate: asString(row.adopt_tofu_estate) } : {}),
|
|
525
|
-
...(asString(row.adopt_tofu_address) ? { adoptAddress: asString(row.adopt_tofu_address) } : {}),
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
for (const entry of asArray(doc.adoptable)) {
|
|
530
|
-
const row = asRecord(entry);
|
|
531
|
-
const addr = asString(row.addr);
|
|
532
|
-
if (!addr) continue;
|
|
533
|
-
const matched = asArray(row.matched)
|
|
534
|
-
.map((m) => asRecord(m))
|
|
535
|
-
.filter((m) => asString(m.attribute))
|
|
536
|
-
.map((m) => ({ attribute: asString(m.attribute)!, value: asString(m.value) ?? "" }));
|
|
537
|
-
index.adoptable.set(addr, {
|
|
538
|
-
addr,
|
|
539
|
-
...(asString(row.type) ? { type: asString(row.type) } : {}),
|
|
540
|
-
...(asString(row.identity) ? { identity: asString(row.identity) } : {}),
|
|
541
|
-
...(asString(row.adopt_tofu_estate) ? { adoptEstate: asString(row.adopt_tofu_estate) } : {}),
|
|
542
|
-
...(asString(row.adopt_tofu_address) ? { adoptAddress: asString(row.adopt_tofu_address) } : {}),
|
|
543
|
-
...(matched.length > 0 ? { matched } : {}),
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
for (const entry of asArray(doc.diagnostics)) {
|
|
548
|
-
const row = asRecord(entry);
|
|
549
|
-
const summary = asString(row.summary);
|
|
550
|
-
if (summary) index.diagnostics.push(`${asString(row.severity) ?? "warning"}: ${summary}`);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
index.addresses = [
|
|
554
|
-
...new Set([
|
|
555
|
-
...index.bound.keys(),
|
|
556
|
-
...index.omissions.keys(),
|
|
557
|
-
...index.unowned.keys(),
|
|
558
|
-
...index.adoptable.keys(),
|
|
559
|
-
]),
|
|
560
|
-
].sort();
|
|
561
|
-
return index;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/** The chant verdict for one omission: `no-credentials` when its detail says so. */
|
|
565
|
-
function omissionVerdict(row: LivePlanOmissionRow): UnobservedReason | "absent" {
|
|
566
|
-
const mapped = LIVE_PLAN_OMISSION_REASONS[row.reason] ?? "read-failed";
|
|
567
|
-
if (mapped === "read-failed" && readsAsCredentials(row.detail)) return "no-credentials";
|
|
568
|
-
return mapped;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Every instance address in the document belonging to the declared block
|
|
573
|
-
* `address`. Exported for the behaviour request builder (`./behaviour/`,
|
|
574
|
-
* #2360), which places the same blocks against the same document.
|
|
575
|
-
*/
|
|
576
|
-
export function instancesOf(address: string, index: LivePlanIndex): string[] {
|
|
577
|
-
// `blockAddressOf` strips every key, so an instance under an expanded
|
|
578
|
-
// module call (`module.app[0].aws_eip.pool[1]`) is the block's too (#4488).
|
|
579
|
-
return index.addresses.filter((a) => a === address || a.startsWith(`${address}[`) || blockAddressOf(a) === address);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/** True when the document names any instance under `module.<name>`, at any depth. */
|
|
583
|
-
function liveModuleMembers(address: string, index: LivePlanIndex): string[] {
|
|
584
|
-
// Keys stripped first, so a nested call under a keyed one
|
|
585
|
-
// (`module.outer[0].module.inner["a"].…`) is a member too (#4513).
|
|
586
|
-
return index.addresses.filter((a) => underModule(a, address));
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
/** One instance's verdict, before a block aggregates its instances. */
|
|
590
|
-
export type InstanceVerdict =
|
|
591
|
-
| { kind: "owned"; row: LivePlanBoundRow }
|
|
592
|
-
| { kind: "adoptable"; row: LivePlanAdoptableRow }
|
|
593
|
-
| { kind: "foreign"; row: LivePlanUnownedRow }
|
|
594
|
-
| { kind: "absent" }
|
|
595
|
-
| { kind: "unobserved"; reason: UnobservedReason; detail: string };
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* Classify one instance address against the document, `unowned[]` first: a
|
|
599
|
-
* declared instance that also carries a `UNOWNED` omission is answered by the
|
|
600
|
-
* section that has the verdict, not by the one that has the apology.
|
|
601
|
-
* `adoptable[]` sits under `bound[]` for the same reason, one rung further
|
|
602
|
-
* down: a content match is the answer for an instance nothing else could
|
|
603
|
-
* answer for, and its paired omission is always `NEEDS_DISCOVERY`, which on
|
|
604
|
-
* its own would read as unsupported-kind and hide a real, actionable verdict
|
|
605
|
-
* (choudoufu #962, chant #2241).
|
|
606
|
-
*/
|
|
607
|
-
export function classifyLiveInstance(address: string, index: LivePlanIndex): InstanceVerdict {
|
|
608
|
-
const unowned = index.unowned.get(address);
|
|
609
|
-
if (unowned) {
|
|
610
|
-
return unowned.adoptEstate || unowned.adoptAddress
|
|
611
|
-
? { kind: "adoptable", row: unowned }
|
|
612
|
-
: { kind: "foreign", row: unowned };
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
const bound = index.bound.get(address);
|
|
616
|
-
if (bound) return { kind: "owned", row: bound };
|
|
617
|
-
|
|
618
|
-
const matched = index.adoptable.get(address);
|
|
619
|
-
if (matched && (matched.adoptEstate || matched.adoptAddress)) {
|
|
620
|
-
return { kind: "adoptable", row: matched };
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
const omission = index.omissions.get(address);
|
|
624
|
-
if (omission) {
|
|
625
|
-
const verdict = omissionVerdict(omission);
|
|
626
|
-
if (verdict === "absent") return { kind: "absent" };
|
|
627
|
-
return {
|
|
628
|
-
kind: "unobserved",
|
|
629
|
-
reason: verdict,
|
|
630
|
-
detail: `${address}: ${omission.reason}${omission.detail ? ` — ${omission.detail}` : ""}`,
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
return { kind: "absent" };
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* Where one instance address of the declared block `address` sits: its own
|
|
639
|
-
* key and the expanded module path (`@intentius/chant/instance-nodes`), or
|
|
640
|
-
* undefined when it is the block's unexpanded address or another block's.
|
|
641
|
-
* An instance under an expanded module call carries `scope` (#4488), so the
|
|
642
|
-
* live graph draws it under the same id the declared graph lists.
|
|
643
|
-
*/
|
|
644
|
-
function instanceKeyAndScope(address: string, instance: string): { key?: string; scope?: string } | undefined {
|
|
645
|
-
if (instance === address || blockAddressOf(instance) !== address) return undefined;
|
|
646
|
-
const path = terraformInstancePath(instance);
|
|
647
|
-
if (!path) return undefined;
|
|
648
|
-
return { ...(path.key !== undefined ? { key: path.key } : {}), ...(path.scope !== undefined ? { scope: path.scope } : {}) };
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Each instance's own verdict (#4454), keyed as Terraform prints it, for the
|
|
653
|
-
* block's `instances`. An instance under an expanded module call carries its
|
|
654
|
-
* module path as `scope` (#4488) and its own key when the block is expanded too.
|
|
655
|
-
*/
|
|
656
|
-
function liveInstanceObservations(address: string, instances: readonly string[], verdicts: readonly InstanceVerdict[]): InstanceObservation[] {
|
|
657
|
-
const out: InstanceObservation[] = [];
|
|
658
|
-
instances.forEach((a, i) => {
|
|
659
|
-
const at = instanceKeyAndScope(address, a);
|
|
660
|
-
if (at === undefined) return;
|
|
661
|
-
const v = verdicts[i]!;
|
|
662
|
-
switch (v.kind) {
|
|
663
|
-
case "owned":
|
|
664
|
-
out.push({ ...at, address: a, verdict: "present", ownership: "owned", status: "bound", ...(v.row.identity ? { physicalId: v.row.identity } : {}) });
|
|
665
|
-
break;
|
|
666
|
-
case "foreign":
|
|
667
|
-
out.push({ ...at, address: a, verdict: "present", ownership: "foreign", status: "unowned", ...(v.row.identity ? { physicalId: v.row.identity } : {}) });
|
|
668
|
-
break;
|
|
669
|
-
case "adoptable":
|
|
670
|
-
out.push({ ...at, address: a, verdict: "present", ownership: "unknown", status: "adoptable", ...(v.row.identity ? { physicalId: v.row.identity } : {}) });
|
|
671
|
-
break;
|
|
672
|
-
case "absent":
|
|
673
|
-
out.push({ ...at, address: a, verdict: "absent" });
|
|
674
|
-
break;
|
|
675
|
-
case "unobserved":
|
|
676
|
-
out.push({ ...at, address: a, verdict: "not-observed", reason: v.reason, detail: v.detail });
|
|
677
|
-
break;
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
|
-
return out;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* The declared block's verdict, aggregated over its instances in the
|
|
685
|
-
* precedence the module doc states: not-observed, then foreign, then
|
|
686
|
-
* adoptable, then owned, and all-absent last. A block whose instances are
|
|
687
|
-
* only partly known is not partly owned; it is unknown, which never becomes
|
|
688
|
-
* a delete.
|
|
689
|
-
*/
|
|
690
|
-
function readLiveResource(
|
|
691
|
-
entity: TerraformDeclared,
|
|
692
|
-
index: LivePlanIndex,
|
|
693
|
-
root: string,
|
|
694
|
-
queried: string,
|
|
695
|
-
): EntityObservation {
|
|
696
|
-
const { address } = entity;
|
|
697
|
-
const instances = instancesOf(address, index);
|
|
698
|
-
if (instances.length === 0) return { absent: true, queried };
|
|
699
|
-
|
|
700
|
-
const verdicts = instances.map((a) => classifyLiveInstance(a, index));
|
|
701
|
-
const attributes: Record<string, unknown> = { address, root, estate: index.estate };
|
|
702
|
-
const expanded = instances.length > 1 || instances[0] !== address;
|
|
703
|
-
if (expanded) attributes.instances = instances;
|
|
704
|
-
const perInstance = expanded ? liveInstanceObservations(address, instances, verdicts) : [];
|
|
705
|
-
const withInstances = perInstance.length > 0 ? { instances: perInstance } : {};
|
|
706
|
-
|
|
707
|
-
const top = rollupInstances(verdicts, TERRAFORM_INSTANCE_ROLLUP);
|
|
708
|
-
|
|
709
|
-
if (top?.kind === "unobserved") {
|
|
710
|
-
return { unobserved: { reason: top.reason, detail: top.detail }, queried };
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
const foreign = top;
|
|
714
|
-
if (foreign?.kind === "foreign") {
|
|
715
|
-
return {
|
|
716
|
-
present: {
|
|
717
|
-
...withInstances,
|
|
718
|
-
type: entity.type,
|
|
719
|
-
physicalId: foreign.row.identity ?? address,
|
|
720
|
-
status: "unowned",
|
|
721
|
-
ownership: "foreign",
|
|
722
|
-
attributes: {
|
|
723
|
-
...attributes,
|
|
724
|
-
...(foreign.row.type ? { resourceType: foreign.row.type } : {}),
|
|
725
|
-
...(foreign.row.heldBy ? { heldBy: foreign.row.heldBy } : {}),
|
|
726
|
-
},
|
|
727
|
-
},
|
|
728
|
-
queried,
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
const adoptable = top;
|
|
733
|
-
if (adoptable?.kind === "adoptable") {
|
|
734
|
-
// `unknown`, not `foreign`: the resource matches the declaration and one
|
|
735
|
-
// tag write claims it. The two values that write carries are the whole
|
|
736
|
-
// adoption proposal #2105 builds its Op on, so they ride the metadata
|
|
737
|
-
// rather than being re-derived from the address there. No `marker` is
|
|
738
|
-
// surfaced, because nothing was read off this resource: it carries none.
|
|
739
|
-
return {
|
|
740
|
-
present: {
|
|
741
|
-
...withInstances,
|
|
742
|
-
type: entity.type,
|
|
743
|
-
physicalId: adoptable.row.identity ?? address,
|
|
744
|
-
status: "adoptable",
|
|
745
|
-
ownership: "unknown",
|
|
746
|
-
attributes: {
|
|
747
|
-
...attributes,
|
|
748
|
-
...(adoptable.row.type ? { resourceType: adoptable.row.type } : {}),
|
|
749
|
-
...(adoptable.row.adoptEstate ? { adoptTofuEstate: adoptable.row.adoptEstate } : {}),
|
|
750
|
-
...(adoptable.row.adoptAddress ? { adoptTofuAddress: adoptable.row.adoptAddress } : {}),
|
|
751
|
-
// Present only on a content match: the arguments the sweep compared,
|
|
752
|
-
// which is the whole evidence for a match nobody read an identity
|
|
753
|
-
// for, and the thing an operator checks before letting a tag write
|
|
754
|
-
// claim the resource.
|
|
755
|
-
...(adoptable.row.matched?.length
|
|
756
|
-
? { matchedOn: adoptable.row.matched.map((m) => `${m.attribute}=${m.value}`) }
|
|
757
|
-
: {}),
|
|
758
|
-
},
|
|
759
|
-
},
|
|
760
|
-
queried,
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
if (top?.kind !== "owned") return { absent: true, queried };
|
|
765
|
-
const owned = verdicts.filter((v) => v.kind === "owned") as Array<{ kind: "owned"; row: LivePlanBoundRow }>;
|
|
766
|
-
|
|
767
|
-
const sources = [...new Set(owned.map((v) => v.row.source ?? "unknown"))].sort();
|
|
768
|
-
const byMarker = sources.length === 1 && sources[0] === "marker";
|
|
769
|
-
return {
|
|
770
|
-
present: {
|
|
771
|
-
...withInstances,
|
|
772
|
-
type: entity.type,
|
|
773
|
-
physicalId: owned.length === 1 ? (owned[0]!.row.identity ?? address) : address,
|
|
774
|
-
status: "bound",
|
|
775
|
-
ownership: "owned",
|
|
776
|
-
// The marker is surfaced only where one was actually read. A `derived`
|
|
777
|
-
// bind computed the identity from the configuration and looked at no
|
|
778
|
-
// tag, so claiming a marker for it would be a guess.
|
|
779
|
-
...(byMarker ? { marker: { stack: index.estate } as OwnershipMarker } : {}),
|
|
780
|
-
attributes: {
|
|
781
|
-
...attributes,
|
|
782
|
-
...(owned[0]!.row.type ? { resourceType: owned[0]!.row.type } : {}),
|
|
783
|
-
boundBy: sources.join(","),
|
|
784
|
-
},
|
|
785
|
-
},
|
|
786
|
-
queried,
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
/**
|
|
791
|
-
* The environment variable that asks for each live root's `live-plan -json`
|
|
792
|
-
* document as a file, in a directory the caller owns (behold#924).
|
|
793
|
-
*
|
|
794
|
-
* The overlay keeps chant's verdict per block and drops the rows behind it:
|
|
795
|
-
* each instance's omission reason and detail, `identity_values`, the adoptable
|
|
796
|
-
* row's own fields. A caller that paints ownership from those rows and wants
|
|
797
|
-
* the plan's attributes from the plan depth would otherwise run its own
|
|
798
|
-
* `live-plan` beside this one, two refreshes of the estate that can disagree
|
|
799
|
-
* (choudoufu #1014). With this set to an absolute directory, the document this
|
|
800
|
-
* read used is written there as `<root>.live-plan.json`, so the caller reads
|
|
801
|
-
* the same `live-plan` the verdicts came from.
|
|
802
|
-
*
|
|
803
|
-
* Opt-in, and never inside the root: a relative path is ignored, so nothing
|
|
804
|
-
* lands in the root by accident (#4379). A write that fails is ignored too;
|
|
805
|
-
* the read answers either way, and the caller sees no file.
|
|
806
|
-
*/
|
|
807
|
-
export const TERRAFORM_LIVE_PLAN_DIR_ENV = "CHANT_TERRAFORM_LIVE_PLAN_DIR";
|
|
808
|
-
|
|
809
|
-
/** The file {@link TERRAFORM_LIVE_PLAN_DIR_ENV} names for a root: the root's name, made safe for a file name. */
|
|
810
|
-
export function livePlanDocumentFile(root: string): string {
|
|
811
|
-
return `${root.replace(/[^A-Za-z0-9._-]/g, "_")}.live-plan.json`;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* Write a live root's document where {@link TERRAFORM_LIVE_PLAN_DIR_ENV} asks,
|
|
816
|
-
* if it asks. The path written, or undefined when nothing was.
|
|
817
|
-
*/
|
|
818
|
-
function handLivePlanDocument(root: string, json: unknown): string | undefined {
|
|
819
|
-
const out = process.env[TERRAFORM_LIVE_PLAN_DIR_ENV];
|
|
820
|
-
if (!out || !isAbsolute(out)) return undefined;
|
|
821
|
-
try {
|
|
822
|
-
mkdirSync(out, { recursive: true });
|
|
823
|
-
const file = join(out, livePlanDocumentFile(root));
|
|
824
|
-
writeFileSync(file, JSON.stringify(json));
|
|
825
|
-
return file;
|
|
826
|
-
} catch {
|
|
827
|
-
// Best effort: the read's answer does not depend on the copy.
|
|
828
|
-
return undefined;
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
/**
|
|
833
|
-
* What a live root's bind leaves for the engine graph read (#4528): the
|
|
834
|
-
* `live-plan -json` document it indexed, the file it was handed to under
|
|
835
|
-
* {@link TERRAFORM_LIVE_PLAN_DIR_ENV} if any, and the estate.
|
|
836
|
-
*/
|
|
837
|
-
interface LivePlanHandoff {
|
|
838
|
-
json?: unknown;
|
|
839
|
-
file?: string;
|
|
840
|
-
estate?: string;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* One live root's reader: `live-plan -json`, then address matching against
|
|
845
|
-
* the document. `terraform show` is never run here, and there is no state
|
|
846
|
-
* file to run it over.
|
|
847
|
-
*/
|
|
848
|
-
function liveAdapter(
|
|
849
|
-
root: string,
|
|
850
|
-
cwd: string | undefined,
|
|
851
|
-
deps: TerraformReadDeps,
|
|
852
|
-
handoff: LivePlanHandoff = {},
|
|
853
|
-
): ObserverAdapter<LivePlanIndex> {
|
|
854
|
-
const where = cwd ? { cwd } : {};
|
|
855
|
-
let dir: string | undefined;
|
|
856
|
-
|
|
857
|
-
return {
|
|
858
|
-
async bind(): Promise<LivePlanIndex> {
|
|
859
|
-
const planned = await deps.livePlan({ root, ...where });
|
|
860
|
-
dir = planned.dir;
|
|
861
|
-
const file = handLivePlanDocument(root, planned.json);
|
|
862
|
-
const index = indexLivePlan(planned.json);
|
|
863
|
-
handoff.json = planned.json;
|
|
864
|
-
handoff.estate = planned.estate ?? index.estate;
|
|
865
|
-
if (file) handoff.file = file;
|
|
866
|
-
return index;
|
|
867
|
-
},
|
|
868
|
-
|
|
869
|
-
classifyBindFailure(err) {
|
|
870
|
-
const message = err instanceof Error ? err.message.split("\n")[0] : String(err);
|
|
871
|
-
const full = err instanceof Error ? err.message : String(err);
|
|
872
|
-
return {
|
|
873
|
-
reason: readsAsCredentials(full) ? "no-credentials" : "read-failed",
|
|
874
|
-
detail: `terraform.roots.${root}${dir ? ` (${dir})` : ""}: ${message}`,
|
|
875
|
-
};
|
|
876
|
-
},
|
|
877
|
-
|
|
878
|
-
async read(index, entity): Promise<EntityObservation> {
|
|
879
|
-
const declared = entity as TerraformDeclared;
|
|
880
|
-
const { address } = declared;
|
|
881
|
-
const queried = `choudoufu live-plan -json (root "${root}", estate "${index.estate}", address "${address}")`;
|
|
882
|
-
|
|
883
|
-
if (entity.type === RESOURCE_TYPE) return readLiveResource(declared, index, root, queried);
|
|
884
|
-
|
|
885
|
-
if (entity.type === DATA_TYPE) {
|
|
886
|
-
return {
|
|
887
|
-
unobserved: {
|
|
888
|
-
reason: "unsupported-kind",
|
|
889
|
-
detail:
|
|
890
|
-
"live-plan's document is prior state for managed resources; a data block has no row in bound, omissions or unowned",
|
|
891
|
-
},
|
|
892
|
-
queried,
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
if (entity.type === MODULE_TYPE) {
|
|
897
|
-
const members = liveModuleMembers(address, index);
|
|
898
|
-
if (members.length === 0) return { absent: true, queried };
|
|
899
|
-
// Same shape as the stock reader's module answer, for the same
|
|
900
|
-
// reason: the document names the module's resources and never the
|
|
901
|
-
// block itself, so the ownership channel has nothing to say about it.
|
|
902
|
-
return {
|
|
903
|
-
present: {
|
|
904
|
-
type: entity.type,
|
|
905
|
-
physicalId: address,
|
|
906
|
-
status: "module",
|
|
907
|
-
ownership: "unknown",
|
|
908
|
-
attributes: { address, root, estate: index.estate, instances: members },
|
|
909
|
-
},
|
|
910
|
-
queried,
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
return {
|
|
915
|
-
unobserved: {
|
|
916
|
-
reason: "unsupported-kind",
|
|
917
|
-
detail: `${entity.type} has no row in a live-plan document: only resource blocks do`,
|
|
918
|
-
},
|
|
919
|
-
queried,
|
|
920
|
-
};
|
|
921
|
-
},
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
/* ─────────────────────── engine facts (#4528) ──────────────────────────── */
|
|
926
|
-
|
|
927
|
-
/** {@link readEngineGraph}'s answer: facts and edges keyed in chant's id space. */
|
|
928
|
-
export interface EngineGraphRead {
|
|
929
|
-
/** Facts of a block node, by entity key. */
|
|
930
|
-
blocks: Map<string, EngineFacts>;
|
|
931
|
-
/** Facts of an instance node, by its block's entity key, then by the instance address. */
|
|
932
|
-
instances: Map<string, Map<string, EngineFacts>>;
|
|
933
|
-
/** Edges with a grain, endpoints as live graph node ids. */
|
|
934
|
-
edges: IREdge[];
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
const GRAINS: ReadonlySet<string> = new Set<EdgeGrain>(["block", "instance", "property"]);
|
|
938
|
-
const OWNERSHIPS: ReadonlySet<string> = new Set(["bound", "unowned", "pending", "foreign"]);
|
|
939
|
-
const OWNED_BY: ReadonlySet<string> = new Set(["marker", "record", "name"]);
|
|
940
|
-
|
|
941
|
-
/**
|
|
942
|
-
* One node's `facts`, keeping only the fields of chant's `EngineFacts` and
|
|
943
|
-
* only values of the shape it declares. Undefined when nothing is left.
|
|
944
|
-
*/
|
|
945
|
-
function engineFactsOf(value: unknown): EngineFacts | undefined {
|
|
946
|
-
const f = asRecord(value);
|
|
947
|
-
const out: EngineFacts = {};
|
|
948
|
-
const ownership = asString(f.ownership);
|
|
949
|
-
if (ownership && OWNERSHIPS.has(ownership)) out.ownership = ownership as EngineFacts["ownership"];
|
|
950
|
-
const ownedBy = asString(f.ownedBy);
|
|
951
|
-
if (ownedBy && OWNED_BY.has(ownedBy)) out.ownedBy = ownedBy as EngineFacts["ownedBy"];
|
|
952
|
-
const markers = asRecord(f.markers);
|
|
953
|
-
const encoding = asString(markers.encoding);
|
|
954
|
-
const source = asString(markers.source);
|
|
955
|
-
if ((encoding === "plain" || encoding === "escaped" || encoding === "digest") && (source === "live" || source === "record")) {
|
|
956
|
-
out.markers = {
|
|
957
|
-
...(asString(markers.owner) ? { owner: asString(markers.owner) } : {}),
|
|
958
|
-
...(asString(markers.address) ? { address: asString(markers.address) } : {}),
|
|
959
|
-
encoding,
|
|
960
|
-
source,
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
const cloudIds = asArray(f.cloudIds)
|
|
964
|
-
.map((c) => ({ kind: asString(asRecord(c).kind), value: asString(asRecord(c).value) }))
|
|
965
|
-
.filter((c): c is NonNullable<EngineFacts["cloudIds"]>[number] =>
|
|
966
|
-
c.value !== undefined && ["import-id", "arn", "provider-id", "self-link", "k8s-uid"].includes(c.kind ?? ""),
|
|
967
|
-
);
|
|
968
|
-
if (cloudIds.length > 0) out.cloudIds = cloudIds;
|
|
969
|
-
const history = asRecord(f.recordVersions);
|
|
970
|
-
if (typeof history.kept === "boolean") {
|
|
971
|
-
out.recordVersions = {
|
|
972
|
-
kept: history.kept,
|
|
973
|
-
versions: asArray(history.versions).flatMap((v) => {
|
|
974
|
-
const r = asRecord(v);
|
|
975
|
-
const id = asString(r.id);
|
|
976
|
-
const writtenAt = asString(r.writtenAt);
|
|
977
|
-
return id && writtenAt ? [{ id, writtenAt, current: r.current === true, deleted: r.deleted === true }] : [];
|
|
978
|
-
}),
|
|
979
|
-
};
|
|
980
|
-
}
|
|
981
|
-
const observedAt = asString(f.observedAt);
|
|
982
|
-
if (observedAt) out.observedAt = observedAt;
|
|
983
|
-
return Object.keys(out).length > 0 ? out : undefined;
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
/**
|
|
987
|
-
* Read an engine graph document (`choudoufu live-graph -json`, chant#4527's
|
|
988
|
-
* schema) for one root into chant's id space. Node ids are choudoufu's
|
|
989
|
-
* addresses (the #4520 ruling, Q2): a block node is the entity
|
|
990
|
-
* {@link entityKeyFor} names; an instance node (`instanceOf`) belongs to its
|
|
991
|
-
* block's entity, and as an edge endpoint it is the live instance node id
|
|
992
|
-
* core's `observedInstanceNodeId` gives. A node with no address (an estate
|
|
993
|
-
* the configuration reads, `estate:<name>`) has no chant entity, so its
|
|
994
|
-
* edges are left out. Edges keep their grain; one without a grain is left out.
|
|
995
|
-
*
|
|
996
|
-
* Throws when the document is not an engine graph document.
|
|
997
|
-
*/
|
|
998
|
-
export function readEngineGraph(root: string, document: unknown): EngineGraphRead {
|
|
999
|
-
const doc = asRecord(document);
|
|
1000
|
-
const engineGraph = asRecord(asRecord(doc.meta).engineGraph);
|
|
1001
|
-
if (doc.version !== 1 || engineGraph.format !== 1 || !Array.isArray(doc.nodes)) {
|
|
1002
|
-
throw new Error("not an engine graph document (want GraphIR version 1 with meta.engineGraph format 1)");
|
|
1003
|
-
}
|
|
1004
|
-
const blocks = new Map<string, EngineFacts>();
|
|
1005
|
-
const instances = new Map<string, Map<string, EngineFacts>>();
|
|
1006
|
-
const nodeIds = new Map<string, string>();
|
|
1007
|
-
|
|
1008
|
-
for (const entry of doc.nodes) {
|
|
1009
|
-
const node = asRecord(entry);
|
|
1010
|
-
const id = asString(node.id);
|
|
1011
|
-
const address = asString(asRecord(node.attrs).address);
|
|
1012
|
-
if (!id || !address) continue;
|
|
1013
|
-
const facts = engineFactsOf(node.facts);
|
|
1014
|
-
const instanceOf = asString(node.instanceOf);
|
|
1015
|
-
if (instanceOf) {
|
|
1016
|
-
const block = entityKeyFor(root, instanceOf);
|
|
1017
|
-
const key = asString(node.instanceKey);
|
|
1018
|
-
const scope = asString(node.instanceScope);
|
|
1019
|
-
const liveId = observedInstanceNodeId(block, {
|
|
1020
|
-
address: id,
|
|
1021
|
-
...(key !== undefined ? { key } : {}),
|
|
1022
|
-
...(scope !== undefined ? { scope } : {}),
|
|
1023
|
-
});
|
|
1024
|
-
if (liveId) nodeIds.set(id, liveId);
|
|
1025
|
-
if (facts) {
|
|
1026
|
-
let byAddress = instances.get(block);
|
|
1027
|
-
if (!byAddress) instances.set(block, (byAddress = new Map()));
|
|
1028
|
-
byAddress.set(id, facts);
|
|
1029
|
-
}
|
|
1030
|
-
continue;
|
|
1031
|
-
}
|
|
1032
|
-
const key = entityKeyFor(root, id);
|
|
1033
|
-
nodeIds.set(id, key);
|
|
1034
|
-
if (facts) blocks.set(key, facts);
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
const edges: IREdge[] = [];
|
|
1038
|
-
const seen = new Set<string>();
|
|
1039
|
-
for (const entry of asArray(doc.edges)) {
|
|
1040
|
-
const edge = asRecord(entry);
|
|
1041
|
-
const grain = asString(edge.grain);
|
|
1042
|
-
if (!grain || !GRAINS.has(grain)) continue;
|
|
1043
|
-
const from = nodeIds.get(asString(edge.from) ?? "");
|
|
1044
|
-
const to = nodeIds.get(asString(edge.to) ?? "");
|
|
1045
|
-
if (!from || !to || from === to) continue;
|
|
1046
|
-
const viaAttr = asString(edge.viaAttr);
|
|
1047
|
-
const key = `${from}\0${to}\0${viaAttr ?? ""}\0${grain}`;
|
|
1048
|
-
if (seen.has(key)) continue;
|
|
1049
|
-
seen.add(key);
|
|
1050
|
-
edges.push({ from, to, kind: "ref", ...(viaAttr ? { viaAttr } : {}), grain: grain as EdgeGrain });
|
|
1051
|
-
}
|
|
1052
|
-
return { blocks, instances, edges };
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
/**
|
|
1056
|
-
* `resources` with {@link readEngineGraph}'s facts on them: a block's on
|
|
1057
|
-
* `ResourceMetadata.facts`, an instance's on its `instances` entry of the
|
|
1058
|
-
* same address. Nothing else changes, and nothing is added for an entity the
|
|
1059
|
-
* read did not return.
|
|
1060
|
-
*/
|
|
1061
|
-
export function withEngineFacts(
|
|
1062
|
-
resources: Record<string, ResourceMetadata>,
|
|
1063
|
-
read: EngineGraphRead,
|
|
1064
|
-
): Record<string, ResourceMetadata> {
|
|
1065
|
-
const out: Record<string, ResourceMetadata> = {};
|
|
1066
|
-
for (const [name, meta] of Object.entries(resources)) {
|
|
1067
|
-
const facts = read.blocks.get(name);
|
|
1068
|
-
const byAddress = read.instances.get(name);
|
|
1069
|
-
const instances = byAddress && meta.instances
|
|
1070
|
-
? meta.instances.map((inst) => {
|
|
1071
|
-
const f = byAddress.get(inst.address);
|
|
1072
|
-
return f ? { ...inst, facts: f } : inst;
|
|
1073
|
-
})
|
|
1074
|
-
: meta.instances;
|
|
1075
|
-
out[name] = {
|
|
1076
|
-
...meta,
|
|
1077
|
-
...(facts ? { facts } : {}),
|
|
1078
|
-
...(instances ? { instances } : {}),
|
|
1079
|
-
};
|
|
1080
|
-
}
|
|
1081
|
-
return out;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
/**
|
|
1085
|
-
* Run `choudoufu live-graph -json -from-plan=<file>` over the document a
|
|
1086
|
-
* live root's bind handed off, and read it (#4528). Never throws: facts are
|
|
1087
|
-
* extra, so a failure is a note and no facts.
|
|
1088
|
-
*/
|
|
1089
|
-
async function engineGraphFor(
|
|
1090
|
-
root: string,
|
|
1091
|
-
cwd: string | undefined,
|
|
1092
|
-
deps: TerraformReadDeps,
|
|
1093
|
-
handoff: LivePlanHandoff,
|
|
1094
|
-
): Promise<{ read?: EngineGraphRead; note?: string }> {
|
|
1095
|
-
if (!deps.liveGraph || handoff.json === undefined) return {};
|
|
1096
|
-
let scratch: string | undefined;
|
|
1097
|
-
try {
|
|
1098
|
-
let file = handoff.file;
|
|
1099
|
-
if (!file) {
|
|
1100
|
-
scratch = mkdtempSync(join(tmpdir(), "chant-live-graph-"));
|
|
1101
|
-
file = join(scratch, livePlanDocumentFile(root));
|
|
1102
|
-
writeFileSync(file, JSON.stringify(handoff.json));
|
|
1103
|
-
}
|
|
1104
|
-
const graph = await deps.liveGraph({ root, ...(cwd ? { cwd } : {}), fromPlan: file, ...(handoff.estate ? { estate: handoff.estate } : {}) });
|
|
1105
|
-
if (!graph.supported) {
|
|
1106
|
-
return {
|
|
1107
|
-
note:
|
|
1108
|
-
`terraform.roots.${root}: engine facts are absent: this choudoufu has no \`live-graph -from-plan\` ` +
|
|
1109
|
-
`(${graph.detail}), which needs v${MIN_CHOUDOUFU_GRAPH_VERSION} or later; the rest of the read is unchanged`,
|
|
1110
|
-
};
|
|
1111
|
-
}
|
|
1112
|
-
return { read: readEngineGraph(root, graph.json) };
|
|
1113
|
-
} catch (err) {
|
|
1114
|
-
const message = (err instanceof Error ? err.message : String(err)).split("\n")[0];
|
|
1115
|
-
return {
|
|
1116
|
-
note: `terraform.roots.${root}: engine facts are absent: \`choudoufu live-graph -json -from-plan\` failed (${message}); the rest of the read is unchanged`,
|
|
1117
|
-
};
|
|
1118
|
-
} finally {
|
|
1119
|
-
if (scratch) rmSync(scratch, { recursive: true, force: true });
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
/* ──────────────────── the estate beyond the declaration ─────────────────── */
|
|
1124
|
-
|
|
1125
|
-
/** One `items[]` entry of a `live-ls -json` listing. */
|
|
1126
|
-
export interface LiveLsItem {
|
|
1127
|
-
/** ARN or other stable identity. */
|
|
1128
|
-
id: string;
|
|
1129
|
-
/** Resource type, e.g. `aws_vpc`. */
|
|
1130
|
-
type: string;
|
|
1131
|
-
/** The configuration address decoded from the marker, when the listing could decode one. */
|
|
1132
|
-
address?: string;
|
|
1133
|
-
/** `tofu-slot`, on a `count` instance. */
|
|
1134
|
-
slot?: string;
|
|
1135
|
-
/** Whether the cross-referenced configuration directory still declares it. */
|
|
1136
|
-
declared: boolean;
|
|
1137
|
-
/** Which read found it: `tagging`, or a per-service pass. */
|
|
1138
|
-
source?: string;
|
|
1139
|
-
/** Every marker tag it carries. */
|
|
1140
|
-
tags: Record<string, string>;
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
/** One `gaps[]` entry: a declared instance this listing's mechanism cannot reach. */
|
|
1144
|
-
export interface LiveLsGap {
|
|
1145
|
-
address: string;
|
|
1146
|
-
type: string;
|
|
1147
|
-
/** `record` or `declaration-carried`, choudoufu's own rung vocabulary. */
|
|
1148
|
-
rung: string;
|
|
1149
|
-
detail: string;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
/** A `live-ls -json` listing, parsed. */
|
|
1153
|
-
export interface LiveLsListing {
|
|
1154
|
-
estate: string;
|
|
1155
|
-
items: LiveLsItem[];
|
|
1156
|
-
gaps: LiveLsGap[];
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
/** Parse a `live-ls -json` document. A missing section reads as empty, never as a throw. */
|
|
1160
|
-
export function readLiveLs(document: unknown): LiveLsListing {
|
|
1161
|
-
const doc = asRecord(document);
|
|
1162
|
-
const items: LiveLsItem[] = [];
|
|
1163
|
-
for (const entry of asArray(doc.items)) {
|
|
1164
|
-
const row = asRecord(entry);
|
|
1165
|
-
const id = asString(row.id);
|
|
1166
|
-
const type = asString(row.type);
|
|
1167
|
-
if (!id || !type) continue;
|
|
1168
|
-
const tags: Record<string, string> = {};
|
|
1169
|
-
for (const [key, value] of Object.entries(asRecord(row.tags))) {
|
|
1170
|
-
if (typeof value === "string") tags[key] = value;
|
|
1171
|
-
}
|
|
1172
|
-
items.push({
|
|
1173
|
-
id,
|
|
1174
|
-
type,
|
|
1175
|
-
...(asString(row.address) ? { address: asString(row.address) } : {}),
|
|
1176
|
-
...(asString(row.slot) ? { slot: asString(row.slot) } : {}),
|
|
1177
|
-
declared: row.declared === true,
|
|
1178
|
-
...(asString(row.source) ? { source: asString(row.source) } : {}),
|
|
1179
|
-
tags,
|
|
1180
|
-
});
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
const gaps: LiveLsGap[] = [];
|
|
1184
|
-
for (const entry of asArray(doc.gaps)) {
|
|
1185
|
-
const row = asRecord(entry);
|
|
1186
|
-
const address = asString(row.address);
|
|
1187
|
-
if (!address) continue;
|
|
1188
|
-
gaps.push({
|
|
1189
|
-
address,
|
|
1190
|
-
type: asString(row.type) ?? "",
|
|
1191
|
-
rung: asString(row.rung) ?? "",
|
|
1192
|
-
detail: asString(row.detail) ?? "",
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
return { estate: asString(doc.estate) ?? "", items, gaps };
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
/**
|
|
1200
|
-
* A live-ls gap's rung, mapped onto chant's vocabulary. Both rungs mean the
|
|
1201
|
-
* same thing to a reader of the listing: this instance can never appear in
|
|
1202
|
-
* it, because the mechanism the listing uses cannot reach it. That is
|
|
1203
|
-
* `unsupported-kind`, not a failure and not an absence.
|
|
1204
|
-
*/
|
|
1205
|
-
function gapReason(): UnobservedReason {
|
|
1206
|
-
return "unsupported-kind";
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
/**
|
|
1210
|
-
* The entity key `buildRoots()` would have produced for a live resource's
|
|
1211
|
-
* address.
|
|
1212
|
-
*
|
|
1213
|
-
* A live address is fully qualified with dots, `module.cdn.null_resource.edge`;
|
|
1214
|
-
* the build keys a descended child module's block with a slash per call,
|
|
1215
|
-
* `app/module.cdn/null_resource.edge` (#2112). Splitting the `module.<name>.`
|
|
1216
|
-
* prefixes back out is what keeps a live row and the block that declared it
|
|
1217
|
-
* on the same key.
|
|
1218
|
-
*/
|
|
1219
|
-
export function entityKeyFor(root: string, address: string): string {
|
|
1220
|
-
const parts = address.split(".");
|
|
1221
|
-
const segments: string[] = [];
|
|
1222
|
-
let i = 0;
|
|
1223
|
-
while (i + 1 < parts.length && parts[i] === "module") {
|
|
1224
|
-
segments.push(`module.${parts[i + 1]}`);
|
|
1225
|
-
i += 2;
|
|
1226
|
-
}
|
|
1227
|
-
segments.push(parts.slice(i).join("."));
|
|
1228
|
-
return [root, ...segments].join("/");
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
/**
|
|
1232
|
-
* The entity types this lexicon can enumerate beyond the declared estate
|
|
1233
|
-
* (#1278). One: a `resource` block, whose live counterparts `live-ls` lists
|
|
1234
|
-
* off the tag index. A `data`, `module` or `provider` block has no live
|
|
1235
|
-
* counterpart to enumerate at all.
|
|
1236
|
-
*/
|
|
1237
|
-
export function ambientKinds(): string[] {
|
|
1238
|
-
return [RESOURCE_TYPE];
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
/** Shared options for the two estate-wide reads. */
|
|
1242
|
-
export interface LiveEstateOptions {
|
|
1243
|
-
/** Directory the activities start the `chant.config.*` search from. Default: the process cwd. */
|
|
1244
|
-
cwd?: string;
|
|
1245
|
-
/** Restrict to these root names. Default: every live root the project declares. */
|
|
1246
|
-
roots?: string[];
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
/**
|
|
1250
|
-
* Every live root the project declares, in config order, leaving out a
|
|
1251
|
-
* `signalOnly` one (#4484). Reads the project
|
|
1252
|
-
* config the same way the activities do, so `terraform.roots` is read once
|
|
1253
|
-
* and the same answer reaches both.
|
|
1254
|
-
*/
|
|
1255
|
-
export async function liveRootNames(cwd?: string): Promise<Array<{ root: string; estate: string }>> {
|
|
1256
|
-
const { loadChantConfigUpward } = await import("@intentius/chant/config");
|
|
1257
|
-
const { detectLiveEstate } = await import("./op/activities/live-detect");
|
|
1258
|
-
const { dirname, resolve } = await import("node:path");
|
|
1259
|
-
|
|
1260
|
-
const start = resolve(cwd ?? process.cwd());
|
|
1261
|
-
const { config, configPath } = await loadChantConfigUpward(start);
|
|
1262
|
-
const projectRoot = configPath ? dirname(configPath) : start;
|
|
1263
|
-
const namespace = (config as { terraform?: { binary?: string; roots?: Record<string, { dir: string; signalOnly?: boolean }> } })
|
|
1264
|
-
.terraform;
|
|
1265
|
-
if (namespace?.binary !== "choudoufu") return [];
|
|
1266
|
-
|
|
1267
|
-
const live: Array<{ root: string; estate: string }> = [];
|
|
1268
|
-
for (const [name, root] of Object.entries(namespace.roots ?? {})) {
|
|
1269
|
-
// A `signalOnly` root (#4484) is another project's: it only brings this one into a change.
|
|
1270
|
-
if (root.signalOnly === true) continue;
|
|
1271
|
-
const estate = detectLiveEstate(resolve(projectRoot, root.dir));
|
|
1272
|
-
if (estate !== undefined) live.push({ root: name, estate });
|
|
1273
|
-
}
|
|
1274
|
-
return live;
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
/**
|
|
1278
|
-
* Report the resources this estate owns that nothing declares (#1278) — the
|
|
1279
|
-
* owned-orphan set, which is `live-ls`'s `declared: false` rows.
|
|
1280
|
-
*
|
|
1281
|
-
* This is the question a state file cannot answer at all, because a state
|
|
1282
|
-
* file knows only what it created. The tag index knows what the estate holds,
|
|
1283
|
-
* whether or not any configuration still mentions it.
|
|
1284
|
-
*/
|
|
1285
|
-
export async function observeAmbient(
|
|
1286
|
-
options: {
|
|
1287
|
-
environment: string;
|
|
1288
|
-
kinds: string[];
|
|
1289
|
-
observed: Record<string, ResourceMetadata>;
|
|
1290
|
-
} & LiveEstateOptions,
|
|
1291
|
-
deps: TerraformReadDeps = REAL_DEPS,
|
|
1292
|
-
): Promise<Record<string, ResourceMetadata>> {
|
|
1293
|
-
// The bound #1278 asks for: a project that declares no terraform resources
|
|
1294
|
-
// is never made to enumerate an estate.
|
|
1295
|
-
if (!options.kinds.includes(RESOURCE_TYPE)) return {};
|
|
1296
|
-
|
|
1297
|
-
const out: Record<string, ResourceMetadata> = {};
|
|
1298
|
-
for (const { root, estate } of await liveRoots(options)) {
|
|
1299
|
-
const listed = await deps.liveLs({
|
|
1300
|
-
root,
|
|
1301
|
-
consistent: true,
|
|
1302
|
-
...(options.cwd ? { cwd: options.cwd } : {}),
|
|
1303
|
-
});
|
|
1304
|
-
const listing = readLiveLs(listed.json);
|
|
1305
|
-
for (const item of listing.items) {
|
|
1306
|
-
if (item.declared) continue; // declared is `describeResources`'s business, not this one's
|
|
1307
|
-
const address = item.address ?? item.id;
|
|
1308
|
-
const name = entityKeyFor(root, address);
|
|
1309
|
-
if (options.observed[name]) continue;
|
|
1310
|
-
out[name] = {
|
|
1311
|
-
type: RESOURCE_TYPE,
|
|
1312
|
-
physicalId: item.id,
|
|
1313
|
-
status: "orphan",
|
|
1314
|
-
ownership: "owned",
|
|
1315
|
-
marker: { stack: listing.estate || estate },
|
|
1316
|
-
ambient: true,
|
|
1317
|
-
attributes: {
|
|
1318
|
-
address,
|
|
1319
|
-
root,
|
|
1320
|
-
estate: listing.estate || estate,
|
|
1321
|
-
resourceType: item.type,
|
|
1322
|
-
...(item.slot ? { slot: item.slot } : {}),
|
|
1323
|
-
...(item.source ? { listedBy: item.source } : {}),
|
|
1324
|
-
tags: item.tags,
|
|
1325
|
-
},
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
return out;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
/**
|
|
1333
|
-
* Name what a teardown of this environment would remove from every live root
|
|
1334
|
-
* (#1222): the estate's owned orphans, which are exactly the set choudoufu's
|
|
1335
|
-
* own default `policy` verb (`undeclared_tagged = "delete"`) removes on the
|
|
1336
|
-
* next apply.
|
|
1337
|
-
*
|
|
1338
|
-
* Candidates carry the requested identity verbatim, because that identity is
|
|
1339
|
-
* what selected them: the roots enumerated here are this project's own, and
|
|
1340
|
-
* their estates are what `terraform.roots` declares for this environment.
|
|
1341
|
-
* The estate that actually answered rides `name`, so a reviewer of the plan
|
|
1342
|
-
* can see which one it was.
|
|
1343
|
-
*
|
|
1344
|
-
* `live-ls`'s own `gaps[]` become holes rather than silence, per #1089: a
|
|
1345
|
-
* declared instance the tag index can never serve is unknown, not clean.
|
|
1346
|
-
*/
|
|
1347
|
-
export async function teardownOwned(
|
|
1348
|
-
options: { environment: string; marker: OwnershipMarker } & LiveEstateOptions,
|
|
1349
|
-
deps: TerraformReadDeps = REAL_DEPS,
|
|
1350
|
-
): Promise<TeardownEnumeration> {
|
|
1351
|
-
const candidates: TeardownCandidate[] = [];
|
|
1352
|
-
const holes: TeardownHole[] = [];
|
|
1353
|
-
|
|
1354
|
-
for (const { root, estate } of await liveRoots(options)) {
|
|
1355
|
-
let listing: LiveLsListing;
|
|
1356
|
-
try {
|
|
1357
|
-
const listed = await deps.liveLs({
|
|
1358
|
-
root,
|
|
1359
|
-
consistent: true,
|
|
1360
|
-
...(options.cwd ? { cwd: options.cwd } : {}),
|
|
1361
|
-
});
|
|
1362
|
-
listing = readLiveLs(listed.json);
|
|
1363
|
-
} catch (err) {
|
|
1364
|
-
// Nothing was read, so nothing is known about this root's estate. A
|
|
1365
|
-
// hole, never an empty candidate list, which would read as "clean".
|
|
1366
|
-
holes.push({
|
|
1367
|
-
name: `terraform.roots.${root}`,
|
|
1368
|
-
reason: "read-failed",
|
|
1369
|
-
detail: `choudoufu live-ls (estate "${estate}"): ${err instanceof Error ? err.message : String(err)}`,
|
|
1370
|
-
});
|
|
1371
|
-
continue;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
for (const item of listing.items) {
|
|
1375
|
-
if (item.declared) continue;
|
|
1376
|
-
candidates.push({
|
|
1377
|
-
name: entityKeyFor(root, item.address ?? item.id),
|
|
1378
|
-
type: RESOURCE_TYPE,
|
|
1379
|
-
physicalId: item.id,
|
|
1380
|
-
marker: options.marker,
|
|
1381
|
-
});
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
for (const gap of listing.gaps) {
|
|
1385
|
-
holes.push({
|
|
1386
|
-
name: entityKeyFor(root, gap.address),
|
|
1387
|
-
type: RESOURCE_TYPE,
|
|
1388
|
-
reason: gapReason(),
|
|
1389
|
-
detail: `${gap.rung}: ${gap.detail}`,
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
return { candidates, ...(holes.length > 0 ? { holes } : {}) };
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
/** The live roots an estate-wide read runs over: the caller's list, or every one declared. */
|
|
1398
|
-
async function liveRoots(options: LiveEstateOptions): Promise<Array<{ root: string; estate: string }>> {
|
|
1399
|
-
const declared = await liveRootNames(options.cwd);
|
|
1400
|
-
if (!options.roots) return declared;
|
|
1401
|
-
const wanted = new Set(options.roots);
|
|
1402
|
-
return declared.filter((entry) => wanted.has(entry.root));
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
/* ─────────────────────────────── dispatch ───────────────────────────────── */
|
|
1406
|
-
|
|
1407
|
-
/** The activities this reader drives. Injectable so tests never run a binary. */
|
|
1408
|
-
export interface TerraformReadDeps {
|
|
1409
|
-
init: typeof terraformInit;
|
|
1410
|
-
show: typeof terraformShow;
|
|
1411
|
-
/** The document alone (chant #2498): this reader indexes it and never reads the human render. */
|
|
1412
|
-
livePlan: typeof choudoufuLivePlanDocument;
|
|
1413
|
-
liveLs: typeof choudoufuLiveLs;
|
|
1414
|
-
/**
|
|
1415
|
-
* The engine graph read on a live root (#4528). Optional so a test that
|
|
1416
|
-
* never asks for facts need not stub it; omitted, no facts are read and no
|
|
1417
|
-
* note is added.
|
|
1418
|
-
*/
|
|
1419
|
-
liveGraph?: typeof choudoufuLiveGraph;
|
|
1420
|
-
/**
|
|
1421
|
-
* The plan depth's read (#4358). Optional so a test that never asks for the
|
|
1422
|
-
* plan depth need not stub it; omitted, the real activity runs.
|
|
1423
|
-
*/
|
|
1424
|
-
planRead?: typeof terraformPlanRead;
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
const REAL_DEPS: TerraformReadDeps = {
|
|
1428
|
-
init: terraformInit,
|
|
1429
|
-
show: terraformShow,
|
|
1430
|
-
livePlan: choudoufuLivePlanDocument,
|
|
1431
|
-
liveLs: choudoufuLiveLs,
|
|
1432
|
-
liveGraph: choudoufuLiveGraph,
|
|
1433
|
-
planRead: terraformPlanRead,
|
|
1434
|
-
};
|
|
1435
|
-
|
|
1436
|
-
/** A declared entity, plus the root, address and mode `buildRoots()` recorded on it. */
|
|
1437
|
-
export interface TerraformDeclared extends DeclaredEntity {
|
|
1438
|
-
root: string;
|
|
1439
|
-
address: string;
|
|
1440
|
-
/** `"live"` when the root runs under choudoufu with a declared estate (#2103). */
|
|
1441
|
-
mode?: string;
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
/**
|
|
1445
|
-
* Split a `<root>/<address>` entity key, or a descended child module's
|
|
1446
|
-
* `<root>/module.<name>/<address>` (#2112). Only a fallback: `buildRoots()`
|
|
1447
|
-
* records the root, the address and the call chain on `props`, and a
|
|
1448
|
-
* duplicated address is keyed `…~2` there, so the props are the reliable
|
|
1449
|
-
* source.
|
|
1450
|
-
*/
|
|
1451
|
-
function fromEntityName(name: string): { root: string; address: string; callers: string[] } {
|
|
1452
|
-
const slash = name.indexOf("/");
|
|
1453
|
-
if (slash === -1) return { root: "", address: name, callers: [] };
|
|
1454
|
-
const last = name.lastIndexOf("/");
|
|
1455
|
-
return {
|
|
1456
|
-
root: name.slice(0, slash),
|
|
1457
|
-
address: name.slice(last + 1).replace(/~\d+$/, ""),
|
|
1458
|
-
callers: callersOfKey(name),
|
|
1459
|
-
};
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
/**
|
|
1463
|
-
* The address the live system knows a block by. For a root-module block that
|
|
1464
|
-
* is the block's own address; for one inside a child module it is what
|
|
1465
|
-
* `terraform show -json` writes in `child_modules[]` and what choudoufu's
|
|
1466
|
-
* markers carry, the call chain and the address joined with dots:
|
|
1467
|
-
* `module.cdn.null_resource.edge` (#2112). The entity KEY keeps its slashes
|
|
1468
|
-
* (`app/module.cdn/null_resource.edge`), so what a build declares and what a
|
|
1469
|
-
* read observes still line up one to one.
|
|
1470
|
-
*/
|
|
1471
|
-
export function qualifiedAddress(address: string, callers: readonly string[]): string {
|
|
1472
|
-
return callers.length === 0 ? address : `${callers.join(".")}.${address}`;
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
/**
|
|
1476
|
-
* The root, qualified address and mode of one declared entity, from what
|
|
1477
|
-
* `buildRoots()` recorded on its props. Exported for the behaviour request
|
|
1478
|
-
* builder (#2360), which groups entities by root the same way.
|
|
1479
|
-
*/
|
|
1480
|
-
export function declaredOf(name: string, entity: { entityType: string; props: Record<string, unknown> } | undefined): TerraformDeclared {
|
|
1481
|
-
const props = entity?.props ?? {};
|
|
1482
|
-
const fallback = fromEntityName(name);
|
|
1483
|
-
const callers = Array.isArray(props.callers)
|
|
1484
|
-
? (props.callers as unknown[]).filter((c): c is string => typeof c === "string")
|
|
1485
|
-
: fallback.callers;
|
|
1486
|
-
return {
|
|
1487
|
-
name,
|
|
1488
|
-
type: entity?.entityType ?? "",
|
|
1489
|
-
props,
|
|
1490
|
-
root: asString(props.root) ?? fallback.root,
|
|
1491
|
-
address: qualifiedAddress(asString(props.address) ?? fallback.address, callers),
|
|
1492
|
-
...(asString(props.mode) ? { mode: asString(props.mode) } : {}),
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
/**
|
|
1497
|
-
* One root's reader: `init`, then `show` over state, then address matching.
|
|
1498
|
-
* The entity-level reads are {@link readStateEntity}, which the plan depth's
|
|
1499
|
-
* fallback shares.
|
|
1500
|
-
*/
|
|
1501
|
-
function adapter(root: string, cwd: string | undefined, deps: TerraformReadDeps): ObserverAdapter<StateIndex> {
|
|
1502
|
-
const where = cwd ? { cwd } : {};
|
|
1503
|
-
let dir: string | undefined;
|
|
1504
|
-
|
|
1505
|
-
return {
|
|
1506
|
-
async bind(): Promise<StateIndex> {
|
|
1507
|
-
// `init` first: `show` against an uninitialized root reports no state at
|
|
1508
|
-
// all, which would read as "everything is absent", the exact failure
|
|
1509
|
-
// the tri-state exists to prevent.
|
|
1510
|
-
const initialized = await deps.init({ root, ...where });
|
|
1511
|
-
dir = initialized.dir;
|
|
1512
|
-
const shown = await deps.show({ root, ...where });
|
|
1513
|
-
dir = shown.dir;
|
|
1514
|
-
return indexStateResources(shown.json);
|
|
1515
|
-
},
|
|
1516
|
-
|
|
1517
|
-
classifyBindFailure(err) {
|
|
1518
|
-
const message = err instanceof Error ? err.message.split("\n")[0] : String(err);
|
|
1519
|
-
return {
|
|
1520
|
-
reason: "read-failed",
|
|
1521
|
-
detail: `terraform.roots.${root}${dir ? ` (${dir})` : ""}: ${message}`,
|
|
1522
|
-
};
|
|
1523
|
-
},
|
|
1524
|
-
|
|
1525
|
-
async read(index, entity): Promise<EntityObservation> {
|
|
1526
|
-
return readStateEntity(index, entity, root, `terraform show -json (root "${root}", address "${(entity as TerraformDeclared).address}")`);
|
|
1527
|
-
},
|
|
1528
|
-
};
|
|
1529
|
-
}
|
|
1530
|
-
|
|
1531
|
-
/** True when the index carries any row for the block `address`, at any instance key. */
|
|
1532
|
-
function blockRows(address: string, index: StateIndex): StateResourceRow[] {
|
|
1533
|
-
const exact = index.rows.get(address);
|
|
1534
|
-
if (exact) return [exact];
|
|
1535
|
-
return [...index.rows.values()].filter((row) => blockAddressOf(row.address) === address);
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
/**
|
|
1539
|
-
* Each row of an expanded block as an instance (#4454), keyed as Terraform
|
|
1540
|
-
* prints it. A state row is a recorded instance, owned by membership. A row
|
|
1541
|
-
* under an expanded module call carries its module path as `scope`, as on
|
|
1542
|
-
* the live read (#4488).
|
|
1543
|
-
*/
|
|
1544
|
-
function stateInstanceObservations(address: string, rows: readonly StateResourceRow[]): InstanceObservation[] {
|
|
1545
|
-
const out: InstanceObservation[] = [];
|
|
1546
|
-
for (const r of rows) {
|
|
1547
|
-
const at = instanceKeyAndScope(address, r.address);
|
|
1548
|
-
if (at === undefined) continue;
|
|
1549
|
-
out.push({ ...at, address: r.address, verdict: "present", ownership: "owned", status: r.mode ?? "managed", ...(r.id ? { physicalId: r.id } : {}) });
|
|
1550
|
-
}
|
|
1551
|
-
return out.sort((a, b) => a.address.localeCompare(b.address));
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
|
-
/**
|
|
1555
|
-
* One declared entity against a state index: the state read's whole verdict,
|
|
1556
|
-
* and the plan depth's too, since a plan's `prior_state` is the same shape.
|
|
1557
|
-
* `extra` is what the plan depth adds to a present resource or data block.
|
|
1558
|
-
*/
|
|
1559
|
-
function readStateEntity(
|
|
1560
|
-
index: StateIndex,
|
|
1561
|
-
entity: DeclaredEntity,
|
|
1562
|
-
root: string,
|
|
1563
|
-
queried: string,
|
|
1564
|
-
extra?: (address: string) => Record<string, unknown>,
|
|
1565
|
-
): EntityObservation {
|
|
1566
|
-
const { address } = entity as TerraformDeclared;
|
|
1567
|
-
|
|
1568
|
-
if (entity.type === RESOURCE_TYPE || entity.type === DATA_TYPE) {
|
|
1569
|
-
// The exact row first, which is the state read's rule since #2087, then
|
|
1570
|
-
// a `count` or `for_each` block by its instances: the plan depth did
|
|
1571
|
-
// that from the start, and the state read does since #4454, which is
|
|
1572
|
-
// what gives a drift row for `aws_eip.pool[0]` a block to roll up to.
|
|
1573
|
-
const rows = blockRows(address, index);
|
|
1574
|
-
if (rows.length === 0) return { absent: true, queried };
|
|
1575
|
-
const row = rows[0]!;
|
|
1576
|
-
const instances = stateInstanceObservations(address, rows);
|
|
1577
|
-
return {
|
|
1578
|
-
present: {
|
|
1579
|
-
...(instances.length > 0 ? { instances } : {}),
|
|
1580
|
-
type: entity.type,
|
|
1581
|
-
physicalId: rows.length === 1 ? (row.id ?? address) : address,
|
|
1582
|
-
status: row.mode ?? "managed",
|
|
1583
|
-
ownership: "owned",
|
|
1584
|
-
attributes: {
|
|
1585
|
-
address,
|
|
1586
|
-
root,
|
|
1587
|
-
...(row.type ? { resourceType: row.type } : {}),
|
|
1588
|
-
...(row.mode ? { mode: row.mode } : {}),
|
|
1589
|
-
...(row.providerName ? { provider: row.providerName } : {}),
|
|
1590
|
-
...(rows.length > 1 ? { instances: rows.map((r) => r.address).sort() } : {}),
|
|
1591
|
-
...(extra ? extra(address) : {}),
|
|
1592
|
-
},
|
|
1593
|
-
},
|
|
1594
|
-
queried,
|
|
1595
|
-
};
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
if (entity.type === MODULE_TYPE) {
|
|
1599
|
-
if (!moduleIsLive(address, index)) return { absent: true, queried };
|
|
1600
|
-
// The state has resources under this module but no row for the block
|
|
1601
|
-
// itself, so state membership, which is the whole ownership channel
|
|
1602
|
-
// here, has nothing to say about it. See the module doc.
|
|
1603
|
-
return {
|
|
1604
|
-
present: {
|
|
1605
|
-
type: entity.type,
|
|
1606
|
-
physicalId: address,
|
|
1607
|
-
status: "module",
|
|
1608
|
-
ownership: classifyStateOwnership(address, index),
|
|
1609
|
-
attributes: { address, root },
|
|
1610
|
-
},
|
|
1611
|
-
queried,
|
|
1612
|
-
};
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
return {
|
|
1616
|
-
unobserved: {
|
|
1617
|
-
reason: "unsupported-kind",
|
|
1618
|
-
detail: `${entity.type} has no row in terraform state: only resource and data blocks do`,
|
|
1619
|
-
},
|
|
1620
|
-
queried,
|
|
1621
|
-
};
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
/* ───────────────────────────── the plan depth (#4358) ───────────────────────────── */
|
|
1625
|
-
|
|
1626
|
-
/** Which read answered a plan-depth root. */
|
|
1627
|
-
export type PlanDepthAnswer = "plan" | "state" | "declared";
|
|
1628
|
-
|
|
1629
|
-
/** What a plan-depth root's bind produced: the plan, or the state read it fell back to. */
|
|
1630
|
-
type PlanDepthIndex = { kind: "plan"; plan: PlanIndex; state: StateIndex } | { kind: "state"; state: StateIndex };
|
|
1631
|
-
|
|
1632
|
-
/** Does this text name a credentials or authorization failure? Exported for the fallback tests. */
|
|
1633
|
-
export function planFailureIsCredentials(text: string): boolean {
|
|
1634
|
-
return readsAsCredentials(text) || /no valid credential sources|could not find default credentials|failed to refresh cached credentials|NoCredentialProviders|AADSTS|InvalidAccessKeyId|token has expired/i.test(text);
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1637
|
-
/**
|
|
1638
|
-
* One plan-depth root's reader. `bind` is the fallback ladder:
|
|
1639
|
-
*
|
|
1640
|
-
* 1. An uninitialised root (or one that needs `init` again) is refused with
|
|
1641
|
-
* the line to run, and nothing else is read: the state read would need
|
|
1642
|
-
* `init` too, and chant never runs it on a read. Declared only.
|
|
1643
|
-
* 2. The plan read answers: `"plan"`.
|
|
1644
|
-
* 3. The plan read failed reaching the backend: the state read needs the
|
|
1645
|
-
* same backend, so declared only.
|
|
1646
|
-
* 4. The plan read failed any other way, missing provider credentials
|
|
1647
|
-
* first among them: `terraform show -json` over state, with no `init`
|
|
1648
|
-
* (the root is initialised, step 1 checked). `"state"`.
|
|
1649
|
-
* 5. That failed too: declared only.
|
|
1650
|
-
*
|
|
1651
|
-
* `answered` is filled as the ladder runs, for the caller's `sources` and
|
|
1652
|
-
* notes.
|
|
1653
|
-
*/
|
|
1654
|
-
function planAdapter(
|
|
1655
|
-
root: string,
|
|
1656
|
-
cwd: string | undefined,
|
|
1657
|
-
deps: TerraformReadDeps,
|
|
1658
|
-
outcome: { answered: PlanDepthAnswer; note: string; read?: RootRead },
|
|
1659
|
-
): ObserverAdapter<PlanDepthIndex> {
|
|
1660
|
-
const where = cwd ? { cwd } : {};
|
|
1661
|
-
const planRead = deps.planRead ?? terraformPlanRead;
|
|
1662
|
-
let dir: string | undefined;
|
|
1663
|
-
let refusal: { reason: UnobservedReason; detail: string } | undefined;
|
|
1664
|
-
const firstLine = (err: unknown): string => (err instanceof Error ? err.message : String(err)).split("\n")[0]!;
|
|
1665
|
-
|
|
1666
|
-
return {
|
|
1667
|
-
async bind(): Promise<PlanDepthIndex> {
|
|
1668
|
-
outcome.answered = "declared";
|
|
1669
|
-
let planErr: unknown;
|
|
1670
|
-
try {
|
|
1671
|
-
const read = await planRead({ root, ...where });
|
|
1672
|
-
dir = read.dir;
|
|
1673
|
-
const plan = indexPlan(read.json);
|
|
1674
|
-
outcome.answered = "plan";
|
|
1675
|
-
outcome.read = { depth: "plan" };
|
|
1676
|
-
outcome.note = `terraform.roots.${root}: the plan read answered (\`${read.command.replace(read.planDir, "<tmp>")}\`)`;
|
|
1677
|
-
return { kind: "plan", plan, state: indexStateResources({ values: asRecord(plan.priorState).values }) };
|
|
1678
|
-
} catch (err) {
|
|
1679
|
-
planErr = err;
|
|
1680
|
-
if (err instanceof TerraformPlanReadError) dir = err.dir;
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
const kind = planErr instanceof TerraformPlanReadError ? planErr.kind : "plan";
|
|
1684
|
-
if (kind === "not-initialised" || kind === "backend") {
|
|
1685
|
-
refusal = {
|
|
1686
|
-
reason: kind === "backend" && planFailureIsCredentials(String((planErr as Error).message)) ? "no-credentials" : kind === "backend" ? "read-failed" : "no-binding",
|
|
1687
|
-
detail: `terraform.roots.${root}${dir ? ` (${dir})` : ""}: declared only. ${firstLine(planErr)}${kind === "backend" ? " The state read needs the same backend, so it was not tried." : ""}`,
|
|
1688
|
-
};
|
|
1689
|
-
outcome.read = { depth: "plan", fellBackTo: "declared", reason: kind === "backend" ? "backend-unreachable" : "needs-init" };
|
|
1690
|
-
outcome.note = `terraform.roots.${root}: no read answered, declared only (${kind === "backend" ? "the plan read could not reach the backend" : "the root needs init, which chant never runs"})`;
|
|
1691
|
-
throw planErr;
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
const why = planFailureIsCredentials(String((planErr as Error)?.message ?? planErr)) ? "no provider credentials" : "the plan failed";
|
|
1695
|
-
try {
|
|
1696
|
-
const shown = await deps.show({ root, ...where });
|
|
1697
|
-
dir = shown.dir;
|
|
1698
|
-
outcome.answered = "state";
|
|
1699
|
-
outcome.read = { depth: "plan", fellBackTo: "state", reason: why === "no provider credentials" ? "no-credentials" : "plan-failed" };
|
|
1700
|
-
outcome.note = `terraform.roots.${root}: the plan read failed (${why}: ${firstLine(planErr)}), so the state read answered; plan attributes are absent`;
|
|
1701
|
-
return { kind: "state", state: indexStateResources(shown.json) };
|
|
1702
|
-
} catch (err) {
|
|
1703
|
-
refusal = {
|
|
1704
|
-
reason: "read-failed",
|
|
1705
|
-
detail: `terraform.roots.${root}${dir ? ` (${dir})` : ""}: declared only. The plan read failed (${firstLine(planErr)}) and the state read after it failed too (${firstLine(err)})`,
|
|
1706
|
-
};
|
|
1707
|
-
outcome.read = { depth: "plan", fellBackTo: "declared", reason: "state-read-failed" };
|
|
1708
|
-
outcome.note = `terraform.roots.${root}: no read answered, declared only (the plan read failed, ${why}, and the state read failed after it)`;
|
|
1709
|
-
throw err;
|
|
1710
|
-
}
|
|
1711
|
-
},
|
|
1712
|
-
|
|
1713
|
-
classifyBindFailure(err) {
|
|
1714
|
-
return refusal ?? { reason: "read-failed", detail: `terraform.roots.${root}${dir ? ` (${dir})` : ""}: ${firstLine(err)}` };
|
|
1715
|
-
},
|
|
1716
|
-
|
|
1717
|
-
async read(index, entity): Promise<EntityObservation> {
|
|
1718
|
-
const { address } = entity as TerraformDeclared;
|
|
1719
|
-
if (index.kind === "state") {
|
|
1720
|
-
return readStateEntity(index.state, entity, root, `terraform show -json (root "${root}", address "${address}", after the plan read failed)`);
|
|
1721
|
-
}
|
|
1722
|
-
const plan = index.plan;
|
|
1723
|
-
const seen = readStateEntity(
|
|
1724
|
-
index.state,
|
|
1725
|
-
entity,
|
|
1726
|
-
root,
|
|
1727
|
-
`terraform plan -lock=false + show -json <planfile> (root "${root}", address "${address}")`,
|
|
1728
|
-
(a) => planAttributesFor(a, plan),
|
|
1729
|
-
);
|
|
1730
|
-
// A planned create (#4372): no row in `prior_state`, so absent, which is
|
|
1731
|
-
// what makes `lifecycle plan` propose the create. The plan still says
|
|
1732
|
-
// what it will do and which values stay unknown until apply, so those
|
|
1733
|
-
// ride as annotations, which never make the block present.
|
|
1734
|
-
if ("absent" in seen && (entity.type === RESOURCE_TYPE || entity.type === DATA_TYPE)) {
|
|
1735
|
-
const planned = plannedAttributesFor(address, plan);
|
|
1736
|
-
if (planned) return { ...seen, annotations: planned };
|
|
1737
|
-
}
|
|
1738
|
-
return seen;
|
|
1739
|
-
},
|
|
1740
|
-
};
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
/** What a live root's plan-depth bind produced: `live-plan`'s index, and the plan when it answered. */
|
|
1744
|
-
type LivePlanDepthIndex = { live: LivePlanIndex; plan?: PlanIndex };
|
|
1745
|
-
|
|
1746
|
-
/** Which reads answered a live root at the plan depth (#4371). */
|
|
1747
|
-
export type LivePlanDepthAnswer = "live+plan" | "live";
|
|
1748
|
-
|
|
1749
|
-
/**
|
|
1750
|
-
* One live root's reader at the plan depth (#4371): {@link liveAdapter}'s
|
|
1751
|
-
* read, unchanged, with the plan's attributes added to every block it bound.
|
|
1752
|
-
* See "On a live root" in the module doc.
|
|
1753
|
-
*/
|
|
1754
|
-
function livePlanDepthAdapter(
|
|
1755
|
-
root: string,
|
|
1756
|
-
cwd: string | undefined,
|
|
1757
|
-
deps: TerraformReadDeps,
|
|
1758
|
-
outcome: { answered: LivePlanDepthAnswer; note: string; read?: RootRead },
|
|
1759
|
-
handoff: LivePlanHandoff = {},
|
|
1760
|
-
): ObserverAdapter<LivePlanDepthIndex> {
|
|
1761
|
-
const where = cwd ? { cwd } : {};
|
|
1762
|
-
const live = liveAdapter(root, cwd, deps, handoff);
|
|
1763
|
-
const planRead = deps.planRead ?? terraformPlanRead;
|
|
1764
|
-
const firstLine = (err: unknown): string => (err instanceof Error ? err.message : String(err)).split("\n")[0]!;
|
|
1765
|
-
let command = "";
|
|
1766
|
-
|
|
1767
|
-
return {
|
|
1768
|
-
async bind(): Promise<LivePlanDepthIndex> {
|
|
1769
|
-
outcome.answered = "live";
|
|
1770
|
-
outcome.note = `terraform.roots.${root}: no read answered (\`live-plan -json\` failed, so the plan read was not tried)`;
|
|
1771
|
-
const index = await live.bind();
|
|
1772
|
-
try {
|
|
1773
|
-
const read = await planRead({ root, ...where });
|
|
1774
|
-
command = read.command.replace(read.planDir, "<tmp>");
|
|
1775
|
-
outcome.answered = "live+plan";
|
|
1776
|
-
outcome.read = { depth: "live+plan" };
|
|
1777
|
-
outcome.note = `terraform.roots.${root}: the plan read answered (\`${command}\`), beside \`live-plan -json\`, which answered presence and ownership`;
|
|
1778
|
-
return { live: index, plan: indexPlan(read.json) };
|
|
1779
|
-
} catch (err) {
|
|
1780
|
-
const kind = err instanceof TerraformPlanReadError ? err.kind : "plan";
|
|
1781
|
-
const why =
|
|
1782
|
-
kind === "not-initialised"
|
|
1783
|
-
? "the root needs init, which chant never runs"
|
|
1784
|
-
: planFailureIsCredentials(String(err instanceof Error ? err.message : err))
|
|
1785
|
-
? "no provider credentials"
|
|
1786
|
-
: kind === "backend"
|
|
1787
|
-
? "the plan read could not reach the backend"
|
|
1788
|
-
: "the plan failed";
|
|
1789
|
-
outcome.read = {
|
|
1790
|
-
depth: "live+plan",
|
|
1791
|
-
fellBackTo: "live",
|
|
1792
|
-
reason: kind === "not-initialised" ? "needs-init" : kind === "backend" ? "backend-unreachable" : why === "no provider credentials" ? "no-credentials" : "plan-failed",
|
|
1793
|
-
};
|
|
1794
|
-
outcome.note = `terraform.roots.${root}: the plan read failed (${why}: ${firstLine(err)}), so \`live-plan -json\` alone answered; plan attributes are absent`;
|
|
1795
|
-
return { live: index };
|
|
1796
|
-
}
|
|
1797
|
-
},
|
|
1798
|
-
|
|
1799
|
-
classifyBindFailure(err) {
|
|
1800
|
-
return live.classifyBindFailure!(err);
|
|
1801
|
-
},
|
|
1802
|
-
|
|
1803
|
-
async read(index, entity): Promise<EntityObservation> {
|
|
1804
|
-
const observed = await live.read(index.live, entity);
|
|
1805
|
-
const { plan } = index;
|
|
1806
|
-
if (!plan) return observed;
|
|
1807
|
-
const queried = `${observed.queried}; ${command} + show -json <planfile>`;
|
|
1808
|
-
const present = "present" in observed ? observed.present : undefined;
|
|
1809
|
-
if (!present || entity.type !== RESOURCE_TYPE || present.ownership !== "owned") return { ...observed, queried };
|
|
1810
|
-
const { address } = entity as TerraformDeclared;
|
|
1811
|
-
return {
|
|
1812
|
-
...observed,
|
|
1813
|
-
present: { ...present, attributes: { ...present.attributes, ...planAttributesFor(address, plan) } },
|
|
1814
|
-
queried,
|
|
1815
|
-
};
|
|
1816
|
-
},
|
|
1817
|
-
};
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
/** The environment variable that overrides every root's observation depth for one run (#4358). */
|
|
1821
|
-
export const TERRAFORM_OBSERVE_ENV = "CHANT_TERRAFORM_OBSERVE";
|
|
1822
|
-
|
|
1823
|
-
/**
|
|
1824
|
-
* Each root's observation depth, in precedence order: the caller's `depth`,
|
|
1825
|
-
* then {@link TERRAFORM_OBSERVE_ENV}, then the root's own `observe`, then the
|
|
1826
|
-
* namespace's, then `"state"`. The config is read only when neither of the
|
|
1827
|
-
* first two settles it, and a config that cannot be read means `"state"`,
|
|
1828
|
-
* which is what every root read before the plan depth existed.
|
|
1829
|
-
*/
|
|
1830
|
-
async function observeDepths(
|
|
1831
|
-
options: Pick<DescribeResourcesOptions, "depth" | "cwd">,
|
|
1832
|
-
notes: string[],
|
|
1833
|
-
): Promise<(root: string) => TerraformObserveDepth> {
|
|
1834
|
-
if (options.depth) return () => options.depth!;
|
|
1835
|
-
const env = process.env[TERRAFORM_OBSERVE_ENV];
|
|
1836
|
-
if (env === "plan" || env === "state") return () => env;
|
|
1837
|
-
if (env) notes.push(`${TERRAFORM_OBSERVE_ENV}=${JSON.stringify(env)} is neither "state" nor "plan" and was ignored`);
|
|
1838
|
-
try {
|
|
1839
|
-
const { loadChantConfigUpward } = await import("@intentius/chant/config");
|
|
1840
|
-
const { resolve } = await import("node:path");
|
|
1841
|
-
const { config } = await loadChantConfigUpward(resolve(options.cwd ?? process.cwd()));
|
|
1842
|
-
const namespace = (config as { terraform?: { observe?: TerraformObserveDepth; roots?: Record<string, { observe?: TerraformObserveDepth }> } }).terraform;
|
|
1843
|
-
return (root) => namespace?.roots?.[root]?.observe ?? namespace?.observe ?? "state";
|
|
1844
|
-
} catch {
|
|
1845
|
-
return () => "state";
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
export interface DescribeResourcesOptions {
|
|
1850
|
-
environment: string;
|
|
1851
|
-
buildOutput: string;
|
|
1852
|
-
entityNames: string[];
|
|
1853
|
-
entities: Map<string, { entityType: string; props: Record<string, unknown> }>;
|
|
1854
|
-
/**
|
|
1855
|
-
* Restrict to state-backed entities (#1348). A withheld entity is
|
|
1856
|
-
* `filtered`, never a silent drop into `absent`: a live module block still
|
|
1857
|
-
* exists, chant just has no state row saying it is managed.
|
|
1858
|
-
*/
|
|
1859
|
-
owned?: boolean;
|
|
1860
|
-
/**
|
|
1861
|
-
* Directory the activities start the `chant.config.*` search from. Default:
|
|
1862
|
-
* the running process's cwd. Same meaning as `TerraformWatchOpConfig.cwd`.
|
|
1863
|
-
*/
|
|
1864
|
-
cwd?: string;
|
|
1865
|
-
/**
|
|
1866
|
-
* Read every stock root at this depth (#4358), over the config's
|
|
1867
|
-
* `terraform.observe` and `terraform.roots.<name>.observe` and the
|
|
1868
|
-
* `CHANT_TERRAFORM_OBSERVE` variable. Not a core option: a caller holding
|
|
1869
|
-
* this lexicon directly (behold) passes it, and the CLI reaches it through
|
|
1870
|
-
* the config or the variable.
|
|
1871
|
-
*/
|
|
1872
|
-
depth?: TerraformObserveDepth;
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
/**
|
|
1876
|
-
* Observe every declared terraform entity, one `init` + `show` per configured
|
|
1877
|
-
* root. Roots are read independently, so a broken backend on one never
|
|
1878
|
-
* un-observes another (`mergeObservations`).
|
|
1879
|
-
*/
|
|
1880
|
-
export async function describeResources(
|
|
1881
|
-
options: DescribeResourcesOptions,
|
|
1882
|
-
deps: TerraformReadDeps = REAL_DEPS,
|
|
1883
|
-
): Promise<DescribeResourcesResult> {
|
|
1884
|
-
const byRoot = new Map<string, TerraformDeclared[]>();
|
|
1885
|
-
const rootless: TerraformDeclared[] = [];
|
|
1886
|
-
|
|
1887
|
-
for (const name of options.entityNames) {
|
|
1888
|
-
const declared = declaredOf(name, options.entities.get(name));
|
|
1889
|
-
if (!declared.root) {
|
|
1890
|
-
rootless.push(declared);
|
|
1891
|
-
continue;
|
|
1892
|
-
}
|
|
1893
|
-
const bucket = byRoot.get(declared.root);
|
|
1894
|
-
if (bucket) bucket.push(declared);
|
|
1895
|
-
else byRoot.set(declared.root, [declared]);
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
const parts = [];
|
|
1899
|
-
const notes: string[] = [];
|
|
1900
|
-
// Which of the two reads answered, per entity (#2267). Filled for every
|
|
1901
|
-
// entity of the root before the read runs, so the answer is on the wire
|
|
1902
|
-
// whatever the verdict came back as: present, absent, or not-observed. A
|
|
1903
|
-
// renderer joins observations to nodes, and painting `terraform show -json`
|
|
1904
|
-
// over state the same green as a live read of the account is the drift lie
|
|
1905
|
-
// an overlay exists to prevent.
|
|
1906
|
-
const sources: Record<string, string> = {};
|
|
1907
|
-
const rootReads: Record<string, RootRead> = {};
|
|
1908
|
-
const edges: IREdge[] = [];
|
|
1909
|
-
// A live root's observation with the engine graph's facts and edges on it (#4528).
|
|
1910
|
-
const withEngineGraph = async (root: string, handoff: LivePlanHandoff, observed: ReturnType<typeof normalizeObservation>) => {
|
|
1911
|
-
const graph = await engineGraphFor(root, options.cwd, deps, handoff);
|
|
1912
|
-
if (graph.note) notes.push(graph.note);
|
|
1913
|
-
if (!graph.read) return observed;
|
|
1914
|
-
edges.push(...graph.read.edges);
|
|
1915
|
-
return { ...observed, resources: withEngineFacts(observed.resources, graph.read) };
|
|
1916
|
-
};
|
|
1917
|
-
const depthOf = byRoot.size > 0 ? await observeDepths(options, notes) : () => "state" as const;
|
|
1918
|
-
for (const [root, declared] of byRoot) {
|
|
1919
|
-
// One fact decides the whole read, and the parse already recorded it on
|
|
1920
|
-
// every entity of the root (#2103). A root is live when its binary is
|
|
1921
|
-
// choudoufu AND it declares an estate, so a single entity carrying
|
|
1922
|
-
// `mode: "live"` settles it for the root.
|
|
1923
|
-
const live = declared.some((entity) => entity.mode === "live");
|
|
1924
|
-
const depth = depthOf(root);
|
|
1925
|
-
if (live) {
|
|
1926
|
-
notes.push(
|
|
1927
|
-
`terraform.roots.${root} is a live root: ownership came from choudoufu's tofu-estate/tofu-address markers via \`live-plan -json\`, not from a state file`,
|
|
1928
|
-
);
|
|
1929
|
-
if (depth === "plan") {
|
|
1930
|
-
// Both reads (#4371): `live-plan` for ownership, the plan for the
|
|
1931
|
-
// attributes on what it bound. `sources` is known only after the read.
|
|
1932
|
-
const outcome: { answered: LivePlanDepthAnswer; note: string; read?: RootRead } = { answered: "live", note: "" };
|
|
1933
|
-
const handoff: LivePlanHandoff = {};
|
|
1934
|
-
const read = await observeEntities(declared, livePlanDepthAdapter(root, options.cwd, deps, outcome, handoff));
|
|
1935
|
-
for (const entity of declared) sources[entity.name] = outcome.answered;
|
|
1936
|
-
if (outcome.read) rootReads[`terraform.roots.${root}`] = outcome.read;
|
|
1937
|
-
if (outcome.note) notes.push(outcome.note);
|
|
1938
|
-
parts.push(await withEngineGraph(root, handoff, normalizeObservation(read)));
|
|
1939
|
-
continue;
|
|
1940
|
-
}
|
|
1941
|
-
for (const entity of declared) sources[entity.name] = "live";
|
|
1942
|
-
const handoff: LivePlanHandoff = {};
|
|
1943
|
-
const read = await observeEntities(declared, liveAdapter(root, options.cwd, deps, handoff));
|
|
1944
|
-
parts.push(await withEngineGraph(root, handoff, normalizeObservation(read)));
|
|
1945
|
-
continue;
|
|
1946
|
-
}
|
|
1947
|
-
if (depth === "plan") {
|
|
1948
|
-
// The third depth (#4358). `sources` says which read answered, which on
|
|
1949
|
-
// a plan-depth root is only known after the read: the plan, the state
|
|
1950
|
-
// read it fell back to, or neither, in which case it names the read
|
|
1951
|
-
// that was attempted last.
|
|
1952
|
-
const outcome: { answered: PlanDepthAnswer; note: string; read?: RootRead } = { answered: "declared", note: "" };
|
|
1953
|
-
const read = await observeEntities(declared, planAdapter(root, options.cwd, deps, outcome));
|
|
1954
|
-
const value = outcome.answered === "state" ? "state" : "plan";
|
|
1955
|
-
for (const entity of declared) sources[entity.name] = value;
|
|
1956
|
-
if (outcome.read) rootReads[`terraform.roots.${root}`] = outcome.read;
|
|
1957
|
-
if (outcome.note) notes.push(outcome.note);
|
|
1958
|
-
parts.push(normalizeObservation(read));
|
|
1959
|
-
continue;
|
|
1960
|
-
}
|
|
1961
|
-
for (const entity of declared) sources[entity.name] = "state";
|
|
1962
|
-
parts.push(normalizeObservation(await observeEntities(declared, adapter(root, options.cwd, deps))));
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
const merged = mergeObservations(parts);
|
|
1966
|
-
merged.notes.push(...notes);
|
|
1967
|
-
const resources = { ...merged.resources };
|
|
1968
|
-
const unobserved = { ...merged.unobserved };
|
|
1969
|
-
|
|
1970
|
-
// An entity carrying no root came from somewhere other than `buildRoots()`;
|
|
1971
|
-
// there is no state file to look it up in, and saying so is not absence.
|
|
1972
|
-
for (const entity of rootless) {
|
|
1973
|
-
unobserved[entity.name] = {
|
|
1974
|
-
...(entity.type ? { type: entity.type } : {}),
|
|
1975
|
-
reason: "unsupported-kind",
|
|
1976
|
-
detail: "no `terraform.roots` entry on this entity, so there is no root module state to read it from",
|
|
1977
|
-
};
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
if (options.owned) {
|
|
1981
|
-
for (const [name, meta] of Object.entries(merged.resources)) {
|
|
1982
|
-
if (meta.ownership === "owned") continue;
|
|
1983
|
-
delete resources[name];
|
|
1984
|
-
unobserved[name] = {
|
|
1985
|
-
type: meta.type,
|
|
1986
|
-
reason: "filtered",
|
|
1987
|
-
detail: `this address read \`${meta.ownership ?? "unknown"}\` on the root's ownership channel (its state file, or its live markers) and --owned was requested`,
|
|
1988
|
-
...(merged.queried[name] ? { queried: merged.queried[name] } : {}),
|
|
1989
|
-
};
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
// A planned create's plan attributes (#4372) ride beside the verdict, never
|
|
1994
|
-
// in `resources`: the block stays absent.
|
|
1995
|
-
return observation(resources, unobserved, merged.queried, merged.notes, undefined, sources, merged.annotations, rootReads, edges);
|
|
1996
|
-
}
|