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

[fix] Change client validation of permissions revoke type #42

Merged
merged 2 commits into from
Dec 13, 2024

Conversation

albertchang
Copy link
Contributor

Description

Currently, we'll get an error if we try to revoke >1 permission of mixed types, like this:

resource "retool_permissions" "test_permissions" {
  subject = {
    type = "group"
    id   = retool_group.test_group.id
  }
  permissions = [
    {
      object = {
        type = "folder"
        id   = retool_folder.test_folder2.id
      }
      access_level = "use"
    },
    {
      object = {
        type = "folder"
        id   = retool_folder.test_folder3.id
      }
      access_level = "own"
    },
  ]
}

This is because the client sdk throws an error when the response type of the permissions endpoint contains more than one "object" type, as visible here in the spec:
image

This is an imprecise mapping of our internal discriminated unions to the openapi spec, since in reality it's possible for our permission group to have multiple types of objects. To resolve, I manually updated the definition in our spec and regenerated the client code to accept anyOf.

Tests

Manually tried to apply and destroy the above terraform, and confirmed there are no errors.

@albertchang albertchang force-pushed the albert-permissions-revoke branch from 7e3223f to f754fd9 Compare December 12, 2024 18:35
@@ -48,6 +48,11 @@ jobs:
go-version-file: go.mod
check-latest: true

- name: Setup Terraform with specified version on the runner
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why this started breaking, but we get a complaint about missing terraform binary, so I added a step to install it.

@albertchang albertchang requested a review from a team December 12, 2024 18:40
@albertchang albertchang merged commit 06fd6e3 into main Dec 13, 2024
3 checks passed
@albertchang albertchang deleted the albert-permissions-revoke branch December 13, 2024 19:20
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