Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] aws_batch_job_definition: add extra nil checks #38716

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions internal/service/batch/job_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,14 @@
}

var oeks, neks *batch.EksPodProperties
if len(o.([]interface{})) > 0 {
if len(o.([]interface{})) > 0 && 0.([]interface{})[0] != nil {

Check failure on line 519 in internal/service/batch/job_definition.go

View workflow job for this annotation

GitHub Actions / go build

invalid operation: cannot call non-function 0. (untyped float constant 0)

Check failure on line 519 in internal/service/batch/job_definition.go

View workflow job for this annotation

GitHub Actions / providerlint

invalid operation: cannot call non-function 0. (untyped float constant 0)

Check failure on line 519 in internal/service/batch/job_definition.go

View workflow job for this annotation

GitHub Actions / providerlint

invalid operation: cannot call non-function 0. (untyped float constant 0)

Check failure on line 519 in internal/service/batch/job_definition.go

View workflow job for this annotation

GitHub Actions / providerlint

invalid operation: cannot call non-function 0. (untyped float constant 0)

Check failure on line 519 in internal/service/batch/job_definition.go

View workflow job for this annotation

GitHub Actions / providerlint

invalid operation: cannot call non-function 0. (untyped float constant 0)

Check failure on line 519 in internal/service/batch/job_definition.go

View workflow job for this annotation

GitHub Actions / build-32-bit

invalid operation: cannot call non-function 0. (untyped float constant 0)

Check failure on line 519 in internal/service/batch/job_definition.go

View workflow job for this annotation

GitHub Actions / 2 of 2

invalid operation: cannot call non-function 0. (untyped float constant 0)) (typecheck)
aristosvo marked this conversation as resolved.
Show resolved Hide resolved
oProps := o.([]interface{})[0].(map[string]interface{})
if opodProps, ok := oProps["pod_properties"].([]interface{}); ok && len(opodProps) > 0 {
oeks = expandEKSPodProperties(opodProps[0].(map[string]interface{}))
}
}

if len(n.([]interface{})) > 0 {
if len(n.([]interface{})) > 0 && n.([]interface{})[0] != nil {
nProps := n.([]interface{})[0].(map[string]interface{})
if npodProps, ok := nProps["pod_properties"].([]interface{}); ok && len(npodProps) > 0 {
neks = expandEKSPodProperties(npodProps[0].(map[string]interface{}))
Expand All @@ -540,12 +540,12 @@
}

var ors, nrs *batch.RetryStrategy
if len(o.([]interface{})) > 0 {
if len(o.([]interface{})) > 0 && o.([]interface{})[0] != nil {
oProps := o.([]interface{})[0].(map[string]interface{})
ors = expandRetryStrategy(oProps)
}

if len(n.([]interface{})) > 0 {
if len(n.([]interface{})) > 0 && n.([]interface{})[0] != nil {
nProps := n.([]interface{})[0].(map[string]interface{})
nrs = expandRetryStrategy(nProps)
}
Expand All @@ -560,12 +560,12 @@
}

var ors, nrs *batch.JobTimeout
if len(o.([]interface{})) > 0 {
if len(o.([]interface{})) > 0 && o.([]interface{})[0] != nil {
oProps := o.([]interface{})[0].(map[string]interface{})
ors = expandJobTimeout(oProps)
}

if len(n.([]interface{})) > 0 {
if len(n.([]interface{})) > 0 && n.([]interface{})[0] != nil {
nProps := n.([]interface{})[0].(map[string]interface{})
nrs = expandJobTimeout(nProps)
}
Expand Down Expand Up @@ -616,7 +616,7 @@
}
}

if v, ok := d.GetOk("eks_properties"); ok && len(v.([]interface{})) > 0 {
if v, ok := d.GetOk("eks_properties"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
eksProps := v.([]interface{})[0].(map[string]interface{})
if podProps, ok := eksProps["pod_properties"].([]interface{}); ok && len(podProps) > 0 {
if aws.StringValue(input.Type) == batch.JobDefinitionTypeContainer {
Expand Down
Loading