Fix entrypoint parsing logic#5830
Conversation
thaJeztah
left a comment
There was a problem hiding this comment.
Nice catch! These tests were added really long ago, and could use some cleaning up in general. I suspect the != 1 was added with the intent to prevent an out of bound if the slice was empty, but indeed flipped the boolean condition; had a quick peek and it looks like this was added when this code still lived in the moby/moby repository, and was part of a bigger refactor (moby/moby#14134) so definitely overlooked in review; moby/moby@d4aec5f#diff-b669db027d2079a55de7d0b67c632c4dc70ab0e577c4de03e8557dfd9f4898d5
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if len(config.Entrypoint) != 1 && config.Entrypoint[0] != "anything" { | ||
| if len(config.Entrypoint) != 1 || config.Entrypoint[0] != "anything" { | ||
| t.Fatalf("Expected entrypoint 'anything', got %v", config.Entrypoint) | ||
| } |
There was a problem hiding this comment.
Given that we already have the gotest.tools assert imported in this package (and use it for other tests in this file), we could use that for this test;
func TestParseEntryPoint(t *testing.T) {
config, _, _, err := parseRun([]string{"--entrypoint=anything", "cmd", "img"})
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(config.Entrypoint, []string{"anything"}))
}|
Thank you for contributing! It appears your commit message is missing a DCO sign-off, We require all commit messages to have a There is no need to open a new pull request, but to fix this (and make CI pass), Unfortunately, it's not possible to do so through GitHub's web UI, so this needs You can find some instructions in the output of the DCO check (which can be found Steps to do so "roughly" come down to:
Sorry for the hassle (I wish GitHub would make this a bit easier to do), and let me know if you need help or more detailed instructions! |
|
Ah, sorry for the canned reply; I see there's a sign-off, but DCO-check saw the spelling of your name was different than the information in the git "author" field ( |
8fde770 to
efa2043
Compare
|
DCO is fixed |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5830 +/- ##
==========================================
+ Coverage 58.79% 59.18% +0.38%
==========================================
Files 349 352 +3
Lines 29536 29547 +11
==========================================
+ Hits 17367 17486 +119
+ Misses 11186 11080 -106
+ Partials 983 981 -2 |
|
Ah! Good one; forgot it was defined using that type; yeah either way (casting to |
Right now the test passes even if you change the expected value. It passes if the array has 1 element. Signed-off-by: Lajos Papp <lalyos@yahoo.com>
efa2043 to
e868f0f
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM!
Thanks for contributing!
|
Btw as it turned out that entrypoint is an strslice, I got the the crazy itch to check if I could give an actual array to It just took 3 lines: 284534f and then you could do: I myself question if its practical at all, but I saw a couple of issues mentioning this feature. |
Right now the test passes even if you change the expected value. It passes if the array has 1 element.
- What I did
I was trying to understand the
docker run --entrypointparsing process, and run the test:go test -v ./cli/command/container -run Entryand even when I changed the expected value, it still passed?!- How to verify it
change the expected value to
fooand run:go test -v ./cli/command/container -run Entry