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

provider/opsgenie: Descriptions for Teams #11391

Merged
merged 4 commits into from
Jan 29, 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
24 changes: 24 additions & 0 deletions builtin/providers/opsgenie/import_opsgenie_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ func TestAccOpsGenieTeam_importBasic(t *testing.T) {
})
}

func TestAccOpsGenieTeam_importWithEmptyDescription(t *testing.T) {
resourceName := "opsgenie_team.test"

ri := acctest.RandInt()
config := fmt.Sprintf(testAccOpsGenieTeam_withEmptyDescription, ri)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckOpsGenieTeamDestroy,
Steps: []resource.TestStep{
{
Config: config,
},

{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccOpsGenieTeam_importWithUser(t *testing.T) {
resourceName := "opsgenie_team.test"

Expand Down
22 changes: 16 additions & 6 deletions builtin/providers/opsgenie/resource_opsgenie_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"fmt"
"strings"

"regexp"

"github.com/hashicorp/terraform/helper/schema"
"github.com/opsgenie/opsgenie-go-sdk/team"
"regexp"
)

func resourceOpsGenieTeam() *schema.Resource {
Expand All @@ -26,6 +27,10 @@ func resourceOpsGenieTeam() *schema.Resource {
Required: true,
ValidateFunc: validateOpsGenieTeamName,
},
"description": {
Type: schema.TypeString,
Optional: true,
},
"member": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -53,10 +58,12 @@ func resourceOpsGenieTeamCreate(d *schema.ResourceData, meta interface{}) error
client := meta.(*OpsGenieClient).teams

name := d.Get("name").(string)
description := d.Get("description").(string)

createRequest := team.CreateTeamRequest{
Name: name,
Members: expandOpsGenieTeamMembers(d),
Name: name,
Description: description,
Members: expandOpsGenieTeamMembers(d),
Copy link
Contributor

Choose a reason for hiding this comment

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

If we pass an empty string here is this ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep - it's caught by the HCL (which picks it up as a null value) - there's also tests for omitting/empty/completed values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep - it's caught by the HCL (which picks it up as a null value) - there's also tests for omitting/empty/completed values

}

log.Printf("[INFO] Creating OpsGenie team '%s'", name)
Expand Down Expand Up @@ -118,6 +125,7 @@ func resourceOpsGenieTeamRead(d *schema.ResourceData, meta interface{}) error {
}

d.Set("name", getResponse.Name)
d.Set("description", getResponse.Description)
d.Set("member", flattenOpsGenieTeamMembers(getResponse.Members))

return nil
Expand All @@ -126,11 +134,13 @@ func resourceOpsGenieTeamRead(d *schema.ResourceData, meta interface{}) error {
func resourceOpsGenieTeamUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*OpsGenieClient).teams
name := d.Get("name").(string)
description := d.Get("description").(string)

updateRequest := team.UpdateTeamRequest{
Id: d.Id(),
Name: name,
Members: expandOpsGenieTeamMembers(d),
Id: d.Id(),
Name: name,
Description: description,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we pass an empty string, is this ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's caught by the HCL (which picks it up as a null value)

Members: expandOpsGenieTeamMembers(d),
}

log.Printf("[INFO] Updating OpsGenie team '%s'", name)
Expand Down
32 changes: 30 additions & 2 deletions builtin/providers/opsgenie/resource_opsgenie_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,25 @@ func TestAccOpsGenieTeam_basic(t *testing.T) {
})
}

func TestAccOpsGenieTeam_withEmptyDescription(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccOpsGenieTeam_withEmptyDescription, ri)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckOpsGenieTeamDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckOpsGenieTeamExists("opsgenie_team.test"),
),
},
},
})
}

func TestAccOpsGenieTeam_withUser(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccOpsGenieTeam_withUser, ri, ri)
Expand Down Expand Up @@ -215,6 +234,13 @@ resource "opsgenie_team" "test" {
}
`

var testAccOpsGenieTeam_withEmptyDescription = `
resource "opsgenie_team" "test" {
name = "acctest%d"
description = ""
}
`

var testAccOpsGenieTeam_withUser = `
resource "opsgenie_user" "test" {
username = "acctest-%d@example.tld"
Expand All @@ -238,7 +264,8 @@ resource "opsgenie_user" "test" {
}

resource "opsgenie_team" "test" {
name = "acctest%d"
name = "acctest%d"
description = "Some exmaple description"
member {
username = "${opsgenie_user.test.username}"
role = "user"
Expand All @@ -259,7 +286,8 @@ resource "opsgenie_user" "second" {
}

resource "opsgenie_team" "test" {
name = "acctest%d"
name = "acctest%d"
description = "Some exmaple description"
member {
username = "${opsgenie_user.first.username}"
}
Expand Down
10 changes: 0 additions & 10 deletions vendor/github.com/opsgenie/opsgenie-go-sdk/CONTRIBUTING.md

This file was deleted.

97 changes: 0 additions & 97 deletions vendor/github.com/opsgenie/opsgenie-go-sdk/README.md

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading