-
Notifications
You must be signed in to change notification settings - Fork 69
feat: add version-file input to read kubectl version from .tool-versions #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,19 +7,28 @@ import { | |
| getkubectlDownloadURL, | ||
| getKubectlArch, | ||
| getExecutableExtension, | ||
| getLatestPatchVersion | ||
| getLatestPatchVersion, | ||
| parseToolVersionsFile | ||
| } from './helpers.js' | ||
|
|
||
| const kubectlToolName = 'kubectl' | ||
| const stableKubectlVersion = 'v1.15.0' | ||
| const stableVersionUrl = 'https://dl.k8s.io/release/stable.txt' | ||
|
|
||
| export async function run() { | ||
| let version = core.getInput('version', {required: true}) | ||
| if (version.toLocaleLowerCase() === 'latest') { | ||
| version = await getStableKubectlVersion() | ||
| const versionFile = core.getInput('version-file') | ||
| let version: string | ||
|
|
||
| if (versionFile) { | ||
| const rawVersion = parseToolVersionsFile(versionFile) | ||
| version = await resolveKubectlVersion(rawVersion) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Tatsinnit do you want me to address this issue ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you so much for the contributions @acouvreur here are some thoughts, please: #261 (review) |
||
| } else { | ||
| version = await resolveKubectlVersion(version) | ||
| version = core.getInput('version', {required: true}) | ||
| if (version.toLocaleLowerCase() === 'latest') { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now the input path handles 'latest' via getStableKubectlVersion(), but the file path doesn't. So kubectl latest in .tool-versions silently breaks, it goes straight to resolveKubectlVersion('latest'). Resolve the version once (from input or file) into a string, then let the existing downstream latest / resolveKubectlVersion branch run unchanged, latest then works for both paths |
||
| version = await getStableKubectlVersion() | ||
| } else { | ||
| version = await resolveKubectlVersion(version) | ||
| } | ||
| } | ||
| const cachedPath = await downloadKubectl(version) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should flip precedence so version wins over version-file. That matches actions/setup-go, actions/setup-node, and Azure/setup-helm #281. And also add a warning that we prefer version over version-file when both are given.