Skip to content

Commit

Permalink
Add lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rick-a-lane-ii committed Mar 6, 2024
1 parent 187a0b4 commit 8a3610c
Show file tree
Hide file tree
Showing 1,206 changed files with 237,926 additions and 1,062 deletions.
9 changes: 9 additions & 0 deletions .github/actions/provision-cluster/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
env:
commonjs: true
es2021: true
node: true
jest: true
extends: eslint:recommended
parserOptions:
ecmaVersion: latest
rules: {}
55 changes: 28 additions & 27 deletions .github/actions/provision-cluster/create.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
'use strict';
"use strict";

const core = require('@actions/core')
const github = require('@actions/github')
const core = require("@actions/core");

const registry = require('./lib/registry.js')
const utils = require('./lib/utils.js')
const registry = require("./lib/registry.js");
const utils = require("./lib/utils.js");

async function create() {
// inputs are defined in action metadata file
const distribution = core.getInput('distribution')
const action = core.getInput('action')
const version = core.getInput('version')
const lifespan = core.getInput('lifespan')
const kubeconfigPath = core.getInput('kubeconfig')
const distribution = core.getInput("distribution");
const action = core.getInput("action");
const version = core.getInput("version");
const lifespan = core.getInput("lifespan");
const kubeconfigPath = core.getInput("kubeconfig");

let provider = registry.getProvider(distribution)
let provider = registry.getProvider(distribution);

if (action === 'expire') {
return
if (action === "expire") {
return;
}

core.notice(`Creating ${distribution} ${version} and writing kubeconfig to file: ${kubeconfigPath}!`)
let cluster = await provider.allocateCluster(version, lifespan)
core.saveState(registry.CLUSTER_NAME, cluster.name)
core.notice(
`Creating ${distribution} ${version} and writing kubeconfig to file: ${kubeconfigPath}!`
);
let cluster = await provider.allocateCluster(version, lifespan);
core.saveState(registry.CLUSTER_NAME, cluster.name);

core.setOutput("clusterName", cluster?.name);
core.setOutput("projectId", cluster?.project);
core.setOutput("location", cluster?.zone);

core.notice(`Creating ${distribution} cluster ${cluster.name} ...`)
let kubeconfig = await provider.makeKubeconfig(cluster)
core.notice(`Cluster created: ${cluster.name}!`)
let contents = JSON.stringify(kubeconfig, undefined, 2) + "\n"
utils.writeFile(kubeconfigPath, contents)
core.notice(`Creating ${distribution} cluster ${cluster.name} ...`);
let kubeconfig = await provider.makeKubeconfig(cluster);
core.notice(`Cluster created: ${cluster.name}!`);
let contents = JSON.stringify(kubeconfig, undefined, 2) + "\n";
utils.writeFile(kubeconfigPath, contents);

core.notice(`Kubeconfig written to ${kubeconfigPath}.`)
core.notice(`Exporting KUBECONFIG as ${kubeconfigPath}`)
core.exportVariable("KUBECONFIG", kubeconfigPath)
core.notice(`Kubeconfig written to ${kubeconfigPath}.`);
core.notice(`Exporting KUBECONFIG as ${kubeconfigPath}`);
core.exportVariable("KUBECONFIG", kubeconfigPath);
}

create().catch((error)=>{
core.setFailed(error.message)
})
create().catch((error) => {
core.setFailed(error.message);
});
45 changes: 22 additions & 23 deletions .github/actions/provision-cluster/delete.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
'use strict';
"use strict";

const core = require('@actions/core')
const github = require('@actions/github')
const core = require("@actions/core");

const registry = require('./lib/registry.js')
const slack = require('./lib/slack.js')
const registry = require("./lib/registry.js");
const slack = require("./lib/slack.js");

async function do_delete() {
// inputs are defined in action metadata file
const distribution = core.getInput('distribution')
const clusterName = core.getState(registry.CLUSTER_NAME)
const distribution = core.getInput("distribution");
const clusterName = core.getState(registry.CLUSTER_NAME);

let provider = registry.getProvider(distribution)
let provider = registry.getProvider(distribution);

let promises = []
promises.push(expire(provider, distribution))
let promises = [];
promises.push(expire(provider, distribution));

if (typeof clusterName !== typeof undefined && clusterName !== "") {
core.notice(`Deleting ${distribution} cluster ${clusterName}!`)
promises.push(delete_allocated(provider, clusterName))
core.notice(`Deleting ${distribution} cluster ${clusterName}!`);
promises.push(delete_allocated(provider, clusterName));
}

return Promise.all(promises)
return Promise.all(promises);
}

async function expire(provider, distribution) {
let orphaned = await provider.expireClusters()
async function expire(provider) {
let orphaned = await provider.expireClusters();

if (orphaned.length == 0) {
return
return;
}

core.notice(`Orhpaned Clusters: ${orphaned.join(', ')}`)
slack.notify(`Orphaned clusters:\n\n - ${orphaned.join("\n - ")}`)
core.notice(`Orhpaned Clusters: ${orphaned.join(", ")}`);
slack.notify(`Orphaned clusters:\n\n - ${orphaned.join("\n - ")}`);
}

async function delete_allocated(provider, name) {
let cluster = await provider.getCluster(name)
return provider.deleteCluster(cluster)
let cluster = await provider.getCluster(name);
return provider.deleteCluster(cluster);
}

do_delete().catch((error)=>{
core.setFailed(error.message)
})
do_delete().catch((error) => {
core.setFailed(error.message);
});
Loading

0 comments on commit 8a3610c

Please sign in to comment.