Compare commits

..

No commits in common. "main" and "0.0.1" have entirely different histories.
main ... 0.0.1

6 changed files with 14 additions and 32 deletions

View File

@ -1,6 +1,6 @@
# action-kubernetes-login
This action create kubeconfig
This action prints "Hello World" or "Hello" + the name of a person to greet to the log.
## Inputs
@ -13,9 +13,8 @@ This action create kubeconfig
## Example usage
```yaml
uses: git.qtoa.cn/actions/action-kubernetes-login@0.0.6
uses: git.qtoa.cn/actions/action-kubernetes-login@0.0.1
with:
kubeconfig: ${{ secrets.KUBE_CONFIG }}
configFileName: config
force: true
```

View File

@ -4,10 +4,7 @@ inputs:
kubeconfig:
description: 'kubeconfig text'
required: true
configFileName:
description: 'config file name in $Home/.kube'
required: false
default: 'config'
default: ''
force:
description: 'force override'
required: false

15
dist/index.js vendored
View File

@ -26587,27 +26587,20 @@ var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
const core = __nccwpck_require__(2186);
const { writeFileSync, existsSync, mkdirSync } = __nccwpck_require__(7147);
const { mkdir, writeFileSync, existsSync } = __nccwpck_require__(7147);
const os = __nccwpck_require__(2037);
const path = __nccwpck_require__(1017);
try {
// `who-to-greet` input defined in action metadata file
const kubeconfig = core.getInput('kubeconfig');
if(!kubeconfig){
throw {
message: "kubeconfig should not be empty"
}
}
const parentDir = path.join(os.homedir(),".kube")
mkdirSync(parentDir,{recursive:true})
const configFileName = core.getInput("configFileName")
const configFile = path.join(parentDir,configFileName)
mkdir(parentDir,{recursive:true})
const configFile = path.join(parentDir,"config")
if(existsSync(configFile) && !core.getBooleanInput("force")){
throw {
message:`.kube/${configFileName} exists`
message:".kube/config exists"
}
}
core.info(`write to ${configFile}`)
writeFileSync(configFile,kubeconfig)
core.info(`save kubeconfig to ${configFile}`);
} catch (error) {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "action-kubernetes-login",
"version": "0.0.5",
"version": "0.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "action-kubernetes-login",
"version": "0.0.5",
"version": "0.0.0",
"dependencies": {
"@actions/core": "^1.10.1"
},

View File

@ -1,6 +1,6 @@
{
"name": "action-kubernetes-login",
"version": "0.0.5",
"version": "0.0.0",
"type": "commonjs",
"scripts": {
"build": "ncc build src/index.js -o dist"

View File

@ -1,25 +1,18 @@
const core = require('@actions/core');
const { writeFileSync, existsSync, mkdirSync } = require('fs');
const { mkdir, writeFileSync, existsSync } = require('fs');
const os = require('os');
const path = require('path');
try {
// `who-to-greet` input defined in action metadata file
const kubeconfig = core.getInput('kubeconfig');
if(!kubeconfig){
throw {
message: "kubeconfig should not be empty"
}
}
const parentDir = path.join(os.homedir(),".kube")
mkdirSync(parentDir,{recursive:true})
const configFileName = core.getInput("configFileName")
const configFile = path.join(parentDir,configFileName)
mkdir(parentDir,{recursive:true})
const configFile = path.join(parentDir,"config")
if(existsSync(configFile) && !core.getBooleanInput("force")){
throw {
message:`.kube/${configFileName} exists`
message:".kube/config exists"
}
}
core.info(`write to ${configFile}`)
writeFileSync(configFile,kubeconfig)
core.info(`save kubeconfig to ${configFile}`);
} catch (error) {