mirror of
https://github.com/imranismail/setup-kustomize.git
synced 2026-05-19 21:22:14 +00:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ba527d4d0 | ||
|
|
a76db1c641 | ||
|
|
6691bdeb1b | ||
|
|
86a0af5aa8 | ||
|
|
8757bab9d6 | ||
|
|
32e634d4e0 | ||
|
|
5f57b3222d | ||
|
|
9e8cf604e6 | ||
|
|
da3f4f22f0 | ||
|
|
841007459d | ||
|
|
aa978fb4ab | ||
|
|
5bd9c67dee | ||
|
|
97446b23bf | ||
|
|
18af3b305d | ||
|
|
058459647a | ||
|
|
d8f8e8a8c7 | ||
|
|
8fa954828e | ||
|
|
51f249a5a4 | ||
|
|
d4a94f2227 | ||
|
|
8975f1988c | ||
|
|
79ebb54aee | ||
|
|
4ebf871144 | ||
|
|
b5ea91485d | ||
|
|
c090480e53 | ||
|
|
bd0edb85fb | ||
|
|
55191c7b61 | ||
|
|
9f90af1b02 | ||
|
|
c4446ec4f6 | ||
|
|
7b7a2518ae | ||
|
|
3aa72b92bd |
@@ -44,7 +44,8 @@
|
||||
"semi": "off",
|
||||
"@typescript-eslint/semi": ["error", "never"],
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"@typescript-eslint/unbound-method": "error"
|
||||
"@typescript-eslint/unbound-method": "error",
|
||||
"i18n-text/no-en": "off"
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
|
||||
@@ -1 +1 @@
|
||||
nodejs 15.14.0
|
||||
nodejs 20.8.1
|
||||
42
CHANGELOG.MD
42
CHANGELOG.MD
@@ -1,42 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## v1.5.2
|
||||
|
||||
### Security
|
||||
|
||||
- Bump @actions/core to v1.2.6 to address deprecations raised in #30
|
||||
|
||||
## v1.5.1
|
||||
|
||||
### Changed
|
||||
|
||||
- Cache kustomize by requested version spec as key
|
||||
|
||||
## v1.5.0
|
||||
|
||||
### Changed
|
||||
|
||||
- Simplified asset look up
|
||||
|
||||
## v1.4.0
|
||||
|
||||
### Added
|
||||
|
||||
- Adds support for semver version ranges. Example: 3.x, 3.2.x
|
||||
- Add a step in the workflow to test the action with default value
|
||||
|
||||
## v1.2.0
|
||||
|
||||
N/A
|
||||
|
||||
## v1.1.0
|
||||
|
||||
### Fixed
|
||||
|
||||
- Support for new download path for kustomize
|
||||
|
||||
## v1.0.0
|
||||
|
||||
### Changed
|
||||
|
||||
- Update metadata
|
||||
11
README.md
11
README.md
@@ -8,10 +8,11 @@ Install any kustomize version as a step in your workflow
|
||||
|
||||
Every argument is optional.
|
||||
|
||||
| Input | Description |
|
||||
| ------------------- | ------------------------------------------------------------------------------------------------------ |
|
||||
| `github-token` | PAT (Personal Access Token) for authorizing the repository.<br>_Defaults to **\${{ github.token }}**_. |
|
||||
| `kustomize-version` | Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0.<br>_Defaults to **\***_. |
|
||||
| Input | Description |
|
||||
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `github-token` | PAT (Personal Access Token) for authorizing the repository.<br>_Defaults to **\${{ github.token }}**_ |
|
||||
| `kustomize-version` | Semver of kustomize to use. Examples: `10.x`, `10.15.1`, `>=10.15.0`<br>_Defaults to **\***_ |
|
||||
| `fail-fast` | When github rate limits us, fail immediately or retry after the timeout that github wishes from us? <br>Note: When this is set to `false`, a github workflow might accrue a long (and possibly expensive) runtime.<br>_Defaults to **true**_ |
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -27,7 +28,7 @@ jobs:
|
||||
needs:
|
||||
- publish-image
|
||||
steps:
|
||||
- uses: imranismail/setup-kustomize@v1
|
||||
- uses: imranismail/setup-kustomize@v2
|
||||
- run: |
|
||||
kustomize edit set image app:${GITHUB_SHA}
|
||||
git add .
|
||||
|
||||
@@ -8,6 +8,7 @@ const tempDir = path.join(__dirname, 'runner', 'temp')
|
||||
|
||||
process.env['RUNNER_TOOL_CACHE'] = toolDir
|
||||
process.env['RUNNER_TEMP'] = tempDir
|
||||
process.env['INPUT_FAIL-FAST'] = 'true'
|
||||
|
||||
import * as installer from '../src/installer'
|
||||
|
||||
@@ -34,6 +35,22 @@ describe('installer tests', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('Acquires kustomize version 5.2.1', async () => {
|
||||
await installer.getKustomize('5.2.1')
|
||||
const kustomizeDir = path.join(toolDir, 'kustomize', '5.2.1', os.arch())
|
||||
|
||||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true)
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true)
|
||||
} else {
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true)
|
||||
expect(() =>
|
||||
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)
|
||||
).not.toThrow()
|
||||
}
|
||||
})
|
||||
|
||||
it('Acquires kustomize version 3.2.0', async () => {
|
||||
await installer.getKustomize('3.2.0')
|
||||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.0', os.arch())
|
||||
|
||||
@@ -13,6 +13,10 @@ inputs:
|
||||
description: 'Token for the repository. Can be passed in using `{{ secrets.GITHUB_TOKEN }}`.'
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
fail-fast:
|
||||
description: 'Fail quickly on github rate limit. "false" or "true".'
|
||||
required: false
|
||||
default: 'true'
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node20'
|
||||
main: 'dist/index.js'
|
||||
|
||||
38644
dist/index.js
vendored
38644
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
117
dist/licenses.txt
vendored
117
dist/licenses.txt
vendored
@@ -12,9 +12,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
|
||||
@actions/exec
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/github
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
@@ -65,6 +83,28 @@ The above copyright notice and this permission notice shall be included in all c
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@fastify/busboy
|
||||
MIT
|
||||
Copyright Brian White. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
|
||||
@octokit/auth-token
|
||||
MIT
|
||||
The MIT License
|
||||
@@ -262,16 +302,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@vercel/ncc
|
||||
MIT
|
||||
Copyright 2018 ZEIT, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
before-after-hook
|
||||
Apache-2.0
|
||||
Apache License
|
||||
@@ -564,32 +594,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
node-fetch
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 David Frank
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
|
||||
once
|
||||
ISC
|
||||
The ISC License
|
||||
@@ -653,22 +657,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
universal-user-agent
|
||||
ISC
|
||||
# [ISC License](https://spdx.org/licenses/ISC)
|
||||
|
||||
Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m)
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
uuid
|
||||
undici
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2010-2016 Robert Kieffer and other contributors
|
||||
Copyright (c) Matteo Collina and Undici contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -689,6 +682,30 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
universal-user-agent
|
||||
ISC
|
||||
# [ISC License](https://spdx.org/licenses/ISC)
|
||||
|
||||
Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m)
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
uuid
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
wrappy
|
||||
ISC
|
||||
The ISC License
|
||||
|
||||
3911
dist/sourcemap-register.js
vendored
3911
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
15566
package-lock.json
generated
15566
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
40
package.json
40
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-kustomize",
|
||||
"version": "0.0.0",
|
||||
"version": "2.1.0",
|
||||
"private": true,
|
||||
"description": "Github action to setup-kustomize",
|
||||
"main": "lib/main.js",
|
||||
@@ -26,26 +26,26 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/github": "^4.0.0",
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^1.3.3",
|
||||
"@octokit/plugin-throttling": "^3.4.1",
|
||||
"semver": "^7.3.2"
|
||||
"@actions/github": "^6.0.0",
|
||||
"@actions/io": "^1.1.1",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@octokit/plugin-throttling": "^8.0.1",
|
||||
"semver": "^7.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^15.0.2",
|
||||
"@types/semver": "^7.3.4",
|
||||
"@typescript-eslint/parser": "^4.8.1",
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
"eslint": "^7.17.0",
|
||||
"eslint-plugin-github": "^4.1.1",
|
||||
"eslint-plugin-jest": "^24.1.3",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"js-yaml": "^3.14.0",
|
||||
"prettier": "2.2.1",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^4.1.3"
|
||||
"@types/jest": "^29.5.6",
|
||||
"@types/node": "^20.8.8",
|
||||
"@types/semver": "^7.3.9",
|
||||
"@typescript-eslint/parser": "^6.9.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint": "^8.52.0",
|
||||
"eslint-plugin-github": "^4.10.1",
|
||||
"eslint-plugin-jest": "^27.4.3",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "^3.0.3",
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {GitHub, getOctokitOptions} from '@actions/github/lib/utils'
|
||||
import {OctokitOptions} from '@octokit/core/dist-types/types'
|
||||
import {OctokitOptions} from '@octokit/core/dist-types/types.d'
|
||||
import {throttling} from '@octokit/plugin-throttling'
|
||||
import * as core from '@actions/core'
|
||||
import * as cache from '@actions/tool-cache'
|
||||
@@ -11,6 +11,7 @@ let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || ''
|
||||
const EnhancedOctokit = GitHub.plugin(throttling)
|
||||
|
||||
const githubToken = core.getInput('github-token')
|
||||
const failFast = core.getBooleanInput('fail-fast')
|
||||
|
||||
let options: OctokitOptions = {
|
||||
throttle: {
|
||||
@@ -18,13 +19,17 @@ let options: OctokitOptions = {
|
||||
core.warning(
|
||||
`Request quota exhausted for request ${opts.method} ${opts.url}`
|
||||
)
|
||||
core.warning(`Retrying after ${retryAfter} seconds!`)
|
||||
return true
|
||||
if (!failFast) {
|
||||
core.warning(`Retrying after ${retryAfter} seconds!`)
|
||||
}
|
||||
return !failFast
|
||||
},
|
||||
onAbuseLimit: (retryAfter: Number, opts: OctokitOptions) => {
|
||||
onSecondaryRateLimit: (retryAfter: Number, opts: OctokitOptions) => {
|
||||
core.warning(`Abuse detected for request ${opts.method} ${opts.url}`)
|
||||
core.warning(`Retrying after ${retryAfter} seconds!`)
|
||||
return true
|
||||
if (!failFast) {
|
||||
core.warning(`Retrying after ${retryAfter} seconds!`)
|
||||
}
|
||||
return !failFast
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,10 +65,14 @@ export async function getKustomize(targetVersion: string): Promise<void> {
|
||||
if (!semver.validRange(targetVersion))
|
||||
throw new Error(`invalid semver requested: ${targetVersion}`)
|
||||
|
||||
const resolver = semver.valid(targetVersion)
|
||||
? getPinnedVersion
|
||||
: getMaxSatisfyingVersion
|
||||
|
||||
let kustomizePath = cache.find('kustomize', targetVersion)
|
||||
|
||||
if (!kustomizePath) {
|
||||
const version = await getMaxSatisfyingVersion(targetVersion)
|
||||
const version = await resolver(targetVersion)
|
||||
kustomizePath = await acquireVersion(version)
|
||||
}
|
||||
|
||||
@@ -76,6 +85,55 @@ interface Version {
|
||||
url: string
|
||||
}
|
||||
|
||||
async function getPinnedVersion(targetVersion: string): Promise<Version> {
|
||||
const prefix = semver.gt(targetVersion, '3.2.0') ? 'kustomize/v' : 'v'
|
||||
|
||||
try {
|
||||
const response = await octokit.rest.repos.getReleaseByTag({
|
||||
owner: 'kubernetes-sigs',
|
||||
repo: 'kustomize',
|
||||
tag: prefix + targetVersion
|
||||
})
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`Invalid response status ${response.status}`)
|
||||
}
|
||||
|
||||
const release = response.data
|
||||
|
||||
const matchingAsset = release.assets.find(
|
||||
asset =>
|
||||
asset.name.includes('kustomize') &&
|
||||
asset.name.includes(platform) &&
|
||||
asset.name.includes(arch)
|
||||
)
|
||||
|
||||
if (matchingAsset) {
|
||||
const kustomizeVersion = (
|
||||
versionRegex.exec(release.tag_name) || []
|
||||
).shift()
|
||||
|
||||
if (kustomizeVersion != null) {
|
||||
return {
|
||||
target: targetVersion,
|
||||
resolved: kustomizeVersion,
|
||||
url: matchingAsset.browser_download_url
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
`Could not find version in release tag ${release.tag_name}`
|
||||
)
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
`Could not find asset for platform '${platform}' and '${arch}'.`
|
||||
)
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(`Could not satisfy version range ${targetVersion}: ${err}`)
|
||||
}
|
||||
}
|
||||
|
||||
async function getMaxSatisfyingVersion(
|
||||
targetVersion: string
|
||||
): Promise<Version> {
|
||||
@@ -83,10 +141,11 @@ async function getMaxSatisfyingVersion(
|
||||
const availableVersions: Map<string, string> = new Map()
|
||||
|
||||
for await (const response of octokit.paginate.iterator(
|
||||
octokit.repos.listReleases,
|
||||
octokit.rest.repos.listReleases,
|
||||
{
|
||||
owner: 'kubernetes-sigs',
|
||||
repo: 'kustomize'
|
||||
repo: 'kustomize',
|
||||
per_page: 100
|
||||
}
|
||||
)) {
|
||||
for (const release of response.data) {
|
||||
@@ -119,7 +178,8 @@ async function getMaxSatisfyingVersion(
|
||||
|
||||
if (!resolved) {
|
||||
throw new Error(
|
||||
`Unable to find Kustomize version '${version.target}' for platform '${platform}' and architecture ${arch}.`
|
||||
`Could not satisfy version '${version.target}': Could not find asset for platform '${platform}' and
|
||||
${arch}'.`
|
||||
)
|
||||
}
|
||||
|
||||
@@ -136,7 +196,6 @@ async function acquireVersion(version: Version): Promise<string> {
|
||||
try {
|
||||
toolPath = await cache.downloadTool(version.url)
|
||||
} catch (err) {
|
||||
core.debug(err)
|
||||
throw new Error(`Failed to download version ${version.target}: ${err}`)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ async function run(): Promise<void> {
|
||||
await installer.getKustomize(version)
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
core.setFailed(`${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user