Skip to content

Commit

Permalink
Merge pull request #148 from rich-boyce/rich.boyce-add-default-tab-jo…
Browse files Browse the repository at this point in the history
…b-arg

Add default_tab job argument
  • Loading branch information
fdevans authored Jan 22, 2025
2 parents 731e6ba + 640a4bd commit 4b9e3e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions rundeck/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type JobDetail struct {
OptionsConfig *JobOptions `xml:"context>options,omitempty"`
Description string `xml:"description"`
ExecutionEnabled bool `xml:"executionEnabled"`
DefaultTab string `xml:"defaultTab"`
LogLevel string `xml:"loglevel,omitempty"`
LoggingLimit *JobLoggingLimit `xml:"logging,omitempty"`
AllowConcurrentExecutions bool `xml:"multipleExecutions,omitempty"`
Expand Down
13 changes: 13 additions & 0 deletions rundeck/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ func resourceRundeckJob() *schema.Resource {
Default: true,
},

"default_tab": {
Type: schema.TypeString,
Optional: true,
Default: "nodes",
},

"log_level": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -724,6 +730,7 @@ func jobFromResourceData(d *schema.ResourceData) (*JobDetail, error) {
ProjectName: d.Get("project_name").(string),
Description: d.Get("description").(string),
ExecutionEnabled: d.Get("execution_enabled").(bool),
DefaultTab: d.Get("default_tab").(string),
Timeout: d.Get("timeout").(string),
ScheduleEnabled: d.Get("schedule_enabled").(bool),
NodesSelectedByDefault: d.Get("nodes_selected_by_default").(bool),
Expand All @@ -741,6 +748,9 @@ func jobFromResourceData(d *schema.ResourceData) (*JobDetail, error) {
RankOrder: d.Get("rank_order").(string),
},
}
if !(job.DefaultTab == "nodes" || job.DefaultTab == "output" || job.DefaultTab == "html") {
return nil, fmt.Errorf("Argument \"default_tab\" must be set to one of `nodes`, `output`, `html`.")
}

successOnEmpty := d.Get("success_on_empty_node_filter")
if successOnEmpty != nil {
Expand Down Expand Up @@ -1027,6 +1037,9 @@ func jobToResourceData(job *JobDetail, d *schema.ResourceData) error {
if err := d.Set("execution_enabled", job.ExecutionEnabled); err != nil {
return err
}
if err := d.Set("default_tab", job.DefaultTab); err != nil {
return err
}
if err := d.Set("schedule_enabled", job.ScheduleEnabled); err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/job.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ The following arguments are supported:

* `execution_enabled` - (Optional) If you want job execution to be enabled or disabled. Defaults to `true`.

* `default_tab` - (Optional) The default tab to show during job execution. Set to 'output' to follow the execution log. Must be set to `output`, `html`, or `nodes`

* `group_name` - (Optional) The name of a group within the project in which to place the job.
Setting this creates collapsable subcategories within the Rundeck UI's project job index.

Expand Down

0 comments on commit 4b9e3e1

Please sign in to comment.