From aacefafe534b42b15fac11c97c6e5cfb857b1b5a Mon Sep 17 00:00:00 2001 From: Charlie Voiselle Date: Tue, 16 Jan 2018 13:13:50 -0500 Subject: [PATCH] Allow `.` in Environment Variable Names From [https://github.com/appc/spec/blob/master/spec/aci.md](https://github.com/appc/spec/blob/master/spec/aci.md): >environment (list of objects, optional) represents the app's environment variables (ACE can append). The listed objects must have two key-value pairs: name and value. The name must consist solely of letters, digits, and underscores '_' as outlined in IEEE Std 1003.1-2008, 2016 Edition, with practical considerations dictating that the name may also include periods '.' and hyphens '-'. The value is an arbitrary string. These values are not evaluated in any way, and no substitutions are made. Dotted environment variables are frequently used as a part of the Spring Boot pattern. (re: ZD-6116) This PR specifically doesn't address the conversion of hyphens (`-`) due to an issue with rkt [[Nomad GH # 2358]](https://github.com/hashicorp/nomad/issues/2358). --- helper/funcs.go | 1 + helper/funcs_test.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/helper/funcs.go b/helper/funcs.go index e66ff40d1..49b300c24 100644 --- a/helper/funcs.go +++ b/helper/funcs.go @@ -263,6 +263,7 @@ func CleanEnvVar(s string, r byte) string { for i, c := range b { switch { case c == '_': + case c == '.': case c >= 'a' && c <= 'z': case c >= 'A' && c <= 'Z': case i > 0 && c >= '0' && c <= '9': diff --git a/helper/funcs_test.go b/helper/funcs_test.go index 564765c62..774030be1 100644 --- a/helper/funcs_test.go +++ b/helper/funcs_test.go @@ -66,7 +66,8 @@ func TestClearEnvVar(t *testing.T) { {"asd0", "asd0"}, {"_asd", "_asd"}, {"-asd", "_asd"}, - {"A~!@#$%^&*()_+-={}[]|\\;:'\"<,>.?/Z", "A_______________________________Z"}, + {"asd.fgh", "asd.fgh"}, + {"A~!@#$%^&*()_+-={}[]|\\;:'\"<,>?/Z", "A______________________________Z"}, {"A\U0001f4a9Z", "A____Z"}, } for _, c := range cases {