Update manifests

This commit is contained in:
Imran Ismail
2020-09-25 22:16:19 +08:00
parent 359e84cbc9
commit ff25099d8b
3 changed files with 28 additions and 25 deletions

42
dist/index.js vendored
View File

@@ -9108,23 +9108,24 @@ if (!tempDirectory) {
} }
tempDirectory = path.join(baseLocation, 'actions', 'temp'); tempDirectory = path.join(baseLocation, 'actions', 'temp');
} }
function getKustomize(versionSpec) { function getKustomize(targetVersion) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let toolPath = cache.find('kustomize', versionSpec); if (!semver.validRange(targetVersion))
if (!toolPath) { throw new Error(`invalid semver requested: ${targetVersion}`);
const version = yield getMaxSatisfyingVersion(versionSpec); let kustomizePath = cache.find('kustomize', targetVersion);
toolPath = yield acquireVersion(version); if (!kustomizePath) {
const version = yield getMaxSatisfyingVersion(targetVersion);
kustomizePath = yield acquireVersion(version);
} }
return core.addPath(toolPath); return core.addPath(kustomizePath);
}); });
} }
exports.getKustomize = getKustomize; exports.getKustomize = getKustomize;
function getMaxSatisfyingVersion(versionSpec) { function getMaxSatisfyingVersion(targetVersion) {
var e_1, _a; var e_1, _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const versionRange = semver.validRange(versionSpec); const version = { target: targetVersion };
const downloadUrls = new Map(); const availableVersions = new Map();
const versions = [];
try { try {
for (var _b = __asyncValues(octokit.paginate.iterator(octokit.repos.listReleases, { for (var _b = __asyncValues(octokit.paginate.iterator(octokit.repos.listReleases, {
owner: 'kubernetes-sigs', owner: 'kubernetes-sigs',
@@ -9136,10 +9137,9 @@ function getMaxSatisfyingVersion(versionSpec) {
asset.name.includes(platform) && asset.name.includes(platform) &&
asset.name.includes(arch)); asset.name.includes(arch));
if (matchingAsset) { if (matchingAsset) {
const version = (versionRegex.exec(release.name) || []).shift(); const kustomizeVersion = (versionRegex.exec(release.name) || []).shift();
if (version != null) { if (kustomizeVersion != null) {
downloadUrls.set(version, matchingAsset.browser_download_url); availableVersions.set(kustomizeVersion, matchingAsset.browser_download_url);
versions.push(version);
} }
} }
} }
@@ -9152,12 +9152,12 @@ function getMaxSatisfyingVersion(versionSpec) {
} }
finally { if (e_1) throw e_1.error; } finally { if (e_1) throw e_1.error; }
} }
const versionToDownload = semver.maxSatisfying(versions, versionRange); const resolved = semver.maxSatisfying([...availableVersions.keys()], version.target);
if (!versionToDownload) { if (!resolved) {
throw new Error(`Unable to find Kustomize version '${versionSpec}' for platform '${platform}' and architecture ${arch}.`); throw new Error(`Unable to find Kustomize version '${version.target}' for platform '${platform}' and architecture ${arch}.`);
} }
const downloadUrl = downloadUrls.get(versionToDownload); const url = availableVersions.get(resolved);
return { name: versionToDownload, url: downloadUrl }; return Object.assign(Object.assign({}, version), { resolved, url });
}); });
} }
function acquireVersion(version) { function acquireVersion(version) {
@@ -9169,7 +9169,7 @@ function acquireVersion(version) {
} }
catch (err) { catch (err) {
core.debug(err); core.debug(err);
throw new Error(`Failed to download version ${version.name}: ${err}`); throw new Error(`Failed to download version ${version.target}: ${err}`);
} }
if (version.url.endsWith('.tar.gz')) { if (version.url.endsWith('.tar.gz')) {
toolPath = yield cache.extractTar(toolPath); toolPath = yield cache.extractTar(toolPath);
@@ -9181,7 +9181,7 @@ function acquireVersion(version) {
fs.chmodSync(toolPath, 0o755); fs.chmodSync(toolPath, 0o755);
break; break;
} }
return yield cache.cacheFile(toolPath, toolFilename, toolName, version.name); return yield cache.cacheFile(toolPath, toolFilename, toolName, version.target);
}); });
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -70,10 +70,13 @@ async function getMaxSatisfyingVersion(
) )
if (matchingAsset) { if (matchingAsset) {
const version = (versionRegex.exec(release.name) || []).shift() const kustomizeVersion = (versionRegex.exec(release.name) || []).shift()
if (version != null) { if (kustomizeVersion != null) {
availableVersions.set(version, matchingAsset.browser_download_url) availableVersions.set(
kustomizeVersion,
matchingAsset.browser_download_url
)
} }
} }
} }