Skip to content

Commit 559b398

Browse files
authored
Merge pull request #3 from tidal-engineering/additional_attrs
Additional attributes
2 parents df61830 + 39bb271 commit 559b398

File tree

3 files changed

+64
-5
lines changed

3 files changed

+64
-5
lines changed

spinnaker/api/application.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ func GetApplication(client *gate.GatewayClient, applicationName string, dest int
3131
return nil
3232
}
3333

34-
func CreateApplication(client *gate.GatewayClient, applicationName, email string) error {
34+
func CreateApplication(client *gate.GatewayClient, applicationName, email,
35+
applicationDescription string, platformHealthOnly, platformHealthOnlyShowOverride bool) error {
3536

3637
app := map[string]interface{}{
37-
"instancePort": 80,
38-
"name": applicationName,
39-
"email": email,
38+
"instancePort": 80,
39+
"name": applicationName,
40+
"email": email,
41+
"platformHealthOnly": platformHealthOnly,
42+
"platformHealthOnlyShowOverride": platformHealthOnlyShowOverride,
43+
"description": applicationDescription,
4044
}
4145

4246
createAppTask := map[string]interface{}{

spinnaker/resource_application.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ func resourceApplication() *schema.Resource {
1919
Type: schema.TypeString,
2020
Required: true,
2121
},
22+
"platform_health_only": {
23+
Type: schema.TypeBool,
24+
Optional: true,
25+
Default: false,
26+
},
27+
"platform_health_only_show_override": {
28+
Type: schema.TypeBool,
29+
Optional: true,
30+
Default: false,
31+
},
32+
"description": {
33+
Type: schema.TypeString,
34+
Optional: true,
35+
Default: "",
36+
},
2237
},
2338
Create: resourceApplicationCreate,
2439
Read: resourceApplicationRead,
@@ -40,8 +55,11 @@ func resourceApplicationCreate(data *schema.ResourceData, meta interface{}) erro
4055
client := clientConfig.client
4156
application := data.Get("application").(string)
4257
email := data.Get("email").(string)
58+
description := data.Get("description").(string)
59+
platform_health_only := data.Get("platform_health_only").(bool)
60+
platform_health_only_show_override := data.Get("platform_health_only_show_override").(bool)
4361

44-
if err := api.CreateApplication(client, application, email); err != nil {
62+
if err := api.CreateApplication(client, application, email, description, platform_health_only, platform_health_only_show_override); err != nil {
4563
return err
4664
}
4765

spinnaker/resource_application_test.go

+37
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,31 @@ func TestAccSpinnakerApplication_basic(t *testing.T) {
2424
testAccCheckApplicationExists(resourceName),
2525
resource.TestCheckResourceAttr(resourceName, "application", rName),
2626
resource.TestCheckResourceAttr(resourceName, "email", "[email protected]"),
27+
resource.TestCheckResourceAttr(resourceName, "description", ""),
28+
resource.TestCheckResourceAttr(resourceName, "platformHealthOnly", "false"),
29+
resource.TestCheckResourceAttr(resourceName, "platformHealthOnly", "false"),
30+
),
31+
},
32+
},
33+
})
34+
}
35+
36+
func TestAccSpinnakerApplication_nondefault(t *testing.T) {
37+
resourceName := "spinnaker_application.test"
38+
rName := acctest.RandomWithPrefix("tf-acc-test")
39+
resource.ParallelTest(t, resource.TestCase{
40+
PreCheck: func() { testAccPreCheck(t) },
41+
Providers: testAccProviders,
42+
Steps: []resource.TestStep{
43+
{
44+
Config: testAccSpinnakerApplication_basic(rName),
45+
Check: resource.ComposeTestCheckFunc(
46+
testAccCheckApplicationExists(resourceName),
47+
resource.TestCheckResourceAttr(resourceName, "application", rName),
48+
resource.TestCheckResourceAttr(resourceName, "email", "[email protected]"),
49+
resource.TestCheckResourceAttr(resourceName, "description", "My application"),
50+
resource.TestCheckResourceAttr(resourceName, "platformHealthOnly", "true"),
51+
resource.TestCheckResourceAttr(resourceName, "platformHealthOnlyShowOverride", "true"),
2752
),
2853
},
2954
},
@@ -70,3 +95,15 @@ resource "spinnaker_application" "test" {
7095
}
7196
`, rName)
7297
}
98+
99+
func testAccSpinnakerApplication_nondefault(rName string) string {
100+
return fmt.Sprintf(`
101+
resource "spinnaker_application" "test" {
102+
application = %q
103+
104+
description = "My application"
105+
platform_health_only = true
106+
platform_health_only_show_override = true
107+
}
108+
`, rName)
109+
}

0 commit comments

Comments
 (0)