Skip to content

feat(deployment): support additionalContainers as a map - #593

Merged
aslafy-z merged 8 commits into
stakater:mainfrom
wpjunior:feature/additionalContainers-as-map
Aug 1, 2026
Merged

feat(deployment): support additionalContainers as a map#593
aslafy-z merged 8 commits into
stakater:mainfrom
wpjunior:feature/additionalContainers-as-map

Conversation

@wpjunior

@wpjunior wpjunior commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

What

Allow deployment.additionalContainers to be specified as a map in addition
to the existing list format. When a map is provided, each key becomes the
container name; the list format continues to work exactly as before.

# Map format (new) — key becomes the container name
deployment:
  additionalContainers:
    sidecar:
      image: busybox
      command: ['/bin/sh']

# List format (still supported)
deployment:
  additionalContainers:
    - name: sidecar
      image: busybox
      command: ['/bin/sh']

Why

Map-keyed values are far easier to override and patch per-container in GitOps
tools such as ArgoCD, where merging into a keyed map is deterministic while
merging into a positional list is not. This mirrors the map style already used
elsewhere in the chart (initContainers, envFrom, volumes, ...).

How

  • templates/deployment.yaml: detect the value kind with kindIs "map". For a
    map, range the entries and merge (dict "name" $name) $container; for a
    list, keep the previous rendering. Empty map/list renders no extra containers.
  • values.yaml: document both formats and annotate the type as
    (list, object, null) so the generated schema validates correctly.
  • values.schema.json: regenerated → type: [array, object, null].
  • README.md: regenerated via helm-docs.

Tests

  • Added unit tests in tests/deployment_test.yaml covering: list format, map
    format (key → name), multiple map entries, and the empty-map case.
  • Converted the additionalContainers example in ci/values.yaml to the map
    format so snapshot tests and Kind API validation exercise the new path.
    Rendered output is byte-identical to the list form (snapshots unchanged).

Backwards compatibility

Fully backwards compatible — the list format is unchanged; the map format is
purely additive.

@wpjunior

Copy link
Copy Markdown
Contributor Author

HI @aslafy-z and @rasheedamir what do you think about this MR?

@aslafy-z aslafy-z left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution, please address the following comment so we can proceed.

Comment thread application/values.yaml Outdated
@aslafy-z

Copy link
Copy Markdown
Collaborator

application/tests/deployment_test.yaml

Could you drop the YAML anchors here and write the asserts out literally?

This is test code, and in tests we want to minimize logic and indirection: each test should be readable standalone, as plain input and expected output. Duplication is fine here, an anchor is not worth the extra hop.

  • &additionalContainersAsserts I get the intent (list and map formats should render the same container), but the map-format test no longer says what it asserts, you have to jump back to the previous test to find out. Duplicating the four-line assert block states the equivalence just as clearly and reads inline.
  • &containersPath is also inconsistent with the rest of the file: spec.template.spec.containers is spelled out ~25 times elsewhere, and even the last test added in this PR (the empty-map notContains case) writes the path literally instead of reusing the alias. Aliasing it in only three spots saves nothing and breaks grep for the path.

Anchors as a convention would only make sense applied consistently across the test files, and I don't think that churn is worth it either way given the point above about keeping tests logic-free.

@aslafy-z

aslafy-z commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

One more thing on the tests: could you use the placeholder image convention instead of real images (busybox, nginx)? #596 normalizes it across the suite: example-registry/example-image:example-tag for the main container (it is the suite fixture at the top of deployment_test.yaml) and another-example-registry/another-example-image:another-example-tag for any additional image (init containers, image templating tests). For the sidecar tests here that means the another-example-* form; in the multi-container test you can vary the tag or mix the example-* / another-example-* components so the two entries stay distinguishable. Renovate's ignoreDeps already covers all these combinations. Once #596 is merged a rebase is worth it anyway, since it renames the fixture values in deployment_test.yaml.

wpjunior and others added 3 commits August 1, 2026 09:52
Allow deployment.additionalContainers to be specified as a map in
addition to the existing list format. When a map is provided, each key
becomes the container name, which makes per-container overrides easier
(e.g. via ArgoCD). The list format remains fully supported and behaves
as before.

Update values.yaml documentation, the values schema to accept objects,
and add unit tests covering both list and map formats, multiple map
entries, and the empty-map case.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Wilson Júnior <wilsonpjunior@gmail.com>
@wpjunior
wpjunior force-pushed the feature/additionalContainers-as-map branch from 2a9ea2f to 338fe5c Compare August 1, 2026 12:54
@wpjunior

wpjunior commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi @aslafy-z I made the requested changes. Thanks

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for configuring deployment.additionalContainers as either a list (existing behavior) or a map (new), enabling deterministic per-container overrides in GitOps workflows while maintaining backward compatibility.

Changes:

  • Updated the Deployment template to render additionalContainers from either list or map input.
  • Updated values docs/schema (values.yaml, values.schema.json, README) to document and validate list/object/null.
  • Added unit tests for list and map formats and updated CI example values to exercise the new map path.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents deployment.additionalContainers as list/object/null and mentions map support rationale.
application/values.yaml Updates inline values documentation and provides examples for both map and list formats.
application/values.schema.json Extends schema type for deployment.additionalContainers to include object.
application/tests/deployment_test.yaml Adds unit tests covering list format, map format, multiple map entries, and empty map behavior.
application/templates/deployment.yaml Implements map-vs-list rendering logic for additional containers.
application/ci/values.yaml Switches CI example to map format so CI exercises the new rendering path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread application/templates/deployment.yaml
Comment thread application/tests/deployment_test.yaml Outdated
wpjunior and others added 2 commits August 1, 2026 15:38
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@wpjunior

wpjunior commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi @aslafy-z I made Copilot suggestions =)

@aslafy-z aslafy-z changed the title feat(chart): support additionalContainers as a map feat(deployment): support additionalContainers as a map Aug 1, 2026
aslafy-z
aslafy-z previously approved these changes Aug 1, 2026

@aslafy-z aslafy-z left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aslafy-z

aslafy-z commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Oh, it looks like tests are failing now. Can you also add one to ensure containers are sorted by names ? Thank you !

@wpjunior

wpjunior commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi @aslafy-z I fixed the bug caused by copilot suggestion. unit test saved us for a bug.

@aslafy-z

aslafy-z commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Perfect! Can you add that additional test ? Thank you !

@wpjunior

wpjunior commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Perfect! Can you add that additional test ? Thank you !

Sure @aslafy-z! added right now ♥️

@aslafy-z aslafy-z left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aslafy-z
aslafy-z merged commit 37d8fc1 into stakater:main Aug 1, 2026
12 checks passed
@wpjunior
wpjunior deleted the feature/additionalContainers-as-map branch August 1, 2026 20:48
@aslafy-z

aslafy-z commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Thank you for your contribution, this change is part of the v9.2.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants