diff --git a/.changes/unreleased/ENHANCEMENTS-20231117-151029.yaml b/.changes/unreleased/ENHANCEMENTS-20231117-151029.yaml index c5744540..4ebbfee0 100644 --- a/.changes/unreleased/ENHANCEMENTS-20231117-151029.yaml +++ b/.changes/unreleased/ENHANCEMENTS-20231117-151029.yaml @@ -1,6 +1,6 @@ kind: ENHANCEMENTS -body: 'generate: Add `provider-schema` flag to pass in a file path to a provider schemas - file, allowing the command to skip schema generation' +body: 'generate: Add `provider-schema` flag to pass in a file path to a provider schema JSON + file, allowing the command to skip building the provider and calling Terraform CLI' time: 2023-11-17T15:10:29.850914-05:00 custom: Issue: "299" diff --git a/README.md b/README.md index ef1d2f86..bf82fb63 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Usage: tfplugindocs generate [] --ignore-deprecated don't generate documentation for deprecated resources and data-sources (default: "false") --provider-dir relative or absolute path to the root provider code directory when running the command outside the root provider code directory --provider-name provider name, as used in Terraform configurations - --providers-schema path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip schema generation via Terraform + --providers-schema path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip building the provider and calling Terraform CLI --rendered-provider-name provider name, as generated in documentation (ex. page titles, ...) --rendered-website-dir output directory based on provider-dir (default: "docs") --tf-version terraform binary version to download @@ -203,7 +203,7 @@ There are two types of acceptance tests: full provider build tests in `tfplugind Provider build tests run the default `tfplugindocs` command which builds the provider source code and runs Terraform to retrieve the schema. These tests require the full provider source code to build a valid provider binary. -Schema json tests run the `tfplugindocs` command with the `--providers-schema=` flag to specify a provider schemas json file. This allows the test to skip the provider build and Terraform run and use the specified file to generate docs. +Schema json tests run the `tfplugindocs` command with the `--providers-schema=` flag to specify a provider schemas json file. This allows the test to skip the provider build and Terraform CLI call, instead using the specified file to generate docs. You can run `make testacc` to run the full suite of acceptance tests. By default, the provider build acceptance tests will create a temporary directory in `/tmp/tftmp` for testing, but you can change this location in `cmd/tfplugindocs/main_test.go`. The schema json tests uses the `testscript` package's [default work directory](https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript#Params.WorkdirRoot). diff --git a/internal/cmd/generate.go b/internal/cmd/generate.go index 58dc56c7..a62907a1 100644 --- a/internal/cmd/generate.go +++ b/internal/cmd/generate.go @@ -74,7 +74,7 @@ func (cmd *generateCmd) Flags() *flag.FlagSet { fs := flag.NewFlagSet("generate", flag.ExitOnError) fs.StringVar(&cmd.flagProviderName, "provider-name", "", "provider name, as used in Terraform configurations") fs.StringVar(&cmd.flagProviderDir, "provider-dir", "", "relative or absolute path to the root provider code directory when running the command outside the root provider code directory") - fs.StringVar(&cmd.flagProvidersSchema, "providers-schema", "", "path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip schema generation via Terraform") + fs.StringVar(&cmd.flagProvidersSchema, "providers-schema", "", "path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip building the provider and calling Terraform CLI") fs.StringVar(&cmd.flagRenderedProviderName, "rendered-provider-name", "", "provider name, as generated in documentation (ex. page titles, ...)") fs.StringVar(&cmd.flagRenderedWebsiteDir, "rendered-website-dir", "docs", "output directory based on provider-dir") fs.StringVar(&cmd.flagExamplesDir, "examples-dir", "examples", "examples directory based on provider-dir")