-
Notifications
You must be signed in to change notification settings - Fork 50
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 HCP status check to run prior to TF commands #184
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.
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.
This is really cool! I left some small comments, but approving because the behavior looks good.
internal/provider/provider.go
Outdated
@@ -64,8 +68,87 @@ func New() func() *schema.Provider { | |||
} | |||
} | |||
|
|||
const statuspageUrl = "https://pdrzb3d64wsj.statuspage.io/api/v2/components.json" |
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.
Will this always check the production status? Maybe an edge case, but it seems like this could unnecessarily disrupt testing in lower envs.
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.
Excellent point! Went ahead and added a HCP_HOST_PATH check so this only runs when pointed at prod.
internal/provider/provider.go
Outdated
func configure(p *schema.Provider) func(context.Context, *schema.ResourceData) (interface{}, diag.Diagnostics) { | ||
return func(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { | ||
|
||
// Check the Hashicorp status page in case there's an outage. |
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.
Nit: Maybe move this functionality out to a separate file, and then just call something like bool, diags = statuspage.isHCPOperational()
. Mainly suggesting this so that the provider/provider.go
doesn't become unwieldy as more functionality is added.
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.
Yeah I like that plan
using static status json example
so all warnings + error show when error triggered
bonus: move around some variables
7c967dd
to
df9eda7
Compare
I just saw this in action and I think it's brilliant! 😍 (I mean, the functionality, not the degraded performance 😆) |
🛠️ Description
Inspired by a recent issue (#172), this PR adds a check to the
ConfigureContextFunc
hook that pings the HCP status json endpoint (https://pdrzb3d64wsj.statuspage.io/api/v2/components.json) and returns one of the following based on HCP's platform status:operational
: no error or warningoutage
: errordegraded_performance
orunder_maintenance
: a warning, which both prints a debug line and only shows if an error is triggered laterNOTE: once hashicorp/terraform-plugin-sdk#790 is fixed, the warnings should show whether or not an error triggers.
This check runs before:
terraform plan, terraform apply, terraform refresh, terraform destroy
.🚢 Release Note
Release note for CHANGELOG:
🏗️ Acceptance tests
Output from acceptance testing (just running HVN to do a quick verify):