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

r/pagerduty_user: Set time_zone as optional #19

Merged
merged 2 commits into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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