diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/go/internal/admin/jvm/application_container.go | 13 | ||||
-rw-r--r-- | client/go/internal/admin/jvm/application_container_test.go (renamed from client/go/internal/util/md5_test.go) | 8 | ||||
-rw-r--r-- | client/go/internal/util/md5.go | 17 |
3 files changed, 16 insertions, 22 deletions
diff --git a/client/go/internal/admin/jvm/application_container.go b/client/go/internal/admin/jvm/application_container.go index c525ea77949..3959ccca5e9 100644 --- a/client/go/internal/admin/jvm/application_container.go +++ b/client/go/internal/admin/jvm/application_container.go @@ -4,7 +4,9 @@ package jvm import ( + "crypto/md5" "fmt" + "io" "os" "github.com/vespa-engine/vespa/client/go/internal/admin/defaults" @@ -22,6 +24,13 @@ type ApplicationContainer struct { containerBase } +func md5Hex(text string) string { + hasher := md5.New() + io.WriteString(hasher, text) + hash := hasher.Sum(nil) + return fmt.Sprintf("%x", hash) +} + func (a *ApplicationContainer) ArgForMain() string { dir := defaults.UnderVespaHome("lib/jars") return fmt.Sprintf("file:%s/%s", dir, JAR_FOR_APPLICATION_CONTAINER) @@ -31,7 +40,7 @@ func (a *ApplicationContainer) Discriminator() string { cfgId := a.ConfigId() if cfgId != "" { trace.Trace("Discriminator: using md5 of", cfgId) - return util.Md5Hex(cfgId + "\n") + return md5Hex(cfgId + "\n") } svcName := a.ServiceName() if svcName != "" { @@ -40,7 +49,7 @@ func (a *ApplicationContainer) Discriminator() string { } pid := os.Getpid() trace.Trace("Discriminator: using md5 of", pid) - return util.Md5Hex(fmt.Sprintf("%d", pid)) + return md5Hex(fmt.Sprintf("%d", pid)) } func (a *ApplicationContainer) addJdiscProperties() { diff --git a/client/go/internal/util/md5_test.go b/client/go/internal/admin/jvm/application_container_test.go index ac3bc6a9546..3a062edee16 100644 --- a/client/go/internal/util/md5_test.go +++ b/client/go/internal/admin/jvm/application_container_test.go @@ -1,5 +1,7 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package util +// Author: arnej + +package jvm import ( "testing" @@ -8,6 +10,6 @@ import ( ) func TestMD5SimpleInputs(t *testing.T) { - assert.Equal(t, "d41d8cd98f00b204e9800998ecf8427e", Md5Hex("")) - assert.Equal(t, "4044e8209f286312a68bbb54f8714922", Md5Hex("admin/cluster-controllers/0\n")) + assert.Equal(t, "d41d8cd98f00b204e9800998ecf8427e", md5Hex("")) + assert.Equal(t, "4044e8209f286312a68bbb54f8714922", md5Hex("admin/cluster-controllers/0\n")) } diff --git a/client/go/internal/util/md5.go b/client/go/internal/util/md5.go deleted file mode 100644 index 6a98b49c472..00000000000 --- a/client/go/internal/util/md5.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Author: arnej - -package util - -import ( - "crypto/md5" - "fmt" - "io" -) - -func Md5Hex(text string) string { - hasher := md5.New() - io.WriteString(hasher, text) - hash := hasher.Sum(nil) - return fmt.Sprintf("%x", hash) -} |