Skip to content

[TFgen] Adding a new terraform generator#3840

Draft
Supam wants to merge 7 commits into
masterfrom
generator-v2
Draft

[TFgen] Adding a new terraform generator#3840
Supam wants to merge 7 commits into
masterfrom
generator-v2

Conversation

@Supam
Copy link
Copy Markdown
Member

@Supam Supam commented Jun 1, 2026

Summary

Introduces .generator-v2/, a new standalone Go module that will replace the hand-written Terraform resource/data source authoring workflow. The generator reads the Datadog OpenAPI Specification, respects a x-datadog-tf-generator tracking field, and emits Go source code using the Datadog go-sdk.

This PR adds the module skeleton only:

  • cmd/tfgen/main.go entry point with Cobra root command
  • Global flags (--spec, --output-root, --hooks-root, --tracking-field, --max-depth, --report, --quiet)
  • tfgen generate and tfgen verify subcommands (no-op stubs)
  • Internal package layout (parser, model, emit, hooks, report)
  • CI step: cd .generator-v2 && go test ./...

Test Plan

cd .generator-v2
go build ./cmd/tfgen
./tfgen --help
./tfgen generate --help
./tfgen verify --help
go test ./...

Copy link
Copy Markdown
Member Author

Supam commented Jun 1, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Supam Supam changed the title [tfgen] Initial commit for generator-v2 [TFgen] Initial commit for generator-v2 Jun 1, 2026
@Supam Supam changed the title [TFgen] Initial commit for generator-v2 [TFgen] Adding a new terraform generator Jun 1, 2026
@datadog-datadog-prod-us1-2

This comment has been minimized.

Supam and others added 7 commits June 4, 2026 13:35
Setup commit for the new generator CLI.
Added stubs for the current .go files.
Added cobra, libopenapi, and their dependencies to the LICENSE-3rdparty
file.
* [1.4] Add a github workflow for build + vet

* [1.5] Add make command to build/test the generator

* [1.6] Create testdata/fixtures with README

* root formatting fixes

* updated 1.4 to any branch and added go depencency files to paths
Added enums :
- ArtifactKind
- SchemaKind
- IdStrategy

Added structs:
- Spec
- Operation
- Schema
- Artifact
- TrackingFieldMetadata
- various other supporting structs...
* [TFgen] Added a identifier translator to match the goSDK

The translator will transform the OAS snake_case names into the
equivalent PascalCase that are used in the go SDK.

Removed internal ticket names.

* [TFgen] Added .gitignore
* [TFgen] Added a parser to load the OAS

Added the parser's test data do `testdata/parser`

* [TFgen] Added $ref cycle detection

* [TFgen] Fail fast on circular $refs and wire --max-depth

LoadSpec now resolves the component schema graph before enumerating:
a circular $ref returns a typed *RefCycleError naming the offending
ref, and expansion past --max-depth returns a depth error.

The --max-depth flag is now wired through the generate command.

* [TFgen] Added -race and -cover to the `make tfgen-test` command

* [TFgen] (Nit) Addressed some minor concerns

- Added better fixture coverage for allOf / anyOf
- Added custom error for when max depth is reached in cycles.go
…tection (#3853)

* Implement tracking-field decoder + duplicate artifact name detection

* Fixed potential errors with missing skip values.

* Support for ignoring duplicates if they have different kinds.

* comment/contracts cleanup

* removed redundant testing while keeping the same coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants