removed unneeded package,function and params
This commit is contained in:
@ -1,7 +1,4 @@
|
||||
import * as core from '@actions/core';
|
||||
import { rejects } from 'assert';
|
||||
import { WebRequest, WebRequestOptions, WebResponse, sendRequest } from './client';
|
||||
import * as querystring from 'querystring';
|
||||
import * as path from 'path';
|
||||
import {spawn} from 'child_process';
|
||||
import * as fs from 'fs';
|
||||
@ -10,47 +7,6 @@ import * as exec from '@actions/exec';
|
||||
var azPath: string;
|
||||
|
||||
const kubeconfig_timeout = 120;//timeout in seconds
|
||||
async function getAzureAccessToken(servicePrincipalId, servicePrincipalKey, tenantId, authorityUrl, managementEndpointUrl: string): Promise<string> {
|
||||
|
||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId || !authorityUrl) {
|
||||
throw new Error("Not all values are present in the creds object. Ensure appId, password and tenant are supplied");
|
||||
}
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
let webRequest = new WebRequest();
|
||||
webRequest.method = "POST";
|
||||
webRequest.uri = `${authorityUrl}/${tenantId}/oauth2/token/`;
|
||||
webRequest.body = querystring.stringify({
|
||||
resource: managementEndpointUrl,
|
||||
client_id: servicePrincipalId,
|
||||
grant_type: "client_credentials",
|
||||
client_secret: servicePrincipalKey
|
||||
});
|
||||
webRequest.headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
|
||||
};
|
||||
|
||||
let webRequestOptions: WebRequestOptions = {
|
||||
retriableStatusCodes: [400, 408, 409, 500, 502, 503, 504],
|
||||
};
|
||||
|
||||
sendRequest(webRequest, webRequestOptions).then(
|
||||
(response: WebResponse) => {
|
||||
if (response.statusCode == 200) {
|
||||
resolve(response.body.access_token);
|
||||
}
|
||||
else if ([400, 401, 403].indexOf(response.statusCode) != -1) {
|
||||
reject('ExpiredServicePrincipal');
|
||||
}
|
||||
else {
|
||||
reject('CouldNotFetchAccessTokenforAzureStatusCode');
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
reject(error)
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export async function getArcKubeconfig(): Promise<string> {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user