Skip to content

feat: Add non-blocking warning for Terraform provider repo naming convention #1506

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AshGodfrey
Copy link
Contributor

  • Add TerraformNamingWarning type and validation logic
  • Display styled warning when repository doesn't follow terraform-provider-{NAME} pattern
  • Warning is non-blocking and includes reference to HashiCorp docs
  • Add comprehensive unit and integration tests

- Add TerraformNamingWarning type and validation logic
- Display styled warning when repository doesn't follow terraform-provider-{NAME} pattern
- Warning is non-blocking and includes reference to HashiCorp docs
- Add comprehensive unit and integration tests
Copy link

linear bot commented Jul 9, 2025

@AshGodfrey AshGodfrey changed the title Add non-blocking warning for Terraform provider repo naming convention (WIP) Add non-blocking warning for Terraform provider repo naming convention Jul 9, 2025
@AshGodfrey AshGodfrey changed the title (WIP) Add non-blocking warning for Terraform provider repo naming convention Feat: Add non-blocking warning for Terraform provider repo naming convention (WIP) Jul 9, 2025
@AshGodfrey AshGodfrey changed the title Feat: Add non-blocking warning for Terraform provider repo naming convention (WIP) feat: Add non-blocking warning for Terraform provider repo naming convention (WIP) Jul 9, 2025
@AshGodfrey AshGodfrey changed the title feat: Add non-blocking warning for Terraform provider repo naming convention (WIP) feat: Add non-blocking warning for Terraform provider repo naming convention Jul 9, 2025
@AshGodfrey AshGodfrey requested a review from bflad July 9, 2025 16:01
@AshGodfrey
Copy link
Contributor Author

Copy link
Member

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Two small changes, otherwise looks good to me 🚀

Comment on lines +51 to +55
// IsTerraformNamingWarning checks if an error is a TerraformNamingWarning
func IsTerraformNamingWarning(err error) bool {
_, ok := err.(*TerraformNamingWarning)
return ok
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: https://pkg.go.dev/errors#As can be used to avoid defining this function, makes it safer in case the error is wrapped by other errors during refactoring, and makes accessing inner details easier.

e.g. instead of

if prompts.IsTerraformNamingWarning(err) {

That logic can use something like this to quickly check the error type:

if errors.As(err, new(prompts.TerraformNamingWarning)) {

If you actually wanted to reference the error type fields, likeRepoName, a variable can be used:

var terraformNamingWarningErr prompts.TerraformNamingWarning
if errorrs.As(err, &terraformNamingWarningErr) {
  // now we have terraformNamingWarningErr.RepoName

Not necessary in this context since the error message already has RepoName in there, but just wanted to mention. 👍

repoName := urlParts[len(urlParts)-1]
if err := checkTerraformRepositoryNaming(repoName); err != nil {
// Return the target with the warning attached
return target, err
Copy link
Member

Choose a reason for hiding this comment

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

Since this return is happening before target.Publishing is being set, technically its acting more like an error rather than a warning. I think we'll want to decide what's better or worse here:

  • (Current) Not updating the workflow configuration.
  • (Alternative) Updating the workflow configuration, then raising the warning.

I think we want the latter by moving this logic below target.Publishing =, since its possible for someone to rectify the issue outside the Speakeasy CLI (unless there's other steps necessary).

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.

3 participants