Skip to content

Commit

Permalink
Merge pull request #16 from funbox/develop
Browse files Browse the repository at this point in the history
Version 0.9.0-1
  • Loading branch information
andyone authored Apr 3, 2017
2 parents c2b2056 + 69fa1bd commit 43442f3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
24 changes: 21 additions & 3 deletions common/init-exporter.spec
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
Summary: Utility for exporting services described by Procfile to init system
Name: init-exporter
Version: 0.9.0
Release: 0%{?dist}
Release: 1%{?dist}
Group: Development/Tools
License: MIT
URL: https://github.com/funbox/init-exporter
Expand All @@ -52,7 +52,7 @@ Source0: %{name}-%{version}.tar.gz

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: golang >= 1.7
BuildRequires: golang >= 1.8

Provides: upstart-exporter = %{version}-%{release}
Provides: systemd-exporter = %{version}-%{release}
Expand All @@ -66,6 +66,17 @@ Utility for exporting services described by Procfile to init system.

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

%package converter

Summary: Utility for converting procfiles from v1 to v2 format
Version: 0.1.1
Release: 0%{?dist}

%description converter
Utility for converting procfiles from v1 to v2 format.

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

%prep
%setup -q

Expand Down Expand Up @@ -111,13 +122,20 @@ rm -rf %{buildroot}
%dir %{_logdir}/%{name}
%dir %{_localstatedir}/local/%{name}/helpers
%{_bindir}/init-exporter
%{_bindir}/init-exporter-converter
%{_bindir}/upstart-export
%{_bindir}/systemd-export

%files converter
%defattr(-,root,root,-)
%{_bindir}/init-exporter-converter

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

%changelog
* Mon Apr 03 2017 Anton Novojilov <[email protected]> - 0.9.0-1
- Format converter moved to separate package
- Minor fixes in format converter

* Fri Mar 31 2017 Anton Novojilov <[email protected]> - 0.9.0-0
- Format support configuration feature
- Pre and post commands support
Expand Down
23 changes: 13 additions & 10 deletions converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
// App props
const (
APP = "init-exporter-converter"
VER = "0.1.0"
VER = "0.2.0"
DESC = "Utility for converting procfiles from v1 to v2 format"
)

Expand All @@ -35,7 +35,6 @@ const (
// Supported arguments
const (
ARG_CONFIG = "c:config"
ARG_APP_NAME = "n:appname"
ARG_IN_PLACE = "i:in-place"
ARG_NO_COLORS = "nc:no-colors"
ARG_HELP = "h:help"
Expand Down Expand Up @@ -102,7 +101,6 @@ type templateData struct {

var argMap = arg.Map{
ARG_CONFIG: {},
ARG_APP_NAME: {},
ARG_IN_PLACE: {Type: arg.BOOL},
ARG_NO_COLORS: {Type: arg.BOOL},
ARG_HELP: {Type: arg.BOOL},
Expand Down Expand Up @@ -147,10 +145,6 @@ func Init() {
func process(file string) {
var err error

if !arg.Has(ARG_APP_NAME) {
printErrorAndExit("Application name must be defined through -n/--appname argument")
}

if arg.Has(ARG_CONFIG) {
err = knf.Global(arg.GetS(ARG_CONFIG))

Expand All @@ -168,10 +162,8 @@ func process(file string) {

// convert read procfile in v1 format and print v2 data or save it to file
func convert(file string) error {
fullAppName := knf.GetS(MAIN_PREFIX, "") + arg.GetS(ARG_APP_NAME)

config := &procfile.Config{
Name: fullAppName,
Name: "",
WorkingDir: knf.GetS(PATHS_WORKING_DIR, "/tmp"),
IsRespawnEnabled: knf.GetB(DEFAULTS_RESPAWN, true),
RespawnInterval: knf.GetI(DEFAULTS_RESPAWN_INTERVAL, 15),
Expand Down Expand Up @@ -251,11 +243,22 @@ func printErrorAndExit(f string, a ...interface{}) {
func showUsage() {
info := usage.NewInfo("", "procfile")

info.AddOption(ARG_CONFIG, "Path to init-exporter config", "file")
info.AddOption(ARG_IN_PLACE, "Edit procfile in place")
info.AddOption(ARG_NO_COLORS, "Disable colors in output")
info.AddOption(ARG_HELP, "Show this help message")
info.AddOption(ARG_VERSION, "Show version")

info.AddExample(
"-i config/Procfile.production",
"Convert Procfile.production to version 2 in-place",
)

info.AddExample(
"config/Procfile.production -c /etc/init-exporter.conf Procfile.production",
"Convert Procfile.production to version 2 with defaults from init-exporter config and print result to console",
)

info.Render()
}

Expand Down

0 comments on commit 43442f3

Please sign in to comment.