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

validate: Default provider name to base directory when running validate #377

Merged
merged 4 commits into from
May 24, 2024

Conversation

austinvalle
Copy link
Member

Closes #376

Prior to fix, running from root of terraform-provider-time:

 $ tfplugindocs validate                     
exporting schema from Terraform
compiling provider ""
using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
running terraform init
Error executing command: validation errors found: 
error exporting provider schema from Terraform: unable to run terraform init on provider: exit status 1
Terraform encountered problems during initialisation, including problems
with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Invalid provider local name

  on provider.tf line 2:
   2: provider "" {

 is an invalid provider local name: must have at least one character


Error: Invalid provider local name

  on provider.tf line 2:
   2: provider "" {

 is an invalid provider local name: must have at least one character

After fix:

 $ tfplugindocs validate
exporting schema from Terraform
compiling provider "time"
using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
running terraform init
getting provider schema
2024/05/24 12:25:25 [DEBUG] Found documentation files [docs/functions/rfc3339_parse.md docs/index.md docs/resources/offset.md docs/resources/rotating.md docs/resources/sleep.md docs/resources/static.md]
running mixed directories check
2024/05/24 12:25:25 [DEBUG] Found directory: docs/functions
2024/05/24 12:25:25 [DEBUG] Found directory: docs
2024/05/24 12:25:25 [DEBUG] Found directory: docs/resources
2024/05/24 12:25:25 [DEBUG] Found directory: docs/resources
2024/05/24 12:25:25 [DEBUG] Found directory: docs/resources
2024/05/24 12:25:25 [DEBUG] Found directory: docs/resources
running number of files check
2024/05/24 12:25:25 [TRACE] Found 1 documentation files in directory: docs/functions
2024/05/24 12:25:25 [TRACE] Found 4 documentation files in directory: docs/resources
2024/05/24 12:25:25 [DEBUG] Found 5 documentation files with limit of 2000
detected static docs directory, running checks
running invalid directories check on docs/functions
running file checks on docs/functions/rfc3339_parse.md
2024/05/24 12:25:25 [DEBUG] Checking file: /Users/austin.valle/code/terraform-provider-time/docs/functions/rfc3339_parse.md
2024/05/24 12:25:25 [DEBUG] File /Users/austin.valle/code/terraform-provider-time/docs/functions/rfc3339_parse.md size: 2061 (limit: 500000)
running file checks on docs/index.md
2024/05/24 12:25:25 [DEBUG] Checking file: /Users/austin.valle/code/terraform-provider-time/docs/index.md
2024/05/24 12:25:25 [DEBUG] File /Users/austin.valle/code/terraform-provider-time/docs/index.md size: 1725 (limit: 500000)
running invalid directories check on docs/resources
running file checks on docs/resources/offset.md
2024/05/24 12:25:25 [DEBUG] Checking file: /Users/austin.valle/code/terraform-provider-time/docs/resources/offset.md
2024/05/24 12:25:25 [DEBUG] File /Users/austin.valle/code/terraform-provider-time/docs/resources/offset.md size: 4082 (limit: 500000)
running file checks on docs/resources/rotating.md
2024/05/24 12:25:25 [DEBUG] Checking file: /Users/austin.valle/code/terraform-provider-time/docs/resources/rotating.md
2024/05/24 12:25:25 [DEBUG] File /Users/austin.valle/code/terraform-provider-time/docs/resources/rotating.md size: 4952 (limit: 500000)
running file checks on docs/resources/sleep.md
2024/05/24 12:25:25 [DEBUG] Checking file: /Users/austin.valle/code/terraform-provider-time/docs/resources/sleep.md
2024/05/24 12:25:25 [DEBUG] File /Users/austin.valle/code/terraform-provider-time/docs/resources/sleep.md size: 4187 (limit: 500000)
running file checks on docs/resources/static.md
2024/05/24 12:25:25 [DEBUG] Checking file: /Users/austin.valle/code/terraform-provider-time/docs/resources/static.md
2024/05/24 12:25:25 [DEBUG] File /Users/austin.valle/code/terraform-provider-time/docs/resources/static.md size: 2713 (limit: 500000)
running file mismatch check
2024/05/24 12:25:25 [DEBUG] Found file offset.md
2024/05/24 12:25:25 [DEBUG] Found file rotating.md
2024/05/24 12:25:25 [DEBUG] Found file sleep.md
2024/05/24 12:25:25 [DEBUG] Found file static.md
2024/05/24 12:25:25 [DEBUG] Found resource time_offset
2024/05/24 12:25:25 [DEBUG] Found resource time_rotating
2024/05/24 12:25:25 [DEBUG] Found resource time_sleep
2024/05/24 12:25:25 [DEBUG] Found resource time_static

@austinvalle austinvalle added the bug Something isn't working label May 24, 2024
@austinvalle austinvalle added this to the v0.19.3 milestone May 24, 2024
@austinvalle austinvalle requested a review from a team as a code owner May 24, 2024 16:27
Copy link
Contributor

@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.

This fix works (verified locally with terraform-provider-random directory which doesn't work on 0.19.2) and looks good to me 🚀

Not sure if it makes sense to update the --provider-name flag for this default behavior (both in the generate and validate commands). It might also be good to figure out how to integration test this in the future as well.

@austinvalle
Copy link
Member Author

Added a comment to all the commands (migrate also has it mentioned, so I just adjusted it for them all to follow the same wording) 4729644

Re testing: agreed. The txtar archive tests all utilize --provider-name and I think would need to be consistently run in a directory. Perhaps we could add that into the actual archived CLI commands itself eventually? 🤔

@austinvalle austinvalle merged commit 7f32d68 into main May 24, 2024
6 checks passed
@austinvalle austinvalle deleted the av/fix-validate-cmd branch May 24, 2024 18:39
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate command not working
2 participants