Skip to content

[TFgen] Adding a new terraform generator#3840

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

[TFgen] Adding a new terraform generator#3840
Supam wants to merge 9 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
Supam added 2 commits June 5, 2026 13:34
* [TFgen] Added a report structure

Added a report structure for after run reports.
This will be used by CI and may be used by other tools downstream.

* [TFgen] Added tests for the reporting structure

* [TFgen] Started wiring the reporter

Set initial values for the run report in the generate command.
The rest of the content should be filled by the actual generation.

* [TFgen] Fix empty generator_version and gofmt the report layer

cmd.Version is empty on the generate subcommand: cobra does not propagate
Version from the root command, so the report's generator_version field was
always "". Read it from cmd.Root().Version, where main.go stamps it.

Also gofmt the RunReport and Spec struct literals (value alignment, stray
blank lines) and fix a doc-comment typo in report.go.
* [TFgen] Added a report structure

Added a report structure for after run reports.
This will be used by CI and may be used by other tools downstream.

* [TFgen] Added tests for the reporting structure

* [TFgen] Started wiring the reporter

Set initial values for the run report in the generate command.
The rest of the content should be filled by the actual generation.

* [TFgen] Fix empty generator_version and gofmt the report layer

cmd.Version is empty on the generate subcommand: cobra does not propagate
Version from the root command, so the report's generator_version field was
always "". Read it from cmd.Root().Version, where main.go stamps it.

Also gofmt the RunReport and Spec struct literals (value alignment, stray
blank lines) and fix a doc-comment typo in report.go.

* [TFgen] (CI) Added the generator go.mod to the license check

Added .generator-v2/go.sum to GO-SUMS when the file exists.
This will prevent the generator-v2 dependencies flying under the radar

* [TFgen] (CI) Added 3rd party licenses used in tfgen

The License check was previously not run in the generator.
Now that is is I have updated the file to add the used licences.
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