Do not use dependency for version injection
Change-Id: Ic3851dccac2b3945f20a6a717a4476c7cc0e85bb
diff --git a/Gopkg.lock b/Gopkg.lock
index 3303ed1..f6b3341 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -235,7 +235,7 @@
[[projects]]
branch = "master"
- digest = "1:8813723b4cd2a23cddb4a2ed14f1949dc11017562ebf2a41903310956a8cb1a0"
+ digest = "1:eed0edabcd9e9549e804d5a7e13844f147687c9ece52c499ebdb04f99ce07f95"
name = "github.com/opencord/voltha-go"
packages = [
"adapters",
@@ -243,14 +243,13 @@
"common/log",
"common/ponresourcemanager",
"common/techprofile",
- "common/version",
"db/kvstore",
"db/model",
"kafka",
"rw_core/utils",
]
pruneopts = "UT"
- revision = "44e134a1c07a5238985f816a3a127853cfd9efd2"
+ revision = "737b9e5045de3b00cd5da2b0c3c48be668e83b9d"
[[projects]]
branch = "master"
@@ -545,7 +544,6 @@
"github.com/opencord/voltha-go/common/log",
"github.com/opencord/voltha-go/common/ponresourcemanager",
"github.com/opencord/voltha-go/common/techprofile",
- "github.com/opencord/voltha-go/common/version",
"github.com/opencord/voltha-go/db/kvstore",
"github.com/opencord/voltha-go/db/model",
"github.com/opencord/voltha-go/kafka",
diff --git a/vendor/github.com/opencord/voltha-go/common/version/version.go b/config/version/version.go
similarity index 84%
rename from vendor/github.com/opencord/voltha-go/common/version/version.go
rename to config/version/version.go
index 49c0b10..269d748 100644
--- a/vendor/github.com/opencord/voltha-go/common/version/version.go
+++ b/config/version/version.go
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+// Package version is used to inject build time information via -X variables
package version
import (
@@ -33,7 +35,8 @@
arch = "unknown-arch"
)
-type VersionInfoType struct {
+// InfoType is a collection of build time environment variables
+type InfoType struct {
Version string `json:"version"`
GoVersion string `json:"goversion"`
VcsRef string `json:"vcsref"`
@@ -43,10 +46,11 @@
Arch string `json:"arch"`
}
-var VersionInfo VersionInfoType
+// VersionInfo is an instance of build time environment variables populated at build time via -X arguments
+var VersionInfo InfoType
func init() {
- VersionInfo = VersionInfoType{
+ VersionInfo = InfoType{
Version: version,
VcsRef: vcsRef,
VcsDirty: vcsDirty,
@@ -57,7 +61,7 @@
}
}
-func (v VersionInfoType) String(indent string) string {
+func (v InfoType) String(indent string) string {
builder := strings.Builder{}
builder.WriteString(fmt.Sprintf("%sVersion: %s\n", indent, VersionInfo.Version))
diff --git a/docker/Dockerfile.openolt b/docker/Dockerfile.openolt
index d7cc1dc..176a454 100644
--- a/docker/Dockerfile.openolt
+++ b/docker/Dockerfile.openolt
@@ -44,13 +44,13 @@
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
RUN go build -o /build/openolt \
-ldflags \
- "-X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
- -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref \
- -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
- -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.goVersion=$(go version 2>&1 | sed -E 's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
- -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.os=$(go env GOHOSTOS) \
- -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
- -X github.com/opencord/voltha-openolt-adapter/vendor/github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date"
+ "-X github.com/opencord/voltha-openolt-adapter/config/version.version=$org_label_schema_version \
+ -X github.com/opencord/voltha-openolt-adapter/config/version.vcsRef=$org_label_schema_vcs_ref \
+ -X github.com/opencord/voltha-openolt-adapter/config/version.vcsDirty=$org_opencord_vcs_dirty \
+ -X github.com/opencord/voltha-openolt-adapter/config/version.goVersion=$(go version 2>&1 | sed -E 's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+ -X github.com/opencord/voltha-openolt-adapter/config/version.os=$(go env GOHOSTOS) \
+ -X github.com/opencord/voltha-openolt-adapter/config/version.arch=$(go env GOHOSTARCH) \
+ -X github.com/opencord/voltha-openolt-adapter/config/version.buildTime=$org_label_schema_build_date"
# -------------
# Image creation stage
diff --git a/main.go b/main.go
index 3a0e966..30efa84 100644
--- a/main.go
+++ b/main.go
@@ -24,11 +24,11 @@
"github.com/opencord/voltha-go/adapters"
com "github.com/opencord/voltha-go/adapters/common"
"github.com/opencord/voltha-go/common/log"
- "github.com/opencord/voltha-go/common/version"
"github.com/opencord/voltha-go/db/kvstore"
"github.com/opencord/voltha-go/kafka"
ac "github.com/opencord/voltha-openolt-adapter/adaptercore"
"github.com/opencord/voltha-openolt-adapter/config"
+ "github.com/opencord/voltha-openolt-adapter/config/version"
ic "github.com/opencord/voltha-protos/go/inter_container"
"github.com/opencord/voltha-protos/go/voltha"
"os"