mirror of
https://github.com/Azure/k8s-set-context.git
synced 2026-06-23 15:29:30 +08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 212a19233d | |||
| 61a0d19c30 | |||
| 5e6a3a4114 | |||
| 2d160654d6 | |||
| a57aa49538 | |||
| a72463cdd7 | |||
| f2d80c8192 | |||
| 3624a1fc64 | |||
| ab43e1cba5 | |||
| f7b05df5e5 | |||
| 6332864ca0 | |||
| d7e25ce077 |
@@ -0,0 +1,18 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: npm
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
groups:
|
||||||
|
actions:
|
||||||
|
patterns:
|
||||||
|
- '*'
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: .github/workflows
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
groups:
|
||||||
|
actions:
|
||||||
|
patterns:
|
||||||
|
- '*'
|
||||||
@@ -1,14 +1,18 @@
|
|||||||
name: Create release PR
|
name: Release Project
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- CHANGELOG.md
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
|
||||||
release:
|
|
||||||
description: 'Define release version (ex: v1, v2, v3)'
|
|
||||||
required: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release-pr:
|
release:
|
||||||
uses: OliverMKing/javascript-release-workflow/.github/workflows/release-pr.yml@main
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: write
|
||||||
|
uses: Azure/action-release-workflows/.github/workflows/release_js_project.yaml@v1
|
||||||
with:
|
with:
|
||||||
release: ${{ github.event.inputs.release }}
|
changelogPath: ./CHANGELOG.md
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
## [4.0.1] - 2024-09-06
|
||||||
|
|
||||||
|
- #90 update dev dependencies with Typescript to 5
|
||||||
|
- #89 Adding dependabot
|
||||||
|
|
||||||
|
## [4.0.0] - 2024-02-13
|
||||||
|
|
||||||
|
- #83 update to node20 as node16 is deprecated
|
||||||
@@ -19,7 +19,7 @@ Refer to the [action metadata file](./action.yml) for details about inputs. Note
|
|||||||
### Kubeconfig approach
|
### Kubeconfig approach
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: azure/k8s-set-context@v2
|
- uses: azure/k8s-set-context@v4
|
||||||
with:
|
with:
|
||||||
method: kubeconfig
|
method: kubeconfig
|
||||||
kubeconfig: <your kubeconfig>
|
kubeconfig: <your kubeconfig>
|
||||||
@@ -50,7 +50,7 @@ Please refer to documentation on fetching [kubeconfig for any generic K8s cluste
|
|||||||
### Service account approach
|
### Service account approach
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: azure/k8s-set-context@v2
|
- uses: azure/k8s-set-context@v4
|
||||||
with:
|
with:
|
||||||
method: service-account
|
method: service-account
|
||||||
k8s-url: <URL of the cluster's API server>
|
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
|
### Service account approach for arc cluster
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: azure/k8s-set-context@v2
|
- uses: azure/k8s-set-context@v4
|
||||||
with:
|
with:
|
||||||
method: service-account
|
method: service-account
|
||||||
cluster-type: arc
|
cluster-type: arc
|
||||||
@@ -86,7 +86,7 @@ kubectl get secret <service-account-secret-name> -n <namespace> -o yaml
|
|||||||
### Service principal approach for arc cluster
|
### Service principal approach for arc cluster
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: azure/k8s-set-context@v2
|
- uses: azure/k8s-set-context@v4
|
||||||
with:
|
with:
|
||||||
method: service-principal
|
method: service-principal
|
||||||
cluster-type: arc
|
cluster-type: arc
|
||||||
|
|||||||
+1
-1
@@ -35,5 +35,5 @@ inputs:
|
|||||||
branding:
|
branding:
|
||||||
color: 'blue'
|
color: 'blue'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'lib/index.js'
|
main: 'lib/index.js'
|
||||||
|
|||||||
+8820
-7228
File diff suppressed because it is too large
Load Diff
Generated
+2372
-1757
File diff suppressed because it is too large
Load Diff
+9
-8
@@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "k8s-set-context-action",
|
"name": "k8s-set-context-action",
|
||||||
"version": "1.0.0",
|
"version": "4.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"prebuild": "npm i @vercel/ncc",
|
||||||
"build": "ncc build src/run.ts -o lib",
|
"build": "ncc build src/run.ts -o lib",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test-coverage": "jest --coverage",
|
"test-coverage": "jest --coverage",
|
||||||
@@ -25,13 +26,13 @@
|
|||||||
"js-yaml": "^4.1.0"
|
"js-yaml": "^4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^28.1.2",
|
"@types/jest": "^29.5.11",
|
||||||
"@types/js-yaml": "^4.0.4",
|
"@types/js-yaml": "^4.0.4",
|
||||||
"@types/node": "^16.0.0",
|
"@types/node": "^20.11.8",
|
||||||
"@vercel/ncc": "^0.34.0",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"jest": "^28.1.1",
|
"jest": "^29.7.0",
|
||||||
"prettier": "2.7.1",
|
"prettier": "^3.2.5",
|
||||||
"ts-jest": "^28.0.5",
|
"ts-jest": "^29.2.5",
|
||||||
"typescript": "4.7.4"
|
"typescript": "^5.3.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {getRequiredInputError} from '../tests/util'
|
import {getRequiredInputError} from '../tests/util'
|
||||||
import {run} from './run'
|
import {run} from './action'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
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'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Kubernetes context based on supplied action inputs
|
||||||
|
*/
|
||||||
|
export async function run() {
|
||||||
|
// get inputs
|
||||||
|
const clusterType: Cluster | undefined = parseCluster(
|
||||||
|
core.getInput('cluster-type', {
|
||||||
|
required: true
|
||||||
|
})
|
||||||
|
)
|
||||||
|
const runnerTempDirectory: string = process.env['RUNNER_TEMP']
|
||||||
|
const kubeconfigPath: string = path.join(
|
||||||
|
runnerTempDirectory,
|
||||||
|
`kubeconfig_${Date.now()}`
|
||||||
|
)
|
||||||
|
|
||||||
|
// get kubeconfig and update context
|
||||||
|
const kubeconfig: string = await getKubeconfig(clusterType)
|
||||||
|
const kubeconfigWithContext: string = setContext(kubeconfig)
|
||||||
|
|
||||||
|
// output kubeconfig
|
||||||
|
core.debug(`Writing kubeconfig contents to ${kubeconfigPath}`)
|
||||||
|
fs.writeFileSync(kubeconfigPath, kubeconfigWithContext)
|
||||||
|
fs.chmodSync(kubeconfigPath, '600')
|
||||||
|
core.debug('Setting KUBECONFIG environment variable')
|
||||||
|
core.exportVariable('KUBECONFIG', kubeconfigPath)
|
||||||
|
}
|
||||||
+1
-32
@@ -1,36 +1,5 @@
|
|||||||
|
import {run} from './action'
|
||||||
import * as core from '@actions/core'
|
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'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Kubernetes context based on supplied action inputs
|
|
||||||
*/
|
|
||||||
export async function run() {
|
|
||||||
// get inputs
|
|
||||||
const clusterType: Cluster | undefined = parseCluster(
|
|
||||||
core.getInput('cluster-type', {
|
|
||||||
required: true
|
|
||||||
})
|
|
||||||
)
|
|
||||||
const runnerTempDirectory: string = process.env['RUNNER_TEMP']
|
|
||||||
const kubeconfigPath: string = path.join(
|
|
||||||
runnerTempDirectory,
|
|
||||||
`kubeconfig_${Date.now()}`
|
|
||||||
)
|
|
||||||
|
|
||||||
// get kubeconfig and update context
|
|
||||||
const kubeconfig: string = await getKubeconfig(clusterType)
|
|
||||||
const kubeconfigWithContext: string = setContext(kubeconfig)
|
|
||||||
|
|
||||||
// output kubeconfig
|
|
||||||
core.debug(`Writing kubeconfig contents to ${kubeconfigPath}`)
|
|
||||||
fs.writeFileSync(kubeconfigPath, kubeconfigWithContext)
|
|
||||||
fs.chmodSync(kubeconfigPath, '600')
|
|
||||||
core.debug('Setting KUBECONFIG environment variable')
|
|
||||||
core.exportVariable('KUBECONFIG', kubeconfigPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run the application
|
// Run the application
|
||||||
run().catch(core.setFailed)
|
run().catch(core.setFailed)
|
||||||
|
|||||||
Reference in New Issue
Block a user