-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
187a0b4
commit 8a3610c
Showing
1,206 changed files
with
237,926 additions
and
1,062 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
Oops, something went wrong.