-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add "split" template function for use with strings #70
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @eamonnotoole and thanks for your contribution.
So, adding a new function for our templates is not a bad idea (there are a few more I'd like to see myself).
But there are a few more things to address in this PR before we can merge it.
- update the README where we document the functions
- update the CHANGELOG to mention the new feature that you are making available
Thank you 👍
.gitignore
Outdated
@@ -16,6 +16,8 @@ tfproviderdocsgen | |||
# OS generated files | |||
.DS_Store | |||
|
|||
vendor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you feel the need to add this here, given we build with Go 1.17?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still use go mod vendor, which is probably bad practice. I can remove.
Thanks for the review @detro. I've made the changes that you requested, see the latest commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but the changelog format required is different.
You need to create a brand new section for 0.8.0
. See link I shared on the specific line.
CHANGELOG.md
Outdated
@@ -4,6 +4,7 @@ ENHANCEMENTS: | |||
|
|||
* cmd/tfplugindocs: Use existing Terraform CLI binary if available on PATH, otherwise download latest Terraform CLI binary (https://github.com/hashicorp/terraform-plugin-docs/pull/124) | |||
* cmd/tfplugindocs: Added `tf-version` flag for specifying Terraform CLI binary version to download, superseding the PATH lookup (https://github.com/hashicorp/terraform-plugin-docs/pull/124) | |||
* template functions: Added the `split` command to split a string into substrings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I think I should have been more explicit.
The changelog format is defined here https://www.terraform.io/plugin/sdkv2/best-practices/versioning#changelog-specification .
Your change will need a new release, probably will be a 0.8.0
, as it's a net new feature, but it's additive so it doesn't warrant a major release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies @detro, see the next commit
@eamonnotoole I'm not sure why, but this branch needs rebasing. Can you do that so we can land this? Again, thank you! |
@detro I've rebased, so I think that it should be okay to merge. |
Hey @eamonnotoole sorry, but GitHub is still complaining saying there are conflicts. Can you please do an actual rebase instead of a merge? Not sure what's going on, but GitHub ain't happy. |
This is an excellent piece of tooling that we are finding very helpful as we develop a new HPE GreenLake provider (called hpegl) that we will publish to the Provider Registry. We're using this tool to generate documentation. We'd like the ability to set the "subcategory" field in the resource and data-source templates. Our provider will support a number of different services and the naming will be the following: hpegl_< service mnemonic >_< service resource or data-source > We want to extract the service mnemonic from the name and add that as a "subcategory". I've added a "split" template function which is set to strings.Split. With this template function I can add the following to a template: subcategory: {{ $arr := split .Name "_" }}"{{ index $arr 1 }}" To extract the service mnemonic from the name. This would be very helpful to us as we generate documentation. In addition I've added .idea and vendor to .gitignore.
0aba311
to
b6fa727
Compare
@detro I've rebased, there was a conflict which I've fixed. I had to do a force push afterwards. |
Congrats :) |
Thanks @detro. When do you think that v0.0.8 will be released? |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
This is an excellent piece of tooling that we are finding very helpful
as we develop a new HPE GreenLake provider (called hpegl) that we will
publish to the Provider Registry. We're using this tool to generate
documentation. We'd like the ability to set the "subcategory" field in
the resource and data-source templates. Our provider will support a
number of different services and the naming will be the following:
hpegl_< service mnemonic >_< service resource or data-source >
We want to extract the service mnemonic from the name and add that as a
"subcategory". I've added a "split" template function which is set to
strings.Split. With this template function I can add the following to a
template:
subcategory: {{ $arr := split .Name "_" }}"{{ index $arr 1 }}"
To extract the service mnemonic from the name. This would be very
helpful to us as we generate documentation.
In addition I've added .idea and vendor to .gitignore.