Skip to content

Commit

Permalink
Revert "modify log_limit to be a Type list and allow convert status a…
Browse files Browse the repository at this point in the history
…nd action to optional"

This reverts commit b46a2a0.
  • Loading branch information
Jesus-Osuna-M committed Jan 20, 2025
1 parent 6bb6615 commit 4959d4f
Show file tree
Hide file tree
Showing 2,175 changed files with 712,716 additions and 23 deletions.
43 changes: 20 additions & 23 deletions rundeck/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func resourceRundeckJob() *schema.Resource {
},

"log_limit": {
Type: schema.TypeList,
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand All @@ -67,12 +67,12 @@ func resourceRundeckJob() *schema.Resource {
},
"action": {
Type: schema.TypeString,
Optional: true,
Required: true,
Description: "Enter either \"halt\" or \"truncate\" to specify the action to take when the log limit is reached.",
},
"status": {
Type: schema.TypeString,
Optional: true,
Required: true,
Description: "Enter either \"failed\" or \"canceled\" or any custom status.",
},
},
Expand Down Expand Up @@ -742,31 +742,28 @@ func jobFromResourceData(d *schema.ResourceData) (*JobDetail, error) {
}

if v, ok := d.GetOk("log_limit"); ok {
logLimitList := v.([]interface{})
logLimit := v.(map[string]interface{})

if len(logLimitList) > 0 {
logLimit := logLimitList[0].(map[string]interface{})
output, outputOk := logLimit["output"].(string)
if !outputOk {
return nil, fmt.Errorf("log_limit.output is required")
}

output, outputOk := logLimit["output"].(string)
if !outputOk || output == "" {
return nil, fmt.Errorf("log_limit.output is required and can't be empty")
}
action, actionOk := logLimit["action"].(string)
if !actionOk || (action != "halt" && action != "truncate") {
return nil, fmt.Errorf("log_limit.action is required and must be either 'halt' or 'truncate'")
}

action, actionOk := logLimit["action"].(string)
if actionOk && action != "" && action != "halt" && action != "truncate" {
return nil, fmt.Errorf("log_limit.action must be either 'halt' or 'truncate'")
}
status, statusOk := logLimit["status"].(string)

status, statusOk := logLimit["status"].(string)
if !statusOk {
return nil, fmt.Errorf("log_limit.status could be either \"failed\" or \"canceled\" or any custom status)")
}
if !statusOk || status == "" {
return nil, fmt.Errorf("log_limit.status is required and can't be empty (any custom status in case of log limit reached and action is halt)")
}

job.LoggingLimit = &JobLoggingLimit{
Output: output,
Action: action,
Status: status,
}
job.LoggingLimit = &JobLoggingLimit{
Output: output,
Action: action,
Status: status,
}
}

Expand Down
202 changes: 202 additions & 0 deletions vendor/cloud.google.com/go/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4959d4f

Please sign in to comment.