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

Removed not used functions #14843

Merged
Changes from 1 commit
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
65 changes: 0 additions & 65 deletions Tasks/DockerV2/dockerbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,69 +75,4 @@ export function run(connection: ContainerConnection, outputUpdate: (data: string
containerImageUtils.shareBuiltImageId(builtImageId);
}
});
}

function getImageDigest(connection: ContainerConnection, imageName: string,): string {
try {
pullImage(connection, imageName);
let inspectObj = inspectImage(connection, imageName);

if (!inspectObj) {
return "";
}

let repoDigests: string[] = inspectObj.RepoDigests;

if (repoDigests.length == 0) {
tl.debug(`No digests were found for image: ${imageName}`);
return "";
}

if (repoDigests.length > 1) {
tl.debug(`Multiple digests were found for image: ${imageName}`);
return "";
}

return repoDigests[0].split("@")[1];
} catch (error) {
tl.debug(`An exception was thrown getting the image digest for ${imageName}, the error was ${error.message}`)
return "";
}
}

function pullImage(connection: ContainerConnection, imageName: string) {
let pullCommand = connection.createCommand();
pullCommand.arg("pull");
pullCommand.arg(imageName);
let pullResult = pullCommand.execSync();

if (pullResult.stderr && pullResult.stderr != "") {
tl.debug(`An error was found pulling the image ${imageName}, the command output was ${pullResult.stderr}`);
}
}

function inspectImage(connection: ContainerConnection, imageName): any {
try {
let inspectCommand = connection.createCommand();
inspectCommand.arg("inspect");
inspectCommand.arg(imageName);
let inspectResult = inspectCommand.execSync();

if (inspectResult.stderr && inspectResult.stderr != "") {
tl.debug(`An error was found inspecting the image ${imageName}, the command output was ${inspectResult.stderr}`);
return null;
}

let inspectObj = JSON.parse(inspectResult.stdout);

if (!inspectObj || inspectObj.length == 0) {
tl.debug(`Inspecting the image ${imageName} produced no results.`);
return null;
}

return inspectObj[0];
} catch (error) {
tl.debug(`An error ocurred running the inspect command: ${error.message}`);
return null;
}
}