From 0ce9ea3bab7ab7c7e265f07743834fb67ef5905a Mon Sep 17 00:00:00 2001 From: Aleksejs Sinicins Date: Sat, 27 Feb 2016 18:42:33 +0200 Subject: [PATCH 1/2] Allow dashes in var names --- helper/args/args.go | 2 +- helper/args/args_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/helper/args/args.go b/helper/args/args.go index 886082e8a..32836f9ea 100644 --- a/helper/args/args.go +++ b/helper/args/args.go @@ -3,7 +3,7 @@ package args import "regexp" var ( - envRe = regexp.MustCompile(`\${[a-zA-Z0-9_\.]+}`) + envRe = regexp.MustCompile(`\${[a-zA-Z0-9_\-\.]+}`) ) // ReplaceEnv takes an arg and replaces all occurences of environment variables. diff --git a/helper/args/args_test.go b/helper/args/args_test.go index b430c9859..974f4cbf3 100644 --- a/helper/args/args_test.go +++ b/helper/args/args_test.go @@ -13,6 +13,8 @@ const ( portVal = ":80" periodKey = "NOMAD.PERIOD" periodVal = "period" + dashKey = "NOMAD-DASH" + dashVal = "dash" ) var ( @@ -20,6 +22,7 @@ var ( ipKey: ipVal, portKey: portVal, periodKey: periodVal, + dashKey: dashVal, } ) @@ -53,6 +56,16 @@ func TestArgs_ReplaceEnv_Period(t *testing.T) { } } +func TestArgs_ReplaceEnv_Dash(t *testing.T) { + input := fmt.Sprintf(`"${%v}"!`, dashKey) + exp := fmt.Sprintf("\"%s\"!", dashVal) + act := ReplaceEnv(input, envVars) + + if !reflect.DeepEqual(act, exp) { + t.Fatalf("ReplaceEnv(%v, %v) returned %#v; want %#v", input, envVars, act, exp) + } +} + func TestArgs_ReplaceEnv_Chained(t *testing.T) { input := fmt.Sprintf("${%s}${%s}", ipKey, portKey) exp := fmt.Sprintf("%s%s", ipVal, portVal) From 3ea76e306e0ef7bbfdc911f7c92d56ab27346c73 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Sun, 28 Feb 2016 17:12:37 -0800 Subject: [PATCH 2/2] Update version and add changelog for 0.3.1 --- CHANGELOG.md | 5 +++++ version.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4be3b4136..2aa03f864 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.3.1 (UNRELEASED) + +BUG FIXES: + * client: Allow dashes in variable names during interprelation [GH-857] + ## 0.3.0 __BACKWARDS INCOMPATIBILITIES:__ diff --git a/version.go b/version.go index 8a41e0c41..3b8a103c6 100644 --- a/version.go +++ b/version.go @@ -5,9 +5,9 @@ var GitCommit string var GitDescribe string // The main version number that is being run at the moment. -const Version = "0.3.0" +const Version = "0.3.1" // A pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release // such as "dev" (in development), "beta", "rc1", etc. -const VersionPrerelease = "" +const VersionPrerelease = "dev"