Skip to content

all: create a Mux terraform for Terraform SDKv2 + plugin framework#645

Merged
alexwlchan merged 1 commit intomainfrom
alexc/mux-server
Mar 11, 2026
Merged

all: create a Mux terraform for Terraform SDKv2 + plugin framework#645
alexwlchan merged 1 commit intomainfrom
alexc/mux-server

Conversation

@alexwlchan
Copy link
Copy Markdown
Member

Start migrating to the Terraform plugin framework by serving the provider using both the existing SDKv2 and the framework served via a mux. This patch contains the basic mux server and enough changes to get the acceptance tests passing, but doesn't actually implement any resources or data sources.

Updates tailscale/corp#37220

@alexwlchan alexwlchan force-pushed the alexc/mux-server branch 4 times, most recently from 011f3df to a6463fe Compare March 6, 2026 11:26
Comment on lines -86 to -87
// Don't require any of the global configuration
p.Schema = nil
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Terraform checks that the schema is consistent across the muxed providers, our old strategy of deleting the schema for the tests doesn't
work; instead, we set an API key via environment variable. The t.Setenv helper can't be used in parallel, so we have to switch parallel tests to
serial.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was originally done for our "unit tests" (e.g., those marked with IsUnitTest: true in resource.TestCase) as they don't run against a real server but do use the Terraform acceptance testing logic.

I think we can likely remove most (if not all) tests of this form as a followup / cleanup action since they don't provide much actual value vs. acceptance tests. E.g., they are a very bare minimum check that a plan / apply can succeed against a completely mocked out server that does not actually return data in the correct shape.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to leave that for a separate PR, rather than stack new changes into this patch.

One reason we might want to keep them: AIUI we don't currently run acceptance tests against PRs? So those minimal tests give us some safety net that something isn't completely broken when we do small patches (e.g. adding Fleet and Huntress last week).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good to me! Yeah we don't currently have an automated way of running acceptance tests against PRs aside from the manual workflow trigger in corp.

Something I've wanted for a bit but not had the time to explore further is adding a GitHub app / bot that listens for PRs here, downloads the repo at the branch, and runs the acceptance test flows (assuming that the author is a contributor or that we have explicitly approved running against a branch from a fork). This is an even further in the future thing, but would be a lot nicer UX for PRs here if / when we have it 🙂

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created as a separate ticket: #649

@alexwlchan alexwlchan force-pushed the alexc/mux-server branch 2 times, most recently from 8212eaf to 36fa76e Compare March 6, 2026 11:34
@alexwlchan alexwlchan requested a review from mpminardi March 6, 2026 17:00
Comment thread tailscale/provider.go Outdated
Comment thread tailscale/provider.go Outdated
Comment thread tailscale/provider.go Outdated
Comment thread tailscale/provider.go Outdated
Comment thread tailscale/provider.go Outdated
Comment thread tailscale/provider.go Outdated
Comment on lines -86 to -87
// Don't require any of the global configuration
p.Schema = nil
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was originally done for our "unit tests" (e.g., those marked with IsUnitTest: true in resource.TestCase) as they don't run against a real server but do use the Terraform acceptance testing logic.

I think we can likely remove most (if not all) tests of this form as a followup / cleanup action since they don't provide much actual value vs. acceptance tests. E.g., they are a very bare minimum check that a plan / apply can succeed against a completely mocked out server that does not actually return data in the correct shape.

Bumps [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) from 6.3.0 to 7.0.0.
- [Release notes](https://github.com/crazy-max/ghaction-import-gpg/releases)
- [Commits](crazy-max/ghaction-import-gpg@e89d409...2dc316d)

---
updated-dependencies:
- dependency-name: crazy-max/ghaction-import-gpg
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

all: create a Mux terraform for Terraform SDKv2 + plugin framework

Start migrating to the Terraform plugin framework by [serving the provider][1]
using both the existing SDKv2 and the framework served via [a mux][2].
This patch contains the basic mux server and enough changes to get the
acceptance tests passing, but doesn't actually implement any resources
or data sources.

Because Terraform checks that the schema is consistent across the muxed
providers, our old strategy of deleting the schema for the tests doesn't
work; instead, we set an API key via environment variable. The `t.Setenv`
helper can't be used in parallel, so we have to switch parallel tests to
serial.

[1]: https://developer.hashicorp.com/terraform/plugin/framework/migrating/providers#serving-the-provider
[2]: https://developer.hashicorp.com/terraform/plugin/framework/migrating/mux

Updates tailscale/corp#37220

Signed-off-by: Alex Chan <alexc@tailscale.com>
@alexwlchan
Copy link
Copy Markdown
Member Author

I've addressed all the nits and broken the framework code into a new file.

@alexwlchan alexwlchan merged commit b209337 into main Mar 11, 2026
5 checks passed
@alexwlchan alexwlchan deleted the alexc/mux-server branch March 11, 2026 07:44
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