VOL-2640 Restructure openolt-adapter repo to best practices
Change-Id: Icead31e8ecb82ec75a22e66361fbf83f80136589
diff --git a/VERSION b/VERSION
index 5aa7c52..66d8a6d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.9
+2.3.10-dev
diff --git a/main.go b/cmd/openolt-adapter/main.go
similarity index 98%
rename from main.go
rename to cmd/openolt-adapter/main.go
index 296b42f..297bf3c 100644
--- a/main.go
+++ b/cmd/openolt-adapter/main.go
@@ -36,9 +36,9 @@
"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
"github.com/opencord/voltha-lib-go/v3/pkg/probe"
- ac "github.com/opencord/voltha-openolt-adapter/adaptercore"
- "github.com/opencord/voltha-openolt-adapter/config"
- "github.com/opencord/voltha-openolt-adapter/config/version"
+ "github.com/opencord/voltha-lib-go/v3/pkg/version"
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
+ ac "github.com/opencord/voltha-openolt-adapter/internal/pkg/core"
ic "github.com/opencord/voltha-protos/v3/go/inter_container"
"github.com/opencord/voltha-protos/v3/go/voltha"
)
diff --git a/main_test.go b/cmd/openolt-adapter/main_test.go
similarity index 97%
rename from main_test.go
rename to cmd/openolt-adapter/main_test.go
index 13f760c..bdf9366 100644
--- a/main_test.go
+++ b/cmd/openolt-adapter/main_test.go
@@ -24,8 +24,8 @@
"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-openolt-adapter/config"
- "github.com/opencord/voltha-openolt-adapter/mocks"
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
+ "github.com/opencord/voltha-openolt-adapter/pkg/mocks"
ca "github.com/opencord/voltha-protos/v3/go/inter_container"
"go.etcd.io/etcd/pkg/mock/mockserver"
)
diff --git a/docker/Dockerfile.openolt b/docker/Dockerfile.openolt
index 3b0697b..bde3d17 100644
--- a/docker/Dockerfile.openolt
+++ b/docker/Dockerfile.openolt
@@ -35,13 +35,14 @@
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
RUN go build -mod=vendor -o /go/bin/openolt \
-ldflags \
- "-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"
+ "-X github.com/opencord/voltha-lib-go/v3/pkg/version.version=$org_label_schema_version \
+ -X github.com/opencord/voltha-lib-go/v3/pkg/version.vcsRef=$org_label_schema_vcs_ref \
+ -X github.com/opencord/voltha-lib-go/v3/pkg/version.vcsDirty=$org_opencord_vcs_dirty \
+ -X github.com/opencord/voltha-lib-go/v3/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/v3/pkg/version.os=$(go env GOHOSTOS) \
+ -X github.com/opencord/voltha-lib-go/v3/pkg/version.arch=$(go env GOHOSTARCH) \
+ -X github.com/opencord/voltha-lib-go/v3/pkg/version.buildTime=$org_label_schema_build_date" \
+ cmd/openolt-adapter/main.go
# -------------
# Image creation stage
diff --git a/config/config.go b/internal/pkg/config/config.go
similarity index 100%
rename from config/config.go
rename to internal/pkg/config/config.go
diff --git a/config/config_test.go b/internal/pkg/config/config_test.go
similarity index 100%
rename from config/config_test.go
rename to internal/pkg/config/config_test.go
diff --git a/adaptercore/device_handler.go b/internal/pkg/core/device_handler.go
similarity index 99%
rename from adaptercore/device_handler.go
rename to internal/pkg/core/device_handler.go
index 447079d..0695af6 100644
--- a/adaptercore/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"context"
@@ -36,7 +36,7 @@
"github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
"github.com/opencord/voltha-lib-go/v3/pkg/pmmetrics"
- rsrcMgr "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
+ rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
"github.com/opencord/voltha-protos/v3/go/common"
ic "github.com/opencord/voltha-protos/v3/go/inter_container"
of "github.com/opencord/voltha-protos/v3/go/openflow_13"
diff --git a/adaptercore/device_handler_test.go b/internal/pkg/core/device_handler_test.go
similarity index 99%
rename from adaptercore/device_handler_test.go
rename to internal/pkg/core/device_handler_test.go
index fbb224d..1d1192e 100644
--- a/adaptercore/device_handler_test.go
+++ b/internal/pkg/core/device_handler_test.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"context"
@@ -33,8 +33,8 @@
fu "github.com/opencord/voltha-lib-go/v3/pkg/flows"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
ponrmgr "github.com/opencord/voltha-lib-go/v3/pkg/ponresourcemanager"
- "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
- "github.com/opencord/voltha-openolt-adapter/mocks"
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
+ "github.com/opencord/voltha-openolt-adapter/pkg/mocks"
ic "github.com/opencord/voltha-protos/v3/go/inter_container"
of "github.com/opencord/voltha-protos/v3/go/openflow_13"
ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
diff --git a/adaptercore/error.go b/internal/pkg/core/error.go
similarity index 98%
rename from adaptercore/error.go
rename to internal/pkg/core/error.go
index 74bd296..0de7dc8 100644
--- a/adaptercore/error.go
+++ b/internal/pkg/core/error.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-// Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+// Package core provides the utility for olt devices, flows and statistics
+package core
import (
"encoding/json"
diff --git a/adaptercore/olt_platform.go b/internal/pkg/core/olt_platform.go
similarity index 98%
rename from adaptercore/olt_platform.go
rename to internal/pkg/core/olt_platform.go
index bca0584..747cccf 100644
--- a/adaptercore/olt_platform.go
+++ b/internal/pkg/core/olt_platform.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"github.com/opencord/voltha-lib-go/v3/pkg/flows"
diff --git a/adaptercore/olt_platform_test.go b/internal/pkg/core/olt_platform_test.go
similarity index 98%
rename from adaptercore/olt_platform_test.go
rename to internal/pkg/core/olt_platform_test.go
index 536e13a..4f3d5bf 100644
--- a/adaptercore/olt_platform_test.go
+++ b/internal/pkg/core/olt_platform_test.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"math"
diff --git a/adaptercore/olt_state_transitions.go b/internal/pkg/core/olt_state_transitions.go
similarity index 97%
rename from adaptercore/olt_state_transitions.go
rename to internal/pkg/core/olt_state_transitions.go
index 51b7ef0..c10d17d 100644
--- a/adaptercore/olt_state_transitions.go
+++ b/internal/pkg/core/olt_state_transitions.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"context"
diff --git a/adaptercore/olt_state_transitions_test.go b/internal/pkg/core/olt_state_transitions_test.go
similarity index 99%
rename from adaptercore/olt_state_transitions_test.go
rename to internal/pkg/core/olt_state_transitions_test.go
index c79aeb0..75e7807 100644
--- a/adaptercore/olt_state_transitions_test.go
+++ b/internal/pkg/core/olt_state_transitions_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package adaptercore
+package core
import (
"context"
diff --git a/adaptercore/openolt.go b/internal/pkg/core/openolt.go
similarity index 98%
rename from adaptercore/openolt.go
rename to internal/pkg/core/openolt.go
index 657f249..9a5167f 100644
--- a/adaptercore/openolt.go
+++ b/internal/pkg/core/openolt.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"context"
@@ -25,7 +25,7 @@
"github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-openolt-adapter/config"
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
ic "github.com/opencord/voltha-protos/v3/go/inter_container"
"github.com/opencord/voltha-protos/v3/go/openflow_13"
"github.com/opencord/voltha-protos/v3/go/voltha"
diff --git a/adaptercore/openolt_eventmgr.go b/internal/pkg/core/openolt_eventmgr.go
similarity index 99%
rename from adaptercore/openolt_eventmgr.go
rename to internal/pkg/core/openolt_eventmgr.go
index f233f6c..4e21d11 100644
--- a/adaptercore/openolt_eventmgr.go
+++ b/internal/pkg/core/openolt_eventmgr.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-// Package adaptercore provides APIs for the openOLT adapter
-package adaptercore
+// Package core provides APIs for the openOLT adapter
+package core
import (
ctx "context"
diff --git a/adaptercore/openolt_eventmgr_test.go b/internal/pkg/core/openolt_eventmgr_test.go
similarity index 98%
rename from adaptercore/openolt_eventmgr_test.go
rename to internal/pkg/core/openolt_eventmgr_test.go
index 7dbda43..d5f1520 100644
--- a/adaptercore/openolt_eventmgr_test.go
+++ b/internal/pkg/core/openolt_eventmgr_test.go
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-// Package adaptercore provides APIs for the openOLT adapter
-package adaptercore
+// Package core provides APIs for the openOLT adapter
+package core
import (
"sync"
"testing"
"time"
- "github.com/opencord/voltha-openolt-adapter/mocks"
+ "github.com/opencord/voltha-openolt-adapter/pkg/mocks"
oop "github.com/opencord/voltha-protos/v3/go/openolt"
)
diff --git a/adaptercore/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
similarity index 99%
rename from adaptercore/openolt_flowmgr.go
rename to internal/pkg/core/openolt_flowmgr.go
index b79e4bd..fe03a79 100644
--- a/adaptercore/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"context"
@@ -31,7 +31,7 @@
"github.com/opencord/voltha-lib-go/v3/pkg/flows"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile"
- rsrcMgr "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
+ rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
"github.com/opencord/voltha-protos/v3/go/common"
ic "github.com/opencord/voltha-protos/v3/go/inter_container"
ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
diff --git a/adaptercore/openolt_flowmgr_test.go b/internal/pkg/core/openolt_flowmgr_test.go
similarity index 98%
rename from adaptercore/openolt_flowmgr_test.go
rename to internal/pkg/core/openolt_flowmgr_test.go
index 50d85ab..2890b19 100644
--- a/adaptercore/openolt_flowmgr_test.go
+++ b/internal/pkg/core/openolt_flowmgr_test.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"context"
@@ -29,9 +29,9 @@
fu "github.com/opencord/voltha-lib-go/v3/pkg/flows"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile"
- "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
- rsrcMgr "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
- "github.com/opencord/voltha-openolt-adapter/mocks"
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
+ rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
+ "github.com/opencord/voltha-openolt-adapter/pkg/mocks"
ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
"github.com/opencord/voltha-protos/v3/go/openolt"
openoltpb2 "github.com/opencord/voltha-protos/v3/go/openolt"
diff --git a/adaptercore/openolt_test.go b/internal/pkg/core/openolt_test.go
similarity index 99%
rename from adaptercore/openolt_test.go
rename to internal/pkg/core/openolt_test.go
index 940704a..5944db2 100644
--- a/adaptercore/openolt_test.go
+++ b/internal/pkg/core/openolt_test.go
@@ -19,8 +19,8 @@
This file also implements the fields struct to mock the Openolt and few utility functions.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"context"
@@ -29,7 +29,7 @@
fu "github.com/opencord/voltha-lib-go/v3/pkg/flows"
"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-openolt-adapter/config"
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
ic "github.com/opencord/voltha-protos/v3/go/inter_container"
"github.com/opencord/voltha-protos/v3/go/openflow_13"
ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
diff --git a/adaptercore/statsmanager.go b/internal/pkg/core/statsmanager.go
similarity index 98%
rename from adaptercore/statsmanager.go
rename to internal/pkg/core/statsmanager.go
index 0ffa351..3133bce 100755
--- a/adaptercore/statsmanager.go
+++ b/internal/pkg/core/statsmanager.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"fmt"
diff --git a/adaptercore/statsmanager_test.go b/internal/pkg/core/statsmanager_test.go
similarity index 98%
rename from adaptercore/statsmanager_test.go
rename to internal/pkg/core/statsmanager_test.go
index c6fddc5..6ea2487 100644
--- a/adaptercore/statsmanager_test.go
+++ b/internal/pkg/core/statsmanager_test.go
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
-package adaptercore
+//Package core provides the utility for olt devices, flows and statistics
+package core
import (
"reflect"
diff --git a/adaptercore/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
similarity index 100%
rename from adaptercore/resourcemanager/resourcemanager.go
rename to internal/pkg/resourcemanager/resourcemanager.go
diff --git a/adaptercore/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
similarity index 100%
rename from adaptercore/resourcemanager/resourcemanager_test.go
rename to internal/pkg/resourcemanager/resourcemanager_test.go
diff --git a/mocks/mockAdapterProxy.go b/pkg/mocks/mockAdapterProxy.go
similarity index 100%
rename from mocks/mockAdapterProxy.go
rename to pkg/mocks/mockAdapterProxy.go
diff --git a/mocks/mockCoreProxy.go b/pkg/mocks/mockCoreProxy.go
similarity index 100%
rename from mocks/mockCoreProxy.go
rename to pkg/mocks/mockCoreProxy.go
diff --git a/mocks/mockEventproxy.go b/pkg/mocks/mockEventproxy.go
similarity index 100%
rename from mocks/mockEventproxy.go
rename to pkg/mocks/mockEventproxy.go
diff --git a/mocks/mockKVClient.go b/pkg/mocks/mockKVClient.go
similarity index 98%
rename from mocks/mockKVClient.go
rename to pkg/mocks/mockKVClient.go
index 2343994..f686ec1 100644
--- a/mocks/mockKVClient.go
+++ b/pkg/mocks/mockKVClient.go
@@ -26,7 +26,7 @@
"time"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
+ "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
"github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
diff --git a/mocks/mockOpenOltClient.go b/pkg/mocks/mockOpenOltClient.go
similarity index 100%
rename from mocks/mockOpenOltClient.go
rename to pkg/mocks/mockOpenOltClient.go
diff --git a/mocks/mockTechprofile.go b/pkg/mocks/mockTechprofile.go
similarity index 100%
rename from mocks/mockTechprofile.go
rename to pkg/mocks/mockTechprofile.go
diff --git a/config/version/version.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/version/version.go
similarity index 84%
rename from config/version/version.go
rename to vendor/github.com/opencord/voltha-lib-go/v3/pkg/version/version.go
index 269d748..49c0b10 100644
--- a/config/version/version.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/version/version.go
@@ -13,8 +13,6 @@
* 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 (
@@ -35,8 +33,7 @@
arch = "unknown-arch"
)
-// InfoType is a collection of build time environment variables
-type InfoType struct {
+type VersionInfoType struct {
Version string `json:"version"`
GoVersion string `json:"goversion"`
VcsRef string `json:"vcsref"`
@@ -46,11 +43,10 @@
Arch string `json:"arch"`
}
-// VersionInfo is an instance of build time environment variables populated at build time via -X arguments
-var VersionInfo InfoType
+var VersionInfo VersionInfoType
func init() {
- VersionInfo = InfoType{
+ VersionInfo = VersionInfoType{
Version: version,
VcsRef: vcsRef,
VcsDirty: vcsDirty,
@@ -61,7 +57,7 @@
}
}
-func (v InfoType) String(indent string) string {
+func (v VersionInfoType) String(indent string) string {
builder := strings.Builder{}
builder.WriteString(fmt.Sprintf("%sVersion: %s\n", indent, VersionInfo.Version))
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 120d8b2..7c3cf72 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -77,6 +77,7 @@
github.com/opencord/voltha-lib-go/v3/pkg/ponresourcemanager
github.com/opencord/voltha-lib-go/v3/pkg/probe
github.com/opencord/voltha-lib-go/v3/pkg/techprofile
+github.com/opencord/voltha-lib-go/v3/pkg/version
# github.com/opencord/voltha-protos/v3 v3.2.4
github.com/opencord/voltha-protos/v3/go/common
github.com/opencord/voltha-protos/v3/go/inter_container