terradart_codegen 0.12.0
terradart_codegen: ^0.12.0 copied to clipboard
terradart Stage 1 codegen — parses Terraform provider schema JSON and Magic Modules YAML and emits annotated abstract Dart classes. Ships the terradart CLI.
terradart_codegen #
Codegen for terradart. Parses terraform providers schema -json (plus optional Magic Modules YAML overlays) and emits typed Dart factory wrappers for use with terradart_core.
This package ships the terradart CLI with three subcommands:
terradart codegen— for anygoogle_*resource that isn't already interradart_google. Emits annotated abstract Dart classes into your ownlib/generated/directory; you then runbuild_runnerto produce the concrete bindings.terradart wrap— used byterradart_googlemaintainers to regenerate the 28 curated factory wrappers + their schema carriers from YAML overrides underlib/src/codegen/wrapper_overrides/yaml/. Run with--checkin CI to verify the wrap output stays byte-identical (deterministic codegen guarantee).terradart wrap-promote— scans a curated override yaml against the parsed schema and proposesenum_valuesblocks +dartTypeOverridesentries for fields whose schema declares a fixed value set. Authors review and integrate manually so naming choices stay with the human.
Installation #
terradart_codegen ships the terradart CLI. terradart is a SemVer pre-release, so activate with an explicit version:
dart pub global activate terradart_codegen 0.1.0-dev
(dart pub global activate terradart_codegen without an explicit version skips pre-releases.)
Quickstart: emit bindings for any other resource #
# 1. Dump the provider schema.
mkdir schema-dir && cd schema-dir
cat > providers.tf <<'EOF'
terraform {
required_providers {
google = { source = "hashicorp/google", version = "~> 7.0" }
}
}
EOF
terraform init
terraform providers schema -json > schema.json
cd ..
# 2. Run codegen.
terradart codegen \
--provider hashicorp/google \
--source schema-dir \
--output lib/generated
# 3. Run build_runner to produce the concrete bindings.
dart run build_runner build
The --source directory must contain schema.json (output of terraform providers schema -json) and may contain an optional mm/<resource>.yaml overlay subdirectory.
For the runtime side (Stack, Resource, Stack.synth / Stack.writeTo), see terradart_core. For the 28 curated GCP factory wrappers, see terradart_google. For project-level documentation see the terradart repo README.