adobe / rules_gitops

This repository contains rules for continuous, GitOps driven Kubernetes deployments.
Apache License 2.0
174 stars 43 forks source link

Crash if you specify an empty initContainer #141

Closed DolceTriade closed 1 year ago

DolceTriade commented 1 year ago

Description of the problem / feature request:

panic: interface conversion: interface {} is nil, not []interface {}

goroutine 1 [running]:
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).updateContainers(0xc0000dde00, 0xc0003884b0?, {0x96bcc1?, 0xe?})
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:115 +0x23b
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findAndReplaceTag(0x8edec0?, 0xc0003883f0?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:101 +0x1ba
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findContainers(0x8edec0?, 0xc0003883f0?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:157 +0x105
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findAndReplaceTag(0x8edec0?, 0xc0003883c0?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:109 +0x1f4
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findContainers(0x8edec0?, 0xc0003883c0?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:157 +0x105
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findAndReplaceTag(0x8edec0?, 0xc000388390?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:109 +0x1f4
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findContainers(0x8edec0?, 0xc000388390?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:157 +0x105
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findAndReplaceTag(0x8edec0?, 0xc000388360?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:109 +0x1f4
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findContainers(0x8edec0?, 0xc000388360?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:157 +0x105
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findAndReplaceTag(0x8edec0?, 0xc0003882d0?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:109 +0x1f4
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findContainers(0x8edec0?, 0xc0003882d0?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:157 +0x105
github.com/adobe/rules_gitops/resolver/pkg.(*imageTagTransformer).findAndReplaceTag(0xc0000a8008?, 0xc0000dde28?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:109 +0x1f4
github.com/adobe/rules_gitops/resolver/pkg.ResolveImages({0xa24800?, 0xc0000a8000?}, {0xa24840, 0xc0000a8008}, 0x5?)
    external/com_adobe_rules_gitops/resolver/pkg/resolver.go:43 +0x1f1
main.main()
    external/com_adobe_rules_gitops/resolver/resolver.go:68 +0x305

Feature requests: what underlying problem are you trying to solve with this feature?

Replace this line with your answer.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Add an empty initContainers: to your yaml file:

Something like this...

          imagePullSecrets:
          - name: image-pull-secret
          initContainers:
          containers:
          - name: git-gc
            imagePullPolicy: Always

What operating system are you running Bazel on?

Linux

What's the output of bazel info release?

INFO: Invocation ID: 19ee5aac-88ff-4179-bced-c34b03442851
release 6.0.0- (@non-git)

Snippet of the WORKSPACE file that includes rules_gitops rules.

# Adobe K8s GitOps
http_archive(
    name = "com_adobe_rules_gitops",
    sha256 = "6e8a2273b8ec19c7bd64904ea819f1e6cca7eee000d6197393e943f8c219949a",
    strip_prefix = "rules_gitops-0.17.0",
    urls = ["https://github.com/adobe/rules_gitops/archive/refs/tags/v0.17.0.tar.gz"],
)

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

Seems like we just need a nil check in resolver.go