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
Strip Provider Prefix from File Names during Migration (#349)
* Add `--provider-name` flag to `migrate` subcommand and strip provider short name prefix during migration
* Update README.md
* Add changelog entries
* Default the `--provider-name` flag to use the provider directory basename
* Update .changes/unreleased/ENHANCEMENTS-20240327-160831.yaml
Co-authored-by: Brian Flad <[email protected]>
---------
Co-authored-by: Brian Flad <[email protected]>
--examples-dir <ARG> examples directory based on provider-dir (default: "examples")
99
99
--provider-dir <ARG> relative or absolute path to the root provider code directory when running the command outside the root provider code directory
100
100
--templates-dir <ARG> new website templates directory based on provider-dir; files will be migrated to this directory (default: "templates")
101
+
--provider-name <ARG> provider name, as used in Terraform configurations; this will default to provider-dir basename if not set
101
102
```
102
103
103
104
### How it Works
@@ -175,23 +176,24 @@ ingress issues.
175
176
176
177
The `migrate` subcommand takes the following actions:
177
178
1. Determines the rendered website directory based on the `--provider-dir` argument
178
-
2. Copies the contents of the rendered website directory to the `--templates-dir` folder (will create this folder if it doesn't exist)
179
-
3. (if the rendered website is using legacy format) Renames `docs/d/` and `docs/r/` subdirectories to `data-sources/` and `resources/` respectively
180
-
4. Change file suffixes for Markdown files to `.md.tmpl` to create website templates
181
-
5. Extracts code blocks from website docs to create individual example files in`--examples-dir` (will create this folder if it doesn't exist)
182
-
6. Replace extracted example code in website templates with `codefile`/`tffile` template functions referencing the example files.
183
-
7. Copies non-template files to `--templates-dir` folder
184
-
8. Removes the `website/` directory
179
+
2. Determines the provider name based on the `--provider-name` argument
180
+
3. Copies the contents of the rendered website directory to the `--templates-dir` folder (will create this folder if it doesn't exist)
181
+
4. (if the rendered website is using legacy format) Renames `docs/d/` and `docs/r/` subdirectories to `data-sources/` and `resources/` respectively
182
+
5. Renames files in the `--templates-dir` folder to remove the provider shortname prefix from the file name
183
+
6. Change file suffixes for Markdown files to `.md.tmpl` to create website templates
184
+
7. Extracts code blocks from website docs to create individual example files in`--examples-dir` (will create this folder if it doesn't exist)
185
+
8. Replace extracted example code in website templates with `codefile`/`tffile` template functions referencing the example files.
186
+
9. Copies non-template files to `--templates-dir` folder
187
+
10. Removes the `website/` directory
185
188
186
189
### Conventional Paths
187
190
188
191
The generation of missing documentation is based on a number of assumptions / conventional paths.
189
192
190
-
> **NOTE:** In the following conventional paths, `<data source name>` and `<resource name>` include the provider prefix as well, but the provider prefix is **NOT** included in`<function name>`.
191
-
> For example, the data source [`caller_identity`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) in the `aws` provider would have an "example" conventional path of: `examples/data-sources/aws_caller_identity/data-source.tf`
192
-
193
193
For templates:
194
194
195
+
> **NOTE:** In the following conventional paths for templates, `<data source name>`, `<resource name>`, and `<function name>` do not include the provider prefix.
@@ -207,6 +209,9 @@ Note: the `.tmpl` extension is necessary, for the file to be correctly handled a
207
209
208
210
For examples:
209
211
212
+
> **NOTE:** In the following conventional paths for examples, `<data source name>` and `<resource name>` include the provider prefix as well, but the provider prefix is **NOT** included in`<function name>`.
213
+
> For example, the data source [`caller_identity`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) in the `aws` provider would have an "example" conventional path of: `examples/data-sources/aws_caller_identity/data-source.tf`
The `migrate` subcommand assumes the following conventional paths for the rendered website directory:
222
227
228
+
> **NOTE:** In the following conventional paths for templates, `<data source name>`, `<resource name>`, and `<function name>` do not include the provider prefix.
229
+
> if the `--provider-name` argument is set, the provider prefix will be removed from the file names during migration.
0 commit comments