Skip to content

Commit

Permalink
sciond: remove global state (scionproto#3785)
Browse files Browse the repository at this point in the history
Remove the gloabl state from sciond main.

Functionality other then initialization is moved to `go/pkg/sciond`.
The remaining global state hides in itopo.

The command is moved to cobra, and the CLI is changed to fluent style
instead of the previous flag style for sub-commands:

    sciond --config sd.toml
    sciond help-config
    sciond version
  • Loading branch information
oncilla authored Jun 16, 2020
1 parent 548a7ef commit 0c7f0c2
Show file tree
Hide file tree
Showing 30 changed files with 458 additions and 261 deletions.
4 changes: 2 additions & 2 deletions acceptance/topo_sd_reload/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ container_image(
base = "//docker:dispatcher_debug",
entrypoint = [
"/app/dispatcher",
"-config",
"--config",
"/disp.toml",
],
files = ["testdata/disp.toml"],
Expand All @@ -35,7 +35,7 @@ container_image(
base = "//docker:sciond_debug",
entrypoint = [
"/app/sciond",
"-config",
"--config",
"/sd.toml",
],
files = [
Expand Down
10 changes: 5 additions & 5 deletions docker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ scion_app_images(
binary = "//go/border:border",
entrypoint = [
"/app/border",
"-config",
"--config",
"/share/conf/br.toml",
],
workdir = "/share",
Expand All @@ -57,7 +57,7 @@ scion_app_images(
binary = "//go/cs:cs",
entrypoint = [
"/app/cs",
"-config",
"--config",
"/share/conf/cs.toml",
],
workdir = "/share",
Expand All @@ -69,7 +69,7 @@ scion_app_images(
binary = "//go/dispatcher:dispatcher",
entrypoint = [
"/app/dispatcher",
"-config",
"--config",
"/share/conf/disp.toml",
],
workdir = "/share",
Expand All @@ -81,7 +81,7 @@ scion_app_images(
binary = "//go/sciond:sciond",
entrypoint = [
"/app/sciond",
"-config",
"--config",
"/share/conf/sd.toml",
],
workdir = "/share",
Expand All @@ -93,7 +93,7 @@ scion_app_images(
binary = "//go/sig:sig",
entrypoint = [
"/app/sig",
"-config",
"--config",
"/share/conf/sig.toml",
],
workdir = "/share",
Expand Down
26 changes: 26 additions & 0 deletions go/pkg/sciond/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["sciond.go"],
importpath = "github.com/scionproto/scion/go/pkg/sciond",
visibility = ["//visibility:public"],
deps = [
"//go/lib/env:go_default_library",
"//go/lib/infra/messenger/tcp:go_default_library",
"//go/lib/infra/modules/itopo:go_default_library",
"//go/lib/infra/modules/segfetcher:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/pathdb:go_default_library",
"//go/lib/revcache:go_default_library",
"//go/lib/serrors:go_default_library",
"//go/pkg/sciond/config:go_default_library",
"//go/pkg/sciond/fetcher:go_default_library",
"//go/pkg/sciond/internal/servers:go_default_library",
"//go/pkg/trust:go_default_library",
"//go/pkg/trust/compat:go_default_library",
"//go/proto:go_default_library",
"@com_github_burntsushi_toml//:go_default_library",
"@com_github_opentracing_opentracing_go//:go_default_library",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go_library(
"config.go",
"sample.go",
],
importpath = "github.com/scionproto/scion/go/sciond/config",
importpath = "github.com/scionproto/scion/go/pkg/sciond/config",
visibility = ["//visibility:public"],
deps = [
"//go/lib/config:go_default_library",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ go_library(
"filter.go",
"pathmeta.go",
],
importpath = "github.com/scionproto/scion/go/sciond/internal/fetcher",
visibility = ["//go/sciond:__subpackages__"],
importpath = "github.com/scionproto/scion/go/pkg/sciond/fetcher",
visibility = ["//visibility:public"],
deps = [
"//go/lib/addr:go_default_library",
"//go/lib/hostinfo:go_default_library",
Expand All @@ -25,10 +25,10 @@ go_library(
"//go/lib/spath:go_default_library",
"//go/lib/topology:go_default_library",
"//go/lib/util:go_default_library",
"//go/pkg/sciond/config:go_default_library",
"//go/pkg/sciond/internal/metrics:go_default_library",
"//go/pkg/trust:go_default_library",
"//go/proto:go_default_library",
"//go/sciond/config:go_default_library",
"//go/sciond/internal/metrics:go_default_library",
],
)

Expand All @@ -47,7 +47,7 @@ go_test(
"//go/lib/pathpol:go_default_library",
"//go/lib/xtest:go_default_library",
"//go/lib/xtest/graph:go_default_library",
"//go/sciond/internal/fetcher/mock_fetcher:go_default_library",
"//go/pkg/sciond/fetcher/mock_fetcher:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import (
"github.com/scionproto/scion/go/lib/spath"
"github.com/scionproto/scion/go/lib/topology"
"github.com/scionproto/scion/go/lib/util"
"github.com/scionproto/scion/go/pkg/sciond/config"
"github.com/scionproto/scion/go/pkg/sciond/internal/metrics"
"github.com/scionproto/scion/go/pkg/trust"
"github.com/scionproto/scion/go/sciond/config"
"github.com/scionproto/scion/go/sciond/internal/metrics"
)

const (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/scionproto/scion/go/lib/pathpol"
"github.com/scionproto/scion/go/lib/xtest"
"github.com/scionproto/scion/go/lib/xtest/graph"
"github.com/scionproto/scion/go/sciond/internal/fetcher"
"github.com/scionproto/scion/go/sciond/internal/fetcher/mock_fetcher"
"github.com/scionproto/scion/go/pkg/sciond/fetcher"
"github.com/scionproto/scion/go/pkg/sciond/fetcher/mock_fetcher"
)

func TestFilter(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["fetcher.go"],
importpath = "github.com/scionproto/scion/go/sciond/internal/fetcher/mock_fetcher",
visibility = ["//go/sciond:__subpackages__"],
importpath = "github.com/scionproto/scion/go/pkg/sciond/fetcher/mock_fetcher",
visibility = ["//visibility:public"],
deps = [
"//go/lib/pathpol:go_default_library",
"//go/lib/sciond:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
],
)
89 changes: 89 additions & 0 deletions go/pkg/sciond/fetcher/mock_fetcher/fetcher.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["metrics.go"],
importpath = "github.com/scionproto/scion/go/sciond/internal/metrics",
visibility = ["//go/sciond:__subpackages__"],
importpath = "github.com/scionproto/scion/go/pkg/sciond/internal/metrics",
visibility = ["//go/pkg/sciond:__subpackages__"],
deps = [
"//go/lib/addr:go_default_library",
"//go/lib/prom:go_default_library",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"testing"

"github.com/scionproto/scion/go/lib/prom/promtest"
"github.com/scionproto/scion/go/sciond/internal/metrics"
"github.com/scionproto/scion/go/pkg/sciond/internal/metrics"
)

func TestLabels(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ go_library(
"handlers.go",
"server.go",
],
importpath = "github.com/scionproto/scion/go/sciond/internal/servers",
visibility = ["//go/sciond:__subpackages__"],
importpath = "github.com/scionproto/scion/go/pkg/sciond/internal/servers",
visibility = ["//go/pkg/sciond:__subpackages__"],
deps = [
"//go/lib/common:go_default_library",
"//go/lib/ctrl/path_mgmt:go_default_library",
Expand All @@ -22,10 +22,10 @@ go_library(
"//go/lib/sciond:go_default_library",
"//go/lib/serrors:go_default_library",
"//go/lib/tracing:go_default_library",
"//go/pkg/sciond/fetcher:go_default_library",
"//go/pkg/sciond/internal/metrics:go_default_library",
"//go/pkg/trust:go_default_library",
"//go/proto:go_default_library",
"//go/sciond/internal/fetcher:go_default_library",
"//go/sciond/internal/metrics:go_default_library",
"@com_github_opentracing_opentracing_go//:go_default_library",
"@com_github_opentracing_opentracing_go//ext:go_default_library",
"@com_zombiezen_go_capnproto2//:go_default_library",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
"github.com/scionproto/scion/go/lib/revcache"
"github.com/scionproto/scion/go/lib/sciond"
"github.com/scionproto/scion/go/lib/serrors"
"github.com/scionproto/scion/go/pkg/sciond/fetcher"
"github.com/scionproto/scion/go/pkg/sciond/internal/metrics"
"github.com/scionproto/scion/go/pkg/trust"
"github.com/scionproto/scion/go/proto"
"github.com/scionproto/scion/go/sciond/internal/fetcher"
"github.com/scionproto/scion/go/sciond/internal/metrics"
)

const (
Expand Down
File renamed without changes.
Loading

0 comments on commit 0c7f0c2

Please sign in to comment.