Skip to content

Commit

Permalink
add success_on_empty_node_filter bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Moultrie authored and ProTip committed Aug 2, 2019
1 parent bebe52c commit 632bc71
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rundeck/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,12 @@ type jobImportResult struct {
}

type JobDispatch struct {
ExcludePrecedence *Boolean `xml:"excludePrecedence"`
MaxThreadCount int `xml:"threadcount,omitempty"`
ContinueOnError bool `xml:"keepgoing"`
RankAttribute string `xml:"rankAttribute,omitempty"`
RankOrder string `xml:"rankOrder,omitempty"`
ExcludePrecedence *Boolean `xml:"excludePrecedence"`
MaxThreadCount int `xml:"threadcount,omitempty"`
ContinueOnError bool `xml:"keepgoing"`
RankAttribute string `xml:"rankAttribute,omitempty"`
RankOrder string `xml:"rankOrder,omitempty"`
SuccessOnEmptyNodeFilter bool `xml:"successOnEmptyNodeFilter,omitempty"`
}

// GetJobSummariesForProject returns summaries of the jobs belonging to the named project.
Expand Down
14 changes: 14 additions & 0 deletions rundeck/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func resourceRundeckJob() *schema.Resource {
Optional: true,
},

"success_on_empty_node_filter": {
Type: schema.TypeBool,
Optional: true,
},

"preserve_options_order": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -438,6 +443,10 @@ func jobFromResourceData(d *schema.ResourceData) (*JobDetail, error) {
RankOrder: d.Get("rank_order").(string),
},
}
successOnEmpty := d.Get("success_on_empty_node_filter")
if successOnEmpty != nil {
job.Dispatch.SuccessOnEmptyNodeFilter = successOnEmpty.(bool)
}

sequence := &JobCommandSequence{
ContinueOnError: d.Get("continue_on_error").(bool),
Expand Down Expand Up @@ -564,6 +573,11 @@ func jobFromResourceData(d *schema.ResourceData) (*JobDetail, error) {
RankAttribute: d.Get("rank_attribute").(string),
RankOrder: d.Get("rank_order").(string),
}

successOnEmpty := d.Get("success_on_empty_node_filter")
if successOnEmpty != nil {
job.Dispatch.SuccessOnEmptyNodeFilter = successOnEmpty.(bool)
}
}

if d.Get("schedule").(string) != "" {
Expand Down
4 changes: 4 additions & 0 deletions rundeck/resource_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func TestAccJob_basic(t *testing.T) {
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)
}
if job.Dispatch.SuccessOnEmptyNodeFilter != true {
return fmt.Errorf("failed to set success_on_empty_node_filter; expected true, got %v", job.Dispatch.SuccessOnEmptyNodeFilter)
}
return nil
},
),
Expand Down Expand Up @@ -185,6 +188,7 @@ resource "rundeck_job" "test" {
execution_enabled = true
node_filter_query = "example"
allow_concurrent_executions = true
success_on_empty_node_filter = true
max_thread_count = 1
rank_order = "ascending"
schedule = "0 0 12 * * * *"
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/job.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ The following arguments are supported:
* `rank_order` - (Optional) Keyword deciding which direction the nodes are sorted in terms of
the chosen `rank_attribute`. May be either "ascending" (the default) or "descending".

* `success_on_empty_node_filter` - (Optional) Boolean determining if an empty node filter yields
a successful result.

* `preserve_options_order`: (Optional) Boolean controlling whether the configured options will
be presented in their configuration order when shown in the Rundeck UI. The default is `false`,
which means that the options will be displayed in alphabetical order by name.
Expand Down

0 comments on commit 632bc71

Please sign in to comment.