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

[Enhancement]: Schema Parameter Validations for all resources #21

Open
ryanhristovski opened this issue Aug 21, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@ryanhristovski
Copy link
Member

Description

We currently don't have any Validators on our resource schemas, setting these in the schema will allow for users to fail fast and not have to wait through a whole terraform apply to determine an error.

Failures here without validators can also put the terraform state file into a corrupted state which will be a huge burden on users.

Here's an example of what this looks like in repos:

"name": schema.StringAttribute{
  MarkdownDescription: "Repository name",
  Required:            true,
  PlanModifiers: []planmodifier.String{
    stringplanmodifier.RequiresReplace(),
  },
  Validators: []validator.String{
    stringvalidator.RegexMatches(
      regexp.MustCompile(`^[a-zA-Z0-9]([-.a-zA-Z0-9]*[a-zA-Z0-9])?$`),
      "Name must only contain alphanumeric characters, '.', or '-', and must start and end with an alphanumeric character",
    ),
  },
},

Affected Resource(s) and/or Data Source(s)

resource_access_token.go
resource_org_setting_image_access_management.go
resource_org_setting_registry_access_management.go
resource_org_team.go
resource_org_team_member_association.go
resource_repository.go
resource_repository_team_permission.go

Potential Terraform Configuration

No response

References

https://developer.hashicorp.com/terraform/plugin/framework/validation#parameter-validation

Would you like to implement a fix?

None

@ryanhristovski ryanhristovski added the enhancement New feature or request label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant