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

Rewrite Validate Command #341

Merged
merged 31 commits into from Mar 27, 2024
Merged

Rewrite Validate Command #341

merged 31 commits into from Mar 27, 2024

Conversation

SBGoods
Copy link
Contributor

@SBGoods SBGoods commented Mar 5, 2024

Closes: #36
Closes: #38
Closes: #182

Rewrites the validate subcommand to migrate and adapt a number of checks from bflad/tfproviderdocs including:

Check Description
InvalidDirectoriesCheck Checks for valid subdirectory structure and throws an error if an invalid Terraform Provider documentation subdirectory is found.
MixedDirectoriesCheck Throws an error if both legacy documentation (/website/docs) and registry documentation (/docs) are found.
NumberOfFilesCheck Throws an error if the number of files in a directory is larger than the registry limit.
FileSizeCheck Throws an error if the documentation file is above the registry storage limit.
FileExtensionCheck Throws an error if the extension of the given file is not a valid registry documentation extension.
FrontMatterCheck Checks the YAML frontmatter of documentation for missing required fields or invalid fields.
FileMismatchCheck Throws an error if the names/number of resources/datasources/functions in the provider schema does not match the names/number of files in the corresponding documentation directory
  • Provider-defined function support has also been added to all checks.
  • Template directory checks have been removed to narrow the scope of the validate subcommand to rendered provider documentation (/website/docs and /docs).
  • Updates Go version to 1.21

@SBGoods SBGoods requested a review from a team as a code owner March 5, 2024 17:50
@SBGoods SBGoods added this to the v0.19.0 milestone Mar 5, 2024
@SBGoods SBGoods added enhancement New feature or request command/validate labels Mar 5, 2024
Copy link
Contributor

@bendbennett bendbennett left a comment

Choose a reason for hiding this comment

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

Awesome job!

Really fantastic work 🚀

internal/check/file.go Outdated Show resolved Hide resolved
defer os.RemoveAll(tmpDir)

l.infof("compiling provider %q", shortName)
providerPath := fmt.Sprintf("plugins/registry.terraform.io/hashicorp/%s/0.0.1/%s_%s", shortName, runtime.GOOS, runtime.GOARCH)
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious to know the significance of using 0.0.1 here.

Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

This is looking great! Left some comments and questions

.changes/unreleased/FEATURES-20240305-135726.yaml Outdated Show resolved Hide resolved
.changes/unreleased/FEATURES-20240305-135933.yaml Outdated Show resolved Hide resolved
.changes/unreleased/FEATURES-20240305-135426.yaml Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
internal/provider/templates/template-description.gotmpl Outdated Show resolved Hide resolved
internal/provider/validate_test.go Outdated Show resolved Hide resolved
internal/provider/validate_test.go Outdated Show resolved Hide resolved
internal/provider/validate.go Outdated Show resolved Hide resolved
internal/provider/validate.go Outdated Show resolved Hide resolved
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.

Overall, great work! Looks like @bendbennett and @austinvalle got the good review items already. 😄

internal/check/provider_file.go Outdated Show resolved Hide resolved
internal/check/frontmatter.go Outdated Show resolved Hide resolved
internal/check/file_test.go Outdated Show resolved Hide resolved
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

LGTM, great work Selena!

I know you mentioned that there may be some additional pieces of work related to using the new YAML library, but I think the tests you wrote should hopefully cover any new changes 🚀

@SBGoods SBGoods merged commit 836a890 into main Mar 27, 2024
6 checks passed
@SBGoods SBGoods deleted the SBGoods/rewrite-validate-command branch March 27, 2024 18:20
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
command/validate enhancement New feature or request
Projects
None yet
4 participants