Skip to content

Commit

Permalink
Merge pull request #32 from funbox/develop
Browse files Browse the repository at this point in the history
Version 0.15.0
  • Loading branch information
andyone authored May 20, 2017
2 parents 47b1d86 + 25a19f7 commit 20bbfa9
Show file tree
Hide file tree
Showing 17 changed files with 416 additions and 587 deletions.
54 changes: 54 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
_Before opening an issue, search for similar bug reports or feature requests on GitHub Issues. If yes, please add a_ 👍 _reaction to the existing issue. If no similar issue can be found, fill out either the "Bug Report" or the "Feature Request" section below. Erase the other section and everything on and above this line._

### Bug report

**System info:**

* **Version used (`init-exporter --version`):**
* **OS (`cat /etc/*-release`):**
* **Kernel (`uname -a`):**
* **Go version (`go version`):**
* **Install tools:**

**System info:**

1. [First Step]
2. [Second Step]
3. [and so on...]

**Expected behavior:**

[What you expected to happen]

**Actual behavior:**

[What actually happened]

**Additional info:**

[Include gist of relevant config, logs, etc.]

Please run those if possible and link them from a [gist](http://gist.github.com).

---

### Feature Request

Opening a feature request kicks off a discussion. Requests may be closed if we're not actively planning to work on them.

**Proposal:**

[Description of the feature]

**Current behavior:**

[What currently happens]

**Desired behavior:**

[What you would like to happen]

**Use case:**

[Why is this important (helps with prioritizing requests)]

25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### What did you implement:

Closes #XXXXX

### How did you implement it:

...

### How can we verify it:

...

### TODO's:

- [ ] Write tests
- [ ] Write documentation
- [ ] Check that there aren't other open pull requests for the same issue/feature
- [ ] Format your source code by `make fmt`
- [ ] Pass the test by `make test`
- [ ] Provide verification config / commands
- [ ] Enable "Allow edits from maintainers" for this PR
- [ ] Update the messages below

**Is this ready for review?:** No
**Is it a breaking change?:** No
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ script:
- make test
- make all
- ./init-exporter --version
- ./init-exporter-converter --version
15 changes: 3 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,21 @@ PREFIX?=/usr

########################################################################################

.PHONY = all clean install uninstall deps deps-glide test upstart-playground systemd-playground
.PHONY = all clean install uninstall deps test upstart-playground systemd-playground

########################################################################################

all: init-exporter init-exporter-converter
all: init-exporter

init-exporter:
go build init-exporter.go

init-exporter-converter:
go build init-exporter-converter.go

deps:
go get -d -v pkg.re/check.v1
go get -d -v pkg.re/essentialkaos/ek.v8
go get -d -v pkg.re/essentialkaos/ek.v9
go get -d -v pkg.re/essentialkaos/go-simpleyaml.v1
go get -d -v pkg.re/yaml.v2

deps-glide:
glide install

fmt:
find . -name "*.go" -exec gofmt -s -w {} \;

Expand All @@ -35,17 +29,14 @@ test:
install:
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp init-exporter $(DESTDIR)$(PREFIX)/bin/
cp init-exporter-converter $(DESTDIR)$(PREFIX)/bin/
cp common/init-exporter.conf $(DESTDIR)/etc/

uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/init-exporter
rm -f $(DESTDIR)$(PREFIX)/bin/init-exporter-converter
rm -rf $(DESTDIR)/etc/init-exporter.conf

clean:
rm -f init-exporter
rm -f init-exporter-converter

upstart-playground:
docker build -f ./Dockerfile.upstart -t upstart-playground . && docker run -ti --rm=true upstart-playground /bin/bash
Expand Down
101 changes: 51 additions & 50 deletions cli/cli.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// +build !windows
package cli

// ////////////////////////////////////////////////////////////////////////////////// //
Expand All @@ -11,15 +12,15 @@ import (
"os"
"runtime"

"pkg.re/essentialkaos/ek.v8/arg"
"pkg.re/essentialkaos/ek.v8/env"
"pkg.re/essentialkaos/ek.v8/fmtc"
"pkg.re/essentialkaos/ek.v8/fsutil"
"pkg.re/essentialkaos/ek.v8/knf"
"pkg.re/essentialkaos/ek.v8/log"
"pkg.re/essentialkaos/ek.v8/system"
"pkg.re/essentialkaos/ek.v8/usage"
"pkg.re/essentialkaos/ek.v8/usage/update"
"pkg.re/essentialkaos/ek.v9/env"
"pkg.re/essentialkaos/ek.v9/fmtc"
"pkg.re/essentialkaos/ek.v9/fsutil"
"pkg.re/essentialkaos/ek.v9/knf"
"pkg.re/essentialkaos/ek.v9/log"
"pkg.re/essentialkaos/ek.v9/options"
"pkg.re/essentialkaos/ek.v9/system"
"pkg.re/essentialkaos/ek.v9/usage"
"pkg.re/essentialkaos/ek.v9/usage/update"

"github.com/funbox/init-exporter/export"
"github.com/funbox/init-exporter/procfile"
Expand All @@ -30,21 +31,21 @@ import (
// App props
const (
APP = "init-exporter"
VER = "0.14.0"
VER = "0.15.0"
DESC = "Utility for exporting services described by Procfile to init system"
)

// Supported arguments
const (
ARG_PROCFILE = "p:procfile"
ARG_APP_NAME = "n:appname"
ARG_DRY_START = "d:dry-start"
ARG_DISABLE_VALIDATION = "D:disable-validation"
ARG_UNINSTALL = "u:uninstall"
ARG_FORMAT = "f:format"
ARG_NO_COLORS = "nc:no-colors"
ARG_HELP = "h:help"
ARG_VERSION = "v:version"
OPT_PROCFILE = "p:procfile"
OPT_APP_NAME = "n:appname"
OPT_DRY_START = "d:dry-start"
OPT_DISABLE_VALIDATION = "D:disable-validation"
OPT_UNINSTALL = "u:uninstall"
OPT_FORMAT = "f:format"
OPT_NO_COLORS = "nc:no-colors"
OPT_HELP = "h:help"
OPT_VERSION = "v:version"
)

// Config properies
Expand Down Expand Up @@ -83,16 +84,16 @@ const CONFIG_FILE = "/etc/init-exporter.conf"

// ////////////////////////////////////////////////////////////////////////////////// //

var argMap = arg.Map{
ARG_APP_NAME: {},
ARG_PROCFILE: {},
ARG_DRY_START: {Type: arg.BOOL},
ARG_DISABLE_VALIDATION: {Type: arg.BOOL},
ARG_UNINSTALL: {Type: arg.BOOL, Alias: "c:clear"},
ARG_FORMAT: {},
ARG_NO_COLORS: {Type: arg.BOOL},
ARG_HELP: {Type: arg.BOOL},
ARG_VERSION: {Type: arg.BOOL},
var optMap = options.Map{
OPT_APP_NAME: {},
OPT_PROCFILE: {},
OPT_DRY_START: {Type: options.BOOL},
OPT_DISABLE_VALIDATION: {Type: options.BOOL},
OPT_UNINSTALL: {Type: options.BOOL, Alias: "c:clear"},
OPT_FORMAT: {},
OPT_NO_COLORS: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL},
OPT_VERSION: {Type: options.BOOL},
}

var user *system.User
Expand All @@ -102,7 +103,7 @@ var user *system.User
func Init() {
runtime.GOMAXPROCS(1)

args, errs := arg.Parse(argMap)
args, errs := options.Parse(optMap)

if len(errs) != 0 {
fmt.Println("Error while arguments parsing:")
Expand All @@ -114,21 +115,21 @@ func Init() {
os.Exit(1)
}

if arg.GetB(ARG_NO_COLORS) {
if options.GetB(OPT_NO_COLORS) {
fmtc.DisableColors = true
}

if arg.GetB(ARG_VERSION) {
if options.GetB(OPT_VERSION) {
showAbout()
return
}

if arg.GetB(ARG_HELP) {
if options.GetB(OPT_HELP) {
showUsage()
return
}

if len(args) == 0 && !arg.Has(ARG_APP_NAME) {
if len(args) == 0 && !options.Has(OPT_APP_NAME) {
showUsage()
return
}
Expand All @@ -141,7 +142,7 @@ func Init() {

switch {
case len(args) == 0:
startProcessing(arg.GetS(ARG_APP_NAME))
startProcessing(options.GetS(OPT_APP_NAME))
default:
startProcessing(args[0])
}
Expand All @@ -164,8 +165,8 @@ func checkForRoot() {

// checkArguments check given arguments
func checkArguments() {
if !arg.GetB(ARG_UNINSTALL) {
proc := arg.GetS(ARG_PROCFILE)
if !options.GetB(OPT_UNINSTALL) {
proc := options.GetS(OPT_PROCFILE)

switch {
case fsutil.IsExist(proc) == false:
Expand Down Expand Up @@ -297,7 +298,7 @@ func setupLogger() {

// startProcessing start processing
func startProcessing(appName string) {
if !arg.GetB(ARG_UNINSTALL) {
if !options.GetB(OPT_UNINSTALL) {
installApplication(appName)
} else {
uninstallApplication(appName)
Expand All @@ -309,7 +310,7 @@ func installApplication(appName string) {
fullAppName := knf.GetS(MAIN_PREFIX) + appName

app, err := procfile.Read(
arg.GetS(ARG_PROCFILE),
options.GetS(OPT_PROCFILE),
&procfile.Config{
Name: fullAppName,
User: knf.GetS(MAIN_RUN_USER),
Expand All @@ -330,7 +331,7 @@ func installApplication(appName string) {

validateApplication(app)

if arg.GetB(ARG_DRY_START) {
if options.GetB(OPT_DRY_START) {
os.Exit(0)
}

Expand Down Expand Up @@ -369,7 +370,7 @@ func validateApplication(app *procfile.Application) {
printErrorAndExit("Proc format version 2 support is disabled")
}

if !arg.GetB(ARG_DRY_START) && arg.GetB(ARG_DISABLE_VALIDATION) {
if !options.GetB(OPT_DRY_START) && options.GetB(OPT_DISABLE_VALIDATION) {
return
}

Expand Down Expand Up @@ -399,7 +400,7 @@ func checkProviderTargetDir(dir string) error {

// getExporter create and configure exporter and return it
func getExporter() *export.Exporter {
providerName, err := detectProvider(arg.GetS(ARG_FORMAT))
providerName, err := detectProvider(options.GetS(OPT_FORMAT))

if err != nil {
printErrorAndExit(err.Error())
Expand Down Expand Up @@ -469,14 +470,14 @@ func printErrorAndExit(f string, a ...interface{}) {
func showUsage() {
info := usage.NewInfo("", "app-name")

info.AddOption(ARG_PROCFILE, "Path to procfile", "file")
info.AddOption(ARG_DRY_START, "Dry start {s-}(don't export anything, just parse and test procfile){!}")
info.AddOption(ARG_DISABLE_VALIDATION, "Disable application validation")
info.AddOption(ARG_UNINSTALL, "Remove scripts and helpers for a particular application")
info.AddOption(ARG_FORMAT, "Format of generated configs", "upstart|systemd")
info.AddOption(ARG_NO_COLORS, "Disable colors in output")
info.AddOption(ARG_HELP, "Show this help message")
info.AddOption(ARG_VERSION, "Show version")
info.AddOption(OPT_PROCFILE, "Path to procfile", "file")
info.AddOption(OPT_DRY_START, "Dry start {s-}(don't export anything, just parse and test procfile){!}")
info.AddOption(OPT_DISABLE_VALIDATION, "Disable application validation")
info.AddOption(OPT_UNINSTALL, "Remove scripts and helpers for a particular application")
info.AddOption(OPT_FORMAT, "Format of generated configs", "?upstart|systemd")
info.AddOption(OPT_NO_COLORS, "Disable colors in output")
info.AddOption(OPT_HELP, "Show this help message")
info.AddOption(OPT_VERSION, "Show version")

info.AddExample("-p ./myprocfile -f systemd myapp", "Export given procfile to systemd as myapp")
info.AddExample("-u -f systemd myapp", "Uninstall myapp from systemd")
Expand Down
Loading

0 comments on commit 20bbfa9

Please sign in to comment.