Skip to content

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Nov 28, 2022

The "docker context show" command is intended to show the currently configured
context. While the context that's configured may not be valid (e.g., in case
an environment variable was set to configure the context, or if the context
was removed from the filesystem), we should still be able to show the
context.

This patch removes the context validation, and instead only shows the context.
This can help in cases where the context is used to (e.g.) set the command-
prompt, but the user removed the context. With this change, the context name
can still be shown, but commands that require the context will still fail.

- Description for the changelog

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

Comment on lines 29 to 32
_, err := dockerCli.ContextStore().GetMetadata(context)
if err != nil {
return err
}
Copy link
Member Author

Choose a reason for hiding this comment

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

From the discussion on #3868 (comment)

As this is a new command, we can still change; do we think we should produce an error at all if the context wasn't found, or just "show the name of the context" (basically: this is what's configured to use, but you'll learn if it works once you use it)?

We could still opt for printing the error (on STDERR) as a warning, but make the command always return a zero exit code ("success").

@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2022

Codecov Report

Merging #3886 (6ba7de3) into master (cbf0522) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3886      +/-   ##
==========================================
+ Coverage   59.22%   59.23%   +0.01%     
==========================================
  Files         285      287       +2     
  Lines       24653    24651       -2     
==========================================
+ Hits        14601    14603       +2     
+ Misses       9168     9166       -2     
+ Partials      884      882       -2     

The "docker context show" command is intended to show the currently configured
context. While the context that's configured may not be valid (e.g., in case
an environment variable was set to configure the context, or if the context
was removed from the filesystem), we should still be able to _show_ the
context.

This patch removes the context validation, and instead only shows the context.
This can help in cases where the context is used to (e.g.) set the command-
prompt, but the user removed the context. With this change, the context name
can still be shown, but commands that _require_ the context will still fail.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the context_lazy_evaluate_step3 branch from 3348a5e to 6ba7de3 Compare November 28, 2022 10:34
@thaJeztah thaJeztah changed the title cli/command/context: allow context show to print context, even on error cli/command/context: "docker context show": don't validate context Nov 28, 2022
@thaJeztah
Copy link
Member Author

Thx! Bringing this one in. We'll probably need to do follow-ups to align compose-cli with the changes we made in the cli itself.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants