diff --git a/package.json b/package.json index 80dad512a2..5b76f81602 100644 --- a/package.json +++ b/package.json @@ -587,7 +587,7 @@ }, { "command": "vscode-docker.registries.deployImageToAca", - "when": "view == dockerRegistries && viewItem =~ /(DockerV2|DockerHubV2);Tag;/ && isAzureAccountInstalled", + "when": "view == dockerRegistries && viewItem =~ /(DockerV2|DockerHubV2|GitLabV4);Tag;/ && isAzureAccountInstalled", "group": "regs_tag_1_general@6" }, { diff --git a/src/commands/registries/azure/deployImageToAca.ts b/src/commands/registries/azure/deployImageToAca.ts index 2d683ca0bc..56daaf3fe3 100644 --- a/src/commands/registries/azure/deployImageToAca.ts +++ b/src/commands/registries/azure/deployImageToAca.ts @@ -21,7 +21,7 @@ const minimumAcaExtensionVersion = '0.4.0'; // TODO: get the exact minimum versi // The interface of the command options passed to the Azure Container Apps extension's deployImageToAca command interface DeployImageToAcaOptionsContract { - imageName: string; + image: string; loginServer?: string; username?: string; secret?: string; @@ -38,27 +38,31 @@ export async function deployImageToAca(context: IActionContext, node?: RemoteTag } const commandOptions: DeployImageToAcaOptionsContract = { - imageName: node.fullTag, + image: node.fullTag, }; - addImageTaggingTelemetry(context, commandOptions.imageName, ''); + addImageTaggingTelemetry(context, commandOptions.image, ''); const registry: RegistryTreeItemBase = node.parent.parent; if (registry instanceof AzureRegistryTreeItem) { // No additional work to do; ACA can handle this on its own - } else if (registry instanceof DockerHubNamespaceTreeItem || registry instanceof DockerV2RegistryTreeItemBase) { - const { auth } = await registry.getDockerCliCredentials() as { auth?: { username?: string, password?: string } }; + } else { + const { auth, registryPath } = await registry.getDockerCliCredentials() as { auth?: { username?: string, password?: string }, registryPath: string }; - if (!auth?.username || !auth?.password) { + if (!auth?.username || !auth?.password || !registryPath) { throw new Error(localize('vscode-docker.commands.registries.azure.deployImageToAca.noCredentials', 'No credentials found for registry "{0}".', registry.label)); } - commandOptions.loginServer = registry.baseUrl; + if (registry instanceof DockerHubNamespaceTreeItem || registry instanceof DockerV2RegistryTreeItemBase) { + // ACA preference for Docker Hub images to be prefixed with 'docker.io/...' + if (!/^docker.io\//.test(commandOptions.image)) { + commandOptions.image = 'docker.io/' + commandOptions.image; + } + } + + commandOptions.loginServer = registryPath; commandOptions.username = auth.username; commandOptions.secret = auth.password; - } else { - context.errorHandling.suppressReportIssue = true; - throw new Error(localize('vscode-docker.commands.registries.azure.deployImageToAca.unsupportedRegistry', 'Unsupported registry type')); } // Don't wait diff --git a/src/tree/registries/dockerHub/DockerHubNamespaceTreeItem.ts b/src/tree/registries/dockerHub/DockerHubNamespaceTreeItem.ts index a28f2c45c8..bd0180d508 100644 --- a/src/tree/registries/dockerHub/DockerHubNamespaceTreeItem.ts +++ b/src/tree/registries/dockerHub/DockerHubNamespaceTreeItem.ts @@ -11,6 +11,8 @@ import { IDockerCliCredentials, RegistryTreeItemBase } from "../RegistryTreeItem import { DockerHubAccountTreeItem } from "./DockerHubAccountTreeItem"; import { DockerHubRepositoryTreeItem } from "./DockerHubRepositoryTreeItem"; +const dockerHubRegistryUrl: string = 'https://index.docker.io/v1/'; + export class DockerHubNamespaceTreeItem extends RegistryTreeItemBase { public parent: DockerHubAccountTreeItem; public baseUrl: string = dockerHubUrl; @@ -57,7 +59,7 @@ export class DockerHubNamespaceTreeItem extends RegistryTreeItemBase { public async getDockerCliCredentials(): Promise { return { - registryPath: '', + registryPath: dockerHubRegistryUrl, auth: { username: this.parent.username, password: await this.parent.getPassword()