56 Commits

Author SHA1 Message Date
dependabot[bot]
c37105ff40 Bump @types/node from 24.9.1 to 24.10.0 in the actions group
Bumps the actions group with 1 update: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node).


Updates `@types/node` from 24.9.1 to 24.10.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 24.10.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-03 10:08:36 +00:00
dependabot[bot]
c0f557132b Bump @types/node from 24.8.1 to 24.9.1 in the actions group (#202)
Bumps the actions group with 1 update: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node).


Updates `@types/node` from 24.8.1 to 24.9.1
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 24.9.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-30 19:07:54 -07:00
dependabot[bot]
aea9a0c3b3 Bump github/codeql-action in /.github/workflows in the actions group (#203)
Bumps the actions group in /.github/workflows with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 4.30.9 to 4.31.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](16140ae1a1...4e94bd11f7)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-30 19:07:30 -07:00
dependabot[bot]
8528c2dbca Bump @types/node from 24.7.2 to 24.8.1 in the actions group (#200) 2025-10-21 11:59:22 -07:00
dependabot[bot]
8cade21a03 Bump the actions group in /.github/workflows with 2 updates (#201) 2025-10-21 14:18:39 -04:00
dependabot[bot]
5f693c4109 Bump the actions group across 1 directory with 5 updates (#197) 2025-10-15 15:12:39 -04:00
dependabot[bot]
c03192ebc0 Bump the actions group in /.github/workflows with 2 updates (#198) 2025-10-15 15:12:30 -04:00
Matt Cavanagh
44bac4685f Description was inaccurate, should have v prefix (#195) 2025-10-08 09:59:30 -04:00
dependabot[bot]
47a0af42ba Bump github/codeql-action in /.github/workflows in the actions group (#196)
Bumps the actions group in /.github/workflows with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.30.3 to 3.30.5
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](192325c861...3599b3baa1)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.30.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-02 14:52:42 -07:00
dependabot[bot]
4d23b307dc Bump the actions group in /.github/workflows with 4 updates (#192) 2025-09-23 18:17:33 +12:00
Chitoku
42b5b7bc56 Update stableVersionUrl to dl.k8s.io (#190) 2025-09-08 10:00:19 -04:00
dependabot[bot]
b011c9c1e8 Bump github/codeql-action in /.github/workflows in the actions group (#189) 2025-08-26 12:05:15 -07:00
dependabot[bot]
4133c5e43f Bump the actions group in /.github/workflows with 2 updates (#187) 2025-08-19 15:05:51 -04:00
dependabot[bot]
cdf8c1d057 Bump @types/node from 24.2.1 to 24.3.0 in the actions group (#188) 2025-08-20 02:29:22 +12:00
dependabot[bot]
b6296bb835 Bump the actions group in /.github/workflows with 2 updates (#185)
Bumps the actions group in /.github/workflows with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [github/codeql-action](https://github.com/github/codeql-action).


Updates `actions/checkout` from 4.2.2 to 4.3.0
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](11bd71901b...08eba0b27e)

Updates `github/codeql-action` from 3.29.7 to 3.29.8
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](51f77329af...76621b61de)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 4.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: github/codeql-action
  dependency-version: 3.29.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-12 12:17:39 -07:00
dependabot[bot]
c680ff81e7 Bump @types/node from 24.2.0 to 24.2.1 in the actions group (#186)
Bumps the actions group with 1 update: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node).


Updates `@types/node` from 24.2.0 to 24.2.1
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 24.2.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-12 12:16:51 -07:00
dependabot[bot]
cce2d7e325 Bump the actions group with 3 updates (#183)
Bumps the actions group with 3 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [ts-jest](https://github.com/kulshekhar/ts-jest) and [typescript](https://github.com/microsoft/TypeScript).


Updates `@types/node` from 24.1.0 to 24.2.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `ts-jest` from 29.4.0 to 29.4.1
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v29.4.0...v29.4.1)

Updates `typescript` from 5.8.3 to 5.9.2
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release-publish.yml)
- [Commits](https://github.com/microsoft/TypeScript/compare/v5.8.3...v5.9.2)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 24.2.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: ts-jest
  dependency-version: 29.4.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: typescript
  dependency-version: 5.9.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-05 15:05:06 -04:00
dependabot[bot]
005393f25c Bump github/codeql-action in /.github/workflows in the actions group (#184)
Bumps the actions group in /.github/workflows with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.29.4 to 3.29.5
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](4e828ff8d4...51f77329af)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-05 15:04:37 -04:00
dependabot[bot]
ca5c5eeeab Bump the actions group with 2 updates (#182)
Bumps the actions group with 2 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) and [jest](https://github.com/jestjs/jest/tree/HEAD/packages/jest).


Updates `@types/node` from 24.0.15 to 24.1.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `jest` from 30.0.4 to 30.0.5
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v30.0.5/packages/jest)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 24.1.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: jest
  dependency-version: 30.0.5
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-29 15:10:41 -04:00
dependabot[bot]
1812bcd3a9 Bump github/codeql-action in /.github/workflows in the actions group (#181)
Bumps the actions group in /.github/workflows with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.29.3 to 3.29.4
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](d6bbdef45e...4e828ff8d4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-29 15:09:27 -04:00
dependabot[bot]
1c38d79705 Bump @types/node from 24.0.13 to 24.0.15 in the actions group (#178)
Bumps the actions group with 1 update: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node).


Updates `@types/node` from 24.0.13 to 24.0.15
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 24.0.15
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-22 15:18:03 -04:00
David Gamero
cc498038af Update CODEOWNERS (#180) 2025-07-22 15:17:25 -04:00
dependabot[bot]
83ce790aa0 Bump github/codeql-action in /.github/workflows in the actions group (#179)
Bumps the actions group in /.github/workflows with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.29.2 to 3.29.3
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](181d5eefc2...d6bbdef45e)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-22 15:06:41 -04:00
David Gamero
773fd39d5c upgrade failing deps (#168)
* upgrade failing deps

* test with no bin links

* remove --no-bin-links flag
2025-07-15 15:10:20 -04:00
dependabot[bot]
0fec332675 Bump @types/node from 24.0.10 to 24.0.13 in the actions group (#177)
Bumps the actions group with 1 update: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node).


Updates `@types/node` from 24.0.10 to 24.0.13
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 24.0.13
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-15 15:06:55 -04:00
Ogheneobukome Ejaife
7500adf963 Resolve #104 : Enhance Version Handling: Auto-Resolve kubectl Major.Minor to Latest Patch (#172)
* feat: Implement resolveKubectlVersion function with comprehensive test coverage

Introduce resolveKubectlVersion function that enables automatic selection of the latest patch version when provided with major.minor version input (e.g., '1.27' resolves to 'v1.27.15')

Test Coverage:
- Major.minor version expansion to latest available patch
- Full version passthrough behavior (returns unchanged)
- Single matching version selection logic
- Comprehensive unit tests for kubectl version resolution scenarios

* chore: fix Prettier formatting

* refactor(resolveKubectlVersion): switch to k8s CDN for security patch retrieval

Replaced GitHub API Octo client with k8s CDN to fetch the latest security patch for improved reliability. Separated the API call logic from resolveKubectlVersion to enhance testability and readability.

* feat: validate semantic version and refactor patch logic

- Added validation to `resolveKubectlVersion` to ensure input follows "major.minor" or "major.minor.patch" format.
- Moved `getLatestPatchVersion` from `run.ts` to `helpers.ts` to improve code organization and ensure a more robust testing process.

* Bump github/codeql-action in /.github/workflows in the actions group (#173)

Bumps the actions group in /.github/workflows with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.29.0 to 3.29.1
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ce28f5bb42...39edc492db)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: fix code style issues with Prettier

* revised parsing logic

* Improved readability and maintainability

* regenerated package-lock.json

* Regenerated Package-lock.json

* removed unnecessary files

* regenerated package-lock.json

* Regenerate package-lock.json to match package.json version ranges

* Restore package-lock.json to previous version

* uninstall ncc and regenerate package-lock.json using npm ci

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-11 15:31:20 -06:00
dependabot[bot]
41a1936057 Bump github/codeql-action in /.github/workflows in the actions group (#175)
Bumps the actions group in /.github/workflows with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.29.1 to 3.29.2
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](39edc492db...181d5eefc2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-08 15:07:39 -04:00
dependabot[bot]
f2e9242c07 Bump the actions group with 2 updates (#176)
Bumps the actions group with 2 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) and [jest](https://github.com/jestjs/jest/tree/HEAD/packages/jest).


Updates `@types/node` from 24.0.7 to 24.0.10
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `jest` from 30.0.3 to 30.0.4
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v30.0.4/packages/jest)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 24.0.10
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: jest
  dependency-version: 30.0.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-08 15:06:34 -04:00
Tatsinnit
00ca972929 Add husky precommit check in the repo. (#171)
Signed-off-by: Tatsat Mishra <tamishra@microsoft.com>
2025-07-03 10:55:16 +12:00
dependabot[bot]
ff4789395b Bump the actions group across 1 directory with 3 updates (#174)
Bumps the actions group with 3 updates in the / directory: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [jest](https://github.com/jestjs/jest/tree/HEAD/packages/jest) and [prettier](https://github.com/prettier/prettier).


Updates `@types/node` from 24.0.3 to 24.0.7
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `jest` from 30.0.0 to 30.0.3
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v30.0.3/packages/jest)

Updates `prettier` from 3.5.3 to 3.6.2
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.5.3...3.6.2)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 24.0.7
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: jest
  dependency-version: 30.0.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: prettier
  dependency-version: 3.6.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 15:16:40 -04:00
dependabot[bot]
71c4c470b9 Bump github/codeql-action in /.github/workflows in the actions group (#173)
Bumps the actions group in /.github/workflows with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.29.0 to 3.29.1
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ce28f5bb42...39edc492db)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 15:16:16 -04:00
David Gamero
d2d46d801e 4.0.1 fix v prefix (#167) 2025-06-18 13:57:02 -04:00
dependabot[bot]
2ec05092d4 Bump github/codeql-action in /.github/workflows in the actions group (#164) 2025-06-17 15:12:52 -04:00
Tatsinnit
8ee333116b Fix the major update packages including Jest. (#166)
Signed-off-by: Tatsat Mishra <tamishra@microsoft.com>
2025-06-17 15:10:19 -04:00
dependabot[bot]
857b11c18c Bump github/codeql-action in /.github/workflows in the actions group (#163) 2025-06-10 15:06:03 -04:00
dependabot[bot]
fa3df0f1e2 Bump @types/node from 22.15.21 to 22.15.29 in the actions group (#161) 2025-06-03 10:25:59 -04:00
dependabot[bot]
4d5f3eda74 Bump @types/node from 22.15.19 to 22.15.21 in the actions group (#160) 2025-05-27 12:04:22 -07:00
dependabot[bot]
393d232f65 Bump github/codeql-action in /.github/workflows in the actions group (#158) 2025-05-20 15:13:31 -04:00
dependabot[bot]
a0d66424c8 Bump the actions group with 2 updates (#159) 2025-05-20 15:13:20 -04:00
dependabot[bot]
a76651a0e0 Bump @types/node from 22.15.3 to 22.15.17 in the actions group (#157) 2025-05-13 15:08:34 -04:00
dependabot[bot]
cf5fdd749b Bump github/codeql-action in /.github/workflows in the actions group (#156) 2025-05-06 15:05:05 -04:00
dependabot[bot]
de1d5ec5de Bump @types/node from 22.14.1 to 22.15.3 in the actions group (#154) 2025-04-29 15:10:58 -04:00
dependabot[bot]
e6e81bbc41 Bump the actions group in /.github/workflows with 2 updates (#155) 2025-04-29 15:10:37 -04:00
dependabot[bot]
30d747582d Bump the actions group with 2 updates (#152) 2025-04-15 15:07:41 -04:00
dependabot[bot]
f4440b5470 Bump the actions group in /.github/workflows with 2 updates (#153) 2025-04-15 15:07:21 -04:00
dependabot[bot]
0fd96d6276 Bump the actions group with 3 updates (#150) 2025-04-08 15:06:25 -04:00
dependabot[bot]
4ef821e7ca Bump github/codeql-action in /.github/workflows in the actions group (#151) 2025-04-08 15:05:58 -04:00
dependabot[bot]
95e0936d6e Bump @types/node from 22.13.12 to 22.13.14 in the actions group (#148) 2025-04-01 15:07:10 -04:00
dependabot[bot]
87e53e3f71 Bump the actions group in /.github/workflows with 2 updates (#149)
Bumps the actions group in /.github/workflows with 2 updates: [github/codeql-action](https://github.com/github/codeql-action) and [actions/setup-python](https://github.com/actions/setup-python).


Updates `github/codeql-action` from 3.28.12 to 3.28.13
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](5f8171a638...1b549b9259)

Updates `actions/setup-python` from 5.4.0 to 5.5.0
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](42375524e2...8d9ed9ac5c)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-01 15:06:48 -04:00
dependabot[bot]
13bef3ca00 Bump the actions group across 1 directory with 2 updates (#147)
Bumps the actions group with 2 updates in the /.github/workflows directory: [github/codeql-action](https://github.com/github/codeql-action) and [actions/setup-node](https://github.com/actions/setup-node).


Updates `github/codeql-action` from 3.28.11 to 3.28.12
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](6bb031afdd...5f8171a638)

Updates `actions/setup-node` from 4.2.0 to 4.3.0
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](1d0ff469b7...cdca7365b2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-26 08:11:07 +13:00
dependabot[bot]
023f859e5d Bump the actions group with 2 updates (#146) 2025-03-26 08:10:51 +13:00
dependabot[bot]
6bd1f0daf1 Bump the actions group across 1 directory with 4 updates (#143)
Bumps the actions group with 4 updates in the / directory: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node), [prettier](https://github.com/prettier/prettier), [ts-jest](https://github.com/kulshekhar/ts-jest) and [typescript](https://github.com/microsoft/TypeScript).


Updates `@types/node` from 22.13.1 to 22.13.10
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `prettier` from 3.5.0 to 3.5.3
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.5.0...3.5.3)

Updates `ts-jest` from 29.2.5 to 29.2.6
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v29.2.5...v29.2.6)

Updates `typescript` from 5.7.3 to 5.8.2
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/microsoft/TypeScript/compare/v5.7.3...v5.8.2)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: ts-jest
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-13 14:20:16 -04:00
dependabot[bot]
574933e749 Bump github/codeql-action (#144)
Bumps the actions group with 1 update in the /.github/workflows directory: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.28.9 to 3.28.11
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](9e8d0789d4...6bb031afdd)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-13 14:19:24 -04:00
dependabot[bot]
46ce001b45 Bump braces, jest and ts-jest (#103) 2025-02-19 20:50:54 -08:00
dependabot[bot]
f7a3237edf Bump the actions group across 1 directory with 2 updates (#135)
Bumps the actions group with 2 updates in the / directory: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) and [prettier](https://github.com/prettier/prettier).


Updates `@types/node` from 22.10.10 to 22.13.1
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `prettier` from 3.4.2 to 3.5.0
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.4.2...3.5.0)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-12 12:11:31 -08:00
dependabot[bot]
9c31f8cc61 Bump github/codeql-action in /.github/workflows in the actions group (#136)
Bumps the actions group in /.github/workflows with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.28.6 to 3.28.9
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](17a820bf2e...9e8d0789d4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-12 12:11:05 -08:00
16 changed files with 3316 additions and 2124 deletions

2
.github/CODEOWNERS vendored
View File

@@ -1 +1 @@
* @Azure/aks-atlanta
* @Azure/cloud-native-github-action-owners

View File

@@ -55,11 +55,11 @@ jobs:
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@17a820bf2e43b47be2c72b39cc905417bc1ab6d0 # v3.28.6
uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v3.29.5
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
@@ -86,6 +86,6 @@ jobs:
echo ' make release'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@17a820bf2e43b47be2c72b39cc905417bc1ab6d0 # v3.28.6
uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v3.29.5
with:
category: '/language:${{matrix.language}}'

View File

@@ -8,7 +8,7 @@ jobs:
label-issues:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 # v10.1.0
name: Setting issue as idle
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -19,7 +19,7 @@ jobs:
operations-per-run: 100
exempt-issue-labels: 'backlog'
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 # v10.1.0
name: Setting PR as idle
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -17,7 +17,7 @@ jobs:
KUBECONFIG: /home/runner/.kube/config
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
name: Checkout from PR branch
- id: action-npm-build
@@ -27,9 +27,11 @@ jobs:
if [[ $PR_BASE_REF != releases/* ]]; then
npm install
npm run build
# remove node_modules to match production environment where only index.js is present
rm -rf node_modules
fi
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
name: Install Python
with:
python-version: '3.x'

View File

@@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: 'lts/*'
cache: 'npm'

View File

@@ -13,7 +13,7 @@ jobs:
build: # make sure build/ci works properly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Build and run L0 tests.
run: |

9
.husky/pre-commit Normal file
View File

@@ -0,0 +1,9 @@
set +e
npm test
# Run format check
npm run format-check || {
echo ""
echo "❌ Formatting check failed."
echo "💡 Run 'npm run format' or 'prettier --write .' to fix formatting issues."
exit 1
}

View File

@@ -1,6 +1,11 @@
# Changelog
## [v4.0.0] - 2024-01-30
## [4.0.1] - 2025-06-17
- Remove erronious 'v' prefix on previous changelog for v4.0.0 that led to "vv4.0.0" tag issue
- Dependabot fixes
## [4.0.0] - 2024-01-30
### Changed

View File

@@ -1,5 +1,5 @@
name: 'Kubectl tool installer'
description: 'Install a specific version of kubectl binary. Acceptable values are latest or any semantic version string like 1.15.0'
description: 'Install a specific version of kubectl binary. Acceptable values are latest or any semantic version string like "v1.15.0"'
inputs:
version:
description: 'Version of kubectl'

5212
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,8 @@
"test": "jest",
"test-coverage": "jest --coverage",
"format": "prettier --write .",
"format-check": "prettier --check ."
"format-check": "prettier --check .",
"prepare": "husky"
},
"keywords": [
"actions",
@@ -23,12 +24,13 @@
"@actions/tool-cache": "^2.0.2"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"@types/node": "^22.10.10",
"@vercel/ncc": "^0.38.3",
"jest": "^29.7.0",
"prettier": "3.4.2",
"ts-jest": "^29.2.5",
"typescript": "5.7.3"
"@types/jest": "^30.0.0",
"@types/node": "^24.10.0",
"@vercel/ncc": "^0.38.4",
"husky": "^9.1.7",
"jest": "^30.2.0",
"prettier": "3.6.2",
"ts-jest": "^29.4.5",
"typescript": "5.9.3"
}
}

View File

@@ -1,6 +1,8 @@
import * as os from 'os'
import * as util from 'util'
import * as fs from 'fs'
import * as core from '@actions/core'
import * as toolCache from '@actions/tool-cache'
export function getKubectlArch(): string {
const arch = os.arch()
if (arch === 'x64') {
@@ -23,6 +25,29 @@ export function getkubectlDownloadURL(version: string, arch: string): string {
}
}
export async function getLatestPatchVersion(
major: string,
minor: string
): Promise<string> {
const version = `${major}.${minor}`
const sourceURL = `https://cdn.dl.k8s.io/release/stable-${version}.txt`
try {
const downloadPath = await toolCache.downloadTool(sourceURL)
const latestPatch = fs
.readFileSync(downloadPath, 'utf8')
.toString()
.trim()
if (!latestPatch) {
throw new Error(`No patch version found for ${version}`)
}
return latestPatch
} catch (error) {
core.debug(error)
core.warning('GetLatestPatchVersionFailed')
throw new Error(`Failed to get latest patch version for ${version}`)
}
}
export function getExecutableExtension(): string {
if (os.type().match(/^Win/)) {
return '.exe'

View File

@@ -2,7 +2,8 @@ import * as run from './run'
import {
getkubectlDownloadURL,
getKubectlArch,
getExecutableExtension
getExecutableExtension,
getLatestPatchVersion
} from './helpers'
import * as os from 'os'
import * as toolCache from '@actions/tool-cache'
@@ -12,15 +13,18 @@ import * as core from '@actions/core'
import * as util from 'util'
describe('Testing all functions in run file.', () => {
beforeEach(() => {
jest.clearAllMocks()
})
test('getExecutableExtension() - return .exe when os is Windows', () => {
jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
expect(getExecutableExtension()).toBe('.exe')
expect(os.type).toBeCalled()
expect(os.type).toHaveBeenCalled()
})
test('getExecutableExtension() - return empty string for non-windows OS', () => {
jest.spyOn(os, 'type').mockReturnValue('Darwin')
expect(getExecutableExtension()).toBe('')
expect(os.type).toBeCalled()
expect(os.type).toHaveBeenCalled()
})
test.each([
['arm', 'arm'],
@@ -29,9 +33,9 @@ describe('Testing all functions in run file.', () => {
])(
'getKubectlArch() - return on %s os arch %s kubectl arch',
(osArch, kubectlArch) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch)
jest.spyOn(os, 'arch').mockReturnValue(osArch as NodeJS.Architecture)
expect(getKubectlArch()).toBe(kubectlArch)
expect(os.arch).toBeCalled()
expect(os.arch).toHaveBeenCalled()
}
)
test.each([['arm'], ['arm64'], ['amd64']])(
@@ -43,7 +47,7 @@ describe('Testing all functions in run file.', () => {
arch
)
expect(getkubectlDownloadURL('v1.15.0', arch)).toBe(kubectlLinuxUrl)
expect(os.type).toBeCalled()
expect(os.type).toHaveBeenCalled()
}
)
test.each([['arm'], ['arm64'], ['amd64']])(
@@ -55,7 +59,7 @@ describe('Testing all functions in run file.', () => {
arch
)
expect(getkubectlDownloadURL('v1.15.0', arch)).toBe(kubectlDarwinUrl)
expect(os.type).toBeCalled()
expect(os.type).toHaveBeenCalled()
}
)
test.each([['arm'], ['arm64'], ['amd64']])(
@@ -67,7 +71,7 @@ describe('Testing all functions in run file.', () => {
arch
)
expect(getkubectlDownloadURL('v1.15.0', arch)).toBe(kubectlWindowsUrl)
expect(os.type).toBeCalled()
expect(os.type).toHaveBeenCalled()
}
)
test('getStableKubectlVersion() - download stable version file, read version and return it', async () => {
@@ -76,7 +80,7 @@ describe('Testing all functions in run file.', () => {
.mockReturnValue(Promise.resolve('pathToTool'))
jest.spyOn(fs, 'readFileSync').mockReturnValue('v1.20.4')
expect(await run.getStableKubectlVersion()).toBe('v1.20.4')
expect(toolCache.downloadTool).toBeCalled()
expect(toolCache.downloadTool).toHaveBeenCalled()
expect(fs.readFileSync).toHaveBeenCalledWith('pathToTool', 'utf8')
})
test('getStableKubectlVersion() - return default v1.15.0 if version read is empty', async () => {
@@ -85,7 +89,7 @@ describe('Testing all functions in run file.', () => {
.mockReturnValue(Promise.resolve('pathToTool'))
jest.spyOn(fs, 'readFileSync').mockReturnValue('')
expect(await run.getStableKubectlVersion()).toBe('v1.15.0')
expect(toolCache.downloadTool).toBeCalled()
expect(toolCache.downloadTool).toHaveBeenCalled()
expect(fs.readFileSync).toHaveBeenCalledWith('pathToTool', 'utf8')
})
test('getStableKubectlVersion() - return default v1.15.0 if unable to download file', async () => {
@@ -93,7 +97,7 @@ describe('Testing all functions in run file.', () => {
.spyOn(toolCache, 'downloadTool')
.mockRejectedValue('Unable to download.')
expect(await run.getStableKubectlVersion()).toBe('v1.15.0')
expect(toolCache.downloadTool).toBeCalled()
expect(toolCache.downloadTool).toHaveBeenCalled()
})
test('downloadKubectl() - download kubectl, add it to toolCache and return path to it', async () => {
jest.spyOn(toolCache, 'find').mockReturnValue('')
@@ -109,9 +113,9 @@ describe('Testing all functions in run file.', () => {
path.join('pathToCachedTool', 'kubectl.exe')
)
expect(toolCache.find).toHaveBeenCalledWith('kubectl', 'v1.15.0')
expect(toolCache.downloadTool).toBeCalled()
expect(toolCache.cacheFile).toBeCalled()
expect(os.type).toBeCalled()
expect(toolCache.downloadTool).toHaveBeenCalled()
expect(toolCache.cacheFile).toHaveBeenCalled()
expect(os.type).toHaveBeenCalled()
expect(fs.chmodSync).toHaveBeenCalledWith(
path.join('pathToCachedTool', 'kubectl.exe'),
'775'
@@ -126,12 +130,12 @@ describe('Testing all functions in run file.', () => {
'DownloadKubectlFailed'
)
expect(toolCache.find).toHaveBeenCalledWith('kubectl', 'v1.15.0')
expect(toolCache.downloadTool).toBeCalled()
expect(toolCache.downloadTool).toHaveBeenCalled()
})
test('downloadKubectl() - throw kubectl not found error when receive 404 response', async () => {
const kubectlVersion = 'v1.15.0'
const arch = 'arm128'
jest.spyOn(os, 'arch').mockReturnValue(arch)
jest.spyOn(os, 'arch').mockReturnValue(arch as any)
jest.spyOn(toolCache, 'find').mockReturnValue('')
jest.spyOn(toolCache, 'downloadTool').mockImplementation((_) => {
throw new toolCache.HTTPError(404)
@@ -143,9 +147,9 @@ describe('Testing all functions in run file.', () => {
arch
)
)
expect(os.arch).toBeCalled()
expect(os.arch).toHaveBeenCalled()
expect(toolCache.find).toHaveBeenCalledWith('kubectl', kubectlVersion)
expect(toolCache.downloadTool).toBeCalled()
expect(toolCache.downloadTool).toHaveBeenCalled()
})
test('downloadKubectl() - return path to existing cache of kubectl', async () => {
jest.spyOn(core, 'getInput').mockImplementation(() => 'v1.15.5')
@@ -157,12 +161,65 @@ describe('Testing all functions in run file.', () => {
path.join('pathToCachedTool', 'kubectl.exe')
)
expect(toolCache.find).toHaveBeenCalledWith('kubectl', 'v1.15.0')
expect(os.type).toBeCalled()
expect(os.type).toHaveBeenCalled()
expect(fs.chmodSync).toHaveBeenCalledWith(
path.join('pathToCachedTool', 'kubectl.exe'),
'775'
)
expect(toolCache.downloadTool).not.toBeCalled()
expect(toolCache.downloadTool).not.toHaveBeenCalled()
})
test('getLatestPatchVersion() - download and return latest patch version', async () => {
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
jest.spyOn(fs, 'readFileSync').mockReturnValue('v1.27.15')
const result = await getLatestPatchVersion('1', '27')
expect(result).toBe('v1.27.15')
expect(toolCache.downloadTool).toHaveBeenCalledWith(
'https://cdn.dl.k8s.io/release/stable-1.27.txt'
)
})
test('getLatestPatchVersion() - throw error when patch version is empty', async () => {
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
jest.spyOn(fs, 'readFileSync').mockReturnValue('')
await expect(getLatestPatchVersion('1', '27')).rejects.toThrow(
'Failed to get latest patch version for 1.27'
)
})
test('getLatestPatchVersion() - throw error when download fails', async () => {
jest
.spyOn(toolCache, 'downloadTool')
.mockRejectedValue(new Error('Network error'))
await expect(getLatestPatchVersion('1', '27')).rejects.toThrow(
'Failed to get latest patch version for 1.27'
)
})
test('resolveKubectlVersion() - expands major.minor to latest patch', async () => {
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
jest.spyOn(fs, 'readFileSync').mockReturnValue('v1.27.15')
const result = await run.resolveKubectlVersion('1.27')
expect(result).toBe('v1.27.15')
})
test('resolveKubectlVersion() - returns full version unchanged', async () => {
const result = await run.resolveKubectlVersion('v1.27.15')
expect(result).toBe('v1.27.15')
})
test('resolveKubectlVersion() - adds v prefix to full version', async () => {
const result = await run.resolveKubectlVersion('1.27.15')
expect(result).toBe('v1.27.15')
})
test('resolveKubectlVersion() - expands v-prefixed major.minor to latest patch', async () => {
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
jest.spyOn(fs, 'readFileSync').mockReturnValue('v1.27.15')
const result = await run.resolveKubectlVersion('v1.27')
expect(result).toBe('v1.27.15')
})
test('run() - download specified version and set output', async () => {
jest.spyOn(core, 'getInput').mockReturnValue('v1.15.5')
@@ -194,7 +251,7 @@ describe('Testing all functions in run file.', () => {
jest.spyOn(core, 'setOutput').mockImplementation()
expect(await run.run()).toBeUndefined()
expect(toolCache.downloadTool).toHaveBeenCalledWith(
'https://storage.googleapis.com/kubernetes-release/release/stable.txt'
'https://dl.k8s.io/release/stable.txt'
)
expect(core.getInput).toHaveBeenCalledWith('version', {required: true})
expect(core.addPath).toHaveBeenCalledWith('pathToCachedTool')

View File

@@ -1,25 +1,25 @@
import * as path from 'path'
import * as util from 'util'
import * as fs from 'fs'
import * as toolCache from '@actions/tool-cache'
import * as core from '@actions/core'
import {
getkubectlDownloadURL,
getKubectlArch,
getExecutableExtension
getExecutableExtension,
getLatestPatchVersion
} from './helpers'
const kubectlToolName = 'kubectl'
const stableKubectlVersion = 'v1.15.0'
const stableVersionUrl =
'https://storage.googleapis.com/kubernetes-release/release/stable.txt'
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()
} else {
version = await resolveKubectlVersion(version)
}
const cachedPath = await downloadKubectl(version)
@@ -89,3 +89,28 @@ export async function downloadKubectl(version: string): Promise<string> {
fs.chmodSync(kubectlPath, '775')
return kubectlPath
}
export async function resolveKubectlVersion(version: string): Promise<string> {
const cleanedVersion = version.trim()
const versionMatch = cleanedVersion.match(
/^v?(?<major>\d+)\.(?<minor>\d+)(?:\.(?<patch>\d+))?$/
)
if (!versionMatch?.groups) {
throw new Error(
`Invalid version format: "${version}". Version must be in "major.minor" or "major.minor.patch" format (e.g., "1.27" or "v1.27.15").`
)
}
const {major, minor, patch} = versionMatch.groups
if (patch) {
// Full version was provided, just ensure it has a 'v' prefix
return cleanedVersion.startsWith('v')
? cleanedVersion
: `v${cleanedVersion}`
}
// Patch version is missing, fetch the latest
return await getLatestPatchVersion(major, minor)
}

View File

@@ -10,7 +10,7 @@ def get_latest_version():
time_to_sleep = 2
for _ in range(10):
response = requests.get(
'https://storage.googleapis.com/kubernetes-release/release/stable.txt')
'https://dl.k8s.io/release/stable.txt')
if response.status_code == 200:
break
print('Failed to obtain latest version info, retrying.')

View File

@@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020", "DOM"]
},
"exclude": ["node_modules", "test"]
}