VOL-2126 - update the dockerfile to set the new version information based on voltha-lib-go
Change-Id: Iab01409e9e73f56fafddfe265998839bc89f95b4
diff --git a/cmd/simulated_olt/main.go b/cmd/simulated_olt/main.go
index d9948f9..018a7e5 100644
--- a/cmd/simulated_olt/main.go
+++ b/cmd/simulated_olt/main.go
@@ -328,6 +328,11 @@
cf := config.NewAdapterFlags()
cf.ParseCommandArguments()
+ if cf.PrintVersion {
+ fmt.Println(version.VersionInfo.String(""))
+ return
+ }
+
//// Setup logging
//Setup default logger - applies for packages that do not have specific logger set
diff --git a/docker/Dockerfile.simulated_olt b/docker/Dockerfile.simulated_olt
index 7346bc9..865dd8b 100644
--- a/docker/Dockerfile.simulated_olt
+++ b/docker/Dockerfile.simulated_olt
@@ -47,13 +47,13 @@
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
RUN go build -mod=vendor -o /build/simulated_olt \
-ldflags \
- "-X github.com/opencord/voltha-go/common/version.version=$org_label_schema_version \
- -X github.com/opencord/voltha-go/common/version.vcsRef=$org_label_schema_vcs_ref \
- -X github.com/opencord/voltha-go/common/version.vcsDirty=$org_opencord_vcs_dirty \
- -X 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-go/common/version.os=$(go env GOHOSTOS) \
- -X github.com/opencord/voltha-go/common/version.arch=$(go env GOHOSTARCH) \
- -X github.com/opencord/voltha-go/common/version.buildTime=$org_label_schema_build_date" \
+ "-X github.com/opencord/voltha-lib-go/pkg/version.version=$org_label_schema_version \
+ -X github.com/opencord/voltha-lib-go/pkg/version.vcsRef=$org_label_schema_vcs_ref \
+ -X github.com/opencord/voltha-lib-go/pkg/version.vcsDirty=$org_opencord_vcs_dirty \
+ -X github.com/opencord/voltha-lib-go/pkg/version.goVersion=$(go version 2>&1 | sed -E 's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') \
+ -X github.com/opencord/voltha-lib-go/pkg/version.os=$(go env GOHOSTOS) \
+ -X github.com/opencord/voltha-lib-go/pkg/version.arch=$(go env GOHOSTARCH) \
+ -X github.com/opencord/voltha-lib-go/pkg/version.buildTime=$org_label_schema_build_date" \
cmd/simulated_olt/main.go
# -------------
@@ -74,6 +74,8 @@
ARG org_opencord_vcs_commit_date=unknown
ARG org_opencord_vcs_dirty=unknown
+RUN echo $org_label_schema_version
+
LABEL org.label-schema.schema-version=1.0 \
org.label-schema.name=voltha-adapter-simulated-olt \
org.label-schema.version=$org_label_schema_version \
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index de5d208..4070256 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -41,6 +41,7 @@
default_OnuNumber = 1
default_ProbeHost = ""
default_ProbePort = 8080
+ default_PrintVersion = false
)
// AdapterFlags represents the set of configurations used by the read-write adaptercore service
@@ -62,6 +63,7 @@
Banner bool
ProbeHost string
ProbePort int
+ PrintVersion bool
}
func init() {
@@ -87,6 +89,7 @@
Banner: default_Banner,
ProbeHost: default_ProbeHost,
ProbePort: default_ProbePort,
+ PrintVersion: default_PrintVersion,
}
return &adapterFlags
}
@@ -141,6 +144,9 @@
help = fmt.Sprintf("The port on which to listen to answer liveness and readiness probe queries over HTTP.")
flag.IntVar(&(so.ProbePort), "probe_port", default_ProbePort, help)
+ help = fmt.Sprintf("Print the version information and exit.")
+ flag.BoolVar(&so.PrintVersion, "version", default_PrintVersion, help)
+
flag.Parse()
containerName := getContainerInfo()