adds `description` to `command` schema in `rundeck_job` resource

Change-Id: I90e729dd6864b79773c80aedb39991eb251ab821
This commit is contained in:
Gerben Jacobs 2017-05-10 14:09:15 +02:00 committed by Paul Stack
parent 98f6d410a4
commit 5d1e649581
2 changed files with 10 additions and 1 deletions

View File

@ -183,6 +183,10 @@ func resourceRundeckJob() *schema.Resource {
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"shell_command": &schema.Schema{
Type: schema.TypeString,
Optional: true,
@ -364,6 +368,7 @@ func jobFromResourceData(d *schema.ResourceData) (*rundeck.JobDetail, error) {
for _, commandI := range commandConfigs {
commandMap := commandI.(map[string]interface{})
command := rundeck.JobCommand{
Description: commandMap["description"].(string),
ShellCommand: commandMap["shell_command"].(string),
Script: commandMap["inline_script"].(string),
ScriptFile: commandMap["script_file"].(string),
@ -552,6 +557,7 @@ func jobToResourceData(job *rundeck.JobDetail, d *schema.ResourceData) error {
d.Set("command_ordering_strategy", job.CommandSequence.OrderingStrategy)
for _, command := range job.CommandSequence.Commands {
commandConfigI := map[string]interface{}{
"description": command.Description,
"shell_command": command.ShellCommand,
"inline_script": command.Script,
"script_file": command.ScriptFile,

View File

@ -5,7 +5,6 @@ import (
"testing"
"github.com/apparentlymart/go-rundeck-api/rundeck"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@ -26,6 +25,9 @@ func TestAccJob_basic(t *testing.T) {
if expected := "basic-job"; job.Name != expected {
return fmt.Errorf("wrong name; expected %v, got %v", expected, job.Name)
}
if expected := "Prints Hello World"; job.CommandSequence.Commands[0].Description != expected {
return fmt.Errorf("failed to set command description; expected %v, got %v", expected, job.CommandSequence.Commands[0].Description)
}
return nil
},
),
@ -98,6 +100,7 @@ resource "rundeck_job" "test" {
default_value = "bar"
}
command {
description = "Prints Hello World"
shell_command = "echo Hello World"
}
}