Skip to content

Commit

Permalink
Merge pull request #73 from rundeck/nodes-selected-by-default
Browse files Browse the repository at this point in the history
Nodes Selected by Default
  • Loading branch information
fdevans authored Oct 6, 2023
2 parents 574c026 + 0a58a45 commit aed8fac
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rundeck/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type JobDetail struct {
* by this reason omitempty cannot be present.
* This has to be handle by the user.
*/
NodesSelectedByDefault *Boolean `xml:"nodesSelectedByDefault"`
NodesSelectedByDefault bool `xml:"nodesSelectedByDefault"`
Schedule *JobSchedule `xml:"schedule,omitempty"`
ScheduleEnabled bool `xml:"scheduleEnabled"`
TimeZone string `xml:"timeZone,omitempty"`
Expand Down
9 changes: 9 additions & 0 deletions rundeck/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ func resourceRundeckJob() *schema.Resource {
Default: true,
},

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

"time_zone": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -592,6 +597,7 @@ func jobFromResourceData(d *schema.ResourceData) (*JobDetail, error) {
ExecutionEnabled: d.Get("execution_enabled").(bool),
Timeout: d.Get("timeout").(string),
ScheduleEnabled: d.Get("schedule_enabled").(bool),
NodesSelectedByDefault: d.Get("nodes_selected_by_default").(bool),
TimeZone: d.Get("time_zone").(string),
LogLevel: d.Get("log_level").(string),
AllowConcurrentExecutions: d.Get("allow_concurrent_executions").(bool),
Expand Down Expand Up @@ -808,6 +814,9 @@ func jobToResourceData(job *JobDetail, d *schema.ResourceData) error {
if err := d.Set("schedule_enabled", job.ScheduleEnabled); err != nil {
return err
}
if err := d.Set("nodes_selected_by_default", job.NodesSelectedByDefault); err != nil {
return err
}
if err := d.Set("time_zone", job.TimeZone); err != nil {
return err
}
Expand Down
5 changes: 5 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 expected := true; job.NodesSelectedByDefault != expected {
return fmt.Errorf("failed to set node selected by default; expected %v, got %v", expected, job.NodesSelectedByDefault)
}
if job.Dispatch.SuccessOnEmptyNodeFilter != true {
return fmt.Errorf("failed to set success_on_empty_node_filter; expected true, got %v", job.Dispatch.SuccessOnEmptyNodeFilter)
}
Expand Down Expand Up @@ -188,6 +191,7 @@ resource "rundeck_job" "test" {
execution_enabled = true
node_filter_query = "example"
allow_concurrent_executions = true
nodes_selected_by_default = true
success_on_empty_node_filter = true
max_thread_count = 1
rank_order = "ascending"
Expand Down Expand Up @@ -231,6 +235,7 @@ resource "rundeck_job" "test" {
execution_enabled = true
node_filter_query = "example"
allow_concurrent_executions = true
nodes_selected_by_default = false
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 @@ -114,6 +114,9 @@ The following arguments are supported:
* `node_filter_exclude_precedence`: (Optional, Deprecated) Boolean controlling a deprecated Rundeck feature that
controls whether node exclusions take priority over inclusions.

* `nodes_selected_by_default`: (Optional) Boolean controlling whether nodes that match the node_query_filter are
selected by default or not.

* `option`: (Optional) Nested block defining an option a user may set when executing this job. A
job may have any number of options. The structure of this nested block is described below.

Expand Down

0 comments on commit aed8fac

Please sign in to comment.