當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript task.getEndpointAuthorizationParameter函數代碼示例

本文整理匯總了TypeScript中vsts-task-lib/task.getEndpointAuthorizationParameter函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getEndpointAuthorizationParameter函數的具體用法?TypeScript getEndpointAuthorizationParameter怎麽用?TypeScript getEndpointAuthorizationParameter使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getEndpointAuthorizationParameter函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getTemplateVariables

    public async getTemplateVariables(packerHost: definitions.IPackerHost): Promise<Map<string, string>> {
        if(!!this._spnVariables) {
            return this._spnVariables;
        }

        var taskParameters = packerHost.getTaskParameters();

        // if custom template is used, SPN variables are not required
        if(taskParameters.templateType === constants.TemplateTypeCustom) {
            this._spnVariables = new Map<string, string>();
            return this._spnVariables;
        }

        this._spnVariables = new Map<string, string>();
        var connectedService = taskParameters.serviceEndpoint;
        var subscriptionId: string = tl.getEndpointDataParameter(connectedService, "SubscriptionId", true)
        this._spnVariables.set(constants.TemplateVariableSubscriptionIdName, subscriptionId);
        this._spnVariables.set(constants.TemplateVariableClientIdName, tl.getEndpointAuthorizationParameter(connectedService, 'serviceprincipalid', false));
        this._spnVariables.set(constants.TemplateVariableClientSecretName, tl.getEndpointAuthorizationParameter(connectedService, 'serviceprincipalkey', false));
        this._spnVariables.set(constants.TemplateVariableTenantIdName, tl.getEndpointAuthorizationParameter(connectedService, 'tenantid', false));


        var spnObjectId = tl.getEndpointDataParameter(connectedService, "spnObjectId", true);
        // if we are creating windows VM and SPN object-id is not available in service endpoint, fetch it from Graph endpoint
        // NOP for nix
        if(!spnObjectId && taskParameters.osType.toLowerCase().match(/^win/)) {
            spnObjectId = await this.getServicePrincipalObjectId(taskParameters.graphCredentials);
        }

        this._spnVariables.set(constants.TemplateVariableObjectIdName, spnObjectId);

        return this._spnVariables;
    }
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:33,代碼來源:azureSpnTemplateVariablesProvider.ts

示例2: getAuthenticationToken

    public getAuthenticationToken(): RegistryAuthenticationToken
    {
        if(this.registryURL && this.endpointName) {      
            return new RegistryAuthenticationToken(tl.getEndpointAuthorizationParameter(this.endpointName, 'serviceprincipalid', true), tl.getEndpointAuthorizationParameter(this.endpointName, 'serviceprincipalkey', true), this.registryURL, "ServicePrincipal@AzureRM");
        }

        return null;
    }
開發者ID:colindembovsky,項目名稱:vsts-tasks,代碼行數:8,代碼來源:acrauthenticationtokenprovider.ts

示例3: createKubeconfig

export function createKubeconfig(kubernetesServiceEndpoint: string): string
{
    var kubeconfigTemplateString = '{"apiVersion":"v1","kind":"Config","clusters":[{"cluster":{"certificate-authority-data": null,"server": null}}], "users":[{"user":{"token": null}}]}';
    var kubeconfigTemplate = JSON.parse(kubeconfigTemplateString);

    //populate server url, ca cert and token fields
    kubeconfigTemplate.clusters[0].cluster.server = tl.getEndpointUrl(kubernetesServiceEndpoint, false);
    kubeconfigTemplate.clusters[0].cluster["certificate-authority-data"] = tl.getEndpointAuthorizationParameter(kubernetesServiceEndpoint, 'serviceAccountCertificate', false);
    kubeconfigTemplate.users[0].user.token = Base64.decode(tl.getEndpointAuthorizationParameter(kubernetesServiceEndpoint, 'apiToken', false));

    return JSON.stringify(kubeconfigTemplate);
}
開發者ID:shubham90,項目名稱:vsts-tasks,代碼行數:12,代碼來源:kubectlutility.ts

示例4: getKubeconfigForCluster

export function getKubeconfigForCluster(kubernetesServiceEndpoint: string): string
{
    var kubeconfig = tl.getEndpointAuthorizationParameter(kubernetesServiceEndpoint, 'kubeconfig', false);
    var clusterContext = tl.getEndpointAuthorizationParameter(kubernetesServiceEndpoint, 'clusterContext', true);
    if (!clusterContext)
    {
        return kubeconfig;
    }

    var kubeconfigTemplate = yaml.safeLoad(kubeconfig);
    kubeconfigTemplate["current-context"] = clusterContext;
    var modifiedKubeConfig = yaml.safeDump(kubeconfigTemplate);
    return modifiedKubeConfig.toString();
}
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:14,代碼來源:kubectlutility.ts

示例5: sendRequestToImageStore

async function sendRequestToImageStore(requestBody: string, requestUrl: string): Promise<any> {
    const request = new WebRequest();
    const accessToken: string = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'ACCESSTOKEN', false);
    request.uri = requestUrl;
    request.method = 'POST';
    request.body = requestBody;
    request.headers = {
        "Content-Type": "application/json",
        "Authorization": "Bearer " + accessToken
    };

    tl.debug("requestUrl: " + requestUrl);
    tl.debug("requestBody: " + requestBody);
    tl.debug("accessToken: " + accessToken);

    try {
        tl.debug("Sending request for pushing image to Image meta data store");
        const response = await sendRequest(request);
        return response;
    }
    catch (error) {
        tl.debug("Unable to push to Image Details Artifact Store, Error: " + error);
    }

    return Promise.resolve();
}
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:26,代碼來源:dockerpush.ts

示例6: resolve

    var promise = new Promise<void>(async (resolve, reject) => {
        let connection = tl.getInput("connection", true);
        let projectId = tl.getInput("project", true);
        let definitionId = tl.getInput("definition", true);
        let buildId = tl.getInput("version", true);
        let itemPattern = tl.getInput("itemPattern", false);
        let downloadPath = tl.getInput("downloadPath", true);

        var endpointUrl = tl.getEndpointUrl(connection, false);
        var itemsUrl = endpointUrl + "/httpAuth/app/rest/builds/id:" + buildId + "/artifacts/children/";
        itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
        console.log(tl.loc("DownloadArtifacts", itemsUrl));

        var templatePath = path.join(__dirname, 'teamcity.handlebars');
        var username = tl.getEndpointAuthorizationParameter(connection, 'username', false);
        var password = tl.getEndpointAuthorizationParameter(connection, 'password', false);
        var teamcityVariables = {
            "endpoint": {
                "url": endpointUrl
            }
        };
        var handler = new webHandlers.BasicCredentialHandler(username, password);
        var webProvider = new providers.WebProvider(itemsUrl, templatePath, teamcityVariables, handler);
        var fileSystemProvider = new providers.FilesystemProvider(downloadPath);
        var parallelLimit : number = +tl.getVariable("release.artifact.download.parallellimit");

        var downloader = new engine.ArtifactEngine();
        var downloaderOptions = new engine.ArtifactEngineOptions();
        downloaderOptions.itemPattern = itemPattern ? itemPattern : '**';
        var debugMode = tl.getVariable('System.Debug');
        downloaderOptions.verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
        var parallelLimit : number = +tl.getVariable("release.artifact.download.parallellimit");
        
        if(parallelLimit){
            downloaderOptions.parallelProcessingLimit = parallelLimit;
        }

        await downloader.processItems(webProvider, fileSystemProvider, downloaderOptions).then((result) => {
            console.log(tl.loc('ArtifactsSuccessfullyDownloaded', downloadPath));
            resolve();
        }).catch((error) => {
            reject(error);
        });
    });
開發者ID:Microsoft,項目名稱:vsts-rm-extensions,代碼行數:44,代碼來源:download.ts

示例7: constructor

    constructor() {
        const serverUrl: string = tl.getVariable('System.TeamFoundationCollectionUri');
        const serverCreds: string = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'ACCESSTOKEN', false);
        const authHandler = vsts.getPersonalAccessTokenHandler(serverCreds);

        const proxy = tl.getHttpProxyConfiguration();
        const options = proxy ? { proxy, ignoreSslError: true } : undefined;

        this.serverConnection = new vsts.WebApi(serverUrl, authHandler, options);
    }
開發者ID:grawcho,項目名稱:vso-agent-tasks,代碼行數:10,代碼來源:securefiles-common.ts

示例8: getDockerRegistryEndpointAuthenticationToken

export function getDockerRegistryEndpointAuthenticationToken(endpointId: string): RegistryServerAuthenticationToken {
    var registryType = tl.getEndpointDataParameter(endpointId, "registrytype", true);
    let authToken: RegistryServerAuthenticationToken;

    if (registryType === "ACR") {
        const loginServer = tl.getEndpointAuthorizationParameter(endpointId, "loginServer", false);
        authToken = new ACRAuthenticationTokenProvider(endpointId, loginServer).getAuthenticationToken();
    }
    else {
        authToken = new GenericAuthenticationTokenProvider(endpointId).getAuthenticationToken();
    }

    return authToken;
}
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:14,代碼來源:registryauthenticationtoken.ts

示例9: getTemplateVariables

    public getTemplateVariables(packerHost: definitions.IPackerHost): Map<string, string> {
        if(!!this._spnVariables) {
            return this._spnVariables;
        }

        var taskParameters = packerHost.getTaskParameters();

        // if custom template is used, SPN variables are not required
        if(taskParameters.templateType === constants.TemplateTypeCustom) {
            this._spnVariables = new Map<string, string>();
            return this._spnVariables;
        } 

        this._spnVariables = new Map<string, string>();
        var connectedService = taskParameters.serviceEndpoint;
        this._spnVariables.set(constants.TemplateVariableSubscriptionIdName, tl.getEndpointDataParameter(connectedService, "SubscriptionId", true));
        this._spnVariables.set(constants.TemplateVariableClientIdName, tl.getEndpointAuthorizationParameter(connectedService, 'serviceprincipalid', false));
        this._spnVariables.set(constants.TemplateVariableClientSecretName, tl.getEndpointAuthorizationParameter(connectedService, 'serviceprincipalkey', false));
        this._spnVariables.set(constants.TemplateVariableTenantIdName, tl.getEndpointAuthorizationParameter(connectedService, 'tenantid', false));
        this._spnVariables.set(constants.TemplateVariableObjectIdName, tl.getEndpointDataParameter(connectedService, "spnObjectId", true));        
        
        return this._spnVariables;
    }
開發者ID:colindembovsky,項目名稱:vsts-tasks,代碼行數:23,代碼來源:azureSpnTemplateVariablesProvider.ts

示例10: resolve

    var promise = new Promise<void>(async (resolve, reject) => {
        let connection = tl.getInput("connection", true);
        let definitionId = tl.getInput("definition", true);
        let buildId = tl.getInput("version", true);
        let itemPattern = tl.getInput("itemPattern", false);
        let downloadPath = tl.getInput("downloadPath", true);

        var endpointUrl = tl.getEndpointUrl(connection, false);
        var itemsUrl = `${endpointUrl}/api/v1.1/project/${definitionId}/${buildId}/artifacts`;
        itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
        console.log(tl.loc("DownloadArtifacts", itemsUrl));

        var templatePath = path.join(__dirname, 'circleCI.handlebars.txt');
        var username = tl.getEndpointAuthorizationParameter(connection, 'username', false);
        var circleciVariables = {
            "endpoint": {
                "url": endpointUrl
            }
        };
        var handler = new webHandlers.BasicCredentialHandler(username, "");
        var webProvider = new providers.WebProvider(itemsUrl, templatePath, circleciVariables, handler);
        var fileSystemProvider = new providers.FilesystemProvider(downloadPath);

        var downloader = new engine.ArtifactEngine();
        var downloaderOptions = new engine.ArtifactEngineOptions();
        downloaderOptions.itemPattern = itemPattern ? itemPattern : '**';
        var debugMode = tl.getVariable('System.Debug');
        downloaderOptions.verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
        var parallelLimit : number = +tl.getVariable("release.artifact.download.parallellimit");
        
        if(parallelLimit){
            downloaderOptions.parallelProcessingLimit = parallelLimit;
        }

        await downloader.processItems(webProvider, fileSystemProvider, downloaderOptions).then((result) => {
            console.log(tl.loc('ArtifactsSuccessfullyDownloaded', downloadPath));
            resolve();
        }).catch((error) => {
            reject(error);
        });
        
        let downloadCommitsFlag: boolean = tl.getBoolInput("downloadCommitsAndWorkItems", true);
        if (downloadCommitsFlag) {
            var webProviderForDownloaingCommits = new providers.WebProvider(itemsUrl, templatePath, circleciVariables, handler);
            downloadCommits(webProviderForDownloaingCommits);
        }
    });
開發者ID:Microsoft,項目名稱:vsts-rm-extensions,代碼行數:47,代碼來源:download.ts


注:本文中的vsts-task-lib/task.getEndpointAuthorizationParameter函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。