Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add methods to read or set docker contexts #9197

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

benoitf
Copy link
Collaborator

@benoitf benoitf commented Oct 3, 2024

What does this PR do?

add methods to list and set the docker contexts
there is always a default context even when there is no files (like .docker/config.json or any .docker/context/** files) on the filesystem, it's what we're calling the system socket path.

unit tests provided

Screenshot / video of UI

What issues does this PR fix or reference?

related to #9026

How to test this PR?

  • Tests are covering the bug fix or the new feature

@benoitf benoitf requested a review from a team as a code owner October 3, 2024 20:12
@benoitf benoitf requested review from dgolovin, jeffmaury and SoniaSandler and removed request for a team October 3, 2024 20:12
Copy link
Contributor

@deboer-tim deboer-tim left a comment

Choose a reason for hiding this comment

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

Minor comments but approving.

});

contextBridge.exposeInMainWorld('switchDockerContext', async (contextName: string): Promise<DockerContextInfo[]> => {
return ipcInvoke('docker-compatibility:switchDockerContext', contextName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: I think I'd prefer setDockerContext. I know there are typically going to be 2, but switch sounds like toggling between two states, where set sounds like picking from the list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there is always the default state, there is never an unknown state

Copy link
Contributor

@jeffmaury jeffmaury left a comment

Choose a reason for hiding this comment

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

Context are retrieved through the internal implementation dependant Docker specific file. Why not use docker context ls --format json instead ? Might be broken by Docker undocumented change, no ?

@benoitf
Copy link
Collaborator Author

benoitf commented Oct 4, 2024

Context are retrieved through the internal implementation dependant Docker specific file. Why not use docker context ls --format json instead ? Might be broken by Docker undocumented change, no ?

To not have a direct dependency on the docker CLI from the Podman Desktop core.
Also docker is really conservative on changes,

Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

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

LGTM Codewise

Copy link
Contributor

@jeffmaury jeffmaury left a comment

Choose a reason for hiding this comment

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

LGTM

@benoitf benoitf merged commit bb05b74 into containers:main Oct 4, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants