-
Notifications
You must be signed in to change notification settings - Fork 212
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
implementation of incident workflow and triggers #596
implementation of incident workflow and triggers #596
Conversation
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"description": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, |
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 not reuse the complete schema from the resource for the datasource too?
The resourcePagerDutyIncidentWorkflowRead()
function should be directly reusable here too.
This would make the datasource more useful IMO, as just returning the name
and description
fields is pretty useless for terraform configuration.
Note: I'm posting this as I was recently confronted to the pagerduty_service
datasource as I wanted to be able to check the status
field of services, only to find out that datasource is pretty much useless:
https://github.com/PagerDuty/terraform-provider-pagerduty/blob/v2.6.5/pagerduty/data_source_pagerduty_service.go#L17-L26
Schema: map[string]*schema.Schema{ | |
"name": { | |
Type: schema.TypeString, | |
Required: true, | |
}, | |
"description": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
}, | |
Schema: map[string]*schema.Schema{ | |
"name": { | |
Type: schema.TypeString, | |
Required: true, | |
}, | |
"description": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
}, |
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.
For an example of how it is done in the Google terraform provider, see: https://github.com/hashicorp/terraform-provider-google/blob/v4.45.0/google/data_source_cloud_run_service.go
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 can see how this would be useful in other cases, but in this particular context, I'm not sure what one would do with the embedded steps of the workflow if they were provided by the data source. Really the only use case for the data source is (as shown in the example in the documentation below) to reference an existing (presumably manually created) workflow by name when managing a trigger in Terraform.
This would make the datasource more useful IMO, as just returning the name and description fields is pretty useless for terraform configuration.
Agreed. Strictly speaking, all you need is the ID; it just promoted some better reuse of the flattenIncidentWorkflow
function to have name
and description
in the schema.
The resourcePagerDutyIncidentWorkflowRead() function should be directly reusable here too.
Sure, but that would do an extra HTTP request. The workflow is already available at that point in the code path, no need to fetch it again. This is different than the Google Cloud Run since that API supports name-based addressing.
c27b8ce
to
53e0a89
Compare
0eb8b3e
to
ad5c619
Compare
5adadf1
to
012b3c6
Compare
012b3c6
to
895dfa0
Compare
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.
@jedelson-pagerduty Please check out the comments I left to continue with the approval after that
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.
thank you for this great addition of Incident Workflows, and also for updating the provider implementations every time you had the opportunity to it 💪🏽 🎉
This adds support for the new PagerDuty Incident Workflows (both Data Source and Resource) and Incident Workflow Triggers (Resource only) features. These are currently in Early Access and not available to all accounts.
Acceptance tests are gated behind an environment variable
PAGERDUTY_ACC_INCIDENT_WORKFLOWS
. This can be set to any value, but1
is recommended for consistency withTF_ACC
:As mentioned in heimweh/go-pagerduty#104, I have tried to avoid the use of deprecated APIs which means these resources/datasources use slightly different patterns than the existing ones, e.g.
CreateContext
vs.Create
. The same applies to the tests, whereProviderFactories
is used instead ofProviders
. Refactoring existing resources/data sources/tests is a useful exercise but not in scope of this PR.