Skip to content

feat: add Map type#18

Merged
hfern merged 5 commits into
hfern:masterfrom
rhencke:feat/map-type
Mar 27, 2026
Merged

feat: add Map type#18
hfern merged 5 commits into
hfern:masterfrom
rhencke:feat/map-type

Conversation

@rhencke
Copy link
Copy Markdown
Contributor

@rhencke rhencke commented Mar 24, 2026

Summary

  • Adds Map(value_type) type for map(string→T) Terraform attributes
  • Wire format: ["map", <value_type>] — matches go-cty/OpenTofu encoding
  • encode/decode delegate to value_type per value, matching List/Set pattern
  • Handles None and Unknown sentinels consistently
  • Full test coverage added to test_types.py

Motivation

Without Map, the only option for key→value attributes (e.g. environment variables, trigger maps) is NormalizedJson, which forces users to write jsonencode({...}) in HCL. With Map(String()) users can write natural HCL:

# Before
environment = jsonencode({ FOO = "bar" })

# After
environment = { FOO = "bar" }

Test plan

  • test_map_encode — None/Unknown passthrough + encode/decode round-trip
  • test_map_encode_delegates_to_value_type — value_type applied per value
  • test_map_type_encoding — tf_type() for String/Number/Bool/nested types
  • test_map_semantic_equality — dict equality, None/Unknown/empty cases

Map(value_type) provides map(string→T) support.
Wire format: ["map", <value_type>], matches go-cty encoding.
Encode/decode delegate to value_type per value.
Handles None and Unknown sentinels like List/Set.
rhencke added a commit to rhencke/terraform-provider-terrible that referenced this pull request Mar 24, 2026
…tags/skip_tags

Drops NormalizedJson workaround for structured framework attributes.
Users can now write natural HCL instead of jsonencode():

  triggers     = { version = var.app_version }
  environment  = { FOO = "bar" }
  tags         = ["deploy"]
  skip_tags    = ["slow"]

Depends on rhencke/tf feat/map-type (upstream PR: hfern/tf#18).
pyproject.toml sources tf from the fork until the PR merges.
github-actions Bot pushed a commit to rhencke/terraform-provider-terrible that referenced this pull request Mar 24, 2026
…128)

* feat: use Map(String()) for triggers/environment, List(String()) for tags/skip_tags

Drops NormalizedJson workaround for structured framework attributes.
Users can now write natural HCL instead of jsonencode():

  triggers     = { version = var.app_version }
  environment  = { FOO = "bar" }
  tags         = ["deploy"]
  skip_tags    = ["slow"]

Depends on rhencke/tf feat/map-type (upstream PR: hfern/tf#18).
pyproject.toml sources tf from the fork until the PR merges.

* docs: update README to reflect current state (uv, dynamic module discovery, features)

* refactor: remove gen/ and EphemeralMixin now that tf fork handles 6.9 natively

- Delete terrible_provider/gen/ (custom 6.9 proto stubs no longer needed)
- Remove EphemeralMixin and _xproto/_xdiags helpers from ephemeral.py
- Simplify cli.py to call tf.runner.run_provider() directly (5 lines)
- Remove EphemeralMixin tests (behaviour now covered in tf fork test suite)
- Clean up pyproject.toml: remove gen/ exclusions from coverage/ruff/ty

* chore: point tf dependency at git fork (feat/ephemeral-resources)
@hfern hfern self-requested a review March 27, 2026 06:59
@hfern
Copy link
Copy Markdown
Owner

hfern commented Mar 27, 2026

Thank you @rhencke for your contribution! 🎉 I've added some docs and a couple of e2e tests.

@hfern hfern merged commit 9149121 into hfern:master Mar 27, 2026
6 checks passed
@rhencke
Copy link
Copy Markdown
Contributor Author

rhencke commented Mar 28, 2026

Thank you! (tf is fantastic by the way)

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