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

Additional application attributes #43

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
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", "[email protected]"),
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", "[email protected]"),
resource.TestCheckResourceAttr(resourceName, "description", "My application"),
resource.TestCheckResourceAttr(resourceName, "platformHealthOnly", "true"),
resource.TestCheckResourceAttr(resourceName, "platformHealthOnly", "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 = "[email protected]"
description = "My application"
platform_health_only = true
platform_health_only_show_override = true
}
`, rName)
}