Skip to content

remove redundant uses of api/types/strslice.StrSlice#49336

Merged
thaJeztah merged 2 commits intomoby:masterfrom
thaJeztah:no_strslice
Jan 27, 2025
Merged

remove redundant uses of api/types/strslice.StrSlice#49336
thaJeztah merged 2 commits intomoby:masterfrom
thaJeztah:no_strslice

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

The only real purpose of strslice.StrSlice is to provide a custom json.Unmarshaler implementation for API responses. For all other purposes, it's a regular string-slice.

This patch removes uses of this type in cases where the custom json.Unmarshaler is irrelevant; in most cases this was in tests, where results were tested using "DeepEquals"; for those tests, the type-assertion did not add real value, so we can cast the values to a []string instead.

- Description for the changelog

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

@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Jan 26, 2025
@thaJeztah thaJeztah added this to the 28.0.0 milestone Jan 26, 2025
@thaJeztah thaJeztah self-assigned this Jan 26, 2025
@thaJeztah thaJeztah requested a review from tonistiigi as a code owner January 26, 2025 14:14
@thaJeztah
Copy link
Copy Markdown
Member Author

Failure looks another case of;

 > [smoketest 3/3] RUN <<EOT (set -ex...):
0.044 + file dockerd
0.051 dockerd: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1 (SYSV), statically linked, for GNU/Linux 3.10.0, Go BuildID=uXVRz8PATDxaLyWkneqK/wnyojFBYzz5tFAUvFPOP/vlLFDoHJb2izLOWXprDR/1FEIXYGG_DwBeSGIxq-3, BuildID[xxHash]=552f96207452146f, with debug_info, not stripped
0.051 + dockerd --version
0.120 Segmentation fault (core dumped)

Copy link
Copy Markdown

@p1-0tr p1-0tr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@robmry robmry left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread builder/dockerfile/dispatchers_test.go Outdated
}

assert.Check(t, is.DeepEqual(expectedCommand, sb.state.runConfig.Cmd))
assert.Check(t, is.DeepEqual(expectedCommand, []string(sb.state.runConfig.Cmd)))
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.

Could swap these checks around to got before want while we're at it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, yes, I was considering some of that; we've not been very consistent on order (and gotest.tools is less descriptive on which one should go to the left). Let me update indeed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated; also push a second commit for some (all?) of the other assertions to put "expected" on the right

The only real purpose of strslice.StrSlice is to provide a custom
json.Unmarshaler implementation for API responses. For all other purposes,
it's a regular string-slice.

This patch removes uses of this type in cases where the custom json.Unmarshaler
is irrelevant; in most cases this was in tests, where results were tested
using "DeepEquals"; for those tests, the type-assertion did not add real
value, so we can cast the values to a []string instead.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah merged commit f760738 into moby:master Jan 27, 2025
@thaJeztah thaJeztah deleted the no_strslice branch January 27, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants