Skip to content

container: validate --pull option on create and run - #3692

Merged
thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:validate_pull_opts
Jun 30, 2022
Merged

thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:validate_pull_opts

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

Before this change, specifying the --pull flag without a value, could
result in the flag after it, or the positional argument to be used as
value.

This patch makes sure that the value is an expected value;

docker create --pull --rm hello-world
docker: invalid pull option: '--rm': must be one of "always", "missing" or "never".

docker run --pull --rm hello-world
docker: invalid pull option: '--rm': must be one of "always", "missing" or "never".

docker run --pull hello-world
docker: invalid pull option: 'hello-world': must be one of "always", "missing" or "never".

- Description for the changelog

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

@thaJeztah thaJeztah added this to the 22.06.0 milestone Jun 27, 2022
@thaJeztah

Copy link
Copy Markdown
Member Author

@ndeloof @vvoland PTAL

Comment thread cli/command/container/create.go Outdated
if err != nil {
return err
reportError(dockerCli.Err(), "create", err.Error(), true)
return cli.StatusError{StatusCode: 125}

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.

Some tests (TestTrustedCreateFromUnreachableTrustServer, TestTrustedCreateFromBadTrustServer, TestNewCreateCommandWithContentTrustErrors) expect exit code 1 here, so they need to be adjusted to account for this change.

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.

Hm.. good one; thinking of that, I may have been a bit too eager to make this a 125, as createContainer may produce an error for other reasons. I had this part initially elsewhere, but decided to move the validation to createContainer. Let me have a look

@thaJeztah
thaJeztah force-pushed the validate_pull_opts branch 4 times, most recently from fb1227e to 78da2e2 Compare June 28, 2022 11:58
Before this change, specifying the `--pull` flag without a value, could
result in the flag after it, or the positional argument to be used as
value.

This patch makes sure that the value is an expected value;

    docker create --pull --rm hello-world
    docker: invalid pull option: '--rm': must be one of "always", "missing" or "never".

    docker run --pull --rm hello-world
    docker: invalid pull option: '--rm': must be one of "always", "missing" or "never".

    docker run --pull hello-world
    docker: invalid pull option: 'hello-world': must be one of "always", "missing" or "never".

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
thaJeztah force-pushed the validate_pull_opts branch from 78da2e2 to 190dac7 Compare June 28, 2022 11:59

@vvoland vvoland 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

@thaJeztah

Copy link
Copy Markdown
Member Author

thx! bringing this in

@thaJeztah
thaJeztah merged commit 8d9b956 into docker:master Jun 30, 2022
@thaJeztah
thaJeztah deleted the validate_pull_opts branch June 30, 2022 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate docker run's --pull values

2 participants