Skip to content

Commit

Permalink
Added WIF support to ContainerStructureTestV0 pipeline task (#19979)
Browse files Browse the repository at this point in the history
  • Loading branch information
starkmsu authored Jun 11, 2024
1 parent 1fbc6b2 commit 132432b
Show file tree
Hide file tree
Showing 23 changed files with 2,634 additions and 690 deletions.

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

1,138 changes: 862 additions & 276 deletions Tasks/ContainerStructureTestV0/_buildConfigs/Node20/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"@types/q": "^1.0.7",
"@types/uuid": "^8.3.0",
"azure-pipelines-task-lib": "^4.1.0",
"azure-pipelines-tasks-docker-common": "2.198.1",
"azure-pipelines-tasks-utility-common": "^3.212.0",
"azure-pipelines-tool-lib": "^2.0.0-preview",
"typed-rest-client": "^1.8.9"
"azure-pipelines-tasks-docker-common": "2.226.0",
"azure-pipelines-tasks-utility-common": "^3.238.0",
"azure-pipelines-tool-lib": "^2.0.7",
"typed-rest-client": "^1.8.11"
},
"devDependencies": {
"typescript": "5.1.6"
Expand Down
17 changes: 10 additions & 7 deletions Tasks/ContainerStructureTestV0/containerregistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ import * as dockerCommandUtils from "azure-pipelines-tasks-docker-common/dockerc


export class ContainerRegistry {
constructor(registryConnection: string) {
let registryAuthenticationToken: RegistryAuthenticationToken = getDockerRegistryEndpointAuthenticationToken(registryConnection);
this.connection = new ContainerConnection();
this.connection.open(null, registryAuthenticationToken, true, false);
constructor() {
this._connection = new ContainerConnection();
}

public async open(registryConnection: string) {
let registryAuthenticationToken: RegistryAuthenticationToken = await getDockerRegistryEndpointAuthenticationToken(registryConnection);
this._connection.open(null, registryAuthenticationToken, true, false);
}

public getQualifiedImageName(repository: string, tag: string){
return `${this.connection.getQualifiedImageName(repository, true)}:${tag}`
return `${this._connection.getQualifiedImageName(repository, true)}:${tag}`;
}

public async pull(repository: string, tag: string): Promise<any> {
return new Promise<any>((resolve, reject) => {
try {
const imageName = this.getQualifiedImageName(repository, tag);
dockerCommandUtils.command(this.connection, "pull", imageName, (output: any) => {
dockerCommandUtils.command(this._connection, "pull", imageName, (output: any) => {
resolve(output);
})
} catch (error) {
Expand All @@ -28,5 +31,5 @@ export class ContainerRegistry {
});
}

private connection: ContainerConnection;
private _connection: ContainerConnection;
}
3 changes: 2 additions & 1 deletion Tasks/ContainerStructureTestV0/containerstructuretest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ async function run() {
let image;
if (endpointId) {
// Establishing registry connection and pulling the container.
let containerRegistry = new ContainerRegistry(endpointId);
let containerRegistry = new ContainerRegistry();
await containerRegistry.open(endpointId);
tl.debug(`Successfully finished docker login`);
image = `${containerRegistry.getQualifiedImageName(repository, tag)}`;
tl.debug(`Image: ${image}`);
Expand Down
Loading

0 comments on commit 132432b

Please sign in to comment.