Skip to content

Commit

Permalink
Merge pull request #19 from heimweh/f-add-time-zone-to-user
Browse files Browse the repository at this point in the history
r/pagerduty_user: Set time_zone as optional
  • Loading branch information
grubernaut authored Jul 14, 2017
2 parents 7252e9e + 82b7664 commit 947ae16
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pagerduty/resource_pagerduty_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions pagerduty/resource_pagerduty_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ resource "pagerduty_user" "foo" {
role = "user"
job_title = "foo"
description = "foo"
time_zone = "Europe/Berlin"
}`, username, email)
}

Expand All @@ -203,6 +204,7 @@ resource "pagerduty_user" "foo" {
role = "team_responder"
job_title = "bar"
description = "bar"
time_zone = "Europe/Dublin"
}`, username, email)
}

Expand Down

0 comments on commit 947ae16

Please sign in to comment.