Repository: scionproto/scion
Pull request #3667 (2020-02-17 11:50:03)

SIG: Move pathmgr to a library


<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/scionproto/scion/3667)
<!-- Reviewable:end -->



Patch:
diff --git a/go/sig/internal/pathmgr/BUILD.bazel b/go/lib/pathmgr/BUILD.bazel
similarity index 90%
rename from go/sig/internal/pathmgr/BUILD.bazel
rename to go/lib/pathmgr/BUILD.bazel
index 43e3ec678..e970cfd65 100644
--- a/go/sig/internal/pathmgr/BUILD.bazel
+++ b/go/lib/pathmgr/BUILD.bazel
@@ -8,8 +8,8 @@ go_library(
         "syncpaths.go",
         "watch.go",
     ],
-    importpath = "github.com/scionproto/scion/go/sig/internal/pathmgr",
-    visibility = ["//go/sig:__subpackages__"],
+    importpath = "github.com/scionproto/scion/go/lib/pathmgr",
+    visibility = ["//visibility:public"],
     deps = [
         "//go/lib/addr:go_default_library",
         "//go/lib/common:go_default_library",
@@ -38,6 +38,7 @@ go_test(
         "//go/lib/ctrl/path_mgmt:go_default_library",
         "//go/lib/infra:go_default_library",
         "//go/lib/log:go_default_library",
+        "//go/lib/pathmgr/mock_pathmgr:go_default_library",
         "//go/lib/pathpol:go_default_library",
         "//go/lib/sciond:go_default_library",
         "//go/lib/sciond/mock_sciond:go_default_library",
@@ -45,7 +46,6 @@ go_test(
         "//go/lib/snet/mock_snet:go_default_library",
         "//go/lib/spath/spathmeta:go_default_library",
         "//go/lib/xtest:go_default_library",
-        "//go/sig/internal/pathmgr/mock_pathmgr:go_default_library",
         "@com_github_golang_mock//gomock:go_default_library",
         "@com_github_smartystreets_goconvey//convey:go_default_library",
         "@com_github_stretchr_testify//assert:go_default_library",
diff --git a/go/sig/internal/pathmgr/main_test.go b/go/lib/pathmgr/main_test.go
similarity index 100%
rename from go/sig/internal/pathmgr/main_test.go
rename to go/lib/pathmgr/main_test.go
diff --git a/go/sig/internal/pathmgr/mock_pathmgr/BUILD.bazel b/go/lib/pathmgr/mock_pathmgr/BUILD.bazel
similarity index 79%
rename from go/sig/internal/pathmgr/mock_pathmgr/BUILD.bazel
rename to go/lib/pathmgr/mock_pathmgr/BUILD.bazel
index 91d91d39b..fb28a3f97 100644
--- a/go/sig/internal/pathmgr/mock_pathmgr/BUILD.bazel
+++ b/go/lib/pathmgr/mock_pathmgr/BUILD.bazel
@@ -3,16 +3,16 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
 go_library(
     name = "go_default_library",
     srcs = ["pathmgr.go"],
-    importpath = "github.com/scionproto/scion/go/sig/internal/pathmgr/mock_pathmgr",
+    importpath = "github.com/scionproto/scion/go/lib/pathmgr/mock_pathmgr",
     visibility = ["//visibility:public"],
     deps = [
         "//go/lib/addr:go_default_library",
         "//go/lib/common:go_default_library",
         "//go/lib/ctrl/path_mgmt:go_default_library",
+        "//go/lib/pathmgr:go_default_library",
         "//go/lib/pathpol:go_default_library",
         "//go/lib/sciond:go_default_library",
         "//go/lib/spath/spathmeta:go_default_library",
-        "//go/sig/internal/pathmgr:go_default_library",
         "@com_github_golang_mock//gomock:go_default_library",
     ],
 )
diff --git a/go/sig/internal/pathmgr/mock_pathmgr/pathmgr.go b/go/lib/pathmgr/mock_pathmgr/pathmgr.go
similarity index 97%
rename from go/sig/internal/pathmgr/mock_pathmgr/pathmgr.go
rename to go/lib/pathmgr/mock_pathmgr/pathmgr.go
index e10958fe2..92e2b3aa7 100644
--- a/go/sig/internal/pathmgr/mock_pathmgr/pathmgr.go
+++ b/go/lib/pathmgr/mock_pathmgr/pathmgr.go
@@ -1,5 +1,5 @@
 // Code generated by MockGen. DO NOT EDIT.
-// Source: github.com/scionproto/scion/go/sig/internal/pathmgr (interfaces: Policy,Querier,Resolver)
+// Source: github.com/scionproto/scion/go/lib/pathmgr (interfaces: Policy,Querier,Resolver)
 
 // Package mock_pathmgr is a generated GoMock package.
 package mock_pathmgr
@@ -10,10 +10,10 @@ import (
 	addr "github.com/scionproto/scion/go/lib/addr"
 	common "github.com/scionproto/scion/go/lib/common"
 	path_mgmt "github.com/scionproto/scion/go/lib/ctrl/path_mgmt"
+	pathmgr "github.com/scionproto/scion/go/lib/pathmgr"
 	pathpol "github.com/scionproto/scion/go/lib/pathpol"
 	sciond "github.com/scionproto/scion/go/lib/sciond"
 	spathmeta "github.com/scionproto/scion/go/lib/spath/spathmeta"
-	pathmgr "github.com/scionproto/scion/go/sig/internal/pathmgr"
 	reflect "reflect"
 )
 
diff --git a/go/sig/internal/pathmgr/util_test.go b/go/lib/pathmgr/util_test.go
similarity index 100%
rename from go/sig/internal/pathmgr/util_test.go
rename to go/lib/pathmgr/util_test.go
diff --git a/go/sig/internal/pathmgr/watch.go b/go/lib/pathmgr/watch.go
similarity index 100%
rename from go/sig/internal/pathmgr/watch.go
rename to go/lib/pathmgr/watch.go
diff --git a/go/sig/egress/session/BUILD.bazel b/go/sig/egress/session/BUILD.bazel
index c27eb4fc2..c14cac463 100644
--- a/go/sig/egress/session/BUILD.bazel
+++ b/go/sig/egress/session/BUILD.bazel
@@ -15,6 +15,7 @@ go_library(
         "//go/lib/ctrl/sig_mgmt:go_default_library",
         "//go/lib/infra:go_default_library",
         "//go/lib/log:go_default_library",
+        "//go/lib/pathmgr:go_default_library",
         "//go/lib/pktdisp:go_default_library",
         "//go/lib/ringbuf:go_default_library",
         "//go/lib/snet:go_default_library",
@@ -24,7 +25,6 @@ go_library(
         "//go/sig/egress/worker:go_default_library",
         "//go/sig/internal/disp:go_default_library",
         "//go/sig/internal/metrics:go_default_library",
-        "//go/sig/internal/pathmgr:go_default_library",
         "//go/sig/internal/sigcmn:go_default_library",
     ],
 )
diff --git a/go/sig/egress/session/session.go b/go/sig/egress/session/session.go
index cc27ec46f..bea0ccaeb 100644
--- a/go/sig/egress/session/session.go
+++ b/go/sig/egress/session/session.go
@@ -28,13 +28,13 @@ import (
 	"github.com/scionproto/scion/go/lib/common"
 	"github.com/scionproto/scion/go/lib/ctrl/sig_mgmt"
 	"github.com/scionproto/scion/go/lib/log"
+	"github.com/scionproto/scion/go/lib/pathmgr"
 	"github.com/scionproto/scion/go/lib/pktdisp"
 	"github.com/scionproto/scion/go/lib/ringbuf"
 	"github.com/scionproto/scion/go/lib/snet"
 	"github.com/scionproto/scion/go/lib/spath/spathmeta"
 	"github.com/scionproto/scion/go/sig/egress/iface"
 	"github.com/scionproto/scion/go/sig/egress/worker"
-	"github.com/scionproto/scion/go/sig/internal/pathmgr"
 	"github.com/scionproto/scion/go/sig/internal/sigcmn"
 )
 
diff --git a/go/sig/internal/sigcmn/BUILD.bazel b/go/sig/internal/sigcmn/BUILD.bazel
index f1d0b73f4..31f624c18 100644
--- a/go/sig/internal/sigcmn/BUILD.bazel
+++ b/go/sig/internal/sigcmn/BUILD.bazel
@@ -12,11 +12,11 @@ go_library(
         "//go/lib/ctrl/sig_mgmt:go_default_library",
         "//go/lib/env:go_default_library",
         "//go/lib/log:go_default_library",
+        "//go/lib/pathmgr:go_default_library",
         "//go/lib/sciond/fake:go_default_library",
         "//go/lib/serrors:go_default_library",
         "//go/lib/snet:go_default_library",
         "//go/lib/sock/reliable:go_default_library",
-        "//go/sig/internal/pathmgr:go_default_library",
         "//go/sig/internal/sigconfig:go_default_library",
         "//go/sig/internal/snetmigrate:go_default_library",
     ],
diff --git a/go/sig/internal/sigcmn/common.go b/go/sig/internal/sigcmn/common.go
index 8f0f296b7..04fb49e4d 100644
--- a/go/sig/internal/sigcmn/common.go
+++ b/go/sig/internal/sigcmn/common.go
@@ -26,11 +26,11 @@ import (
 	"github.com/scionproto/scion/go/lib/ctrl/sig_mgmt"
 	"github.com/scionproto/scion/go/lib/env"
 	"github.com/scionproto/scion/go/lib/log"
+	"github.com/scionproto/scion/go/lib/pathmgr"
 	"github.com/scionproto/scion/go/lib/sciond/fake"
 	"github.com/scionproto/scion/go/lib/serrors"
 	"github.com/scionproto/scion/go/lib/snet"
 	"github.com/scionproto/scion/go/lib/sock/reliable"
-	"github.com/scionproto/scion/go/sig/internal/pathmgr"
 	"github.com/scionproto/scion/go/sig/internal/sigconfig"
 	"github.com/scionproto/scion/go/sig/internal/snetmigrate"
 )
diff --git a/go/sig/internal/snetmigrate/BUILD.bazel b/go/sig/internal/snetmigrate/BUILD.bazel
index 1ae021422..656bc62dd 100644
--- a/go/sig/internal/snetmigrate/BUILD.bazel
+++ b/go/sig/internal/snetmigrate/BUILD.bazel
@@ -12,12 +12,12 @@ go_library(
     deps = [
         "//go/lib/addr:go_default_library",
         "//go/lib/common:go_default_library",
+        "//go/lib/pathmgr:go_default_library",
         "//go/lib/pathpol:go_default_library",
         "//go/lib/sciond:go_default_library",
         "//go/lib/serrors:go_default_library",
         "//go/lib/snet:go_default_library",
         "//go/lib/spath:go_default_library",
         "//go/lib/spath/spathmeta:go_default_library",
-        "//go/sig/internal/pathmgr:go_default_library",
     ],
 )
diff --git a/go/sig/internal/snetmigrate/querier.go b/go/sig/internal/snetmigrate/querier.go
index f9e8297d1..4ef037a44 100644
--- a/go/sig/internal/snetmigrate/querier.go
+++ b/go/sig/internal/snetmigrate/querier.go
@@ -19,11 +19,11 @@ import (
 
 	"github.com/scionproto/scion/go/lib/addr"
 	"github.com/scionproto/scion/go/lib/common"
+	"github.com/scionproto/scion/go/lib/pathmgr"
 	"github.com/scionproto/scion/go/lib/pathpol"
 	"github.com/scionproto/scion/go/lib/sciond"
 	"github.com/scionproto/scion/go/lib/snet"
 	"github.com/scionproto/scion/go/lib/spath/spathmeta"
-	"github.com/scionproto/scion/go/sig/internal/pathmgr"
 )
 
 // PathQuerier implements snet.PathQuerier. This struct just exists to simplify
diff --git a/go/sig/internal/snetmigrate/resolver.go b/go/sig/internal/snetmigrate/resolver.go
index 19fa92915..4ba22c4dc 100644
--- a/go/sig/internal/snetmigrate/resolver.go
+++ b/go/sig/internal/snetmigrate/resolver.go
@@ -17,9 +17,9 @@ package snetmigrate
 import (
 	"context"
 
+	"github.com/scionproto/scion/go/lib/pathmgr"
 	"github.com/scionproto/scion/go/lib/sciond"
 	"github.com/scionproto/scion/go/lib/serrors"
-	"github.com/scionproto/scion/go/sig/internal/pathmgr"
 )
 
 func ResolverFromSD(sciondPath string, pathCount uint16) (pathmgr.Resolver, error) {
diff --git a/tools/gomocks b/tools/gomocks
index 572903512..519557665 100755
--- a/tools/gomocks
+++ b/tools/gomocks
@@ -55,6 +55,7 @@ MOCK_TARGETS = [
         (SCION_PACKAGE_PREFIX + "/go/lib/log", "Handler,Logger"),
         (SCION_PACKAGE_PREFIX + "/go/lib/overlay/conn", "Conn"),
         (SCION_PACKAGE_PREFIX + "/go/lib/pathdb", "PathDB,Transaction,ReadWrite"),
+        (SCION_PACKAGE_PREFIX + "/go/lib/pathmgr", "Policy,Querier,Resolver"),
         (SCION_PACKAGE_PREFIX + "/go/lib/revcache", "RevCache"),
         (SCION_PACKAGE_PREFIX + "/go/lib/sciond", "Service,Connector"),
         (SCION_PACKAGE_PREFIX + "/go/lib/snet", "Conn,PacketDispatcherService,Network,PacketConn," +
@@ -67,7 +68,6 @@ MOCK_TARGETS = [
         (SCION_PACKAGE_PREFIX + "/go/lib/periodic/internal/metrics", "ExportMetric"),
         (SCION_PACKAGE_PREFIX + "/go/lib/xtest", "Callback"),
         (SCION_PACKAGE_PREFIX + "/go/sciond/internal/fetcher", "Policy"),
-        (SCION_PACKAGE_PREFIX + "/go/sig/internal/pathmgr", "Policy,Querier,Resolver"),
         (SCION_PACKAGE_PREFIX + "/go/sig/egress/iface", "Session"),
         (SCION_PACKAGE_PREFIX + "/go/sig/egress/worker", "SCIONWriter"),
 ]


Test patch:
diff --git a/go/sig/internal/pathmgr/pathmgr.go b/go/lib/pathmgr/pathmgr.go
similarity index 100%
rename from go/sig/internal/pathmgr/pathmgr.go
rename to go/lib/pathmgr/pathmgr.go
diff --git a/go/sig/internal/pathmgr/pathmgr_test.go b/go/lib/pathmgr/pathmgr_test.go
similarity index 98%
rename from go/sig/internal/pathmgr/pathmgr_test.go
rename to go/lib/pathmgr/pathmgr_test.go
index 620ffda44..44ff53531 100644
--- a/go/sig/internal/pathmgr/pathmgr_test.go
+++ b/go/lib/pathmgr/pathmgr_test.go
@@ -30,12 +30,12 @@ import (
 	"github.com/scionproto/scion/go/lib/common"
 	"github.com/scionproto/scion/go/lib/ctrl/path_mgmt"
 	"github.com/scionproto/scion/go/lib/infra"
+	"github.com/scionproto/scion/go/lib/pathmgr"
+	"github.com/scionproto/scion/go/lib/pathmgr/mock_pathmgr"
 	"github.com/scionproto/scion/go/lib/pathpol"
 	"github.com/scionproto/scion/go/lib/sciond"
 	"github.com/scionproto/scion/go/lib/sciond/mock_sciond"
 	"github.com/scionproto/scion/go/lib/xtest"
-	"github.com/scionproto/scion/go/sig/internal/pathmgr"
-	"github.com/scionproto/scion/go/sig/internal/pathmgr/mock_pathmgr"
 )
 
 const timeUnitDuration time.Duration = 10 * time.Millisecond
diff --git a/go/sig/internal/pathmgr/polling_policy.go b/go/lib/pathmgr/polling_policy.go
similarity index 100%
rename from go/sig/internal/pathmgr/polling_policy.go
rename to go/lib/pathmgr/polling_policy.go
diff --git a/go/sig/internal/pathmgr/syncpaths.go b/go/lib/pathmgr/syncpaths.go
similarity index 100%
rename from go/sig/internal/pathmgr/syncpaths.go
rename to go/lib/pathmgr/syncpaths.go
diff --git a/go/sig/internal/pathmgr/syncpaths_test.go b/go/lib/pathmgr/syncpaths_test.go
similarity index 97%
rename from go/sig/internal/pathmgr/syncpaths_test.go
rename to go/lib/pathmgr/syncpaths_test.go
index e10b219ae..dc5ffcc15 100644
--- a/go/sig/internal/pathmgr/syncpaths_test.go
+++ b/go/lib/pathmgr/syncpaths_test.go
@@ -21,8 +21,8 @@ import (
 
 	. "github.com/smartystreets/goconvey/convey"
 
+	"github.com/scionproto/scion/go/lib/pathmgr"
 	"github.com/scionproto/scion/go/lib/spath/spathmeta"
-	"github.com/scionproto/scion/go/sig/internal/pathmgr"
 )
 
 func TestSyncPathsTimestamp(t *testing.T) {