Socket
Socket
Sign inDemoInstall

kube-workflow

Package Overview
Dependencies
Maintainers
1
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kube-workflow - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

.git/objects/pack/pack-ca758c086fc98e8648b887d8d81942bbac786e41.idx

21

action/build/builder.js

@@ -21,3 +21,6 @@ const os = require("os")

const builder = async (envVars) => {
module.exports = async (envVars) => {
buildCtx.provide()
asyncShell.ctx.provide()
if (!envVars) {

@@ -165,14 +168,12 @@ envVars = getEnv()

logger.debug(`Write final manifests file`)
await fs.writeFile(`${KWBUILD_PATH}/manifests.yaml`, manifests)
const manifestsFile = `${KWBUILD_PATH}/manifests.yaml`
await fs.writeFile(manifestsFile, manifests)
logger.debug(`Built manifests: ${KWBUILD_PATH}/manifests.yaml`)
return manifests
return {
manifestsFile,
manifests,
values,
}
}
module.exports = async (envVars) => {
buildCtx.provide()
asyncShell.ctx.provide()
const manifests = await builder(envVars)
return manifests
}

@@ -11,8 +11,10 @@ const yaml = require("js-yaml")

}
if (!manifest.metadata) {
manifest.metadata = {}
if (manifest.kind !== "Namespace") {
if (!manifest.metadata) {
manifest.metadata = {}
}
if (!manifest.metadata.namespace) {
manifest.metadata.namespace = defaultNamespace
}
}
if (!manifest.metadata.namespace) {
manifest.metadata.namespace = defaultNamespace
}
manifests.push(yaml.dump(manifest))

@@ -19,0 +21,0 @@ }

module.exports = {
REPOSITORY: "GITHUB_REPOSITORY",
GIT_REPOSITORY: "GITHUB_REPOSITORY",
GIT_HEAD_REF: "GITHUB_HEAD_REF",

@@ -4,0 +4,0 @@ GIT_REF: "GITHUB_REF",

const pino = require("pino")
const pretty = require("pino-pretty")
const logger = pino(pretty())
if (
process.env.DEBUG &&
process.env.DEBUG !== "0" &&
process.env.DEBUG !== "false"
) {
logger.level = pino.levels.values.debug
const logger = pino(
pretty({
translateTime: "yyyy-mm-dd HH:mm:ss",
ignore: "pid,hostname",
})
)
const configureDebug = (debug) => {
if (debug && debug !== "0" && debug !== "false") {
logger.level = pino.levels.values.debug
}
}
configureDebug(process.env.DEBUG)
module.exports = logger
module.exports.configureDebug = configureDebug

@@ -5,8 +5,10 @@ const { generate } = require("@socialgouv/env-slug")

const versionTagRe = /v[0-9]*/
function generateValues() {
const {
REPOSITORY,
ENVIRONMENT,
RANCHER_PROJECT_ID,
RANCHER_PROJECT_NAME,
GIT_REPOSITORY,
GIT_REF,

@@ -17,8 +19,7 @@ GIT_SHA,

const gitBranch = GIT_HEAD_REF || GIT_REF
const branchName = gitBranch
const gitBranch = (GIT_HEAD_REF || GIT_REF)
.replace("refs/heads/", "")
.replace("refs/tags/", "")
const branchSlug = generate(branchName)
const branchSlug = generate(gitBranch)

@@ -30,3 +31,3 @@ const env = ENVIRONMENT

const repository = REPOSITORY
const repository = GIT_REPOSITORY
const repositoryName = repository.split("/").pop()

@@ -38,3 +39,3 @@

? `${repositoryName}-preprod`
: generate(`${repositoryName}-${branchName}`)
: generate(`${repositoryName}-${gitBranch}`)

@@ -45,5 +46,5 @@ const namespace = isProduction

? `${repositoryName}-preprod`
: generate(`${repositoryName}-${branchName}`)
: generate(`${repositoryName}-${gitBranch}`)
const isRenovate = branchName.startsWith("renovate")
const isRenovate = gitBranch.startsWith("renovate")

@@ -55,4 +56,4 @@ const ttl = isDev ? (isRenovate ? "1d" : "7d") : ""

? `preprod-${sha}`
: gitBranch.startsWith("refs/tags/")
? (gitBranch.split("/").pop() || "").substring(1)
: versionTagRe.test(gitBranch)
? gitBranch
: `sha-${sha}`

@@ -99,3 +100,4 @@

const jobNamespace = `${RANCHER_PROJECT_NAME || repositoryName}-ci`
const rancherProjectName = RANCHER_PROJECT_NAME || repositoryName
const jobNamespace = `${rancherProjectName}-ci`

@@ -110,3 +112,2 @@ return {

namespace,
gitBranch,
rancherProjectId,

@@ -123,3 +124,3 @@ certSecretName,

branchSlug,
branchName,
gitBranch,
jobNamespace,

@@ -126,0 +127,0 @@ sha,

#!/usr/bin/env node
const os = require("os")
const path = require("path")
const { mkdtemp } = require("fs/promises")
const fs = require("fs-extra")
const { Command } = require("commander")
const { Command, Option } = require("commander")
const { highlight, fromJson: themeFromJson } = require("cli-highlight")
const program = new Command()
const builder = require("../action/build/builder")
const logger = require("../action/build/utils/logger")
const shell = require("../action/build/utils/shell")
const { configureDebug } = require("../action/build/utils/logger")
const build = require("./cli/build")
const deploy = require("./cli/deploy")
program
.name("kube-workflow")
.description("CI pipeline running on Kubernetes deploying to Kubernetes 🚀")
.version(require(`${__dirname}/../package.json`).version)
.command("build-manifests")
.addOption(
new Option(
"--env, -e <env>",
"select environment, default autodetect from current git branch"
).choices(["dev", "preprod", "prod"])
)
.option("--components, -c <component>", "override components to enable")
.option("--helm-args, -a <args>", "add extra helm arguments")
.option("--cwd <path>", "set current working directory")
.option("--debug, -d", "enable debugging loglevel")
program
.command("build")
.alias("b")
.alias("build")
.description(
"Build manifests using kube-workflow with current directory configuration"
)
.option("--env, -e <env>", "select environment (dev | preprod | prod), default dev")
.option("--components <component>, -c", "override components to enable")
.option("--helm-args <args>, -a", "add extra helm arguments")
.option("--repository, -r <repo>", "set repository, default to current folder name")
.option("--output, -o", "enable direct output of manifest")

@@ -33,54 +37,36 @@ .option(

)
.action(async (options) => {
const tmpDir = await mkdtemp(path.join(os.tmpdir(), `kube-workflow`))
.action(async (_options, command) => {
const options = command.optsWithGlobals()
configureDebug(options.D)
await build(options)
})
let GIT_REF
let GIT_SHA
try {
GIT_REF = shell("git branch --show-current").trim()
GIT_SHA = shell("git show -s --format=%H").trim()
} catch (e) {
GIT_REF = "master"
GIT_SHA = "01c1226fc326a2651631ed61e6cbd96cd97f375d"
}
const envVars = {
...process.env,
ENVIRONMENT: options.E || process.env.ENVIRONMENT || "dev",
COMPONENTS: options.C || process.env.COMPONENTS,
HELM_ARGS: options.A || process.env.HELM_ARGS,
GIT_REF,
GIT_SHA,
KUBEWORKFLOW_PATH: path.resolve(__dirname, ".."),
WORKSPACE_PATH: process.cwd(),
REPOSITORY:
options.R || process.env.REPOSITORY || path.basename(process.cwd()),
KWBUILD_PATH: tmpDir,
}
await builder(envVars)
const manifestsFile = `${tmpDir}/manifests.yaml`
if (options.O) {
let manifests = await fs.readFile(manifestsFile, { encoding: "utf-8" })
if (options.S) {
const theme = themeFromJson({
keyword: "blue",
built_in: ["cyan", "dim"],
string: "green",
default: "gray",
})
manifests = highlight(manifests, {
language: "yaml",
theme,
})
}
console.log(manifests)
} else {
logger.info(`Built manifests files: ${manifestsFile}`)
}
program
.command("deploy")
.alias("d")
.option(
"--file, -f <file>",
"select a manifests yaml file, default will build one"
)
.option(
"--rancher-project-name <project>",
"rancher project name, default to repository basename"
)
.option(
"--rancher-project-id <project-id>",
"rancher project id, default retrieved from ci namespace"
)
.option(
"--kubeconfig-context <context>",
"kubeconfig context, default inferred from environment"
)
.description(
"Deploy manifests using kapp with current directory configuration"
)
.action(async (_options, command) => {
const options = command.optsWithGlobals()
configureDebug(options.D)
await deploy(options)
})
program.parse(process.argv)

@@ -5,2 +5,17 @@ # Changelog

## [1.4.0](https://github.com/SocialGouv/kube-workflow/compare/v1.3.0...v1.4.0) (2022-03-26)
### Features
* npx deploy + rollback ns + refacto+things ([b0a813d](https://github.com/SocialGouv/kube-workflow/commit/b0a813df7040731379863043a3ff52865ceec272))
### Bug Fixes
* add yarn delivery ([0b54301](https://github.com/SocialGouv/kube-workflow/commit/0b5430102f08f8a0becc56a4d2e82a60852a7fd2))
* clean ([862bb11](https://github.com/SocialGouv/kube-workflow/commit/862bb11c7dba51b01a212feda69c32db67c6760f))
* up tests ([c22d248](https://github.com/SocialGouv/kube-workflow/commit/c22d24848849cf806b04e1eea401bbe3d490fda2))
* yarn push ([361305a](https://github.com/SocialGouv/kube-workflow/commit/361305aedc0edd417226cbaa678885b6334df87a))
## [1.3.0](https://github.com/SocialGouv/kube-workflow/compare/v1.2.6...v1.3.0) (2022-03-26)

@@ -7,0 +22,0 @@

{
"name": "kube-workflow",
"version": "1.3.0",
"version": "1.4.0",
"repository": "git@github.com:SocialGouv/kube-workflow.git",

@@ -8,4 +8,7 @@ "license": "MIT",

"@socialgouv/env-slug": "^1.2.2",
"async-retry": "^1.3.3",
"degit": "^2.8.4",
"delay": "^5.0.0",
"fs-extra": "^10.0.1",
"git-url-parse": "^11.6.0",
"js-yaml": "^4.1.0",

@@ -58,3 +61,4 @@ "lodash.defaultsdeep": "^4.6.1",

"retag": "git tag -f $(git describe --tags $(git rev-list --tags --max-count=1) | cut -d '.' -f 1)",
"push": "git push -f --tags"
"push": "git push -f --follow-tags origin master",
"delivery": "yarn release && yarn push"
},

@@ -61,0 +65,0 @@ "standard-version": {

@@ -49,3 +49,3 @@ /* eslint-disable no-undef */

WORKSPACE_SUBPATH: "",
REPOSITORY: `test-${testdir}`,
GIT_REPOSITORY: `kube-workflow/test-${testdir}`,
}

@@ -59,6 +59,6 @@ const envFile = `${testdirPath}/.env`

}
const output = await builder(env)
expect(output).toMatchSpecificSnapshot(
const { manifests } = await builder(env)
expect(manifests).toMatchSpecificSnapshot(
`./__snapshots__/${testdir}.${environment}.yaml`
)
})

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc