Skip to content

Commit

Permalink
Merge pull request #3 from tidal-engineering/additional_attrs
Browse files Browse the repository at this point in the history
Additional attributes
  • Loading branch information
awsiv authored Sep 18, 2020
2 parents df61830 + 39bb271 commit 559b398
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
12 changes: 8 additions & 4 deletions spinnaker/api/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ func GetApplication(client *gate.GatewayClient, applicationName string, dest int
return nil
}

func CreateApplication(client *gate.GatewayClient, applicationName, email string) error {
func CreateApplication(client *gate.GatewayClient, applicationName, email,
applicationDescription string, platformHealthOnly, platformHealthOnlyShowOverride bool) error {

app := map[string]interface{}{
"instancePort": 80,
"name": applicationName,
"email": email,
"instancePort": 80,
"name": applicationName,
"email": email,
"platformHealthOnly": platformHealthOnly,
"platformHealthOnlyShowOverride": platformHealthOnlyShowOverride,
"description": applicationDescription,
}

createAppTask := map[string]interface{}{
Expand Down
20 changes: 19 additions & 1 deletion spinnaker/resource_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ func resourceApplication() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"platform_health_only": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"platform_health_only_show_override": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"description": {
Type: schema.TypeString,
Optional: true,
Default: "",
},
},
Create: resourceApplicationCreate,
Read: resourceApplicationRead,
Expand All @@ -40,8 +55,11 @@ func resourceApplicationCreate(data *schema.ResourceData, meta interface{}) erro
client := clientConfig.client
application := data.Get("application").(string)
email := data.Get("email").(string)
description := data.Get("description").(string)
platform_health_only := data.Get("platform_health_only").(bool)
platform_health_only_show_override := data.Get("platform_health_only_show_override").(bool)

if err := api.CreateApplication(client, application, email); err != nil {
if err := api.CreateApplication(client, application, email, description, platform_health_only, platform_health_only_show_override); err != nil {
return err
}

Expand Down
37 changes: 37 additions & 0 deletions spinnaker/resource_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@ func TestAccSpinnakerApplication_basic(t *testing.T) {
testAccCheckApplicationExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "application", rName),
resource.TestCheckResourceAttr(resourceName, "email", "acceptance@test.com"),
resource.TestCheckResourceAttr(resourceName, "description", ""),
resource.TestCheckResourceAttr(resourceName, "platformHealthOnly", "false"),
resource.TestCheckResourceAttr(resourceName, "platformHealthOnly", "false"),
),
},
},
})
}

func TestAccSpinnakerApplication_nondefault(t *testing.T) {
resourceName := "spinnaker_application.test"
rName := acctest.RandomWithPrefix("tf-acc-test")
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccSpinnakerApplication_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckApplicationExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "application", rName),
resource.TestCheckResourceAttr(resourceName, "email", "acceptance@test.com"),
resource.TestCheckResourceAttr(resourceName, "description", "My application"),
resource.TestCheckResourceAttr(resourceName, "platformHealthOnly", "true"),
resource.TestCheckResourceAttr(resourceName, "platformHealthOnlyShowOverride", "true"),
),
},
},
Expand Down Expand Up @@ -70,3 +95,15 @@ resource "spinnaker_application" "test" {
}
`, rName)
}

func testAccSpinnakerApplication_nondefault(rName string) string {
return fmt.Sprintf(`
resource "spinnaker_application" "test" {
application = %q
email = "acceptance@test.com"
description = "My application"
platform_health_only = true
platform_health_only_show_override = true
}
`, rName)
}

0 comments on commit 559b398

Please sign in to comment.