Skip to content
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 custom fields for terraform #623

Merged

Conversation

jedelson-pagerduty
Copy link
Contributor

@jedelson-pagerduty jedelson-pagerduty commented Jan 31, 2023

This adds support for the new PagerDuty Custom Fields on Incidents features. These are currently in Early Access and not available to all accounts.

API Documentation for this feature are visible on https://developer.pagerduty.com/api-reference/f1a95bb9397ba-changelog

Dependent upon heimweh/go-pagerduty#120

Testing is done similarly to incident workflows where there is an environment variable (PAGERDUTY_ACC_CUSTOM_FIELDS) that must be set. As with workflows, any value will do, but 1 is recommended:

PAGERDUTY_ACC_CUSTOM_FIELDS=1 make testacc TESTARGS="-run PagerDutyCustomField"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run PagerDutyCustomField -timeout 120m
?       github.com/terraform-providers/terraform-provider-pagerduty     [no test files]
=== RUN   TestAccDataSourcePagerDutyCustomField
--- PASS: TestAccDataSourcePagerDutyCustomField (6.24s)
=== RUN   TestAccDataSourcePagerDutyCustomFieldSchema
--- PASS: TestAccDataSourcePagerDutyCustomFieldSchema (5.20s)
=== RUN   TestAccPagerDutyCustomFieldOptions_Basic
--- PASS: TestAccPagerDutyCustomFieldOptions_Basic (11.44s)
=== RUN   TestAccPagerDutyCustomFieldOptions_Integer
--- PASS: TestAccPagerDutyCustomFieldOptions_Integer (11.48s)
=== RUN   TestAccPagerDutyCustomFieldOptions_Integer_Bad
--- PASS: TestAccPagerDutyCustomFieldOptions_Integer_Bad (1.60s)
=== RUN   TestAccPagerDutyCustomFieldOptions_Integer_Bad_Float
--- PASS: TestAccPagerDutyCustomFieldOptions_Integer_Bad_Float (1.22s)
=== RUN   TestAccPagerDutyCustomFieldOptions_Float
--- PASS: TestAccPagerDutyCustomFieldOptions_Float (11.48s)
=== RUN   TestAccPagerDutyCustomFieldOptions_Float_Bad
--- PASS: TestAccPagerDutyCustomFieldOptions_Float_Bad (1.10s)
=== RUN   TestAccPagerDutyCustomFieldSchemaAssignment
--- PASS: TestAccPagerDutyCustomFieldSchemaAssignment (12.06s)
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_integer,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_42_for_type_integer,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_42_for_type_integer,_multi-value:_true
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[42,"foo"]_for_type_integer,_multi-value:_true
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[50.5,"foo"]_for_type_float,_multi-value:_true
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[50.5,42.3]_for_type_float,_multi-value:_true
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_float,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_50.5_for_type_float,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_50.5_for_type_float,_multi-value:_true
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[50.5,"foo"]_for_type_float,_multi-value:_true#01
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[50.5,42.3]_for_type_float,_multi-value:_true#01
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_boolean,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_True_for_type_boolean,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_true_for_type_boolean,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_false_for_type_boolean,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_url,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_\x01_for_type_url,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_https://www.pagerduty.com/_for_type_url,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_datetime,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_2022-01-03T15:04:05Z_for_type_datetime,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_anything_goes_--_validated_server-side_for_type_field_option,_multi-value:_false
=== RUN   TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_something_for_type_field_option,_multi-value:_true
--- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_integer,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_42_for_type_integer,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_42_for_type_integer,_multi-value:_true (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[42,"foo"]_for_type_integer,_multi-value:_true (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[50.5,"foo"]_for_type_float,_multi-value:_true (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[50.5,42.3]_for_type_float,_multi-value:_true (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_float,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_50.5_for_type_float,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_50.5_for_type_float,_multi-value:_true (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[50.5,"foo"]_for_type_float,_multi-value:_true#01 (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_[50.5,42.3]_for_type_float,_multi-value:_true#01 (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_boolean,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_True_for_type_boolean,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_true_for_type_boolean,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_false_for_type_boolean,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_url,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_\x01_for_type_url,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_https://www.pagerduty.com/_for_type_url,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_default!!!_for_type_datetime,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_2022-01-03T15:04:05Z_for_type_datetime,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_anything_goes_--_validated_server-side_for_type_field_option,_multi-value:_false (0.00s)
    --- PASS: TestPagerDutyCustomField_ValidateDefaultFieldValue/Test_value:_something_for_type_field_option,_multi-value:_true (0.00s)
=== RUN   TestAccPagerDutyCustomFieldConfiguration_Basic
--- PASS: TestAccPagerDutyCustomFieldConfiguration_Basic (7.31s)
=== RUN   TestAccPagerDutyCustomFieldConfiguration_Required
--- PASS: TestAccPagerDutyCustomFieldConfiguration_Required (12.79s)
=== RUN   TestAccPagerDutyCustomFieldConfiguration_Required_BadDataType
--- PASS: TestAccPagerDutyCustomFieldConfiguration_Required_BadDataType (1.04s)
=== RUN   TestAccPagerDutyCustomFieldConfiguration_Required_Without_Default
--- PASS: TestAccPagerDutyCustomFieldConfiguration_Required_Without_Default (1.02s)
=== RUN   TestAccPagerDutyCustomFieldConfiguration_Required_Without_DefaultDataType
--- PASS: TestAccPagerDutyCustomFieldConfiguration_Required_Without_DefaultDataType (1.00s)
=== RUN   TestAccPagerDutyCustomFieldConfiguration_Default_Without_Required
--- PASS: TestAccPagerDutyCustomFieldConfiguration_Default_Without_Required (1.03s)
=== RUN   TestAccPagerDutyCustomFieldConfiguration_Required_InvalidValue_MultiValue
--- PASS: TestAccPagerDutyCustomFieldConfiguration_Required_InvalidValue_MultiValue (1.08s)
=== RUN   TestAccPagerDutyCustomFieldSchemas_Basic
--- PASS: TestAccPagerDutyCustomFieldSchemas_Basic (8.16s)
=== RUN   TestAccPagerDutyCustomFields_Basic
--- PASS: TestAccPagerDutyCustomFields_Basic (8.09s)
=== RUN   TestAccPagerDutyCustomField_BasicWithDescription
--- PASS: TestAccPagerDutyCustomField_BasicWithDescription (4.42s)
=== RUN   TestAccPagerDutyCustomFields_UnknownDataType
--- PASS: TestAccPagerDutyCustomFields_UnknownDataType (1.03s)
=== RUN   TestAccPagerDutyCustomFields_IllegalDataType
--- PASS: TestAccPagerDutyCustomFields_IllegalDataType (0.97s)
=== RUN   TestPagerDutyCustomField_ConvertValueForBuild
--- PASS: TestPagerDutyCustomField_ConvertValueForBuild (0.00s)
=== RUN   TestPagerDutyCustomField_ConvertDefaultValueForFlatten
--- PASS: TestPagerDutyCustomField_ConvertDefaultValueForFlatten (0.00s)
PASS
ok      github.com/terraform-providers/terraform-provider-pagerduty/pagerduty   110.134s

@jedelson-pagerduty jedelson-pagerduty force-pushed the issue/custom-fields branch 2 times, most recently from ae55e13 to 89f1782 Compare February 2, 2023 20:06
@jedelson-pagerduty jedelson-pagerduty force-pushed the issue/custom-fields branch 3 times, most recently from 07c3f62 to b254905 Compare February 13, 2023 20:59
@jedelson-pagerduty jedelson-pagerduty marked this pull request as ready for review February 13, 2023 20:59
Copy link
Contributor

@imjaroiswebdev imjaroiswebdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jedelson-pagerduty before proceeding with the merge, there are a few comments that need to be addressed please

website/docs/r/custom_field.html.markdown Outdated Show resolved Hide resolved
website/docs/r/custom_field_option.html.markdown Outdated Show resolved Hide resolved
website/docs/r/custom_field_option.html.markdown Outdated Show resolved Hide resolved
website/docs/r/custom_field_schema.html.markdown Outdated Show resolved Hide resolved
website/docs/d/custom_field.html.markdown Outdated Show resolved Hide resolved
website/docs/d/custom_field.html.markdown Outdated Show resolved Hide resolved
website/docs/d/custom_field_schema.html.markdown Outdated Show resolved Hide resolved
pagerduty/util.go Outdated Show resolved Hide resolved
pagerduty/resource_pagerduty_custom_field.go Outdated Show resolved Hide resolved
@jedelson-pagerduty
Copy link
Contributor Author

Thanks for all the feedback @imjaroiswebdev . I think I've addressed all of these issues.

Copy link
Contributor

@imjaroiswebdev imjaroiswebdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still a couple of comments to be addressed before merging @jedelson-pagerduty please 🙏🏽

Copy link
Contributor

@imjaroiswebdev imjaroiswebdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Terraform managed Custom Fields will be loved by users. Thank you @jedelson-pagerduty 🎉 💪🏽 😎

@imjaroiswebdev imjaroiswebdev merged commit 76fdd3f into PagerDuty:master Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants