Repository: hyperledger/firefly (go)

Issue:
Add version Command to Core Binary
Just like in [ethconnect](https://github.com/hyperledger-labs/firefly-ethconnect/blob/dd53ec2afc184da9b72eb92e83b1446d784c69f7/main.go#L26-L32) where we use `ldflags` to add build metadata (commit sha, tags, etc.) to the binary and log it at startup, we should then take it a step further and add a `version` command (similar to what `helm`, `kubectl`, `go` have) that then will output the same information.

Pull request:
Version Command
Closes #132, resurrects #586. Uses new preferred way of versioning with module fields in the `cmd` package rather than an `internal` package, see https://github.com/hyperledger/firefly-cli/pull/164 for original implementation of this approach.

Example "default" usage:
```
make build
./firefly version
{
  "Version": "(devel)",
  "Date": "2022-04-25T19:52:28Z",
  "License": "Apache-2.0"
}

./firefly version -o yaml
Date: "2022-04-25T19:52:28Z"
License: Apache-2.0
Version: (devel)

./firefly version --short
(devel)

make docker
docker run -it --entrypoint /bin/sh hyperledger/firefly
/firefly # firefly version
{
  "Version": "(devel)",
  "Date": "2022-04-25T19:45:02Z",
  "License": "Apache-2.0"
}
/firefly # firefly version -o yaml
Date: "2022-04-25T19:45:02Z"
License: Apache-2.0
Version: (devel)

/firefly # firefly version --short
(devel)

```

Patch:
diff --git a/.github/workflows/docker_main.yml b/.github/workflows/docker_main.yml
index 84bd460ff..8a0263f4d 100644
--- a/.github/workflows/docker_main.yml
+++ b/.github/workflows/docker_main.yml
@@ -23,6 +23,8 @@ jobs:
       - name: Build
         run: |
           make DOCKER_ARGS="\
+            --build-arg BUILD_VERSION=${{ steps.build_tag_generator.outputs.BUILD_TAG }} \
+            --build-arg GIT_REF=$GITHUB_SHA \
             --label commit=$GITHUB_SHA \
             --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
             --label tag=${{ steps.build_tag_generator.outputs.BUILD_TAG }} \
diff --git a/.github/workflows/docker_release.yml b/.github/workflows/docker_release.yml
index 471c0cb72..e32617aac 100644
--- a/.github/workflows/docker_release.yml
+++ b/.github/workflows/docker_release.yml
@@ -15,6 +15,8 @@ jobs:
       - name: Build
         run: |
           make DOCKER_ARGS="\
+            --build-arg BUILD_VERSION=${GITHUB_REF##*/} \
+            --build-arg GIT_REF=$GITHUB_SHA \
             --label commit=$GITHUB_SHA \
             --label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
             --label tag=${GITHUB_REF##*/} \
diff --git a/Dockerfile b/Dockerfile
index af2273b7e..b277cf8b5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,6 +3,8 @@ ARG FABRIC_BUILDER_TAG
 ARG FABRIC_BUILDER_PLATFORM
 ARG SOLIDITY_BUILDER_TAG
 ARG BASE_TAG
+ARG BUILD_VERSION
+ARG GIT_REF
 
 FROM $FIREFLY_BUILDER_TAG AS firefly-builder
 ARG UI_TAG
@@ -15,7 +17,7 @@ ENV UI_RELEASE https://github.com/hyperledger/firefly-ui/releases/download/$UI_T
 RUN mkdir /firefly/frontend \
  && curl -sLo - $UI_RELEASE | tar -C /firefly/frontend -zxvf -
 ADD . .
-RUN make build
+RUN make build BUILD_VERSION=$BUILD_VERSION GIT_REF=$GIT_REF
 
 FROM --platform=$FABRIC_BUILDER_PLATFORM $FABRIC_BUILDER_TAG AS fabric-builder
 RUN apk add libc6-compat
diff --git a/Makefile b/Makefile
index 0b992e593..7a5175382 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ GOFILES := $(shell find cmd internal pkg -name '*.go' -print)
 GOBIN := $(shell $(VGO) env GOPATH)/bin
 LINT := $(GOBIN)/golangci-lint
 MOCKERY := $(GOBIN)/mockery
+DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
 
 # Expect that FireFly compiles with CGO disabled
 CGO_ENABLED=0
@@ -75,9 +76,9 @@ $(eval $(call makemock, internal/metrics,          Manager,            metricsmo
 $(eval $(call makemock, internal/operations,       Manager,            operationmocks))
 
 firefly-nocgo: ${GOFILES}
-		CGO_ENABLED=0 $(VGO) build -o ${BINARY_NAME}-nocgo -ldflags "-X main.buildDate=`date -u +\"%Y-%m-%dT%H:%M:%SZ\"` -X main.buildVersion=$(BUILD_VERSION)" -tags=prod -tags=prod -v
+		CGO_ENABLED=0 $(VGO) build -o ${BINARY_NAME}-nocgo -ldflags "-X main.buildDate=$(DATE) -X main.buildVersion=$(BUILD_VERSION) -X 'github.com/hyperledger/firefly/cmd.BuildVersionOverride=$(BUILD_VERSION)' -X 'github.com/hyperledger/firefly/cmd.BuildDate=$(DATE)' -X 'github.com/hyperledger/firefly/cmd.BuildCommit=$(GIT_REF)'" -tags=prod -tags=prod -v
 firefly: ${GOFILES}
-		$(VGO) build -o ${BINARY_NAME} -ldflags "-X main.buildDate=`date -u +\"%Y-%m-%dT%H:%M:%SZ\"` -X main.buildVersion=$(BUILD_VERSION)" -tags=prod -tags=prod -v
+		$(VGO) build -o ${BINARY_NAME} -ldflags "-X main.buildDate=$(DATE) -X main.buildVersion=$(BUILD_VERSION) -X 'github.com/hyperledger/firefly/cmd.BuildVersionOverride=$(BUILD_VERSION)' -X 'github.com/hyperledger/firefly/cmd.BuildDate=$(DATE)' -X 'github.com/hyperledger/firefly/cmd.BuildCommit=$(GIT_REF)'" -tags=prod -tags=prod -v
 go-mod-tidy: .ALWAYS
 		$(VGO) mod tidy
 build: firefly-nocgo firefly
diff --git a/cmd/version.go b/cmd/version.go
new file mode 100644
index 000000000..f60310671
--- /dev/null
+++ b/cmd/version.go
@@ -0,0 +1,102 @@
+// Copyright © 2022 Kaleido, Inc.
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package cmd
+
+import (
+	"context"
+	"encoding/json"
+	"fmt"
+	"runtime/debug"
+
+	"github.com/ghodss/yaml"
+	"github.com/hyperledger/firefly/internal/coremsgs"
+	"github.com/hyperledger/firefly/pkg/i18n"
+	"github.com/spf13/cobra"
+)
+
+var shortened, output = false, "yaml"
+
+var BuildDate string
+var BuildCommit string
+var BuildVersionOverride string
+
+type Info struct {
+	Version string `json:"Version,omitempty" yaml:"Version,omitempty"`
+	Commit  string `json:"Commit,omitempty" yaml:"Commit,omitempty"`
+	Date    string `json:"Date,omitempty" yaml:"Date,omitempty"`
+	License string `json:"License,omitempty" yaml:"License,omitempty"`
+}
+
+func setBuildInfo(info *Info, buildInfo *debug.BuildInfo, ok bool) {
+	if ok {
+		info.Version = buildInfo.Main.Version
+	}
+}
+
+// versionCmd represents the version command
+var versionCmd = &cobra.Command{
+	Use:   "version",
+	Short: "Prints the version info",
+	Long:  "Prints the version info of the Core binary",
+	RunE: func(cmd *cobra.Command, args []string) error {
+		info := &Info{
+			Date:    BuildDate,
+			Commit:  BuildCommit,
+			Version: BuildVersionOverride,
+			License: "Apache-2.0",
+		}
+
+		// Where you are using go install, we will get good version information usefully from Go
+		// When we're in go-releaser in a Github action, we will have the version passed in explicitly
+		if info.Version == "" {
+			buildInfo, ok := debug.ReadBuildInfo()
+			setBuildInfo(info, buildInfo, ok)
+		}
+
+		if shortened {
+			fmt.Println(info.Version)
+		} else {
+
+			var (
+				bytes []byte
+				err   error
+			)
+
+			switch output {
+			case "json":
+				bytes, err = json.MarshalIndent(info, "", "  ")
+			case "yaml":
+				bytes, err = yaml.Marshal(info)
+			default:
+				err = i18n.NewError(context.Background(), coremsgs.MsgInvalidOutputOption, output)
+			}
+			if err != nil {
+				return err
+			}
+
+			fmt.Println(string(bytes))
+		}
+
+		return nil
+	},
+}
+
+func init() {
+	versionCmd.Flags().BoolVarP(&shortened, "short", "s", false, "Prints only the version number")
+	versionCmd.Flags().StringVarP(&output, "output", "o", "json", "output format (\"yaml\"|\"json\")")
+	rootCmd.AddCommand(versionCmd)
+}
diff --git a/docs/_config.yml b/docs/_config.yml
index c31b1bfe4..1194179b7 100644
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -8,8 +8,8 @@ aux_links:
     - "//github.com/hyperledger/firefly"
   "Wiki":
     - "https://wiki.hyperledger.org/display/FIR"
-  "Discord":
-    - "https://discord.gg/hyperledger"
+  "Chat":
+    - "https://chat.hyperledger.org/channel/firefly"
   "Mailing List":
     - "https://lists.hyperledger.org/g/firefly"
   "Calendar":
diff --git a/docs/faqs/faqs.md b/docs/faqs/faqs.md
index a5ec3c20f..205896247 100644
--- a/docs/faqs/faqs.md
+++ b/docs/faqs/faqs.md
@@ -9,6 +9,6 @@ has_children: true
 
 Find answers to the most commonly asked FireFly questions.
 
-This content is coming soon and will be guided by community interactions via Discord, meetups, webinars and other technical forums.
+This content is coming soon and will be guided by community interactions via RocketChat, meetups, webinars and other technical forums.
 
-If you have immediate questions please don't hesitate to reach out to us on the [Hyperledger Discord](https://discord.gg/hyperledger) in the `#firefly` channel.
+If you have immediate questions please don't hesitate to reach out to us on our [FireFly RocketChat Channel](https://chat.hyperledger.org/channel/firefly).
diff --git a/internal/blockchain/ethereum/config.go b/internal/blockchain/ethereum/config.go
index 47e57f6df..e42297fac 100644
--- a/internal/blockchain/ethereum/config.go
+++ b/internal/blockchain/ethereum/config.go
@@ -17,9 +17,9 @@
 package ethereum
 
 import (
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/pkg/config"
 	"github.com/hyperledger/firefly/pkg/ffresty"
-	"github.com/hyperledger/firefly/pkg/wsclient"
 )
 
 const (
@@ -71,7 +71,7 @@ const (
 
 func (e *Ethereum) InitPrefix(prefix config.Prefix) {
 	ethconnectConf := prefix.SubPrefix(EthconnectConfigKey)
-	wsclient.InitPrefix(ethconnectConf)
+	wsconfig.InitPrefix(ethconnectConf)
 	ethconnectConf.AddKnownKey(EthconnectConfigInstancePath)
 	ethconnectConf.AddKnownKey(EthconnectConfigTopic)
 	ethconnectConf.AddKnownKey(EthconnectConfigBatchSize, defaultBatchSize)
diff --git a/internal/blockchain/ethereum/ethereum.go b/internal/blockchain/ethereum/ethereum.go
index 73f335372..26f75ab77 100644
--- a/internal/blockchain/ethereum/ethereum.go
+++ b/internal/blockchain/ethereum/ethereum.go
@@ -25,6 +25,7 @@ import (
 	"strings"
 
 	"github.com/go-resty/resty/v2"
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/internal/coremsgs"
 	"github.com/hyperledger/firefly/internal/metrics"
 	"github.com/hyperledger/firefly/pkg/blockchain"
@@ -206,7 +207,7 @@ func (e *Ethereum) Init(ctx context.Context, prefix config.Prefix, callbacks blo
 	e.prefixShort = ethconnectConf.GetString(EthconnectPrefixShort)
 	e.prefixLong = ethconnectConf.GetString(EthconnectPrefixLong)
 
-	wsConfig := wsclient.GenerateConfigFromPrefix(ethconnectConf)
+	wsConfig := wsconfig.GenerateConfigFromPrefix(ethconnectConf)
 
 	if wsConfig.WSKeyPath == "" {
 		wsConfig.WSKeyPath = "/ws"
diff --git a/internal/blockchain/fabric/config.go b/internal/blockchain/fabric/config.go
index 21c655d81..541bbcfb4 100644
--- a/internal/blockchain/fabric/config.go
+++ b/internal/blockchain/fabric/config.go
@@ -17,8 +17,8 @@
 package fabric
 
 import (
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/pkg/config"
-	"github.com/hyperledger/firefly/pkg/wsclient"
 )
 
 const (
@@ -53,7 +53,7 @@ const (
 
 func (f *Fabric) InitPrefix(prefix config.Prefix) {
 	fabconnectConf := prefix.SubPrefix(FabconnectConfigKey)
-	wsclient.InitPrefix(fabconnectConf)
+	wsconfig.InitPrefix(fabconnectConf)
 	fabconnectConf.AddKnownKey(FabconnectConfigDefaultChannel)
 	fabconnectConf.AddKnownKey(FabconnectConfigChaincode)
 	fabconnectConf.AddKnownKey(FabconnectConfigSigner)
diff --git a/internal/blockchain/fabric/fabric.go b/internal/blockchain/fabric/fabric.go
index 60d06ad1c..55a6a5bda 100644
--- a/internal/blockchain/fabric/fabric.go
+++ b/internal/blockchain/fabric/fabric.go
@@ -27,6 +27,7 @@ import (
 	"strings"
 
 	"github.com/go-resty/resty/v2"
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/internal/coremsgs"
 	"github.com/hyperledger/firefly/internal/metrics"
 	"github.com/hyperledger/firefly/pkg/blockchain"
@@ -190,7 +191,7 @@ func (f *Fabric) Init(ctx context.Context, prefix config.Prefix, callbacks block
 		GlobalSequencer: true,
 	}
 
-	wsConfig := wsclient.GenerateConfigFromPrefix(fabconnectConf)
+	wsConfig := wsconfig.GenerateConfigFromPrefix(fabconnectConf)
 
 	if wsConfig.WSKeyPath == "" {
 		wsConfig.WSKeyPath = "/ws"
diff --git a/pkg/wsclient/wsconfig.go b/internal/coreconfig/wsconfig/wsconfig.go
similarity index 95%
rename from pkg/wsclient/wsconfig.go
rename to internal/coreconfig/wsconfig/wsconfig.go
index c9936f6c0..9c202437c 100644
--- a/pkg/wsclient/wsconfig.go
+++ b/internal/coreconfig/wsconfig/wsconfig.go
@@ -14,11 +14,12 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package wsclient
+package wsconfig
 
 import (
 	"github.com/hyperledger/firefly/pkg/config"
 	"github.com/hyperledger/firefly/pkg/ffresty"
+	"github.com/hyperledger/firefly/pkg/wsclient"
 )
 
 const (
@@ -53,8 +54,8 @@ func InitPrefix(prefix config.KeySet) {
 	prefix.AddKnownKey(WSConfigHeartbeatInterval, defaultHeartbeatInterval)
 }
 
-func GenerateConfigFromPrefix(prefix config.Prefix) *WSConfig {
-	return &WSConfig{
+func GenerateConfigFromPrefix(prefix config.Prefix) *wsclient.WSConfig {
+	return &wsclient.WSConfig{
 		HTTPURL:                prefix.GetString(ffresty.HTTPConfigURL),
 		WSKeyPath:              prefix.GetString(WSConfigKeyPath),
 		ReadBufferSize:         int(prefix.GetByteSize(WSConfigKeyReadBufferSize)),
diff --git a/internal/coremsgs/en_error_messages.go b/internal/coremsgs/en_error_messages.go
index b7d3755a5..d133d690b 100644
--- a/internal/coremsgs/en_error_messages.go
+++ b/internal/coremsgs/en_error_messages.go
@@ -229,4 +229,5 @@ var (
 	MsgFFStructTagMissing           = ffe("FF10382", "ffstruct tag is missing for '%s' on route '%s'")
 	MsgContractListenerExists       = ffe("FF10383", "A contract listener already exists for this combination of topic + location + event", 409)
 	MsgRouteDescriptionMissing      = ffe("FF10384", "API route description missing for route '%s'")
+	MsgInvalidOutputOption          = ffe("FF10385", "invalid output option '%s'")
 )
diff --git a/internal/dataexchange/ffdx/config.go b/internal/dataexchange/ffdx/config.go
index 14637d742..8b42b181f 100644
--- a/internal/dataexchange/ffdx/config.go
+++ b/internal/dataexchange/ffdx/config.go
@@ -17,8 +17,8 @@
 package ffdx
 
 import (
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/pkg/config"
-	"github.com/hyperledger/firefly/pkg/wsclient"
 )
 
 const (
@@ -29,7 +29,7 @@ const (
 )
 
 func (h *FFDX) InitPrefix(prefix config.Prefix) {
-	wsclient.InitPrefix(prefix)
+	wsconfig.InitPrefix(prefix)
 	prefix.AddKnownKey(DataExchangeManifestEnabled, false)
 	prefix.AddKnownKey(DataExchangeInitEnabled, false)
 }
diff --git a/internal/dataexchange/ffdx/ffdx.go b/internal/dataexchange/ffdx/ffdx.go
index 5d8e61818..780a94b98 100644
--- a/internal/dataexchange/ffdx/ffdx.go
+++ b/internal/dataexchange/ffdx/ffdx.go
@@ -26,6 +26,7 @@ import (
 	"sync"
 
 	"github.com/go-resty/resty/v2"
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/internal/coremsgs"
 	"github.com/hyperledger/firefly/pkg/config"
 	"github.com/hyperledger/firefly/pkg/dataexchange"
@@ -126,7 +127,7 @@ func (h *FFDX) Init(ctx context.Context, prefix config.Prefix, nodes []fftypes.J
 		Manifest: prefix.GetBool(DataExchangeManifestEnabled),
 	}
 
-	wsConfig := wsclient.GenerateConfigFromPrefix(prefix)
+	wsConfig := wsconfig.GenerateConfigFromPrefix(prefix)
 
 	h.wsconn, err = wsclient.New(ctx, wsConfig, h.beforeConnect, nil)
 	if err != nil {
diff --git a/internal/tokens/fftokens/config.go b/internal/tokens/fftokens/config.go
index d19540ee6..50ae74fef 100644
--- a/internal/tokens/fftokens/config.go
+++ b/internal/tokens/fftokens/config.go
@@ -17,10 +17,10 @@
 package fftokens
 
 import (
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/pkg/config"
-	"github.com/hyperledger/firefly/pkg/wsclient"
 )
 
 func (ft *FFTokens) InitPrefix(prefix config.PrefixArray) {
-	wsclient.InitPrefix(prefix)
+	wsconfig.InitPrefix(prefix)
 }
diff --git a/internal/tokens/fftokens/fftokens.go b/internal/tokens/fftokens/fftokens.go
index 7007d88bb..221dd96b1 100644
--- a/internal/tokens/fftokens/fftokens.go
+++ b/internal/tokens/fftokens/fftokens.go
@@ -21,6 +21,7 @@ import (
 	"encoding/json"
 
 	"github.com/go-resty/resty/v2"
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/internal/coremsgs"
 	"github.com/hyperledger/firefly/pkg/blockchain"
 	"github.com/hyperledger/firefly/pkg/config"
@@ -143,7 +144,7 @@ func (ft *FFTokens) Init(ctx context.Context, name string, prefix config.Prefix,
 	ft.client = ffresty.New(ft.ctx, prefix)
 	ft.capabilities = &tokens.Capabilities{}
 
-	wsConfig := wsclient.GenerateConfigFromPrefix(prefix)
+	wsConfig := wsconfig.GenerateConfigFromPrefix(prefix)
 
 	if wsConfig.WSKeyPath == "" {
 		wsConfig.WSKeyPath = "/api/ws"


Test patch:
diff --git a/cmd/version_test.go b/cmd/version_test.go
new file mode 100644
index 000000000..21746bbff
--- /dev/null
+++ b/cmd/version_test.go
@@ -0,0 +1,65 @@
+// Copyright © 2022 Kaleido, Inc.
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package cmd
+
+import (
+	"runtime/debug"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestVersionCmdDefault(t *testing.T) {
+	rootCmd.SetArgs([]string{"version"})
+	defer rootCmd.SetArgs([]string{})
+	err := rootCmd.Execute()
+	assert.NoError(t, err)
+}
+
+func TestVersionCmdYAML(t *testing.T) {
+	rootCmd.SetArgs([]string{"version", "-o", "yaml"})
+	defer rootCmd.SetArgs([]string{})
+	err := rootCmd.Execute()
+	assert.NoError(t, err)
+}
+
+func TestVersionCmdJSON(t *testing.T) {
+	rootCmd.SetArgs([]string{"version", "-o", "json"})
+	defer rootCmd.SetArgs([]string{})
+	err := rootCmd.Execute()
+	assert.NoError(t, err)
+}
+
+func TestVersionCmdInvalidType(t *testing.T) {
+	rootCmd.SetArgs([]string{"version", "-o", "wrong"})
+	defer rootCmd.SetArgs([]string{})
+	err := rootCmd.Execute()
+	assert.Regexp(t, "FF10385", err)
+}
+
+func TestVersionCmdShorthand(t *testing.T) {
+	rootCmd.SetArgs([]string{"version", "-s"})
+	defer rootCmd.SetArgs([]string{})
+	err := rootCmd.Execute()
+	assert.NoError(t, err)
+}
+
+func TestSetBuildInfoWithBI(t *testing.T) {
+	info := &Info{}
+	setBuildInfo(info, &debug.BuildInfo{Main: debug.Module{Version: "12345"}}, true)
+	assert.Equal(t, "12345", info.Version)
+}
diff --git a/internal/adminevents/manager_test.go b/internal/adminevents/manager_test.go
index 0d0660ecc..03d5f777d 100644
--- a/internal/adminevents/manager_test.go
+++ b/internal/adminevents/manager_test.go
@@ -27,6 +27,7 @@ import (
 	"time"
 
 	"github.com/hyperledger/firefly/internal/coreconfig"
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/pkg/config"
 	"github.com/hyperledger/firefly/pkg/ffresty"
 	"github.com/hyperledger/firefly/pkg/fftypes"
@@ -41,9 +42,9 @@ func newTestAdminEventsManager(t *testing.T) (ae *adminEventManager, ws *webSock
 	svr := httptest.NewServer(http.HandlerFunc(ae.ServeHTTPWebSocketListener))
 
 	clientPrefix := config.NewPluginConfig("ut.wsclient")
-	wsclient.InitPrefix(clientPrefix)
+	wsconfig.InitPrefix(clientPrefix)
 	clientPrefix.Set(ffresty.HTTPConfigURL, fmt.Sprintf("http://%s", svr.Listener.Addr()))
-	wsConfig := wsclient.GenerateConfigFromPrefix(clientPrefix)
+	wsConfig := wsconfig.GenerateConfigFromPrefix(clientPrefix)
 
 	wsc, err := wsclient.New(ae.ctx, wsConfig, nil, nil)
 	assert.NoError(t, err)
diff --git a/pkg/wsclient/wsconfig_test.go b/internal/coreconfig/wsconfig/wsconfig_test.go
similarity index 98%
rename from pkg/wsclient/wsconfig_test.go
rename to internal/coreconfig/wsconfig/wsconfig_test.go
index d8eef914b..65f72488f 100644
--- a/pkg/wsclient/wsconfig_test.go
+++ b/internal/coreconfig/wsconfig/wsconfig_test.go
@@ -1,4 +1,4 @@
-package wsclient
+package wsconfig
 
 import (
 	"testing"
diff --git a/internal/events/websockets/websockets_test.go b/internal/events/websockets/websockets_test.go
index f348e3514..d9901b80b 100644
--- a/internal/events/websockets/websockets_test.go
+++ b/internal/events/websockets/websockets_test.go
@@ -27,6 +27,7 @@ import (
 	"testing"
 
 	"github.com/hyperledger/firefly/internal/coreconfig"
+	"github.com/hyperledger/firefly/internal/coreconfig/wsconfig"
 	"github.com/hyperledger/firefly/mocks/eventsmocks"
 	"github.com/hyperledger/firefly/pkg/config"
 	"github.com/hyperledger/firefly/pkg/events"
@@ -54,13 +55,13 @@ func newTestWebsockets(t *testing.T, cbs *eventsmocks.Callbacks, queryParams ...
 	svr := httptest.NewServer(ws)
 
 	clientPrefix := config.NewPluginConfig("ut.wsclient")
-	wsclient.InitPrefix(clientPrefix)
+	wsconfig.InitPrefix(clientPrefix)
 	qs := ""
 	if len(queryParams) > 0 {
 		qs = fmt.Sprintf("?%s", strings.Join(queryParams, "&"))
 	}
 	clientPrefix.Set(ffresty.HTTPConfigURL, fmt.Sprintf("http://%s%s", svr.Listener.Addr(), qs))
-	wsConfig := wsclient.GenerateConfigFromPrefix(clientPrefix)
+	wsConfig := wsconfig.GenerateConfigFromPrefix(clientPrefix)
 
 	wsc, err := wsclient.New(ctx, wsConfig, nil, nil)
 	assert.NoError(t, err)