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

Added Untag Image Command for Azure RDP #4041

Merged
merged 5 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,12 @@
},
{
"command": "vscode-docker.registries.copyRemoteFullTag",
"when": "view == dockerRegistries && viewItem =~ /(dockerHubTag|registryV2Tag|azureContainerTag)/i",
"when": "view == dockerRegistries && viewItem =~ /(dockerHubTag|genericRegistryV2Tag|azureContainerTag|githubRegistryTag)/i",
Copy link
Member Author

@alexyaang alexyaang Aug 25, 2023

Choose a reason for hiding this comment

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

should we change this to (dockerHubTag|registryV2Tag)?

Copy link
Member Author

Choose a reason for hiding this comment

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

the advantage would be any RDP class that extends v2 registry would be able to have the command show up

Copy link
Collaborator

@bwateratmsft bwateratmsft Aug 25, 2023

Choose a reason for hiding this comment

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

Yes, I think that's a good idea. I'd do that for as many commands as possible.

"group": "regs_tag_1_general@2"
},
{
"command": "vscode-docker.registries.copyImageDigest",
"when": "view == dockerRegistries && viewItem =~ /(dockerHubTag|registryV2Tag|azureContainerTag|githubRegistryTag)/",
"when": "view == dockerRegistries && viewItem =~ /(dockerHubTag|genericRegistryV2Tag|azureContainerTag|githubRegistryTag)/",
"group": "regs_tag_1_general@3"
},
{
Expand All @@ -531,7 +531,7 @@
},
{
"command": "vscode-docker.registries.deleteImage",
"when": "view == dockerRegistries && viewItem =~ /(genericRegistryV2Tag|azureContainerTag|githubRegistryTag)/i",
"when": "view == dockerRegistries && viewItem =~ /(genericRegistryV2Tag|azureContainerTag)/i",
"group": "regs_tag_2_destructive@2"
},
{
Expand Down
3 changes: 2 additions & 1 deletion src/commands/registries/azure/untagAzureImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ export async function untagAzureImage(context: IActionContext, node?: UnifiedReg
const untagging = l10n.t('Untagging image "{0}"...', fullTag);
await window.withProgress({ location: ProgressLocation.Notification, title: untagging }, async () => {
const provider = node.provider as unknown as AzureRegistryDataProvider;
await provider.deleteTag(node.wrappedItem);
await provider.untagImage(node.wrappedItem);
});

// don't wait
void ext.registriesTree.refresh();
/* eslint-disable-next-line @typescript-eslint/no-floating-promises */
window.showInformationMessage(l10n.t('Successfully untagged image "{0}".', fullTag));
}
10 changes: 4 additions & 6 deletions src/commands/registries/deleteRemoteImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
*--------------------------------------------------------------------------------------------*/

import { DialogResponses, IActionContext, UserCancelledError, parseError } from '@microsoft/vscode-azext-utils';
import { CommonTag, GenericRegistryV2DataProvider } from '@microsoft/vscode-docker-registries';
import { RegistryV2DataProvider, V2Tag } 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?: UnifiedRegistryItem<CommonTag>): Promise<void> {
export async function deleteRemoteImage(context: IActionContext, node?: UnifiedRegistryItem<V2Tag>): Promise<void> {
if (!node) {
node = await registryExperience(context, ext.registriesTree, { include: ['genericRegistryV2Tag', 'azureContainerTag', 'githubRegistryTag'] }, false);
node = await registryExperience(context, ext.registriesTree, { include: ['genericRegistryV2Tag', 'azureContainerTag'] }, false);
}

const tagName = getImageNameFromRegistryTagItem(node.wrappedItem);
Expand All @@ -23,7 +23,7 @@ export async function deleteRemoteImage(context: IActionContext, node?: UnifiedR

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;
const provider = node.provider as unknown as RegistryV2DataProvider;

try {
await provider.deleteTag(node.wrappedItem);
Expand All @@ -40,8 +40,6 @@ export async function deleteRemoteImage(context: IActionContext, node?: UnifiedR
}
});

// 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();
Expand Down
2 changes: 1 addition & 1 deletion src/tree/registries/Azure/AzureRegistryDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class AzureRegistryDataProvider extends RegistryV2DataProvider implements
await client.registries.beginDeleteAndWait(resourceGroup, item.label);
}

public override async deleteTag(item: AzureTag): Promise<void> {
public async untagImage(item: AzureTag): Promise<void> {
const authenticationProvider = this.getAuthenticationProvider(item.parent.parent as unknown as AzureRegistryItem);

const reponse = await registryV2Request({
Expand Down