commented unwanted parts
This commit is contained in:
parent
9584d802fc
commit
b182570c21
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@ -6,7 +6,7 @@ name: k8s-set-context
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the master branch
|
||||
push:
|
||||
branches: [ cluster-connect ]
|
||||
branches: [ cluster-connect-2 ]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
@ -23,7 +23,7 @@ jobs:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: Azure/k8s-set-context@cluster-connect
|
||||
- uses: atharvamulmuley/k8s-set-context@cluster-connect-2
|
||||
with:
|
||||
method: spn
|
||||
cluster-type: 'arc'
|
||||
|
16
action.yml
16
action.yml
@ -46,18 +46,18 @@ inputs:
|
||||
default: ''
|
||||
|
||||
# inputs for az login
|
||||
enable-AzPSSession:
|
||||
description: 'Set this value to true to enable Azure PowerShell Login in addition to Az CLI login'
|
||||
required: false
|
||||
default: false
|
||||
# enable-AzPSSession:
|
||||
# description: 'Set this value to true to enable Azure PowerShell Login in addition to Az CLI login'
|
||||
# required: false
|
||||
# default: false
|
||||
environment:
|
||||
description: 'Name of the environment. Supported values are azurecloud, azurestack, azureusgovernment, azurechinacloud, azuregermancloud. Default being azurecloud'
|
||||
required: false
|
||||
default: AzureCloud
|
||||
allow-no-subscriptions:
|
||||
description: 'Set this value to true to enable support for accessing tenants without subscriptions'
|
||||
required: false
|
||||
default: false
|
||||
# allow-no-subscriptions:
|
||||
# description: 'Set this value to true to enable support for accessing tenants without subscriptions'
|
||||
# required: false
|
||||
# default: false
|
||||
branding:
|
||||
color: 'green' # optional, decorates the entry in the GitHub Marketplace
|
||||
runs:
|
||||
|
60
lib/main.js
60
lib/main.js
@ -13,7 +13,6 @@ const core = require("@actions/core");
|
||||
const exec = require("@actions/exec");
|
||||
const io = require("@actions/io");
|
||||
const actions_secret_parser_1 = require("actions-secret-parser");
|
||||
const ServicePrincipalLogin_1 = require("./PowerShell/ServicePrincipalLogin");
|
||||
var azPath;
|
||||
var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : "";
|
||||
var azPSHostEnv = !!process.env.AZUREPS_HOST_ENVIRONMENT ? `${process.env.AZUREPS_HOST_ENVIRONMENT}` : "";
|
||||
@ -54,12 +53,12 @@ function main() {
|
||||
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
||||
let resourceManagerEndpointUrl = secrets.getSecret("$.resourceManagerEndpointUrl", false);
|
||||
let environment = core.getInput("environment").toLowerCase();
|
||||
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||
// const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||
// const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
||||
}
|
||||
if (!subscriptionId && !allowNoSubscriptionsLogin) {
|
||||
if (!subscriptionId) {
|
||||
throw new Error("Not all values are present in the creds object. Ensure subscriptionId is supplied.");
|
||||
}
|
||||
if (!azureSupportedCloudName.has(environment)) {
|
||||
@ -97,17 +96,18 @@ function main() {
|
||||
yield executeAzCliCommand(`cloud set -n "${environment}"`, false);
|
||||
console.log(`Done setting cloud: "${environment}"`);
|
||||
// Attempting Az cli login
|
||||
if (allowNoSubscriptionsLogin) {
|
||||
let args = [
|
||||
"--allow-no-subscriptions",
|
||||
"--service-principal",
|
||||
"-u", servicePrincipalId,
|
||||
"-p", servicePrincipalKey,
|
||||
"--tenant", tenantId
|
||||
];
|
||||
yield executeAzCliCommand(`login`, true, {}, args);
|
||||
}
|
||||
else {
|
||||
// if (allowNoSubscriptionsLogin) {
|
||||
// let args = [
|
||||
// "--allow-no-subscriptions",
|
||||
// "--service-principal",
|
||||
// "-u", servicePrincipalId,
|
||||
// "-p", servicePrincipalKey,
|
||||
// "--tenant", tenantId
|
||||
// ];
|
||||
// await executeAzCliCommand(`login`, true, {}, args);
|
||||
// }
|
||||
// else {
|
||||
// }
|
||||
let args = [
|
||||
"--service-principal",
|
||||
"-u", servicePrincipalId,
|
||||
@ -120,24 +120,30 @@ function main() {
|
||||
subscriptionId
|
||||
];
|
||||
yield executeAzCliCommand(`account set`, true, {}, args);
|
||||
}
|
||||
isAzCLISuccess = true;
|
||||
if (enableAzPSSession) {
|
||||
// Attempting Az PS login
|
||||
console.log(`Running Azure PS Login`);
|
||||
const spnlogin = new ServicePrincipalLogin_1.ServicePrincipalLogin(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin, environment, resourceManagerEndpointUrl);
|
||||
yield spnlogin.initialize();
|
||||
yield spnlogin.login();
|
||||
}
|
||||
// if (enableAzPSSession) {
|
||||
// // Attempting Az PS login
|
||||
// console.log(`Running Azure PS Login`);
|
||||
// const spnlogin: ServicePrincipalLogin = new ServicePrincipalLogin(
|
||||
// servicePrincipalId,
|
||||
// servicePrincipalKey,
|
||||
// tenantId,
|
||||
// subscriptionId,
|
||||
// allowNoSubscriptionsLogin,
|
||||
// environment,
|
||||
// resourceManagerEndpointUrl);
|
||||
// await spnlogin.initialize();
|
||||
// await spnlogin.login();
|
||||
// }
|
||||
console.log("Login successful.");
|
||||
}
|
||||
catch (error) {
|
||||
if (!isAzCLISuccess) {
|
||||
core.error("Az CLI Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows");
|
||||
}
|
||||
else {
|
||||
core.error(`Azure PowerShell Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows"`);
|
||||
}
|
||||
// else {
|
||||
// core.error(`Azure PowerShell Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows"`);
|
||||
// }
|
||||
core.setFailed(error);
|
||||
}
|
||||
finally {
|
||||
@ -160,4 +166,4 @@ function executeAzCliCommand(command, silent, execOptions = {}, args = []) {
|
||||
});
|
||||
}
|
||||
exports.executeAzCliCommand = executeAzCliCommand;
|
||||
main();
|
||||
//main();
|
||||
|
67
src/main.ts
67
src/main.ts
@ -47,14 +47,14 @@ export async function main() {
|
||||
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
||||
let resourceManagerEndpointUrl = secrets.getSecret("$.resourceManagerEndpointUrl", false);
|
||||
let environment = core.getInput("environment").toLowerCase();
|
||||
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||
// const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||
// const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||
|
||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
||||
}
|
||||
|
||||
if (!subscriptionId && !allowNoSubscriptionsLogin) {
|
||||
if (!subscriptionId) {
|
||||
throw new Error("Not all values are present in the creds object. Ensure subscriptionId is supplied.");
|
||||
}
|
||||
|
||||
@ -99,17 +99,19 @@ export async function main() {
|
||||
console.log(`Done setting cloud: "${environment}"`);
|
||||
|
||||
// Attempting Az cli login
|
||||
if (allowNoSubscriptionsLogin) {
|
||||
let args = [
|
||||
"--allow-no-subscriptions",
|
||||
"--service-principal",
|
||||
"-u", servicePrincipalId,
|
||||
"-p", servicePrincipalKey,
|
||||
"--tenant", tenantId
|
||||
];
|
||||
await executeAzCliCommand(`login`, true, {}, args);
|
||||
}
|
||||
else {
|
||||
// if (allowNoSubscriptionsLogin) {
|
||||
// let args = [
|
||||
// "--allow-no-subscriptions",
|
||||
// "--service-principal",
|
||||
// "-u", servicePrincipalId,
|
||||
// "-p", servicePrincipalKey,
|
||||
// "--tenant", tenantId
|
||||
// ];
|
||||
// await executeAzCliCommand(`login`, true, {}, args);
|
||||
// }
|
||||
// else {
|
||||
|
||||
// }
|
||||
let args = [
|
||||
"--service-principal",
|
||||
"-u", servicePrincipalId,
|
||||
@ -122,23 +124,22 @@ export async function main() {
|
||||
subscriptionId
|
||||
];
|
||||
await executeAzCliCommand(`account set`, true, {}, args);
|
||||
}
|
||||
|
||||
isAzCLISuccess = true;
|
||||
if (enableAzPSSession) {
|
||||
// Attempting Az PS login
|
||||
console.log(`Running Azure PS Login`);
|
||||
const spnlogin: ServicePrincipalLogin = new ServicePrincipalLogin(
|
||||
servicePrincipalId,
|
||||
servicePrincipalKey,
|
||||
tenantId,
|
||||
subscriptionId,
|
||||
allowNoSubscriptionsLogin,
|
||||
environment,
|
||||
resourceManagerEndpointUrl);
|
||||
await spnlogin.initialize();
|
||||
await spnlogin.login();
|
||||
}
|
||||
// if (enableAzPSSession) {
|
||||
// // Attempting Az PS login
|
||||
// console.log(`Running Azure PS Login`);
|
||||
// const spnlogin: ServicePrincipalLogin = new ServicePrincipalLogin(
|
||||
// servicePrincipalId,
|
||||
// servicePrincipalKey,
|
||||
// tenantId,
|
||||
// subscriptionId,
|
||||
// allowNoSubscriptionsLogin,
|
||||
// environment,
|
||||
// resourceManagerEndpointUrl);
|
||||
// await spnlogin.initialize();
|
||||
// await spnlogin.login();
|
||||
// }
|
||||
|
||||
console.log("Login successful.");
|
||||
}
|
||||
@ -146,9 +147,9 @@ export async function main() {
|
||||
if (!isAzCLISuccess) {
|
||||
core.error("Az CLI Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows");
|
||||
}
|
||||
else {
|
||||
core.error(`Azure PowerShell Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows"`);
|
||||
}
|
||||
// else {
|
||||
// core.error(`Azure PowerShell Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows"`);
|
||||
// }
|
||||
core.setFailed(error);
|
||||
}
|
||||
finally {
|
||||
@ -173,4 +174,4 @@ export async function executeAzCliCommand(
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
//main();
|
Loading…
x
Reference in New Issue
Block a user