Skip to content

Commit

Permalink
Merge pull request #30 from funbox/develop
Browse files Browse the repository at this point in the history
Version 0.14.0
  • Loading branch information
andyone authored Apr 26, 2017
2 parents f411f71 + ba77bd5 commit 48e533c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
// App props
const (
APP = "init-exporter"
VER = "0.13.0"
VER = "0.14.0"
DESC = "Utility for exporting services described by Procfile to init system"
)

Expand Down
8 changes: 6 additions & 2 deletions common/init-exporter.spec
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

Summary: Utility for exporting services described by Procfile to init system
Name: init-exporter
Version: 0.13.0
Release: 1%{?dist}
Version: 0.14.0
Release: 0%{?dist}
Group: Development/Tools
License: MIT
URL: https://github.com/funbox/init-exporter
Expand Down Expand Up @@ -132,6 +132,10 @@ rm -rf %{buildroot}
###############################################################################

%changelog
* Wed Apr 26 2017 Anton Novojilov <[email protected]> - 0.14.0-0
- Environment variables and file with environment variables now can defined
in same time

* Mon Apr 24 2017 Anton Novojilov <[email protected]> - 0.13.0-1
- [init-exporter-converter] Replaced text/template by basic procfile rendering

Expand Down
5 changes: 3 additions & 2 deletions export/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (s *ExportSuite) TestUpstartExport(c *C) {
c.Assert(service2Helper[4:], DeepEquals,
[]string{
"[[ -r /etc/profile.d/rbenv.sh ]] && source /etc/profile.d/rbenv.sh", "",
"cd /srv/service/working-dir && exec env $(cat /srv/service/working-dir/shared/env.vars 2>/dev/null | xargs) /bin/echo 'service2'",
"cd /srv/service/working-dir && exec env $(cat /srv/service/working-dir/shared/env.vars 2>/dev/null | xargs) STAGING=true /bin/echo 'service2'",
""},
)

Expand Down Expand Up @@ -370,7 +370,7 @@ func (s *ExportSuite) TestSystemdExport(c *C) {
c.Assert(service2Helper[4:], DeepEquals,
[]string{
"[[ -r /etc/profile.d/rbenv.sh ]] && source /etc/profile.d/rbenv.sh", "",
"exec env $(cat /srv/service/working-dir/shared/env.vars 2>/dev/null | xargs) /bin/echo 'service2'",
"exec env $(cat /srv/service/working-dir/shared/env.vars 2>/dev/null | xargs) STAGING=true /bin/echo 'service2'",
""},
)

Expand Down Expand Up @@ -425,6 +425,7 @@ func createTestApp(helperDir, targetDir string) *procfile.Application {
Application: app,
Options: &procfile.ServiceOptions{
EnvFile: "shared/env.vars",
Env: map[string]string{"STAGING": "true"},
WorkingDir: "/srv/service/working-dir",
ReloadSignal: "SIGUSR2",
IsRespawnEnabled: true,
Expand Down
24 changes: 15 additions & 9 deletions procfile/procfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ func (so *ServiceOptions) Validate() []error {
errs.Add(checkPath(so.LogFile))
errs.Add(checkPath(so.EnvFile))

if so.IsEnvSet() && so.IsEnvFileSet() {
errs.Add(fmt.Errorf("Environment file and environment variables cannot be defined in same time"))
}

for envName, envVal := range so.Env {
errs.Add(checkEnv(envName, envVal))
}
Expand All @@ -184,10 +180,16 @@ func (s *Service) HasPostCmd() bool {
func (s *Service) GetCommandExec(command string) string {
var result = "exec "

if s.Options.IsEnvSet() {
result += "env " + s.Options.EnvString() + " "
} else if s.Options.IsEnvFileSet() {
result += "env $(cat " + s.Options.FullEnvFilePath() + " 2>/dev/null | xargs) "
if s.Options.IsEnvSet() || s.Options.IsEnvFileSet() {
result += "env "

if s.Options.IsEnvFileSet() {
result += "$(cat " + s.Options.FullEnvFilePath() + " 2>/dev/null | xargs) "
}

if s.Options.IsEnvSet() {
result += s.Options.EnvString() + " "
}
}

switch command {
Expand Down Expand Up @@ -357,10 +359,14 @@ func convertMapType(m map[interface{}]interface{}) map[string]string {
// mergeServiceOptions merge two ServiceOptions structs
func mergeServiceOptions(dst, src *ServiceOptions) {

if !dst.IsEnvFileSet() && src.IsEnvSet() {
if src.IsEnvSet() {
mergeStringMaps(dst.Env, src.Env)
}

if dst.EnvFile == "" {
dst.EnvFile = src.EnvFile
}

if dst.WorkingDir == "" {
dst.WorkingDir = src.WorkingDir
}
Expand Down
2 changes: 1 addition & 1 deletion procfile/procfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (s *ProcfileSuite) TestProcV2Parsing(c *C) {
c.Assert(service.Options.RespawnInterval, Equals, 22)
c.Assert(service.Options.IsRespawnEnabled, Equals, false)
c.Assert(service.Options.EnvFile, Equals, "shared/env.file")
c.Assert(service.Options.EnvString(), Equals, "")
c.Assert(service.Options.EnvString(), Equals, "RAILS_ENV=production TEST=true")
c.Assert(service.Options.LimitFile, Equals, 8192)
c.Assert(service.Options.LimitProc, Equals, 8192)
c.Assert(service.Application, NotNil)
Expand Down

0 comments on commit 48e533c

Please sign in to comment.