Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added data_tailscale_acl data source #304

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

markwellis
Copy link
Contributor

What this PR does / why we need it:
there is currently no acl data_source which makes working with the acl hard

Which issue this PR fixes (use fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged):

Fixes #180

Special notes for your reviewer:
I decided to expose it as a json blob as writing a schema and mangling it into that schema at load time was a lot of work and I don't see the benefit.
resource "tailscale_acl" takes a json string so it doesn't seem unreasonable that the data source for that would give a json string too
Also the external script I've been using up till now also works by providing a json string, which makes this a drop in replacement for that.

It works quite well with this test

data "tailscale_acl" "acl" {}

locals {
  acl = jsondecode(data.tailscale_acl.acl.json)
}

resource "tailscale_acl" "acl" {
  acl = jsonencode(merge(local.acl, {groups = merge(local.acl.groups, {"group:foo" = ["br@asd.com"]})}))

  allow_overwrite = true # in #303 
}

P.s. sorry if the code's not great, it's the first go I've written so I have no idea about best practice etc

Copy link
Collaborator

@knyar knyar left a comment

Choose a reason for hiding this comment

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

Thank you! Just a couple of minor comments here.

tailscale/data_source_acl.go Outdated Show resolved Hide resolved
tailscale/data_source_acl.go Outdated Show resolved Hide resolved
tailscale/data_source_acl.go Outdated Show resolved Hide resolved
tailscale/data_source_acl.go Outdated Show resolved Hide resolved
tailscale/data_source_acl.go Outdated Show resolved Hide resolved
tailscale/provider.go Outdated Show resolved Hide resolved
@markwellis
Copy link
Contributor Author

anything you need from me to get this moving?

thanks

@knyar
Copy link
Collaborator

knyar commented Dec 7, 2023

anything you need from me to get this moving?

It seems that CI checks are still failing. In this case I think what's missing is running go generate (or tfplugindocs directly) to regenerate markdown docs. Thank you!

@markwellis
Copy link
Contributor Author

I have updated the PR with tfplugindocs

Copy link
Collaborator

@knyar knyar left a comment

Choose a reason for hiding this comment

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

Thank you!

@knyar knyar merged commit 43b5098 into tailscale:main Dec 7, 2023
3 checks passed
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.

data resource for ACL
2 participants