Compare commits

...

7 Commits

Author SHA1 Message Date
GitHub Action 89b837d75b build 2026-04-07 20:08:00 +00:00
Suneha Bose cb028f04f3 release: prepare v5.0.0 (#232)
* release: prepare v4.1.0 changelog and version updates

* update major ver

* update ver in readme
2026-04-07 16:06:54 -04:00
dependabot[bot] f4285249b3 Bump the actions group with 2 updates (#233)
Bumps the actions group with 2 updates: [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) and [esbuild](https://github.com/evanw/esbuild).


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

Updates `esbuild` from 0.27.4 to 0.28.0
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.27.4...v0.28.0)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 25.5.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: esbuild
  dependency-version: 0.28.0
  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>
2026-04-07 21:14:27 +12:00
dependabot[bot] 9b0406cb40 Bump vite from 8.0.3 to 8.0.5 (#234) 2026-04-07 06:36:59 +12:00
dependabot[bot] 1c8fffe8b3 Bump github/codeql-action in /.github/workflows in the actions group (#231)
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.34.1 to 4.35.1
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/38697555549f1db7851b81482ff19f1fa5c4fedc...c10b8064de6f491fea524254123dbe5e09572f13)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.35.1
  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>
2026-03-31 00:36:41 +13:00
dependabot[bot] 2be70f5a52 Bump typescript in the actions group across 1 directory (#230)
Bumps the actions group with 1 update in the / directory: [typescript](https://github.com/microsoft/TypeScript).


Updates `typescript` from 5.9.3 to 6.0.2
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Commits](https://github.com/microsoft/TypeScript/compare/v5.9.3...v6.0.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-version: 6.0.2
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-26 18:51:21 -04:00
Suneha Bose 1f527c033f Migrate to ESM with esbuild, vitest (#227)
* Migrate to ESM, esbuild, vitest, and update actions/* to latest

- Update @actions/core to 3.x, @actions/exec to 3.x, @actions/io to 3.x
- Replace @vercel/ncc + babel with esbuild (build.mjs) targeting Node 20 ESM
- Replace jest/babel-jest/ts-jest with vitest and @vitest/coverage-v8
- Update tsconfig to NodeNext module resolution with strict mode
- Add explicit .js extensions to all relative imports (NodeNext requirement)
- Fix implicit any index signatures in parseCluster and parseMethod
- Migrate all test files from jest to vi.mock/vi.mocked APIs
- Fix ESM module spying limitations using vi.mock() at module level
- Fix env var test pollution in default.test.ts with afterEach cleanup

* remove build.mjs and update build script

* update pkg lock

* update pkg lock
2026-03-26 17:25:46 -04:00
27 changed files with 72209 additions and 10379 deletions
+2 -2
View File
@@ -59,7 +59,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@38697555549f1db7851b81482ff19f1fa5c4fedc # v3.29.5
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # 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@38697555549f1db7851b81482ff19f1fa5c4fedc # v3.29.5
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v3.29.5
with:
category: '/language:${{matrix.language}}'
-1
View File
@@ -331,4 +331,3 @@ node_modules
coverage
# Transpiled JS
lib/
+39
View File
@@ -1,5 +1,44 @@
# Change Log
## [5.0.0] - 2026-04-07
### Features
- #227 Migrate to ESM with esbuild, vitest
### Runtime and platform
- #222 Update Node version from 20 to 24
### Dependabot updates
- #231 Bump github/codeql-action in /.github/workflows in the actions group
- #230 Bump typescript in the actions group across 1 directory
- #228 Bump picomatch
- #226 Bump github/codeql-action in /.github/workflows in the actions group
- #223 Bump undici from 6.23.0 to 6.24.0
- #221 Bump the actions group in /.github/workflows with 2 updates
- #218 Bump the actions group in /.github/workflows with 2 updates
- #219 Bump minimatch
- #217 Bump undici and @actions/http-client
- #216 Bump github/codeql-action in /.github/workflows in the actions group
- #214 Bump the actions group in /.github/workflows with 2 updates
- #212 Bump the actions group in /.github/workflows with 2 updates
- #211 Bump the actions group with 3 updates
- #210 Bump the actions group with 2 updates
- #208 Bump @types/node from 25.0.2 to 25.0.3 in the actions group
- #209 Bump github/codeql-action in /.github/workflows in the actions group
- #206 Bump the actions group with 3 updates
- #207 Bump github/codeql-action in /.github/workflows in the actions group
- #205 Bump the actions group in /.github/workflows with 4 updates
- #204 Bump the actions group with 2 updates
- #202 Bump the actions group in /.github/workflows with 2 updates
- #203 Bump prettier from 3.6.2 to 3.7.3 in the actions group
- #201 Bump glob from 10.4.5 to 10.5.0
- #200 Bump js-yaml from 3.14.1 to 3.14.2
- #198 Bump js-yaml from 4.1.0 to 4.1.1
- #199 Bump the actions group with 2 updates
## [4.0.2] - 2025-11-13
- #[164](https://github.com/Azure/k8s-set-context/pull/164) Adding optional kubeconfig encoding variable
+4 -4
View File
@@ -19,7 +19,7 @@ Refer to the [action metadata file](./action.yml) for details about inputs. Note
### Kubeconfig approach
```yaml
- uses: azure/k8s-set-context@v4
- uses: azure/k8s-set-context@v5
with:
method: kubeconfig
kubeconfig: <your kubeconfig>
@@ -50,7 +50,7 @@ Please refer to documentation on fetching [kubeconfig for any generic K8s cluste
### Service account approach
```yaml
- uses: azure/k8s-set-context@v4
- uses: azure/k8s-set-context@v5
with:
method: service-account
k8s-url: <URL of the cluster's API server>
@@ -74,7 +74,7 @@ kubectl get secret <service-account-secret-name> -n <namespace> -o yaml
### Service account approach for arc cluster
```yaml
- uses: azure/k8s-set-context@v4
- uses: azure/k8s-set-context@v5
with:
method: service-account
cluster-type: arc
@@ -86,7 +86,7 @@ kubectl get secret <service-account-secret-name> -n <namespace> -o yaml
### Service principal approach for arc cluster
```yaml
- uses: azure/k8s-set-context@v4
- uses: azure/k8s-set-context@v5
with:
method: service-principal
cluster-type: arc
-7
View File
@@ -1,7 +0,0 @@
// babel.config.js
export default {
presets: [
'@babel/preset-env', // For handling ES modules
'@babel/preset-typescript' // For handling TypeScript
]
}
-28
View File
@@ -1,28 +0,0 @@
export default {
restoreMocks: true,
clearMocks: true,
resetMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.ts$': 'ts-jest', // Use ts-jest for TypeScript files
'^.+\\.js$': 'babel-jest' // Transform TypeScript files
},
transformIgnorePatterns: [
'/node_modules/(?!@kubernetes/client-node)/' // Make sure to transform the Kubernetes client module
],
moduleNameMapper: {
'^.+\\.css$': 'jest-transform-stub' // Handle CSS imports (if any)
},
extensionsToTreatAsEsm: ['.ts', '.tsx'], // Treat TypeScript files as ESM
verbose: true,
coverageThreshold: {
global: {
branches: 0,
functions: 40,
lines: 22,
statements: 22
}
}
}
+70335
View File
File diff suppressed because one or more lines are too long
+1704 -10221
View File
File diff suppressed because it is too large Load Diff
+12 -17
View File
@@ -1,14 +1,14 @@
{
"name": "k8s-set-context-action",
"version": "4.0.2",
"version": "5.0.0",
"private": true,
"main": "lib/index.js",
"type": "module",
"scripts": {
"prebuild": "npm i @vercel/ncc",
"build": "ncc build src/run.ts -o lib",
"test": "jest",
"test-coverage": "jest --coverage",
"build": "tsc --noEmit && esbuild src/run.ts --bundle --platform=node --target=node20 --format=esm --outfile=lib/index.js --banner:js=\"import { createRequire } from 'module';const require = createRequire(import.meta.url);\"",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test-coverage": "vitest run --coverage",
"format": "prettier --write .",
"format-check": "prettier --check .",
"prepare": "husky"
@@ -21,24 +21,19 @@
"author": "GitHub",
"license": "MIT",
"dependencies": {
"@actions/core": "^2.0.2",
"@actions/exec": "^2.0.0",
"@actions/io": "^2.0.0",
"@actions/core": "^3.0.0",
"@actions/exec": "^3.0.0",
"@actions/io": "^3.0.2",
"@kubernetes/client-node": "^1.4.0",
"husky": "^9.1.7",
"js-yaml": "^4.1.1"
},
"devDependencies": {
"@babel/preset-env": "^7.28.6",
"@babel/preset-typescript": "^7.28.5",
"@types/jest": "^30.0.0",
"@types/js-yaml": "^4.0.9",
"@types/node": "^25.0.9",
"@vercel/ncc": "^0.38.4",
"babel-jest": "^30.2.0",
"jest": "^30.2.0",
"@types/node": "^25.5.2",
"esbuild": "^0.28.0",
"prettier": "^3.8.0",
"ts-jest": "^29.4.6",
"typescript": "^5.9.3"
"typescript": "^6.0.2",
"vitest": "^4.1.1"
}
}
+16 -13
View File
@@ -1,7 +1,9 @@
import {getRequiredInputError} from '../tests/util'
import {run} from './action'
import fs from 'fs'
import * as utils from './utils'
import {vi, describe, it, expect} from 'vitest'
import {getRequiredInputError} from '../tests/util.js'
import {run} from './action.js'
vi.mock('fs')
vi.mock('./utils.js')
describe('Run', () => {
it('throws error without cluster type', async () => {
@@ -9,22 +11,23 @@ describe('Run', () => {
})
it('writes kubeconfig and sets context', async () => {
const {getKubeconfig, setContext} = await import('./utils.js')
const fs = await import('fs')
const kubeconfig = 'kubeconfig'
process.env['INPUT_CLUSTER-TYPE'] = 'default'
process.env['RUNNER_TEMP'] = '/sample/path'
jest
.spyOn(utils, 'getKubeconfig')
.mockImplementation(async () => kubeconfig)
jest.spyOn(fs, 'writeFileSync').mockImplementation(() => {})
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
jest.spyOn(utils, 'setContext').mockImplementation(() => kubeconfig)
vi.mocked(getKubeconfig).mockResolvedValue(kubeconfig)
vi.mocked(setContext).mockReturnValue(kubeconfig)
vi.mocked(fs.writeFileSync).mockImplementation(() => {})
vi.mocked(fs.chmodSync).mockImplementation(() => {})
expect(await run())
expect(utils.getKubeconfig).toHaveBeenCalled()
await run()
expect(getKubeconfig).toHaveBeenCalled()
expect(fs.writeFileSync).toHaveBeenCalled()
expect(fs.chmodSync).toHaveBeenCalled()
expect(utils.setContext).toHaveBeenCalled()
expect(setContext).toHaveBeenCalled()
})
})
+3 -3
View File
@@ -1,8 +1,8 @@
import * as core from '@actions/core'
import * as path from 'path'
import * as fs from 'fs'
import {Cluster, parseCluster} from './types/cluster'
import {setContext, getKubeconfig} from './utils'
import {Cluster, parseCluster} from './types/cluster.js'
import {setContext, getKubeconfig} from './utils.js'
/**
* Sets the Kubernetes context based on supplied action inputs
@@ -14,7 +14,7 @@ export async function run() {
required: true
})
)
const runnerTempDirectory: string = process.env['RUNNER_TEMP']
const runnerTempDirectory: string = process.env['RUNNER_TEMP'] ?? ''
const kubeconfigPath: string = path.join(
runnerTempDirectory,
`kubeconfig_${Date.now()}`
+12 -9
View File
@@ -1,8 +1,11 @@
import * as actions from '@actions/exec'
import {vi, describe, test, it, expect, beforeEach} from 'vitest'
import * as io from '@actions/io'
import {getRequiredInputError} from '../../tests/util'
import {getArcKubeconfig, KUBECONFIG_LOCATION} from './arc'
import * as az from './azCommands'
import {getRequiredInputError} from '../../tests/util.js'
import {getArcKubeconfig, KUBECONFIG_LOCATION} from './arc.js'
import * as az from './azCommands.js'
vi.mock('@actions/io')
vi.mock('./azCommands.js')
describe('Arc kubeconfig', () => {
test('it throws error without resource group', async () => {
@@ -28,11 +31,11 @@ describe('Arc kubeconfig', () => {
process.env['INPUT_RESOURCE-GROUP'] = group
process.env['INPUT_CLUSTER-NAME'] = name
jest.spyOn(io, 'which').mockImplementation(async () => path)
jest.spyOn(az, 'runAzCliCommand').mockImplementation(async () => {})
jest
.spyOn(az, 'runAzKubeconfigCommandBlocking')
.mockImplementation(async () => kubeconfig)
vi.mocked(io.which).mockResolvedValue(path)
vi.mocked(az.runAzCliCommand).mockResolvedValue(undefined)
vi.mocked(az.runAzKubeconfigCommandBlocking).mockResolvedValue(
kubeconfig
)
})
it('throws an error without method', async () => {
+2 -2
View File
@@ -1,8 +1,8 @@
import * as core from '@actions/core'
import * as io from '@actions/io'
import {Method, parseMethod} from '../types/method'
import {Method, parseMethod} from '../types/method.js'
import * as path from 'path'
import {runAzCliCommand, runAzKubeconfigCommandBlocking} from './azCommands'
import {runAzCliCommand, runAzKubeconfigCommandBlocking} from './azCommands.js'
const RUNNER_TEMP: string = process.env['RUNNER_TEMP'] || ''
export const KUBECONFIG_LOCATION: string = path.join(
+6 -3
View File
@@ -1,14 +1,17 @@
import {vi, describe, test, expect, beforeEach} from 'vitest'
import * as actions from '@actions/exec'
import {runAzCliCommand} from './azCommands'
import {runAzCliCommand} from './azCommands.js'
vi.mock('@actions/exec')
describe('Az commands', () => {
test('it runs an az cli command', async () => {
const path = 'path'
const args = ['args']
jest.spyOn(actions, 'exec').mockImplementation(async () => 0)
vi.mocked(actions.exec).mockResolvedValue(0)
expect(await runAzCliCommand(path, args))
await runAzCliCommand(path, args)
expect(actions.exec).toHaveBeenCalledWith(path, args, {})
})
})
+1 -2
View File
@@ -1,6 +1,5 @@
import * as fs from 'fs'
import {ExecOptions} from '@actions/exec/lib/interfaces'
import {exec} from '@actions/exec'
import {ExecOptions, exec} from '@actions/exec'
import {spawn} from 'child_process'
const AZ_TIMEOUT_SECONDS: number = 120
+15 -24
View File
@@ -1,7 +1,7 @@
import {vi, describe, test, expect, beforeEach, afterEach} from 'vitest'
import * as fs from 'fs'
import * as core from '@actions/core'
import {getRequiredInputError} from '../../tests/util'
import {createKubeconfig, getDefaultKubeconfig} from './default'
import {getRequiredInputError} from '../../tests/util.js'
import {createKubeconfig, getDefaultKubeconfig} from './default.js'
describe('Default kubeconfig', () => {
test('it creates a kubeconfig with proper format', () => {
@@ -51,6 +51,11 @@ describe('Default kubeconfig', () => {
process.env['INPUT_METHOD'] = 'default'
})
afterEach(() => {
delete process.env['INPUT_KUBECONFIG']
delete process.env['INPUT_KUBECONFIG-ENCODING']
})
test('it throws error without kubeconfig', () => {
expect(() => getDefaultKubeconfig()).toThrow(
getRequiredInputError('kubeconfig')
@@ -66,39 +71,25 @@ describe('Default kubeconfig', () => {
test('returns kubeconfig as plaintext when encoding is plaintext', () => {
const kc = 'example kc'
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
if (name === 'method') return 'default'
if (name === 'kubeconfig-encoding') return 'plaintext'
if (name === 'kubeconfig') return kc
return ''
})
process.env['INPUT_KUBECONFIG'] = kc
process.env['INPUT_KUBECONFIG-ENCODING'] = 'plaintext'
expect(getDefaultKubeconfig()).toBe(kc)
})
test('it gets default config through base64 kubeconfig input', () => {
const kc = 'example kc'
const base64Kc = Buffer.from(kc, 'utf-8').toString('base64')
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
if (name === 'method') return 'default'
if (name === 'kubeconfig-encoding') return 'base64'
if (name === 'kubeconfig') return base64Kc
return ''
})
process.env['INPUT_KUBECONFIG'] = base64Kc
process.env['INPUT_KUBECONFIG-ENCODING'] = 'base64'
expect(getDefaultKubeconfig()).toBe(kc)
})
test('it throws error for unknown kubeconfig-encoding', () => {
const kc = 'example kc'
const unknownEncoding = 'foobar'
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
if (name === 'method') return 'default'
if (name === 'kubeconfig-encoding') return unknownEncoding
if (name === 'kubeconfig') return kc
return ''
})
process.env['INPUT_KUBECONFIG'] = kc
process.env['INPUT_KUBECONFIG-ENCODING'] = 'foobar'
expect(() => getDefaultKubeconfig()).toThrow(
"Invalid kubeconfig-encoding: 'foobar'. Must be 'plaintext' or 'base64'."
+2 -2
View File
@@ -1,8 +1,8 @@
import * as core from '@actions/core'
import * as jsyaml from 'js-yaml'
import {KubeConfig} from '@kubernetes/client-node'
import {K8sSecret, parseK8sSecret} from '../types/k8sSecret'
import {Method, parseMethod} from '../types/method'
import {K8sSecret, parseK8sSecret} from '../types/k8sSecret.js'
import {Method, parseMethod} from '../types/method.js'
/**
* Gets the kubeconfig based on provided method for a default Kubernetes cluster
+1 -1
View File
@@ -1,4 +1,4 @@
import {run} from './action'
import {run} from './action.js'
import * as core from '@actions/core'
// Run the application
+3 -2
View File
@@ -1,8 +1,9 @@
import {Cluster, parseCluster} from './cluster'
import {describe, test, expect} from 'vitest'
import {Cluster, parseCluster} from './cluster.js'
describe('Cluster type', () => {
test('it has required values', () => {
const vals = <any>Object.values(Cluster)
const vals = Object.values(Cluster) as string[]
expect(vals.includes('arc')).toBe(true)
expect(vals.includes('generic')).toBe(true)
})
+7 -6
View File
@@ -8,9 +8,10 @@ export enum Cluster {
* @param str The cluster type (case insensitive)
* @returns The Cluster enum or undefined if it can't be parsed
*/
export const parseCluster = (str: string): Cluster | undefined =>
Cluster[
Object.keys(Cluster).filter(
(k) => Cluster[k].toString().toLowerCase() === str.toLowerCase()
)[0] as keyof typeof Cluster
]
export const parseCluster = (str: string): Cluster | undefined => {
const key = Object.keys(Cluster).find(
(k) =>
Cluster[k as keyof typeof Cluster].toLowerCase() === str.toLowerCase()
) as keyof typeof Cluster | undefined
return key !== undefined ? Cluster[key] : undefined
}
+2 -1
View File
@@ -1,4 +1,5 @@
import {parseK8sSecret, K8sSecret} from './k8sSecret'
import {describe, test, expect} from 'vitest'
import {parseK8sSecret} from './k8sSecret.js'
describe('K8sSecret type', () => {
describe('Parsing from any', () => {
+3 -2
View File
@@ -1,8 +1,9 @@
import {Method, parseMethod} from './method'
import {describe, test, expect} from 'vitest'
import {Method, parseMethod} from './method.js'
describe('Method type', () => {
test('it has required values', () => {
const vals = <any>Object.values(Method)
const vals = Object.values(Method) as string[]
expect(vals.includes('kubeconfig')).toBe(true)
expect(vals.includes('service-account')).toBe(true)
expect(vals.includes('service-principal')).toBe(true)
+7 -6
View File
@@ -9,9 +9,10 @@ export enum Method {
* @param str The method (case insensitive)
* @returns The Method enum or undefined if it can't be parsed
*/
export const parseMethod = (str: string): Method | undefined =>
Method[
Object.keys(Method).filter(
(k) => Method[k].toString().toLowerCase() === str.toLowerCase()
)[0] as keyof typeof Method
]
export const parseMethod = (str: string): Method | undefined => {
const key = Object.keys(Method).find(
(k) =>
Method[k as keyof typeof Method].toLowerCase() === str.toLowerCase()
) as keyof typeof Method | undefined
return key !== undefined ? Method[key] : undefined
}
+11 -10
View File
@@ -1,25 +1,26 @@
import {vi, describe, test, expect} from 'vitest'
import fs from 'fs'
import * as arc from './kubeconfigs/arc'
import * as def from './kubeconfigs/default'
import {Cluster} from './types/cluster'
import {getKubeconfig, setContext} from './utils'
import * as arc from './kubeconfigs/arc.js'
import * as def from './kubeconfigs/default.js'
import {Cluster} from './types/cluster.js'
import {getKubeconfig, setContext} from './utils.js'
describe('Utils', () => {
describe('get kubeconfig', () => {
test('it gets arc kubeconfig when type is arc', async () => {
const arcKubeconfig = 'arckubeconfig'
jest
.spyOn(arc, 'getArcKubeconfig')
.mockImplementation(async () => arcKubeconfig)
vi.spyOn(arc, 'getArcKubeconfig').mockImplementation(
async () => arcKubeconfig
)
expect(await getKubeconfig(Cluster.ARC)).toBe(arcKubeconfig)
})
test('it defaults to default kubeconfig', async () => {
const defaultKubeconfig = 'arckubeconfig'
jest
.spyOn(def, 'getDefaultKubeconfig')
.mockImplementation(() => defaultKubeconfig)
vi.spyOn(def, 'getDefaultKubeconfig').mockImplementation(
() => defaultKubeconfig
)
expect(await getKubeconfig(undefined)).toBe(defaultKubeconfig)
expect(await getKubeconfig(Cluster.GENERIC)).toBe(defaultKubeconfig)
+3 -3
View File
@@ -1,9 +1,9 @@
import * as core from '@actions/core'
import * as fs from 'fs'
import {KubeConfig} from '@kubernetes/client-node'
import {getDefaultKubeconfig} from './kubeconfigs/default'
import {getArcKubeconfig} from './kubeconfigs/arc'
import {Cluster} from './types/cluster'
import {getDefaultKubeconfig} from './kubeconfigs/default.js'
import {getArcKubeconfig} from './kubeconfigs/arc.js'
import {Cluster} from './types/cluster.js'
/**
* Gets the kubeconfig based on Kubernetes cluster type
+9 -10
View File
@@ -1,15 +1,14 @@
{
"compilerOptions": {
"baseUrl": ".",
"module": "ESNext", // or "NodeNext" depending on your setup
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "ES2020",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": "./src",
"outDir": "./lib",
"noImplicitAny": false,
"skipLibCheck": true,
"paths": {
"@actions/core": ["node_modules/@actions/core"],
"@kubernetes/client-node": ["node_modules/@kubernetes/client-node"]
}
"noEmit": true,
"types": ["node", "vitest/globals"]
},
"exclude": ["node_modules", "tests", "src/**/*.test.ts"]
"exclude": ["node_modules", "**/*.test.ts", "vitest.config.ts", "tests/"]
}
+10
View File
@@ -0,0 +1,10 @@
import {defineConfig} from 'vitest/config'
export default defineConfig({
test: {
globals: true,
environment: 'node',
include: ['**/*.test.ts'],
clearMocks: true
}
})