-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add API Token Resource #110
Conversation
@@ -103,6 +103,36 @@ func ApiTokenRoleAttributeTypes() map[string]attr.Type { | |||
} | |||
} | |||
|
|||
func ResourceApiTokenRoleSchemaAttributes() map[string]resourceSchema.Attribute { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you look at resource_deployment.go
's ValidateConfig
We should have something like that for the roles.
For example, if its an organization token, then it can have any role
If it is a deployment token, it can just have one role
In this we should also check that the role matches the entity. Ie. workspace roles for workspace entities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also add a bunch of error test cases for these in the acceptance tests
…terraform-provider-astro into 105-add-api-tokens-resource
Roles: []apiTokenRole{ | ||
{ | ||
Role: string(iam.WORKSPACEOWNER), | ||
EntityId: workspaceId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EntityId: workspaceId, | |
EntityId: organizationId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is workspaceId intentionally - we want the role to be completely wrong
var invalidRoleError string | ||
|
||
for _, role := range roles { | ||
if entityType == string(iam.ApiTokenRoleEntityTypeWORKSPACE) && role.EntityType == iam.ApiTokenRoleEntityTypeORGANIZATION { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we check that if entityType
is organization then the entityId
matches r.OrganizationId
and add a test case as well for when it doesnt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't include this validation because r.OrganizationId
is not set when ValidateConfig
is run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add that as a comment in the code as well
Description
Add API Token resource to terraform.
Supports:
🎟 Issue(s)
#105
🧪 Functional Testing
Create
Update
Delete
📸 Screenshots
📋 Checklist
examples/
directory