From 63d515de4d30d7e884355cdc6f9efcdf6de408b1 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Fri, 8 Dec 2017 15:54:04 -0800 Subject: [PATCH] Lowercase service IDs to prevent eye bleeding --- nomad/structs/structs.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 1f4f533aa..52c0f1410 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -45,6 +45,9 @@ var ( // validPolicyName is used to validate a policy name validPolicyName = regexp.MustCompile("^[a-zA-Z0-9-]{1,128}$") + + // b32 is a lowercase base32 encoding for use in URL friendly service hashes + b32 = base32.NewEncoding(strings.ToLower("abcdefghijklmnopqrstuvwxyz234567")) ) type MessageType uint8 @@ -3158,7 +3161,7 @@ func (s *Service) Hash(allocID, taskName string) string { // encoded without padding, only 4 bytes larger than base64, and saves // 8 bytes vs hex. Since these hashes are used in Consul URLs it's nice // to have a reasonably compact URL-safe representation. - return base32.StdEncoding.EncodeToString(h.Sum(nil)) + return b32.EncodeToString(h.Sum(nil)) } const (