-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rutusamai/list build tasks for each registry (#37)
* tslint updates, transfered from old branch * updated icon * Addressed PR comments- mostly styling/code efficiency * Changed url to aka.ms link * changed Error window to Info message for no build tasks in your registry * Changed default sku and unified parsing resource group into a new method, getResourceGroup in acrTools.ts * Changed build task icon
- Loading branch information
Showing
9 changed files
with
142 additions
and
61 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { ResourceManagementClient, SubscriptionClient, SubscriptionModels } from 'azure-arm-resource'; | ||
import * as opn from 'opn'; | ||
import * as vscode from 'vscode'; | ||
import * as ContainerModels from '../../node_modules/azure-arm-containerregistry/lib/models'; | ||
import { AzureAccount, AzureSession } from '../../typings/azure-account.api'; | ||
import * as acrTools from '../../utils/Azure/acrTools'; | ||
import { AzureCredentialsManager } from '../../utils/azureCredentialsManager'; | ||
import { NodeBase } from './nodeBase'; | ||
|
||
/* Single TaskRootNode under each Repository. Labeled "Build Tasks" */ | ||
export class TaskRootNode extends NodeBase { | ||
constructor( | ||
public readonly label: string, | ||
public readonly contextValue: string, | ||
public subscription: SubscriptionModels.Subscription, | ||
public readonly azureAccount: AzureAccount, | ||
public registry: ContainerModels.Registry, | ||
public readonly iconPath: any = {} | ||
) { | ||
super(label); | ||
} | ||
|
||
public name: string; | ||
|
||
public getTreeItem(): vscode.TreeItem { | ||
return { | ||
label: this.label, | ||
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed, | ||
contextValue: this.contextValue, | ||
iconPath: this.iconPath | ||
} | ||
} | ||
|
||
/* Making a list view of BuildTaskNodes, or the Build Tasks of the current registry */ | ||
public async getChildren(element: TaskRootNode): Promise<BuildTaskNode[]> { | ||
const buildTaskNodes: BuildTaskNode[] = []; | ||
let buildTasks: ContainerModels.BuildTask[] = []; | ||
|
||
const client = AzureCredentialsManager.getInstance().getContainerRegistryManagementClient(element.subscription); | ||
const resourceGroup: string = acrTools.getResourceGroup(element.registry); | ||
|
||
buildTasks = await client.buildTasks.list(resourceGroup, element.registry.name); | ||
if (buildTasks.length === 0) { | ||
vscode.window.showInformationMessage(`You do not have any Build Tasks in the registry, '${element.registry.name}'. You can create one with ACR Build. `, "Learn More").then(val => { | ||
if (val === "Learn More") { | ||
opn('https://aka.ms/acr/buildtask'); | ||
} | ||
}) | ||
} | ||
|
||
for (let buildTask of buildTasks) { | ||
let node = new BuildTaskNode(buildTask.name, "buildTaskNode"); | ||
buildTaskNodes.push(node); | ||
} | ||
return buildTaskNodes; | ||
} | ||
} | ||
|
||
export class BuildTaskNode extends NodeBase { | ||
|
||
constructor( | ||
public readonly label: string, | ||
public readonly contextValue: string, | ||
) { | ||
super(label); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.