From 1081dd839e8c6c7b373624cc5746d497d2bcdf6d Mon Sep 17 00:00:00 2001 From: Alexander Hellbom Date: Thu, 13 Jul 2017 20:03:29 +0200 Subject: [PATCH 1/2] Add optional support for time_zone --- pagerduty/resource_pagerduty_user.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pagerduty/resource_pagerduty_user.go b/pagerduty/resource_pagerduty_user.go index d3861b83c..befb5c52e 100644 --- a/pagerduty/resource_pagerduty_user.go +++ b/pagerduty/resource_pagerduty_user.go @@ -21,15 +21,18 @@ func resourcePagerDutyUser() *schema.Resource { Type: schema.TypeString, Required: true, }, + "email": { Type: schema.TypeString, Required: true, }, + "color": { Type: schema.TypeString, Optional: true, Computed: true, }, + "role": { Type: schema.TypeString, Optional: true, @@ -43,14 +46,17 @@ func resourcePagerDutyUser() *schema.Resource { "user", }), }, + "job_title": { Type: schema.TypeString, Optional: true, }, + "avatar_url": { Type: schema.TypeString, Computed: true, }, + "teams": { Type: schema.TypeSet, Optional: true, @@ -59,18 +65,23 @@ func resourcePagerDutyUser() *schema.Resource { }, Set: schema.HashString, }, + "time_zone": { Type: schema.TypeString, + Optional: true, Computed: true, }, + "html_url": { Type: schema.TypeString, Computed: true, }, + "invitation_sent": { Type: schema.TypeBool, Computed: true, }, + "description": { Type: schema.TypeString, Optional: true, @@ -90,6 +101,10 @@ func buildUserStruct(d *schema.ResourceData) *pagerduty.User { user.Color = attr.(string) } + if attr, ok := d.GetOk("time_zone"); ok { + user.TimeZone = attr.(string) + } + if attr, ok := d.GetOk("role"); ok { role := attr.(string) // Skip setting the role if the user is the owner of the account. From 82b7664205b540b669c08d5b13d0d641095b649e Mon Sep 17 00:00:00 2001 From: Alexander Hellbom Date: Thu, 13 Jul 2017 20:03:32 +0200 Subject: [PATCH 2/2] Update tests --- pagerduty/resource_pagerduty_user_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pagerduty/resource_pagerduty_user_test.go b/pagerduty/resource_pagerduty_user_test.go index 6455eaf53..c2fdada9a 100644 --- a/pagerduty/resource_pagerduty_user_test.go +++ b/pagerduty/resource_pagerduty_user_test.go @@ -191,6 +191,7 @@ resource "pagerduty_user" "foo" { role = "user" job_title = "foo" description = "foo" + time_zone = "Europe/Berlin" }`, username, email) } @@ -203,6 +204,7 @@ resource "pagerduty_user" "foo" { role = "team_responder" job_title = "bar" description = "bar" + time_zone = "Europe/Dublin" }`, username, email) }