public async execute()

in src/tasks/ECRPullImage/TaskOperations.ts [24:68]


    public async execute(): Promise<void> {
        this.dockerPath = await this.dockerHandler.locateDockerExecutable()

        const authData = await getEcrAuthorizationData(this.ecrClient)
        if (!authData) {
            throw new Error(tl.loc('FailureToObtainAuthToken'))
        }

        let endpoint = ''
        let authToken = ''
        let proxyEndpoint = ''
        if (authData.proxyEndpoint) {
            endpoint = `${parse(authData.proxyEndpoint).host}`
        }
        if (!endpoint) {
            throw new Error(tl.loc('NoValidEndpoint', this.taskParameters.repository))
        }
        if (authData.authorizationToken) {
            authToken = authData.authorizationToken
        }
        if (authData.proxyEndpoint) {
            proxyEndpoint = authData.proxyEndpoint
        }

        let sourceImageRef: string
        if (this.taskParameters.imageSource === imageTagSource) {
            sourceImageRef = `${this.taskParameters.repository}:${this.taskParameters.imageTag}`
            console.log(tl.loc('PullImageWithTag', endpoint, sourceImageRef))
        } else {
            sourceImageRef = `${this.taskParameters.repository}@${this.taskParameters.imageDigest}`
            console.log(tl.loc('PullImageWithDigest', endpoint, sourceImageRef))
        }

        const targetImageRef = `${endpoint}/${sourceImageRef}`

        await loginToRegistry(this.dockerHandler, this.dockerPath, authToken, proxyEndpoint)
        await this.pullImageFromECR(targetImageRef)

        if (this.taskParameters.outputVariable) {
            console.log(tl.loc('SettingOutputVariable', this.taskParameters.outputVariable, targetImageRef))
            tl.setVariable(this.taskParameters.outputVariable, targetImageRef)
        }

        console.log(tl.loc('TaskCompleted'))
    }