-
Notifications
You must be signed in to change notification settings - Fork 71
Rewrite Validate Command #341
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
713f451
Initial validate implementation
SBGoods fd6e513
Add function tests to TestFileMismatchCheck
SBGoods f6810df
Add MixedDirectoryCheck and refactor relevant tests
SBGoods 7e3458e
Add functions and guides to glob pattern
SBGoods 71b2b72
Update README.md
SBGoods 7a851fd
Update documentationDirGlob to pass tests
SBGoods bbaa513
Add copyright headers
SBGoods 31cea02
Resolve linting errors
SBGoods ffb5959
Update README.md with a link to provider documentation guidelines
SBGoods 6b5d908
Merge branch 'main' into SBGoods/rewrite-validate-command
SBGoods 53a168f
Resolve linting errors
SBGoods 57bb756
Add changelog entries
SBGoods 86eb271
Add `NumberOfFilesCheck` to validate
SBGoods 6fefacb
Make file paths OS-agnostic
SBGoods 7e9d98a
Fix file path in test error assertion
SBGoods 0fd871a
Update Go version to `1.21`
SBGoods b2eef92
Change wording to past tense on changelog entries
SBGoods e4fff52
Remove unused file
SBGoods cc6300a
Remove `filecheck` interface
SBGoods a1b156e
Refactor `schemamd` and `functionmd` packages to `internal/`
SBGoods 96e07d4
Remove unused method
SBGoods 64373fb
Revert "Refactor `schemamd` and `functionmd` packages to `internal/`"
SBGoods 3f27ed2
Remove go compatability section
SBGoods 1bbf77f
Switch to `yuin/goldmark` for frontmatter parsing
SBGoods 3f57c3a
Remove unused test
SBGoods 498a524
Move global variables to top of file
SBGoods ed37a07
Refactor `testcases` to use `map[string]struct`
SBGoods 7411fa7
Refactor to use `t.tempDir()`
SBGoods 5702e4f
Fix documentationGlobPattern and add more debug and info logs
SBGoods 0ed7c0a
Add negative scenario acceptance tests
SBGoods 07b9f75
Merge remote-tracking branch 'origin/main' into SBGoods/rewrite-valid…
SBGoods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
kind: FEATURES | ||
body: 'validate: Add support for Provider-defined Function documentation' | ||
time: 2024-03-05T13:54:26.307742-05:00 | ||
custom: | ||
Issue: "341" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'validate: Add `InvalidDirectoriesCheck` which checks for valid provider documentation | ||
structure' | ||
SBGoods marked this conversation as resolved.
Show resolved
Hide resolved
|
||
time: 2024-03-05T13:57:26.273538-05:00 | ||
custom: | ||
Issue: "341" |
SBGoods marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'validate: Add `MixedDirectoriesCheck` which throws an error if both legacy | ||
documentation and registry documentation are found' | ||
time: 2024-03-05T13:59:33.741601-05:00 | ||
custom: | ||
Issue: "341" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'validate: Add `NumberOfFilesCheck` which checks the number of provider | ||
documentation files against the registry limit' | ||
time: 2024-03-05T14:01:06.742843-05:00 | ||
custom: | ||
Issue: "341" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'validate: Add `FileSizeCheck` which checks the provider documentation file | ||
size against the registry limit' | ||
time: 2024-03-05T14:02:34.112782-05:00 | ||
custom: | ||
Issue: "341" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'validate: Add `FileExtensionCheck` which checks for valid provider documentation | ||
file extensions' | ||
time: 2024-03-05T14:03:46.816256-05:00 | ||
custom: | ||
Issue: "341" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'validate: Add `FrontMatterCheck` which checks the YAML frontmatter of provider | ||
documentation for missing required fields or invalid fields' | ||
time: 2024-03-05T14:04:51.781688-05:00 | ||
custom: | ||
Issue: "341" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: FEATURES | ||
body: 'validate: Add `FileMismatchCheck` which checks the names/number of provider | ||
documentation files against the provider schema' | ||
time: 2024-03-05T14:06:22.168518-05:00 | ||
custom: | ||
Issue: "341" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
177 changes: 177 additions & 0 deletions
177
...indocs/testdata/scripts/schema-json/validate/framework_provider_success_legacy_docs.txtar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
# Successful run of tfplugindocs validate command on a Framework provider with docs in the legacy directory structure (i.e. r/<resource name>.md.tmpl) | ||
[!unix] skip | ||
exec tfplugindocs validate --provider-name=terraform-provider-scaffolding --providers-schema=schema.json | ||
cmp stdout expected-output.txt | ||
|
||
-- expected-output.txt -- | ||
exporting schema from JSON file | ||
getting provider schema | ||
detected legacy website directory, running checks | ||
running invalid directories check on website/docs/d | ||
running file checks on website/docs/d/example.html.md | ||
running invalid directories check on website/docs/functions | ||
running file checks on website/docs/functions/example.html.md | ||
running invalid directories check on website/docs/guides | ||
running file checks on website/docs/guides/example.html.md | ||
running file checks on website/docs/index.html.md | ||
running invalid directories check on website/docs/r | ||
running file checks on website/docs/r/example.html.md | ||
running file mismatch check | ||
-- website/docs/guides/example.html.md -- | ||
--- | ||
subcategory: "Example" | ||
layout: "example" | ||
page_title: "Example Guide" | ||
description: |- | ||
Example description. | ||
--- | ||
|
||
# Example Guide | ||
|
||
Example contents. | ||
|
||
-- website/docs/r/example.html.md -- | ||
--- | ||
subcategory: "Example" | ||
layout: "example" | ||
page_title: "Example: example_thing" | ||
description: |- | ||
Example description. | ||
--- | ||
# Data Fields | ||
|
||
Name: {{.Name}} | ||
Type: {{.Type}} | ||
-- website/docs/d/example.html.md -- | ||
--- | ||
subcategory: "Example" | ||
layout: "example" | ||
page_title: "Example: example_thing" | ||
description: |- | ||
Example description. | ||
--- | ||
# Data Fields | ||
|
||
Name: {{.Name}} | ||
Type: {{.Type}} | ||
-- website/docs/functions/example.html.md -- | ||
--- | ||
subcategory: "Example" | ||
layout: "example" | ||
page_title: "Example: example_thing" | ||
description: |- | ||
Example description. | ||
--- | ||
# Data Fields | ||
|
||
Name: {{.Name}} | ||
Type: {{.Type}} | ||
-- website/docs/index.html.md -- | ||
--- | ||
layout: "example" | ||
page_title: "Example Provider" | ||
description: |- | ||
Example description. | ||
--- | ||
# Data Fields | ||
|
||
Name: {{.Name}} | ||
Type: {{.Type}} | ||
-- schema.json -- | ||
{ | ||
"format_version": "1.0", | ||
"provider_schemas": { | ||
"registry.terraform.io/hashicorp/scaffolding": { | ||
"provider": { | ||
"version": 0, | ||
"block": { | ||
"attributes": { | ||
"endpoint": { | ||
"type": "string", | ||
"description": "Example provider attribute", | ||
"description_kind": "markdown", | ||
"optional": true | ||
} | ||
}, | ||
"description": "Example provider", | ||
"description_kind": "markdown" | ||
} | ||
}, | ||
"resource_schemas": { | ||
"scaffolding_example": { | ||
"version": 0, | ||
"block": { | ||
"attributes": { | ||
"configurable_attribute": { | ||
"type": "string", | ||
"description": "Example configurable attribute", | ||
"description_kind": "markdown", | ||
"optional": true | ||
}, | ||
"defaulted": { | ||
"type": "string", | ||
"description": "Example configurable attribute with default value", | ||
"description_kind": "markdown", | ||
"optional": true, | ||
"computed": true | ||
}, | ||
"id": { | ||
"type": "string", | ||
"description": "Example identifier", | ||
"description_kind": "markdown", | ||
"computed": true | ||
} | ||
}, | ||
"description": "Example resource", | ||
"description_kind": "markdown" | ||
} | ||
} | ||
}, | ||
"data_source_schemas": { | ||
"scaffolding_example": { | ||
"version": 0, | ||
"block": { | ||
"attributes": { | ||
"configurable_attribute": { | ||
"type": "string", | ||
"description": "Example configurable attribute", | ||
"description_kind": "markdown", | ||
"optional": true | ||
}, | ||
"id": { | ||
"type": "string", | ||
"description": "Example identifier", | ||
"description_kind": "markdown", | ||
"computed": true | ||
} | ||
}, | ||
"description": "Example data source", | ||
"description_kind": "markdown" | ||
} | ||
} | ||
}, | ||
"functions": { | ||
"example": { | ||
"description": "Given a string value, returns the same value.", | ||
"summary": "Echo a string", | ||
"return_type": "string", | ||
"parameters": [ | ||
{ | ||
"name": "input", | ||
"description": "Value to echo.", | ||
"type": "string" | ||
} | ||
], | ||
"variadic_parameter": { | ||
"name": "variadicInput", | ||
"description": "Variadic input to echo.", | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.