hashicorp-community / tf-helper

Commands for performing operations on Terraform states, configurations, TFE using the API, and more. Please target all PRs to the master branch, not the release branch.
Mozilla Public License 2.0
102 stars 32 forks source link

Support for retrieving/configuration notifications? #7

Open woneill opened 5 years ago

woneill commented 5 years ago

Being able to apply notifications across workspaces would be a useful feature. There appears to be support for it in the API.

fprimex commented 5 years ago

I'm up for implementing anything that's in the API. My goal right now is to address the 2 issues and 1 PR that are still over at tfe-cli, then I'd be happy to tackle this next.

Please note that notification support is coming to the tfe provider soon, and in general we like to encourage the use of that provider where it makes sense to do so:

https://github.com/terraform-providers/terraform-provider-tfe/issues/68

If you enjoy shell scripting and want to contribute the notifications commands, it is pretty easy to get started. I've re-engineered tfh from tfe-cli with ease-of-development in mind.

notification would work almost exactly like workspace. The options are created by writing documentation:

tfh/usr/share/doc/tfh/tfh_notification.md
tfh/usr/share/doc/tfh/tfh_notification_new.md
tfh/usr/share/doc/tfh/tfh_notification_list.md
tfh/usr/share/doc/tfh/tfh_notification_show.md
tfh/usr/share/doc/tfh/tfh_notification_verify.md
tfh/usr/share/doc/tfh/tfh_notification_delete.md

And then the implementation for each command goes in its own shell file as a function:

tfh/lib/tfh/cmd/tfh_notification.sh
tfh/lib/tfh/cmd/tfh_notification_new.sh
tfh/lib/tfh/cmd/tfh_notification_list.sh
tfh/lib/tfh/cmd/tfh_notification_show.sh
tfh/lib/tfh/cmd/tfh_notification_verify.sh
tfh/lib/tfh/cmd/tfh_notification_delete.sh

Everything else will be wired up correctly just by implementing those two things (docs and function) properly.

You could (and I will) literally copy the workspace commands to new notification names, do search and replace (carefully), then modify the variables, JSON payload structures, and output.

woneill commented 5 years ago

Thanks for the pointer to the tfe provider as I hadn't been aware of that option!