-
Notifications
You must be signed in to change notification settings - Fork 294
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
fix(container-detail): display the entire command instead of the first piece only #6604
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6c5b784
fix(container-detail): display the entire command instead of the firs…
GLEF1X d174962
Merge branch 'main' into show-all-command-container-detail
GLEF1X e388b1a
fix: typescript errors
GLEF1X 24dbdb3
Update packages/main/src/plugin/container-registry.ts
GLEF1X b1e2ce7
fix: change back to undefined
GLEF1X File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/renderer/src/lib/container/ContainerDetailsSummary.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/********************************************************************** | ||
* Copyright (C) 2023 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
***********************************************************************/ | ||
import '@testing-library/jest-dom/vitest'; | ||
|
||
import { render, screen } from '@testing-library/svelte'; | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import ContainerDetailsSummary from './ContainerDetailsSummary.svelte'; | ||
import type { ContainerInfoUI } from './ContainerInfoUI'; | ||
|
||
test('Expect container command to be displayed as an array', async () => { | ||
const container: ContainerInfoUI = { | ||
shortId: 'myContainer', | ||
command: ['sh', '-c', 'something', 'else'], | ||
state: 'RUNNING', | ||
hasPublicPort: false, | ||
} as unknown as ContainerInfoUI; | ||
|
||
render(ContainerDetailsSummary, { container }); | ||
expect(screen.getByTestId('container-details-command-td')).toHaveTextContent('["sh", "-c", "something", "else"]'); | ||
}); | ||
|
||
describe('Expect command to be hidden if command is an empty array or undefined', async () => { | ||
// eslint-disable-next-line no-null/no-null | ||
test.each([[], undefined, null])('given %p should not be visible', async command => { | ||
const container: ContainerInfoUI = { | ||
shortId: 'myContainer', | ||
command: command, | ||
state: 'RUNNING', | ||
hasPublicPort: false, | ||
} as unknown as ContainerInfoUI; | ||
|
||
render(ContainerDetailsSummary, { container }); | ||
expect(screen.getByTestId('container-details-command-tr').classList.contains('hidden')).to.be.true; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding, this interface is inspired from dockerode definiton
https://github.com/codershiba/DefinitelyTyped/blob/2639c808780fbe2c5ac588c14c7344fd8fdd1c1c/types/dockerode/index.d.ts#L351-L356
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, you're totally right. However, I changed it to
readonly string[]
becauselistContainers
dynamically selects among various providers, leading to the use of workarounds such aspodmanContainer.Command?.length > 0 ? podmanContainer.Command[0]: undefined
. In my opinion,ContainerInfo
should use an array to represent a command even thoughdockerode
returns a string because it enables us to not lose data(in this case other parts of the command).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I looked at the podman repository and they are indeed sending an array compared to dockerode definition.
https://github.com/containers/podman/blob/17f36a369035b4d5c27f416af9cb961ede807eed/pkg/domain/entities/types/container_ps.go#L14-L15
I would be in favour to get something closer to what podman provide, the changes you are providing only touch the internal api, so it would not have much side effect, however the
ContainerInfo
is also provided to theextension-api
.podman-desktop/packages/extension-api/src/extension-api.d.ts
Line 1970 in 689b3f8
However for the
extension-api
we have something different, with an interface calledSimpleContainerInfo
which is some extending of dockerode.podman-desktop/packages/main/src/plugin/api/container-info.ts
Line 53 in 6c5b784
And I am wondering if we change/fix it at one place we would not have to propagate the changes also elsewhere... Waiting for @benoitf opinion on the matter