You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for --provider-schema flag and context to generate sub-command errors (#299)
* Add context to errors
* Refactor to use `g.providerName` instead of passing the provider name as a parameter.
* Add support for `--providers-schema` flag to pass in a providers schema JSON file.
* Add schema json acceptance tests and move provider build tests into a separate folder.
* Update README.md
* Add copyright headers
* Add more schema json tests
* Add changelog entry
* Apply documentation suggestions
Co-authored-by: Brian Flad <[email protected]>
---------
Co-authored-by: Brian Flad <[email protected]>
--ignore-deprecated <ARG> don't generate documentation for deprecated resources and data-sources (default: "false")
44
44
--provider-dir <ARG> relative or absolute path to the root provider code directory when running the command outside the root provider code directory
45
45
--provider-name <ARG> provider name, as used in Terraform configurations
46
+
--providers-schema <ARG> 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
46
47
--rendered-provider-name <ARG> provider name, as generated in documentation (ex. page titles, ...)
47
48
--rendered-website-dir <ARG> output directory based on provider-dir (default: "docs")
48
49
--tf-version <ARG> terraform binary version to download
@@ -198,9 +199,15 @@ This can be autogenerated by running `make generate` or running `go generate ./.
198
199
199
200
This repo uses the `testscript` [package](https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript) for acceptance testing.
200
201
201
-
You can run `make testacc` to run the acceptance tests. By default, the acceptance tests will create a temporary directory in `/tmp/tftmp` for testing but you can change this location in `cmd/tfplugindocs/main_test.go`
202
+
There are two types of acceptance tests: full provider build tests in `tfplugindocs/testdata/scripts/provider-build` and provider schema json tests in `tfplugindocs/testdata/scripts/schema-json`.
202
203
203
-
The test scripts are defined in the `tfplugindocs/testdata/scripts` directory. Each script includes the test, golden files, and the provider source code needed to run the test.
204
+
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.
205
+
206
+
Schema json tests run the `tfplugindocs` command with the `--providers-schema=<arg>` 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.
207
+
208
+
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).
209
+
210
+
The test scripts are defined in the `tfplugindocs/testdata/scripts` directory. Each script includes the test, golden files, and the provider source code or schema JSON file needed to run the test.
204
211
205
212
Each script is a [text archive](https://pkg.go.dev/golang.org/x/tools/txtar). You can install the `txtar` CLI locally by running `go install golang.org/x/exp/cmd/txtar@latest` to extract the files in the test script for debugging.
206
213
You can also use `txtar` CLI archive files into the `.txtar` format to create new tests or modify existing ones.
0 commit comments