From 60a9b51a39cba51a89fecb82ff5ee5b275910058 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 29 Jul 2018 13:10:56 -0400 Subject: [PATCH 1/3] fix: ensure the docker image being built has a proper tag --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c771694..fb21b73 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,10 @@ PACKAGECLOUD_REPOSITORY ?= dokku/dokku-betafish ifeq ($(CIRCLE_BRANCH),release) VERSION ?= $(BASE_VERSION) + DOCKER_VERSION = $(VERSION) else VERSION = $(shell echo "${BASE_VERSION}")build+$(shell git rev-parse --short HEAD) + DOCKER_VERSION = $(shell echo "${BASE_VERSION}")build-$(shell git rev-parse --short HEAD) endif version: @@ -123,7 +125,7 @@ deps: dep ensure -vendor-only docker-image: - docker build --rm -q -f Dockerfile.hub -t $(IMAGE_NAME):$(VERSION) . + docker build --rm -q -f Dockerfile.hub -t $(IMAGE_NAME):$(DOCKER_VERSION) . release: build go get -u github.com/progrium/gh-release/... From adf588bcb11a5f9b6e66bf6c97f3822e28babcfe Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 29 Jul 2018 13:27:36 -0400 Subject: [PATCH 2/3] feat: allow specifying the default port to use during variable expansion --- README.md | 14 ++++++++++++++ main.go | 16 ++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 05db003..6f3dfe0 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,9 @@ procfile-util exists -p non-existent # will result in empty string for variable replacements procfile-util expand +# specify a default-port to use (default: 5000) +procfile-util expand --default-port 3000 + # expand variables with getenv used for variable expansion # may use any variable available when executing procfile-util procfile-util expand --allow-getenv @@ -50,6 +53,9 @@ procfile-util expand --env-file .env # combines getenv and .env file parsing to provide variable expansion procfile-util expand --allow-getenv --env-file .env + +# specify the default-port when performing variable expansion +procfile-util expand --allow-getenv --env-file .env --default-port 3000 ``` ### list @@ -67,6 +73,10 @@ procfile-util list # shows the command for the web process procfile-util show -p web +# shows the command for the web process +# specify a default-port to use (default: 5000) +procfile-util show -p web --default-port 3000 + # shows the command for the web process # expand variables with getenv used for variable expansion # may use any variable available when executing procfile-util @@ -79,4 +89,8 @@ procfile-util show -p web --env-file .env # shows the command for the web process # combines getenv and .env file parsing to provide variable expansion procfile-util show -p web --allow-getenv --env-file .env + +# shows the command for the web process +# specify the default-port when performing variable expansion +procfile-util show web --allow-getenv --env-file .env --default-port 3000 ``` diff --git a/main.go b/main.go index d0a7c8d..03ccd65 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,6 @@ type procfileEntry struct { Command string } -const defaultPort = "5000" const portEnvVar = "PORT" // Version contains the procfile-util version @@ -91,7 +90,7 @@ func parseProcfile(path string, delimiter string) ([]procfileEntry, error) { return entries, nil } -func expandEnv(e procfileEntry, envPath string, allowEnv bool) (string, error) { +func expandEnv(e procfileEntry, envPath string, allowEnv bool, defaultPort string) (string, error) { baseExpandFunc := func(key string) string { if key == "PS" { return os.Getenv("PS") @@ -176,11 +175,11 @@ func existsCommand(entries []procfileEntry, processType string) bool { return false } -func expandCommand(entries []procfileEntry, envPath string, allowGetenv bool, processType string) bool { +func expandCommand(entries []procfileEntry, envPath string, allowGetenv bool, processType string, defaultPort string) bool { hasErrors := false commands := make(map[string]string) for _, entry := range entries { - command, err := expandEnv(entry, envPath, allowGetenv) + command, err := expandEnv(entry, envPath, allowGetenv, defaultPort) if err != nil { fmt.Fprintf(os.Stderr, "error processing command: %s\n", err) hasErrors = true @@ -208,7 +207,7 @@ func listCommand(entries []procfileEntry) bool { return true } -func showCommand(entries []procfileEntry, envPath string, allowGetenv bool, processType string) bool { +func showCommand(entries []procfileEntry, envPath string, allowGetenv bool, processType string, defaultPort string) bool { var foundEntry procfileEntry for _, entry := range entries { if processType == entry.Name { @@ -222,7 +221,7 @@ func showCommand(entries []procfileEntry, envPath string, allowGetenv bool, proc return false } - command, err := expandEnv(foundEntry, envPath, allowGetenv) + command, err := expandEnv(foundEntry, envPath, allowGetenv, defaultPort) if err != nil { fmt.Fprintf(os.Stderr, "error processing command: %s\n", err) return false @@ -237,6 +236,7 @@ func main() { procfileFlag := parser.String("P", "procfile", &argparse.Options{Default: "Procfile", Help: "path to a procfile"}) delimiterFlag := parser.String("D", "delimiter", &argparse.Options{Default: ":", Help: "delimiter in use within procfile"}) versionFlag := parser.Flag("v", "version", &argparse.Options{Help: "show version"}) + defaultPortFlag := parser.String("d", "default-port", &argparse.Options{Default: "5000", Help: "default port to use"}) existsCmd := parser.NewCommand("exists", "check if a process type exists") processTypeExistsFlag := existsCmd.String("p", "process-type", &argparse.Options{Help: "name of process to retrieve"}) @@ -281,11 +281,11 @@ func main() { } else if existsCmd.Happened() { success = existsCommand(entries, *processTypeExistsFlag) } else if expandCmd.Happened() { - success = expandCommand(entries, *envPathExpandFlag, *allowGetenvExpandFlag, *processTypeExpandFlag) + success = expandCommand(entries, *envPathExpandFlag, *allowGetenvExpandFlag, *processTypeExpandFlag, *defaultPortFlag) } else if listCmd.Happened() { success = listCommand(entries) } else if showCmd.Happened() { - success = showCommand(entries, *envPathShowFlag, *allowGetenvShowFlag, *processTypeShowFlag) + success = showCommand(entries, *envPathShowFlag, *allowGetenvShowFlag, *processTypeShowFlag, *defaultPortFlag) } else { fmt.Print(parser.Usage(err)) } From 3285be97b7102efea3c271b5e599a1a8851b1dfd Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 29 Jul 2018 13:27:56 -0400 Subject: [PATCH 3/3] Release 0.2.0 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fb21b73..d3260bc 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ MAINTAINER = josegonzalez MAINTAINER_NAME = Jose Diaz-Gonzalez REPOSITORY = go-procfile-util HARDWARE = $(shell uname -m) -BASE_VERSION ?= 0.1.2 +BASE_VERSION ?= 0.2.0 IMAGE_NAME ?= $(MAINTAINER)/$(REPOSITORY) PACKAGECLOUD_REPOSITORY ?= dokku/dokku-betafish