Skip to content

Commit

Permalink
adds description to command schema in rundeck_job resource
Browse files Browse the repository at this point in the history
Change-Id: I90e729dd6864b79773c80aedb39991eb251ab821
  • Loading branch information
Gerben Jacobs authored and stack72 committed May 11, 2017
1 parent 98f6d41 commit 5d1e649
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions builtin/providers/rundeck/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion builtin/providers/rundeck/resource_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

"github.com/apparentlymart/go-rundeck-api/rundeck"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
Expand All @@ -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
},
),
Expand Down Expand Up @@ -98,6 +100,7 @@ resource "rundeck_job" "test" {
default_value = "bar"
}
command {
description = "Prints Hello World"
shell_command = "echo Hello World"
}
}
Expand Down

0 comments on commit 5d1e649

Please sign in to comment.