git-to-k8s
Advanced tools
Comparing version 0.2.7 to 0.2.8
36
index.js
@@ -132,2 +132,3 @@ 'use strict' | ||
this.debug = parser.get('debug') !== undefined | ||
this.local = parser.get('local') !== undefined | ||
this.purge_first = parser.get('purge') !== undefined | ||
@@ -145,3 +146,3 @@ this.repo_branch = parser.get('b') || 'master' | ||
if (parser.get('help')) { | ||
logger.info('Usage: git-to-k8s repo_url [--dry] [-b branch] [--purge] [--debug]') | ||
logger.info('Usage: git-to-k8s repo_url [--dry] [-b branch] [--purge] [--debug] [--local]') | ||
logger.exit_success() | ||
@@ -182,3 +183,2 @@ } | ||
} | ||
} | ||
@@ -191,20 +191,20 @@ | ||
// STEP-1: clone repo | ||
this.steps.push(new Step({ | ||
name: 'Clone repo to local temp work directory', | ||
cmds: [ | ||
const make_repo_copy = () => { | ||
let get_repo_cmd = `git clone --single-branch --branch ${this.repo_branch} --depth=1 ${this.repo_url} ${path.join(pkg.tmp_dir, this.repo_name)}` | ||
if (this.local) get_repo_cmd = `cp -rf ${this.repo_branch} ${path.join(pkg.tmp_dir, this.repo_name)}` | ||
const cmds = [ | ||
`mkdir -p ${pkg.tmp_dir}`, | ||
`cd ${pkg.tmp_dir}`, | ||
`rm -rf ${this.repo_name}`, | ||
`git clone --single-branch --branch ${this.repo_branch} --depth=1 ${this.repo_url} ${path.join(pkg.tmp_dir, this.repo_name)}`, | ||
get_repo_cmd, | ||
`cd ${this.repo_name}` | ||
], | ||
dry_cmds: [ | ||
`mkdir -p ${pkg.tmp_dir}`, | ||
`cd ${pkg.tmp_dir}`, | ||
`rm -rf ${this.repo_name}`, | ||
`git clone --single-branch --branch ${this.repo_branch} --depth=1 ${this.repo_url} ${path.join(pkg.tmp_dir, this.repo_name)}`, | ||
`cd ${this.repo_name}` | ||
], | ||
post: parse_proj | ||
})) | ||
] | ||
return { | ||
name: `${this.local? 'Copy' : 'Clone'} repo to local temp work directory`, | ||
cmds, | ||
dry_cmds: cmds, | ||
post: parse_proj | ||
} | ||
} | ||
this.steps.push(new Step(make_repo_copy())) | ||
@@ -226,3 +226,3 @@ // STEP-2: build and images | ||
return new Step({ | ||
name: 'build docker images and push to registry', | ||
name: 'Build docker images and push to registry', | ||
cmds: cmds_build_image.concat(cmds_push_image), | ||
@@ -250,3 +250,3 @@ dry_cmds: cmds_build_image | ||
return new Step({ | ||
name: 'deploy charts', | ||
name: 'Deploy charts', | ||
cmds | ||
@@ -253,0 +253,0 @@ }) |
{ | ||
"name": "git-to-k8s", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "Small tool to automate the git to url flow on k8s", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,4 +24,4 @@ # git-to-k8s | ||
- commit project code to git repo | ||
- included deployment attributes and charts in package.json | ||
- use custom tool clone the repo, build images and push to container registry | ||
- include deployment attributes in package.json and add charts | ||
- clone the repo to local, build images and push to container registry | ||
- launch deployment with helm on k8s (helm install or helm upgrade) | ||
@@ -62,4 +62,8 @@ | ||
$ git-to-k8s --help | ||
Usage: git-to-k8s repo_url [--dry] [-b branch] [--purge] [--debug] | ||
Usage: git-to-k8s repo_url [--dry] [-b branch] [--purge] [--debug] [--local] | ||
// --purge will do helm delete --purge to remove old releases | ||
// --local will use local repo directly | ||
// -b specify the branch, default will use master branch | ||
$ git-to-k8s https://github.com/devfans/git-to-k8s | ||
@@ -129,3 +133,3 @@ Checking dependencies... | ||
Step: 4 / 4 - Clean up | ||
- shell: rm -rf /var/tmp/git-to-k8s | ||
- shell: rm -rf /var/tmp/git-to-k8s/git-to-k8s | ||
@@ -132,0 +136,0 @@ ``` |
89326
2184
145