-
Notifications
You must be signed in to change notification settings - Fork 216
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
[CSGINS-1453] Add incident types resources #962
Conversation
cjgajard
commented
Jan 7, 2025
- data pagerduty_incident_type
- data pagerduty_incident_type_custom_field
- resource pagerduty_incident_type
- resource pagerduty_incident_type_custom_field
* data pagerduty_incident_type * data pagerduty_incident_type_custom_field * resource pagerduty_incident_type * resource pagerduty_incident_type_custom_field
996b418
to
0cbaa64
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.
Tested:
- able to create an incident type (though left a comment, seems like it creates it disabled by default)
- able to update an incident type
- able to disable an incident type
- able to import an existing type
- unable to delete a type (as expected; and a warning is printed)
- able to use
data
block to refer to an existing type by Display Name - able to create a field under a given type
- able to update a field
- able to disable a field
- able to delete a field
- able to import an existing field
- able to refer to an existing field with data block
- able to handle expected errors/validation errors and print (with the caveat that for some validation errors, it fails to print because we haven't yet fixed the nested errors on our end: https://pagerduty.atlassian.net/browse/INCIDENTS-2186)
* `field_type` - (Required) [Updating causes resource replacement] The field type of the field. Must be one of `single_value`, `single_value_fixed`, `multi_value`, or `multi_value_fixed`. | ||
* `description` - The description of the custom field. | ||
* `default_value` - The default value to set when new incidents are created. Always specified as a string. | ||
* `enabled` - Whether the custom field is enabled. |
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.
Should we note that it defaults to enabled if this property is not pssed in?
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.
Since there's no incident_custom_field_option
resource, that means we can't update the name of a field option in-place, we can only replace (delete+create) field options, here with the incident_type_custom_field
resource, am I understanding correctly?
Or would I be expected to use https://registry.terraform.io/providers/PagerDuty/pagerduty/latest/docs/resources/incident_custom_field_option with this? I think that doesn't work currently since that resource is not expecting the compound id
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.
Yes, I opted into not implementing a incident_type_custom_field_option
resource nor datasource because they don't have a name, hence they can't be searched by anything other than value (or ID).
Also, the requirement for a field_options
in *_fixed
fields made it difficult to use with an option resource.
If you create field_options = ["a", "b"]
and then create a resource "incident_type_custom_field_option" "c" { value = "c" }
it would break its parent definition.
Now they're accesible through their parent field field_options
.
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.
:ack: Okay, that makes sense 👍
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.
Re-tested and incident type was created in enabled mode when that property is not provided now 👍 ✅
All feedback has been addressed. Functionality-wise LGTM! (I'm not super familiar with golang so I can't speak to that end of things but it all works :D)