Skip to content

api/types/container: omit Config.OnBuild when empty#51154

Merged
thaJeztah merged 1 commit intomoby:masterfrom
austinvazquez:add-omits-for-container-config-onbuild
Oct 10, 2025
Merged

api/types/container: omit Config.OnBuild when empty#51154
thaJeztah merged 1 commit intomoby:masterfrom
austinvazquez:add-omits-for-container-config-onbuild

Conversation

@austinvazquez
Copy link
Contributor

- What I did
Added omit annotations for container configuration OnBuild field.

- How I did it

- How to verify it

- Human readable description for the release notes

api/types/container: `OnBuild` will now be omitted if its value is empty or zero.

- A picture of a cute animal (not mandatory but encouraged)

@austinvazquez austinvazquez added this to the 29.0.0 milestone Oct 9, 2025
@austinvazquez austinvazquez self-assigned this Oct 9, 2025
@austinvazquez austinvazquez added area/api API kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. impact/api labels Oct 9, 2025
@austinvazquez
Copy link
Contributor Author

omitzero was added in Go1.24 but I tested with a 1.23 toolchain and the test I added passed.

docker run -it --rm -v ./api:/workspace -w /workspace golang:1.23 go test ./...

@austinvazquez austinvazquez added the release-blocker PRs we want to block a release on label Oct 9, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds JSON serialization optimization to the container configuration by omitting the OnBuild field when it's empty or zero-valued. This reduces JSON payload size for container configurations that don't use ONBUILD instructions.

  • Added omitempty,omitzero JSON tags to the OnBuild field in container configuration
  • Added comprehensive test coverage to verify empty OnBuild arrays are omitted during JSON marshaling
  • Updated API changelog to document the behavioral change

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
api/types/container/config.go Added omitempty,omitzero JSON tags to OnBuild field
api/types/container/config_test.go Added test to verify OnBuild field omission behavior
api/docs/CHANGELOG.md Documented the API change for container JSON response

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@austinvazquez austinvazquez force-pushed the add-omits-for-container-config-onbuild branch from bbcaca7 to 554c896 Compare October 10, 2025 13:16
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
@thaJeztah
Copy link
Member

Flaky test; already has a tracking issue;

=== Failed
=== FAIL: daemon/logger/fluentd TestReadWriteTimeoutsAreEffective (10.00s)
    fluentd_test.go:315: Test timed out, which is unexpected
--- PASS: TestReadWriteTimeoutsAreEffective/write_timeout (0.00s)
--- PASS: TestReadWriteTimeoutsAreEffective/read_timeout (10.00s)

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah merged commit 4d3da4f into moby:master Oct 10, 2025
293 of 296 checks passed
@austinvazquez austinvazquez deleted the add-omits-for-container-config-onbuild branch October 11, 2025 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API area/docs impact/api impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. module/api release-blocker PRs we want to block a release on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants