kube-workflow
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -8,3 +8,3 @@ const os = require("os") | ||
const shell = require("./utils/shell") | ||
const asyncShell = require("./utils/asyncShell") | ||
@@ -17,3 +17,3 @@ const generateValues = require("./values") | ||
const logger = require("./logger") | ||
const logger = require("./utils/logger") | ||
@@ -47,5 +47,8 @@ module.exports = async (envVars) => { | ||
logger.debug("Prepare charts and overlays") | ||
logger.debug("Merge charts and overlays") | ||
await fs.copy(`${KUBEWORKFLOW_PATH}/chart`, ".") | ||
await Promise.all([ | ||
fs.copy("./env", "./env.autodevops"), | ||
fs.copy("./common", "./common.autodevops") | ||
]) | ||
const workspaceKubeworkflowPath = `${WORKSPACE_PATH}${WORKSPACE_SUBPATH}` | ||
@@ -63,3 +66,3 @@ if (await fs.pathExists(workspaceKubeworkflowPath)){ | ||
if (await fs.pathExists(filePath)) { | ||
return yaml.load(await fs.readFile(filePath)) | ||
return yaml.load(await fs.readFile(filePath, {encoding: "utf-8"})) | ||
} | ||
@@ -79,3 +82,3 @@ } | ||
logger.debug("Compiling additional subcharts instances") | ||
const chart = compileChart(values) | ||
const chart = await compileChart(values) | ||
@@ -103,3 +106,3 @@ | ||
const { HELM_ARGS = "" } = envVars | ||
let baseManifests = shell(`helm template -f values.json ${HELM_ARGS} .`) | ||
let baseManifests = await asyncShell(`helm template -f values.json ${HELM_ARGS} .`) | ||
@@ -110,6 +113,6 @@ logger.debug("Set default namespace") | ||
logger.debug("Write base manifests file") | ||
await fs.writeFile("manifests.base.yaml", baseManifests) | ||
await fs.writeFile("base/manifests.yaml", baseManifests) | ||
logger.debug("Build final manifests using kustomize") | ||
const manifests = shell(`kustomize build --load-restrictor=LoadRestrictionsNone "env/${ENVIRONMENT}"`) | ||
const manifests = await asyncShell(`kustomize build --load-restrictor=LoadRestrictionsNone env/${ENVIRONMENT}`) | ||
@@ -116,0 +119,0 @@ logger.debug("Write final manifests file") |
@@ -1,6 +0,6 @@ | ||
const fs = require('fs'); | ||
const fs = require('fs-extra'); | ||
const yaml = require('js-yaml'); | ||
module.exports = (values) => { | ||
const chart = yaml.load(fs.readFileSync("Chart.yaml")) | ||
module.exports = async (values) => { | ||
const chart = yaml.load(await fs.readFile("Chart.yaml", { encoding: "utf-8" })) | ||
@@ -27,3 +27,3 @@ const { dependencies } = chart | ||
} | ||
fs.writeFileSync("Chart.yaml", yaml.dump(chart)) | ||
await fs.writeFile("Chart.yaml", yaml.dump(chart)) | ||
@@ -30,0 +30,0 @@ for (const {name, alias} of dependencies){ |
@@ -8,6 +8,4 @@ const fs = require('fs-extra'); | ||
const miniHash = require("./utils/miniHash") | ||
const logger = require("./logger") | ||
const logger = require("./utils/logger") | ||
fs.mkdirSync("uses", {recursive: true}) | ||
const downloadingPromises = {} | ||
@@ -20,3 +18,3 @@ | ||
let target = `uses/${slug}` | ||
if (!fs.existsSync(`${process.cwd()}/${target}`)){ | ||
if (!await fs.pathExists(`${process.cwd()}/${target}`)){ | ||
let loading = downloadingPromises[slug] | ||
@@ -44,3 +42,3 @@ if (!loading){ | ||
if (file){ | ||
values = yaml.load(fs.readFileSync(file)) | ||
values = yaml.load(await fs.readFile(file, { encoding: "utf-8" })) | ||
} | ||
@@ -47,0 +45,0 @@ if (!values){ |
@@ -1,2 +0,2 @@ | ||
const fs = require('fs'); | ||
const fs = require('fs-extra'); | ||
@@ -3,0 +3,0 @@ const envsDir = `${__dirname}/envs` |
@@ -1,17 +0,35 @@ | ||
const { execFile } = require("child_process"); | ||
const { spawn } = require('child_process'); | ||
const logger = require("./logger") | ||
const promiseFromChildProcess = (child) => { | ||
const out = [] | ||
child.stdout.on("data", (data)=>{ | ||
out.push(data) | ||
}) | ||
const err = [] | ||
child.stderr.on("data", (data) => { | ||
err.push(data) | ||
}) | ||
return new Promise(function (resolve, reject) { | ||
child.addListener("error", reject); | ||
child.addListener("exit", resolve); | ||
child.on("close", (code)=>{ | ||
if (code===0){ | ||
if (err.length>0){ | ||
logger.warn(err.join()) | ||
} | ||
resolve(out.join()) | ||
}else{ | ||
reject(err.join()) | ||
} | ||
}); | ||
}); | ||
} | ||
const asyncShell = ([cmd, ...args], options = {}, pipe = true) => { | ||
const asyncShell = (arg, options = {}) => { | ||
if(typeof arg === "string"){ | ||
arg = arg.split(" ").filter(arg=>!!arg) | ||
} | ||
const [cmd, ...args] = arg | ||
const defaultOptions = { encoding: "utf8" } | ||
const childProcess = execFile(cmd, args, {...defaultOptions, ...options}) | ||
if (pipe) { | ||
childProcess.stdout.pipe(process.stdout) | ||
childProcess.stderr.pipe(process.stderr) | ||
} | ||
const childProcess = spawn(cmd, args, {...defaultOptions, ...options}) | ||
return promiseFromChildProcess(childProcess) | ||
@@ -18,0 +36,0 @@ } |
{ | ||
"name": "kube-workflow", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"repository": "git@github.com:SocialGouv/kube-workflow.git", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -36,3 +36,3 @@ # `socialgouv/kube-workflow` 🚀 | ||
## Merge commons manifests as helm templates | ||
Every yaml file in `.kube-workflow/chart/templates` will be merged with the helm Chart `templates` folder before the build. | ||
Every yaml file in `.kube-workflow/templates` will be merged with the helm Chart `templates` folder before the build. | ||
@@ -44,3 +44,3 @@ All theses files can use the Helm templating syntax (or not if you don't need it, helm template is a superset of yaml). | ||
## Merge manifests per environment as helm templates | ||
Every yaml files in `.kube-workflow/env/$ENVIRONMENT` will be merged with the helm Chart `templates` folder before the build, according to the `environment` input (dev | preprod | prod). | ||
Every yaml files in `.kube-workflow/env/$ENVIRONMENT/templates` will be merged with the helm Chart `templates` folder before the build, according to the `environment` input (dev | preprod | prod). | ||
@@ -77,3 +77,3 @@ All theses files can use the Helm templating syntax. | ||
resources: | ||
- ../../autodevops/common | ||
- ../../common.autodevops | ||
@@ -87,4 +87,4 @@ patches: | ||
resources: | ||
# - ../manifests.base.yaml # here is if you want to optout | ||
- ../autodevops/common # here is if you want to extends from autodevops default settings | ||
# - ../base # here is if you want to optout | ||
- ../common.autodevops # here is if you want to extends from autodevops default settings | ||
@@ -105,13 +105,13 @@ patches: | ||
kind: Deployment | ||
path: ../../patches/kapp-delete-orphan.yaml | ||
path: patches/kapp-delete-orphan.yaml | ||
- target: | ||
kind: Service | ||
path: ../../patches/kapp-delete-orphan.yaml | ||
path: patches/kapp-delete-orphan.yaml | ||
- target: | ||
kind: Ingress | ||
path: ../../patches/kapp-delete-orphan.yaml | ||
path: patches/kapp-delete-orphan.yaml | ||
# - target: | ||
# kind: Service | ||
# path: ../patches/kapp.yaml | ||
# path: patches/kapp.yaml | ||
``` | ||
@@ -122,3 +122,4 @@ | ||
### Test Helm chart generation | ||
required: | ||
#### required: | ||
- helm v3 [install guide](https://helm.sh/docs/intro/install/) | ||
@@ -135,4 +136,11 @@ ```sh | ||
test with local kube-workflow repository and local project | ||
#### developments on your project, easy test, got to your project directory | ||
```sh | ||
npx kube-workflow b | ||
``` | ||
#### developments on kubeworkflow, test with local kube-workflow repository and local project | ||
```sh | ||
# get kube-workflow | ||
@@ -160,3 +168,3 @@ export KUBEWORKFLOW_PATH=$PWD/kube-workflow | ||
### Development | ||
### Development resources | ||
@@ -191,4 +199,2 @@ #### helm templates | ||
#### repo cycle automation | ||
- add releaser script with changelog generation (triggerable locally) | ||
- run tests on push (via simple github action) | ||
- build docker image for default runner image | ||
@@ -195,0 +201,0 @@ via itself with jobs/docker-build, et la boucle est bouclée |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
458068
442
202
131