-
Notifications
You must be signed in to change notification settings - Fork 513
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 Back createAzureRegistry
command
#4029
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f9be94e
adjusted scheduleRunReuqest to work with new registries tree
alexyaang ea30d6d
delete azure repository command implementation
alexyaang d9402ce
actually added back delete azure repository
alexyaang 08c05fc
added back delete Azure Registry command
alexyaang d3bb8b8
changed registry tree util file name to be more general
alexyaang f96dc3e
added openInAzurePortalCommand
alexyaang b5324aa
added back create azure registry command
alexyaang 26939df
merged with registries branch
alexyaang 1ffa022
move createAzureClient to azureUtils
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
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
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
58 changes: 58 additions & 0 deletions
58
src/tree/registries/Azure/createWizard/AzureRegistryCreateStep.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,58 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import type { AzExtLocation } from '@microsoft/vscode-azext-azureutils'; | ||
import { AzureWizardExecuteStep, nonNullProp, parseError } from '@microsoft/vscode-azext-utils'; | ||
import { Progress, l10n } from 'vscode'; | ||
import { ext } from '../../../../extensionVariables'; | ||
import { createAzureContainerRegistryClient } from '../../../../utils/azureUtils'; | ||
import { getAzExtAzureUtils } from '../../../../utils/lazyPackages'; | ||
import { IAzureRegistryWizardContext } from './IAzureRegistryWizardContext'; | ||
|
||
export class AzureRegistryCreateStep extends AzureWizardExecuteStep<IAzureRegistryWizardContext> { | ||
public priority: number = 130; | ||
|
||
public async execute(context: IAzureRegistryWizardContext, progress: Progress<{ message?: string; increment?: number }>): Promise<void> { | ||
const newRegistryName = nonNullProp(context, 'newRegistryName'); | ||
|
||
const client = await createAzureContainerRegistryClient(context.azureSubscription); | ||
|
||
const azExtAzureUtils = await getAzExtAzureUtils(); | ||
const creating: string = l10n.t('Creating registry "{0}"...', newRegistryName); | ||
ext.outputChannel.info(creating); | ||
progress.report({ message: creating }); | ||
|
||
const location: AzExtLocation = await azExtAzureUtils.LocationListStep.getLocation(context); | ||
const locationName: string = nonNullProp(location, 'name'); | ||
const resourceGroup = nonNullProp(context, 'resourceGroup'); | ||
try { | ||
context.registry = await client.registries.beginCreateAndWait( | ||
nonNullProp(resourceGroup, 'name'), | ||
newRegistryName, | ||
{ | ||
sku: { | ||
name: nonNullProp(context, 'newRegistrySku') | ||
}, | ||
location: locationName | ||
} | ||
); | ||
} | ||
catch (err) { | ||
const parsedError = parseError(err); | ||
if (parsedError.errorType === 'MissingSubscriptionRegistration') { | ||
context.errorHandling.suppressReportIssue = true; | ||
} | ||
|
||
throw err; | ||
} | ||
|
||
const created = l10n.t('Successfully created registry "{0}".', newRegistryName); | ||
ext.outputChannel.info(created); | ||
} | ||
|
||
public shouldExecute(context: IAzureRegistryWizardContext): boolean { | ||
return !context.registry; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/tree/registries/Azure/createWizard/AzureRegistryNameStep.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,50 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import type { ContainerRegistryManagementClient } from '@azure/arm-containerregistry'; // These are only dev-time imports so don't need to be lazy | ||
import { AzureNameStep } from '@microsoft/vscode-azext-utils'; | ||
import { l10n } from 'vscode'; | ||
import { getArmContainerRegistry, getAzExtAzureUtils } from '../../../../utils/lazyPackages'; | ||
import { IAzureRegistryWizardContext } from './IAzureRegistryWizardContext'; | ||
|
||
export class AzureRegistryNameStep extends AzureNameStep<IAzureRegistryWizardContext> { | ||
protected async isRelatedNameAvailable(context: IAzureRegistryWizardContext, name: string): Promise<boolean> { | ||
const azExtAzureUtils = await getAzExtAzureUtils(); | ||
return await azExtAzureUtils.ResourceGroupListStep.isNameAvailable(context, name); | ||
} | ||
|
||
public async prompt(context: IAzureRegistryWizardContext): Promise<void> { | ||
const azExtAzureUtils = await getAzExtAzureUtils(); | ||
const armContainerRegistry = await getArmContainerRegistry(); | ||
const client = azExtAzureUtils.createAzureClient(context, armContainerRegistry.ContainerRegistryManagementClient); | ||
context.newRegistryName = (await context.ui.showInputBox({ | ||
placeHolder: l10n.t('Registry name'), | ||
prompt: l10n.t('Provide a registry name'), | ||
/* eslint-disable-next-line @typescript-eslint/promise-function-async */ | ||
validateInput: (name: string) => validateRegistryName(name, client) | ||
})).trim(); | ||
|
||
context.relatedNameTask = this.generateRelatedName(context, context.newRegistryName, azExtAzureUtils.resourceGroupNamingRules); | ||
} | ||
|
||
public shouldPrompt(context: IAzureRegistryWizardContext): boolean { | ||
return !context.newRegistryName; | ||
} | ||
} | ||
|
||
async function validateRegistryName(name: string, client: ContainerRegistryManagementClient): Promise<string | undefined> { | ||
name = name ? name.trim() : ''; | ||
|
||
const min = 5; | ||
const max = 50; | ||
if (name.length < min || name.length > max) { | ||
return l10n.t('The name must be between {0} and {1} characters.', min, max); | ||
} else if (name.match(/[^a-z0-9]/i)) { | ||
return l10n.t('The name can only contain alphanumeric characters.'); | ||
} else { | ||
const nameStatus = await client.registries.checkNameAvailability({ name, type: 'Microsoft.ContainerRegistry/registries' }); | ||
return nameStatus.message; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/tree/registries/Azure/createWizard/AzureRegistrySkuStep.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,23 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import type { SkuName as AcrSkuName } from '@azure/arm-containerregistry'; // These are only dev-time imports so don't need to be lazy | ||
import { AzureWizardPromptStep, IAzureQuickPickItem } from '@microsoft/vscode-azext-utils'; | ||
import { l10n } from 'vscode'; | ||
import { IAzureRegistryWizardContext } from './IAzureRegistryWizardContext'; | ||
|
||
export class AzureRegistrySkuStep extends AzureWizardPromptStep<IAzureRegistryWizardContext> { | ||
public async prompt(context: IAzureRegistryWizardContext): Promise<void> { | ||
const skus: AcrSkuName[] = ["Basic", "Standard", "Premium"]; | ||
const picks: IAzureQuickPickItem<AcrSkuName>[] = skus.map(s => { return { label: s, data: s }; }); | ||
|
||
const placeHolder: string = l10n.t('Select a SKU'); | ||
context.newRegistrySku = (await context.ui.showQuickPick(picks, { placeHolder })).data; | ||
} | ||
|
||
public shouldPrompt(context: IAzureRegistryWizardContext): boolean { | ||
return !context.newRegistrySku; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/tree/registries/Azure/createWizard/IAzureRegistryWizardContext.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,15 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import type { Registry as AcrRegistry, SkuName as AcrSkuName } from '@azure/arm-containerregistry'; // These are only dev-time imports so don't need to be lazy | ||
import { AzureSubscription } from '@microsoft/vscode-azext-azureauth'; | ||
import { IResourceGroupWizardContext } from '@microsoft/vscode-azext-azureutils'; | ||
|
||
export interface IAzureRegistryWizardContext extends IResourceGroupWizardContext { | ||
newRegistryName?: string; | ||
newRegistrySku?: AcrSkuName; | ||
registry?: AcrRegistry; | ||
readonly azureSubscription: AzureSubscription; | ||
} |
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.
we don't need to wait here right?
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.
Nah