generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Radu M <root@radu.sh>
- Loading branch information
Radu M
committed
May 22, 2020
1 parent
c4d560a
commit b36da88
Showing
96 changed files
with
9,477 additions
and
2 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
node_modules/ | ||
# node_modules/ | ||
__tests__/runner/* | ||
lib/ | ||
# lib/ |
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,100 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core = __importStar(require("@actions/core")); | ||
const tc = __importStar(require("@actions/tool-cache")); | ||
const exec = __importStar(require("@actions/exec")); | ||
const path = __importStar(require("path")); | ||
const VersionInput = "version"; | ||
const ConfigInput = "config"; | ||
const ImageInput = "image"; | ||
const NameInput = "name"; | ||
const WaitInput = "wait"; | ||
const SkipClusterCreationInput = "skipClusterCreation"; | ||
const toolName = "kind"; | ||
class KindConfig { | ||
constructor(version, configFile, image, name, waitDuration, skipClusterCreation) { | ||
this.version = version; | ||
this.configFile = configFile; | ||
this.image = image; | ||
this.name = name; | ||
this.waitDuration = waitDuration; | ||
this.skipClusterCreation = (skipClusterCreation == 'true'); | ||
} | ||
// returns the arguments to pass to `kind create cluster` | ||
getCommand() { | ||
let args = ["create", "cluster"]; | ||
if (this.configFile != "") { | ||
const wd = process.env[`GITHUB_WORKSPACE`] || ""; | ||
const absPath = path.join(wd, this.configFile); | ||
args.push("--config", absPath); | ||
} | ||
if (this.image != "") { | ||
args.push("--image", this.image); | ||
} | ||
if (this.name != "") { | ||
args.push("--name", this.name); | ||
} | ||
if (this.waitDuration != "") { | ||
args.push("--wait", this.waitDuration); | ||
} | ||
return args; | ||
} | ||
createCluster() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.skipClusterCreation) | ||
return; | ||
console.log("Executing kind with args " + this.getCommand()); | ||
yield exec.exec("kind", this.getCommand()); | ||
}); | ||
} | ||
} | ||
exports.KindConfig = KindConfig; | ||
function getKindConfig() { | ||
const v = core.getInput(VersionInput); | ||
const c = core.getInput(ConfigInput); | ||
const i = core.getInput(ImageInput); | ||
const n = core.getInput(NameInput); | ||
const w = core.getInput(WaitInput); | ||
const s = core.getInput(SkipClusterCreationInput); | ||
return new KindConfig(v, c, i, n, w, s); | ||
} | ||
exports.getKindConfig = getKindConfig; | ||
// this action should always be run from a Linux worker | ||
function downloadKind(version) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let url = `https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-linux-amd64`; | ||
console.log("downloading kind from " + url); | ||
let downloadPath = null; | ||
downloadPath = yield tc.downloadTool(url); | ||
yield exec.exec("chmod", ["+x", downloadPath]); | ||
let toolPath = yield tc.cacheFile(downloadPath, "kind", toolName, version); | ||
core.debug(`kind is cached under ${toolPath}`); | ||
return toolPath; | ||
}); | ||
} | ||
exports.downloadKind = downloadKind; | ||
function getKind(version) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let toolPath = tc.find(toolName, version); | ||
if (toolPath === "") { | ||
toolPath = yield downloadKind(version); | ||
} | ||
return toolPath; | ||
}); | ||
} | ||
exports.getKind = getKind; |
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,33 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core = __importStar(require("@actions/core")); | ||
const kind_1 = require("./kind"); | ||
function run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
let cfg = kind_1.getKindConfig(); | ||
let toolPath = yield kind_1.getKind(cfg.version); | ||
core.addPath(toolPath); | ||
yield cfg.createCluster(); | ||
} | ||
catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
}); | ||
} | ||
run(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.