-
Notifications
You must be signed in to change notification settings - Fork 555
Implemented Delete Remote Image for GenericV2 #4039
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0da1e23
added logic for copy remote imgage digest
alexyaang b2f86dc
added back delete image
alexyaang 909aab1
refined logic for delete image
alexyaang 11813c0
fixed pushImage
alexyaang 3e23733
reverted changes to registryExperience
alexyaang ccbd125
tag logic for GitHub
alexyaang c191cf4
be able to debug github image
alexyaang dd75f2e
added back skipIfOne flag
alexyaang 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,37 +1,50 @@ | ||
| // /*--------------------------------------------------------------------------------------------- | ||
| // * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // * Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
| // *--------------------------------------------------------------------------------------------*/ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| // import { DialogResponses, IActionContext } from '@microsoft/vscode-azext-utils'; | ||
| // import { l10n, ProgressLocation, window } from 'vscode'; | ||
| // import { ext } from '../../extensionVariables'; | ||
| // import { DockerV2TagTreeItem } from '../../tree/registries/dockerV2/DockerV2TagTreeItem'; | ||
| // import { registryExpectedContextValues } from '../../tree/registries/registryContextValues'; | ||
| import { DialogResponses, IActionContext, UserCancelledError, parseError } from '@microsoft/vscode-azext-utils'; | ||
| import { CommonTag, GenericRegistryV2DataProvider } from '@microsoft/vscode-docker-registries'; | ||
| import { ProgressLocation, l10n, window } from 'vscode'; | ||
| import { ext } from '../../extensionVariables'; | ||
| import { UnifiedRegistryItem } from '../../tree/registries/UnifiedRegistryTreeDataProvider'; | ||
| import { getImageNameFromRegistryTagItem } from '../../tree/registries/registryTreeUtils'; | ||
| import { registryExperience } from '../../utils/registryExperience'; | ||
|
|
||
| // export async function deleteRemoteImage(context: IActionContext, node?: DockerV2TagTreeItem): Promise<void> { | ||
| // if (!node) { | ||
| // node = await ext.registriesTree.showTreeItemPicker<DockerV2TagTreeItem>(registryExpectedContextValues.dockerV2.tag, { | ||
| // ...context, | ||
| // suppressCreatePick: true, | ||
| // noItemFoundErrorMessage: l10n.t('No remote images are available to delete') | ||
| // }); | ||
| // } | ||
| export async function deleteRemoteImage(context: IActionContext, node?: UnifiedRegistryItem<CommonTag>): Promise<void> { | ||
| if (!node) { | ||
| node = await registryExperience(context, ext.registriesTree, { include: ['genericRegistryV2Tag', 'azureContainerTag', 'githubRegistryTag'] }, false); | ||
| } | ||
|
|
||
| // const confirmDelete = l10n.t('Are you sure you want to delete image "{0}"? This will delete all images that have the same digest.', node.repoNameAndTag); | ||
| // // no need to check result - cancel will throw a UserCancelledError | ||
| // await context.ui.showWarningMessage(confirmDelete, { modal: true }, DialogResponses.deleteResponse); | ||
| const tagName = getImageNameFromRegistryTagItem(node.wrappedItem); | ||
| const confirmDelete = l10n.t('Are you sure you want to delete image "{0}"? This will delete all images that have the same digest.', tagName); | ||
| // no need to check result - cancel will throw a UserCancelledError | ||
| await context.ui.showWarningMessage(confirmDelete, { modal: true }, DialogResponses.deleteResponse); | ||
|
|
||
| // const repoTI = node.parent; | ||
| // const deleting = l10n.t('Deleting image "{0}"...', node.repoNameAndTag); | ||
| // await window.withProgress({ location: ProgressLocation.Notification, title: deleting }, async () => { | ||
| // await node.deleteTreeItem(context); | ||
| // }); | ||
| const deleting = l10n.t('Deleting image "{0}"...', tagName); | ||
| await window.withProgress({ location: ProgressLocation.Notification, title: deleting }, async () => { | ||
| const provider = node.provider as unknown as GenericRegistryV2DataProvider; | ||
|
|
||
| // // Other tags that also matched the image may have been deleted, so refresh the whole repository | ||
| // await repoTI.refresh(context); | ||
| // const message = l10n.t('Successfully deleted image "{0}".', node.repoNameAndTag); | ||
| // // don't wait | ||
| // /* eslint-disable-next-line @typescript-eslint/no-floating-promises */ | ||
| // window.showInformationMessage(message); | ||
| // } | ||
| try { | ||
| await provider.deleteTag(node.wrappedItem); | ||
| } catch (error) { | ||
| const errorType: string = parseError(error).errorType.toLowerCase(); | ||
| if (errorType === '405' || errorType === 'unsupported') { | ||
| // Don't wait | ||
| // eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
| context.ui.showWarningMessage('Deleting remote images is not supported on this registry. It may need to be enabled.', { learnMoreLink: 'https://aka.ms/AA7jsql' }); | ||
| throw new UserCancelledError(); | ||
| } else { | ||
| throw error; | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| // TODO: investigate if we can do this for GitHub | ||
|
|
||
| // Other tags that also matched the image may have been deleted, so refresh the whole repository | ||
| // don't wait | ||
| void ext.registriesTree.refresh(); | ||
| /* eslint-disable-next-line @typescript-eslint/no-floating-promises */ | ||
| window.showInformationMessage(l10n.t('Successfully deleted image "{0}".', tagName)); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.