-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added code generation for new provider functions.
- Loading branch information
Showing
24 changed files
with
738 additions
and
83 deletions.
There are no files selected for viewing
This file contains 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 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,12 @@ | ||
#!/usr/bin/env bats | ||
# https://bats-core.readthedocs.io/en/stable/writing-tests.html | ||
|
||
@test "corefunc_env_ensure: attrs" { | ||
run bash -c "tfschema data show -format=json corefunc_env_ensure | jq -Mrc '.attributes[]'" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ ${lines[0]} == '{"name":"id","type":"number","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
[[ ${lines[1]} == '{"name":"name","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[2]} == '{"name":"pattern","type":"string","required":false,"optional":true,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[3]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
} |
This file contains 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,11 @@ | ||
#!/usr/bin/env bats | ||
# https://bats-core.readthedocs.io/en/stable/writing-tests.html | ||
|
||
@test "corefunc_str_camel: attrs" { | ||
run bash -c "tfschema data show -format=json corefunc_str_camel | jq -Mrc '.attributes[]'" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ ${lines[0]} == '{"name":"id","type":"number","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
[[ ${lines[1]} == '{"name":"string","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[2]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
} |
This file contains 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,11 @@ | ||
#!/usr/bin/env bats | ||
# https://bats-core.readthedocs.io/en/stable/writing-tests.html | ||
|
||
@test "corefunc_str_constant: attrs" { | ||
run bash -c "tfschema data show -format=json corefunc_str_constant | jq -Mrc '.attributes[]'" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ ${lines[0]} == '{"name":"id","type":"number","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
[[ ${lines[1]} == '{"name":"string","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[2]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
} |
This file contains 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,11 @@ | ||
#!/usr/bin/env bats | ||
# https://bats-core.readthedocs.io/en/stable/writing-tests.html | ||
|
||
@test "corefunc_str_kebab: attrs" { | ||
run bash -c "tfschema data show -format=json corefunc_str_kebab | jq -Mrc '.attributes[]'" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ ${lines[0]} == '{"name":"id","type":"number","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
[[ ${lines[1]} == '{"name":"string","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[2]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
} |
This file contains 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,12 @@ | ||
#!/usr/bin/env bats | ||
# https://bats-core.readthedocs.io/en/stable/writing-tests.html | ||
|
||
@test "corefunc_str_pascal: attrs" { | ||
run bash -c "tfschema data show -format=json corefunc_str_pascal | jq -Mrc '.attributes[]'" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ ${lines[0]} == '{"name":"acronym_caps","type":"bool","required":false,"optional":true,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[1]} == '{"name":"id","type":"number","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
[[ ${lines[2]} == '{"name":"string","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[3]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
} |
This file contains 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,11 @@ | ||
#!/usr/bin/env bats | ||
# https://bats-core.readthedocs.io/en/stable/writing-tests.html | ||
|
||
@test "corefunc_str_snake: attrs" { | ||
run bash -c "tfschema data show -format=json corefunc_str_snake | jq -Mrc '.attributes[]'" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ ${lines[0]} == '{"name":"id","type":"number","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
[[ ${lines[1]} == '{"name":"string","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[2]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
} |
This file contains 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,13 @@ | ||
#!/usr/bin/env bats | ||
# https://bats-core.readthedocs.io/en/stable/writing-tests.html | ||
|
||
@test "corefunc_str_truncate_label: attrs" { | ||
run bash -c "tfschema data show -format=json corefunc_str_truncate_label | jq -Mrc '.attributes[]'" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ ${lines[0]} == '{"name":"id","type":"number","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
[[ ${lines[1]} == '{"name":"label","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[2]} == '{"name":"max_length","type":"number","required":false,"optional":true,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[3]} == '{"name":"prefix","type":"string","required":true,"optional":false,"computed":false,"sensitive":false}' ]] | ||
[[ ${lines[4]} == '{"name":"value","type":"string","required":false,"optional":false,"computed":true,"sensitive":false}' ]] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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,16 @@ | ||
#!/usr/bin/env bats | ||
# https://bats-core.readthedocs.io/en/stable/writing-tests.html | ||
|
||
@test "listing the data sources" { | ||
run tfschema data list corefunc | ||
|
||
[ "$status" -eq 0 ] | ||
[[ ${lines[0]} == "corefunc_env_ensure" ]] | ||
[[ ${lines[1]} == "corefunc_str_camel" ]] | ||
[[ ${lines[2]} == "corefunc_str_constant" ]] | ||
[[ ${lines[3]} == "corefunc_str_kebab" ]] | ||
[[ ${lines[4]} == "corefunc_str_pascal" ]] | ||
[[ ${lines[5]} == "corefunc_str_snake" ]] | ||
[[ ${lines[6]} == "corefunc_str_truncate_label" ]] | ||
|
||
} |
This file contains 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,33 @@ | ||
# Stub Generator | ||
|
||
## Generator | ||
|
||
This will accept a name, then generate the correct files needed to implement the provider functionality. | ||
|
||
The name should match what the Terraform data source will be called (e.g., `corefunc_example`). | ||
|
||
From this `generator/` directory, run the command. | ||
|
||
```bash | ||
go run main.go --name corefunc_example | ||
``` | ||
|
||
After that, search the project for `@TODO` and make the appropriate changes. Exclude `./generator,*.md,.*.yml`. | ||
|
||
## Checklist | ||
|
||
* [ ] Generate the stub files. | ||
* [ ] In the new `*_data_source.go` file, update the `*SourceModel` struct. | ||
* [ ] In the new `*_data_source.go` file, update the Schema Attributes to match the `*SourceModel` struct. | ||
* [ ] In the new `*_data_source.go` file, implement the remainder of the `Read` function. | ||
* [ ] In the new test fixture file, implement the test cases. | ||
* [ ] In the new `*_data_source_fixture.tftpl` file, ensure the fixture is implemented correctly. | ||
* [ ] In the new `*_data_source_test.go` file, ensure the test references the fixture correctly. | ||
* [ ] Run the integration tests. | ||
* [ ] In the new `examples/data-sources/*/data-source.tf` file, ensure the example is implemented correctly. | ||
* [ ] In the new `examples/data-sources/*/terraform-plan.example` file, copy content or delete. | ||
* [ ] In the new `templates/data-sources/*.tmpl` file, update the template that will be used by the `tfplugindocs` package. | ||
* [ ] Generate the Terraform provider documentation. | ||
* [ ] Run `tfschema data show -format=json DATASOURCE | jq -Mrc '.attributes[]'`. | ||
* [ ] In the new `bats/*.bats.sh` file, update its contents to match the `tfschema` output. | ||
* [ ] Run the bats tests. |
This file contains 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,9 @@ | ||
#!/usr/bin/env bats | ||
# https://bats-core.readthedocs.io/en/stable/writing-tests.html | ||
|
||
@test "{{ .Snake }}: attrs" { | ||
run bash -c "tfschema data show -format=json {{ .Snake }} | jq -Mrc '.attributes[]'" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ ${lines[0]} == '@TODO' ]] | ||
} |
Oops, something went wrong.