From c4eb6dd5dc08378382a8720c3740a8cc81c6949e Mon Sep 17 00:00:00 2001 From: Jim Wang Date: Wed, 20 Jan 2021 18:22:24 -0700 Subject: [PATCH] feat(security): Address PR feedback Address Lenny's PR feedbacks Signed-off-by: Jim Wang --- .../entrypoint-scripts/consul_wait_install.sh | 6 +-- .../entrypoint-scripts/kong_wait_install.sh | 5 ++- .../postgres_wait_install.sh | 7 ++-- .../entrypoint-scripts/redis_wait_install.sh | 11 +++--- cmd/security-bootstrapper/entrypoint.sh | 3 +- .../res/configuration.toml | 14 ++++--- cmd/security-secretstore-setup/entrypoint.sh | 5 +-- .../bootstrapper/command/cmd_dispatcher.go | 2 +- .../command/cmd_dispatcher_test.go | 2 +- .../bootstrapper/command/flags_common.go | 2 +- .../bootstrapper/command/gate/command.go | 20 +++++----- .../bootstrapper/command/gate/command_test.go | 36 +++++++++--------- .../command/genpassword/command.go | 2 +- .../command/genpassword/command_test.go | 6 +-- .../command/gethttpstatus/command.go | 2 +- .../command/gethttpstatus/command_test.go | 6 +-- .../bootstrapper/command/help/command.go | 2 +- .../bootstrapper/command/help/command_test.go | 6 +-- .../bootstrapper/command/listen/command.go | 4 +- .../command/listen/command_test.go | 6 +-- .../bootstrapper/command/ping/command.go | 14 +++---- .../bootstrapper/command/ping/command_test.go | 6 +-- .../security/bootstrapper/config/config.go | 5 +-- .../security/bootstrapper/config/types.go | 38 +++++++++---------- .../bootstrapper/container/container.go | 3 +- .../security/bootstrapper/handlers/init.go | 6 +-- internal/security/bootstrapper/main.go | 8 ++-- internal/security/bootstrapper/tcp/client.go | 2 +- .../security/bootstrapper/tcp/client_test.go | 4 +- .../security/bootstrapper/tcp/listener.go | 2 +- .../bootstrapper/tcp/listener_test.go | 4 +- 31 files changed, 121 insertions(+), 118 deletions(-) diff --git a/cmd/security-bootstrapper/entrypoint-scripts/consul_wait_install.sh b/cmd/security-bootstrapper/entrypoint-scripts/consul_wait_install.sh index 767033276d..bcb57552c8 100755 --- a/cmd/security-bootstrapper/entrypoint-scripts/consul_wait_install.sh +++ b/cmd/security-bootstrapper/entrypoint-scripts/consul_wait_install.sh @@ -68,13 +68,13 @@ exec docker-entrypoint.sh agent -ui -bootstrap -server -client 0.0.0.0 & # wait for the consul port echo "$(date) Executing dockerize on Consul with waiting on its own port \ - tcp://${REGISTRY_HOST}:${STAGEGATE_CONSUL_PORT}" -/edgex-init/dockerize -wait tcp://"${REGISTRY_HOST}":"${STAGEGATE_CONSUL_PORT}" \ + tcp://${STAGEGATE_REGISTRY_HOST}:${STAGEGATE_REGISTRY_PORT}" +/edgex-init/dockerize -wait tcp://"${STAGEGATE_REGISTRY_HOST}":"${STAGEGATE_REGISTRY_PORT}" \ -timeout "${SECTY_BOOTSTRAP_GATING_TIMEOUT_DURATION}" # Signal that Consul is ready for services blocked waiting on Consul /edgex-init/security-bootstrapper --confdir=/edgex-init/res listenTcp \ - --port="${STAGEGATE_CONSUL_READYPORT}" --host="${REGISTRY_HOST}" + --port="${STAGEGATE_REGISTRY_READYPORT}" --host="${STAGEGATE_REGISTRY_HOST}" if [ $? -ne 0 ]; then echo "$(date) failed to gating the consul ready port, exits" fi diff --git a/cmd/security-bootstrapper/entrypoint-scripts/kong_wait_install.sh b/cmd/security-bootstrapper/entrypoint-scripts/kong_wait_install.sh index 98d9629c44..44eb6522cc 100755 --- a/cmd/security-bootstrapper/entrypoint-scripts/kong_wait_install.sh +++ b/cmd/security-bootstrapper/entrypoint-scripts/kong_wait_install.sh @@ -32,9 +32,10 @@ echo "$(date) Executing dockerize with waiting on tcp://${STAGEGATE_BOOTSTRAPPER -timeout "${SECTY_BOOTSTRAP_GATING_TIMEOUT_DURATION}" echo "$(date) Kong waits on Postgres to be initialized" -/edgex-init/dockerize -wait tcp://"${STAGEGATE_PG_HOST}":"${STAGEGATE_PG_READYPORT}" \ +/edgex-init/dockerize -wait tcp://"${STAGEGATE_KONGDB_HOST}":"${STAGEGATE_KONGDB_READYPORT}" \ -timeout "${SECTY_BOOTSTRAP_GATING_TIMEOUT_DURATION}" +# KONG_PG_PASSWORD_FILE is env used by Kong, it is for kong-db's password file echo "$(date) Executing dockerize with waiting on file:${KONG_PG_PASSWORD_FILE}" /edgex-init/dockerize -wait file://"${KONG_PG_PASSWORD_FILE}" \ -timeout "${SECTY_BOOTSTRAP_GATING_TIMEOUT_DURATION}" @@ -52,7 +53,7 @@ until [ $pg_inited -eq 1 ]; do fi fi if [ $pg_inited -ne 1 ]; then - echo "$(date) waiting for ${STAGEGATE_PG_HOST} to be initialized" + echo "$(date) waiting for ${STAGEGATE_KONGDB_HOST} to be initialized" sleep 1 fi done diff --git a/cmd/security-bootstrapper/entrypoint-scripts/postgres_wait_install.sh b/cmd/security-bootstrapper/entrypoint-scripts/postgres_wait_install.sh index cff6a99cb4..93ff856f6a 100755 --- a/cmd/security-bootstrapper/entrypoint-scripts/postgres_wait_install.sh +++ b/cmd/security-bootstrapper/entrypoint-scripts/postgres_wait_install.sh @@ -52,6 +52,7 @@ done echo "$(date) ${SECRETSTORE_HOST} is ready" +# POSTGRES_PASSWORD_FILE env is used by Postgres and it is for the db password file # if password already in then re-use if [ -n "${POSTGRES_PASSWORD_FILE}" ] && [ -f "${POSTGRES_PASSWORD_FILE}" ]; then echo "$(date) previous file already exists, skipping creation" @@ -83,16 +84,16 @@ until [ $pg_inited -eq 1 ]; do fi fi if [ $pg_inited -ne 1 ]; then - echo "$(date) waiting for ${STAGEGATE_PG_HOST} to be initialized" + echo "$(date) waiting for ${STAGEGATE_KONGDB_HOST} to be initialized" sleep 1 fi done -echo "$(date) ${STAGEGATE_PG_HOST} is initialized" +echo "$(date) ${STAGEGATE_KONGDB_HOST} is initialized" # Signal that Postgres is ready for services blocked waiting on Postgres /edgex-init/security-bootstrapper --confdir=/edgex-init/res listenTcp \ - --port="${STAGEGATE_PG_READYPORT}" --host="${STAGEGATE_PG_HOST}" + --port="${STAGEGATE_KONGDB_READYPORT}" --host="${STAGEGATE_KONGDB_HOST}" if [ $? -ne 0 ]; then echo "$(date) failed to gating the postgres ready port, exits" fi diff --git a/cmd/security-bootstrapper/entrypoint-scripts/redis_wait_install.sh b/cmd/security-bootstrapper/entrypoint-scripts/redis_wait_install.sh index 586a98e090..60406813f1 100755 --- a/cmd/security-bootstrapper/entrypoint-scripts/redis_wait_install.sh +++ b/cmd/security-bootstrapper/entrypoint-scripts/redis_wait_install.sh @@ -28,13 +28,14 @@ echo "Script for waiting security bootstrapping on Redis" # gating on the TokensReadyPort echo "$(date) Executing dockerize on Redis with waiting on TokensReadyPort \ - tcp://${STAGEGATE_VAULTWORKER_HOST}:${STAGEGATE_VAULTWORKER_TOKENS_READYPORT}" -/edgex-init/dockerize -wait tcp://"${STAGEGATE_VAULTWORKER_HOST}":"${STAGEGATE_VAULTWORKER_TOKENS_READYPORT}" \ + tcp://${STAGEGATE_SECRETSTORESETUP_HOST}:${STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT}" +/edgex-init/dockerize -wait tcp://"${STAGEGATE_SECRETSTORESETUP_HOST}":"${STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT}" \ -timeout "${SECTY_BOOTSTRAP_GATING_TIMEOUT_DURATION}" # the bootstrap-redis needs the connection from Redis db to set it up. -# Hence, here bootstrap-redis runs in background and then starts the Redis db. -echo "$(date) ${STAGEGATE_VAULTWORKER_HOST} tokens ready, bootstrapping redis..." +# Hence, here bootstrap-redis runs in background and then after bootstrap-redis starts, +# the Redis db starts in background. +echo "$(date) ${STAGEGATE_SECRETSTORESETUP_HOST} tokens ready, bootstrapping redis..." /edgex-init/bootstrap-redis/security-bootstrap-redis --confdir=/edgex-init/bootstrap-redis/res & redis_bootstrapper_pid=$! @@ -55,7 +56,7 @@ fi # Signal that Redis is ready for services blocked waiting on Redis /edgex-init/security-bootstrapper --confdir=/edgex-init/res listenTcp \ - --port="${STAGEGATE_REDIS_READYPORT}" --host="${DATABASES_PRIMARY_HOST}" + --port="${STAGEGATE_DATABASE_READYPORT}" --host="${DATABASES_PRIMARY_HOST}" if [ $? -ne 0 ]; then echo "$(date) failed to gating the redis ready port, exits" fi diff --git a/cmd/security-bootstrapper/entrypoint.sh b/cmd/security-bootstrapper/entrypoint.sh index d35e757cf0..4e29f0dd14 100755 --- a/cmd/security-bootstrapper/entrypoint.sh +++ b/cmd/security-bootstrapper/entrypoint.sh @@ -33,7 +33,8 @@ fi DEFAULT_EDGEX_USER_ID=2002 EDGEX_USER_ID=${EDGEX_USER:-$DEFAULT_EDGEX_USER_ID} -# only doing the bootstrapping with the env. injecting into all other related containers +# During the bootstrapping, environment variables come for compose file environment files, +# which then injecting into all other related containers on other services' entrypoint scripts # if the executable is not 'security-bootstrapper'; then we consider it not running the bootstrapping process # for the user may just want to debug into the container shell itself if [ "$1" = 'security-bootstrapper' ]; then diff --git a/cmd/security-bootstrapper/res/configuration.toml b/cmd/security-bootstrapper/res/configuration.toml index 2b044ba3b8..d99769cf40 100644 --- a/cmd/security-bootstrapper/res/configuration.toml +++ b/cmd/security-bootstrapper/res/configuration.toml @@ -7,19 +7,21 @@ LogLevel = 'INFO' StartPort = 54321 [StageGate.Ready] ToRunPort = 54329 - [StageGate.VaultWorker] - Host = "edgex-vault-worker" - [StageGate.VaultWorker.Tokens] + [StageGate.SecretStoreSetup] + Host = "edgex-secretstore-setup" + [StageGate.SecretStoreSetup.Tokens] ReadyPort = 54322 - [StageGate.Redis] + [StageGate.Database] + # this is intended to be the same as Database.Primary.Host/.Port for other services Host = "edgex-redis" Port = 6379 ReadyPort = 54323 - [StageGate.Consul] + [StageGate.Registry] + # this is intended to be the same as Registry.Host/.Port for other services Host = "edgex-core-consul" Port = 8500 ReadyPort = 54324 - [StageGate.PG] + [StageGate.KongDb] Host = "kong-db" Port = 5432 ReadyPort = 54325 diff --git a/cmd/security-secretstore-setup/entrypoint.sh b/cmd/security-secretstore-setup/entrypoint.sh index 665497cbd0..d3ecf2b3a1 100644 --- a/cmd/security-secretstore-setup/entrypoint.sh +++ b/cmd/security-secretstore-setup/entrypoint.sh @@ -37,10 +37,7 @@ chown -Rh ${EDGEX_USER}:${EDGEX_GROUP} /tmp/edgex/secrets # Signal tokens ready port for other services waiting on /edgex-init/security-bootstrapper --confdir=/edgex-init/res listenTcp \ - --port="${STAGEGATE_VAULTWORKER_TOKENS_READYPORT}" --host="${STAGEGATE_VAULTWORKER_HOST}" + --port="${STAGEGATE_SECRETSTORESETUP_TOKENS_READYPORT}" --host="${STAGEGATE_SECRETSTORESETUP_HOST}" if [ $? -ne 0 ]; then echo "$(date) failed to gating the tokens ready port" fi - -echo "Waiting for termination signal" -exec tail -f /dev/null diff --git a/internal/security/bootstrapper/command/cmd_dispatcher.go b/internal/security/bootstrapper/command/cmd_dispatcher.go index 303d9ee4ef..a7e68e5ec8 100644 --- a/internal/security/bootstrapper/command/cmd_dispatcher.go +++ b/internal/security/bootstrapper/command/cmd_dispatcher.go @@ -28,7 +28,7 @@ import ( "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) // NewCommand instantiates a command implementing interfaces.Command based on the input command argument diff --git a/internal/security/bootstrapper/command/cmd_dispatcher_test.go b/internal/security/bootstrapper/command/cmd_dispatcher_test.go index 042f1913ea..fcebe50592 100644 --- a/internal/security/bootstrapper/command/cmd_dispatcher_test.go +++ b/internal/security/bootstrapper/command/cmd_dispatcher_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) func TestNewCommand(t *testing.T) { diff --git a/internal/security/bootstrapper/command/flags_common.go b/internal/security/bootstrapper/command/flags_common.go index 34b6380464..b9999f73f8 100644 --- a/internal/security/bootstrapper/command/flags_common.go +++ b/internal/security/bootstrapper/command/flags_common.go @@ -22,7 +22,7 @@ import ( "github.com/edgexfoundry/edgex-go/internal" - "github.com/edgexfoundry/go-mod-bootstrap/bootstrap/flags" + "github.com/edgexfoundry/go-mod-bootstrap/v2/bootstrap/flags" ) // commonFlags is a custom implementation of flags.Common from go-mod-bootstrap diff --git a/internal/security/bootstrapper/command/gate/command.go b/internal/security/bootstrapper/command/gate/command.go index a314e346c5..eff231a02b 100644 --- a/internal/security/bootstrapper/command/gate/command.go +++ b/internal/security/bootstrapper/command/gate/command.go @@ -27,7 +27,7 @@ import ( "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/tcp" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) const ( @@ -85,31 +85,31 @@ func (c *cmd) Execute() (statusCode int, err error) { // wait on for others to be done: each of tcp dialers is a blocking call c.loggingClient.Debug("Waiting on dependent semaphores required to raise the ready-to-run semaphore ...") if err := tcp.DialTcp( - c.config.StageGate.Consul.Host, - c.config.StageGate.Consul.ReadyPort, + c.config.StageGate.Registry.Host, + c.config.StageGate.Registry.ReadyPort, c.loggingClient); err != nil { retErr := fmt.Errorf("found error while waiting for readiness of Consul at %s:%d, err: %v", - c.config.StageGate.Consul.Host, c.config.StageGate.Consul.ReadyPort, err) + c.config.StageGate.Registry.Host, c.config.StageGate.Registry.ReadyPort, err) return interfaces.StatusCodeExitWithError, retErr } c.loggingClient.Info("Consul is ready") if err := tcp.DialTcp( - c.config.StageGate.PG.Host, - c.config.StageGate.PG.ReadyPort, + c.config.StageGate.KongDB.Host, + c.config.StageGate.KongDB.ReadyPort, c.loggingClient); err != nil { retErr := fmt.Errorf("found error while waiting for readiness of Postgres at %s:%d, err: %v", - c.config.StageGate.PG.Host, c.config.StageGate.PG.ReadyPort, err) + c.config.StageGate.KongDB.Host, c.config.StageGate.KongDB.ReadyPort, err) return interfaces.StatusCodeExitWithError, retErr } c.loggingClient.Info("Postgres is ready") if err := tcp.DialTcp( - c.config.StageGate.Redis.Host, - c.config.StageGate.Redis.ReadyPort, + c.config.StageGate.Database.Host, + c.config.StageGate.Database.ReadyPort, c.loggingClient); err != nil { retErr := fmt.Errorf("found error while waiting for readiness of Redis at %s:%d, err: %v", - c.config.StageGate.Redis.Host, c.config.StageGate.Redis.ReadyPort, err) + c.config.StageGate.Database.Host, c.config.StageGate.Database.ReadyPort, err) return interfaces.StatusCodeExitWithError, retErr } c.loggingClient.Info("Redis is ready") diff --git a/internal/security/bootstrapper/command/gate/command_test.go b/internal/security/bootstrapper/command/gate/command_test.go index 36031fba5e..36ac2d06ca 100644 --- a/internal/security/bootstrapper/command/gate/command_test.go +++ b/internal/security/bootstrapper/command/gate/command_test.go @@ -21,13 +21,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/tcp" - "github.com/stretchr/testify/require" - - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) func TestNewCommand(t *testing.T) { @@ -62,9 +62,9 @@ func TestNewCommand(t *testing.T) { type testConfig struct { testHost string bootstrapperStartPort int - consulReadyPort int - redisReadyPort int - postgresReadyPort int + registryReadyPort int + databaseReadyPort int + kongDBReadyPort int readyToRunPort int } @@ -75,9 +75,9 @@ func TestExecuteWithAllDependentsRun(t *testing.T) { testConfig := &testConfig{ testHost: "localhost", bootstrapperStartPort: 28001, - consulReadyPort: 28002, - redisReadyPort: 28003, - postgresReadyPort: 28004, + registryReadyPort: 28002, + databaseReadyPort: 28003, + kongDBReadyPort: 28004, readyToRunPort: 28009, } config := setupMockServiceConfigs(testConfig) @@ -107,15 +107,15 @@ func TestExecuteWithAllDependentsRun(t *testing.T) { tcpSrvErr := make(chan error) // start up all other dependent mock services: go func() { - tcpSrvErr <- tcp.NewTcpServer().StartListener(testConfig.consulReadyPort, + tcpSrvErr <- tcp.NewTcpServer().StartListener(testConfig.registryReadyPort, lc, testHost) }() go func() { - tcpSrvErr <- tcp.NewTcpServer().StartListener(testConfig.postgresReadyPort, + tcpSrvErr <- tcp.NewTcpServer().StartListener(testConfig.kongDBReadyPort, lc, testHost) }() go func() { - tcpSrvErr <- tcp.NewTcpServer().StartListener(testConfig.redisReadyPort, + tcpSrvErr <- tcp.NewTcpServer().StartListener(testConfig.databaseReadyPort, lc, testHost) }() @@ -137,20 +137,20 @@ func setupMockServiceConfigs(testConf *testConfig) *config.ConfigurationStruct { Host: testConf.testHost, StartPort: testConf.bootstrapperStartPort, }, - Consul: config.ConsulInfo{ + Registry: config.RegistryInfo{ Host: testConf.testHost, Port: 12001, - ReadyPort: testConf.consulReadyPort, + ReadyPort: testConf.registryReadyPort, }, - Redis: config.RedisInfo{ + Database: config.DatabaseInfo{ Host: testConf.testHost, Port: 12002, - ReadyPort: testConf.redisReadyPort, + ReadyPort: testConf.databaseReadyPort, }, - PG: config.PostgresInfo{ + KongDB: config.KongDBInfo{ Host: testConf.testHost, Port: 12003, - ReadyPort: testConf.postgresReadyPort, + ReadyPort: testConf.kongDBReadyPort, }, Ready: config.ReadyInfo{ ToRunPort: testConf.readyToRunPort, diff --git a/internal/security/bootstrapper/command/genpassword/command.go b/internal/security/bootstrapper/command/genpassword/command.go index b0e241ecf6..eaad93f35a 100644 --- a/internal/security/bootstrapper/command/genpassword/command.go +++ b/internal/security/bootstrapper/command/genpassword/command.go @@ -28,7 +28,7 @@ import ( "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) const ( diff --git a/internal/security/bootstrapper/command/genpassword/command_test.go b/internal/security/bootstrapper/command/genpassword/command_test.go index 96b4db6067..f37edf6ba4 100644 --- a/internal/security/bootstrapper/command/genpassword/command_test.go +++ b/internal/security/bootstrapper/command/genpassword/command_test.go @@ -20,12 +20,12 @@ import ( "sync" "testing" + "github.com/stretchr/testify/require" + "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" - "github.com/stretchr/testify/require" - - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) func TestNewCommand(t *testing.T) { diff --git a/internal/security/bootstrapper/command/gethttpstatus/command.go b/internal/security/bootstrapper/command/gethttpstatus/command.go index bb2c1f21cc..b72a4aa2c3 100644 --- a/internal/security/bootstrapper/command/gethttpstatus/command.go +++ b/internal/security/bootstrapper/command/gethttpstatus/command.go @@ -30,7 +30,7 @@ import ( "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" "github.com/edgexfoundry/edgex-go/internal/security/secretstoreclient" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) const ( diff --git a/internal/security/bootstrapper/command/gethttpstatus/command_test.go b/internal/security/bootstrapper/command/gethttpstatus/command_test.go index 83173e0d0a..fa4f815aa5 100644 --- a/internal/security/bootstrapper/command/gethttpstatus/command_test.go +++ b/internal/security/bootstrapper/command/gethttpstatus/command_test.go @@ -22,12 +22,12 @@ import ( "sync" "testing" + "github.com/stretchr/testify/require" + "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" - "github.com/stretchr/testify/require" - - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) func TestNewCommand(t *testing.T) { diff --git a/internal/security/bootstrapper/command/help/command.go b/internal/security/bootstrapper/command/help/command.go index 2baddb6551..b541ff7bf1 100644 --- a/internal/security/bootstrapper/command/help/command.go +++ b/internal/security/bootstrapper/command/help/command.go @@ -24,7 +24,7 @@ import ( "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) const ( diff --git a/internal/security/bootstrapper/command/help/command_test.go b/internal/security/bootstrapper/command/help/command_test.go index 50454b72fa..404dbf6e4a 100644 --- a/internal/security/bootstrapper/command/help/command_test.go +++ b/internal/security/bootstrapper/command/help/command_test.go @@ -18,12 +18,12 @@ package help import ( "testing" + "github.com/stretchr/testify/require" + "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" - - "github.com/stretchr/testify/require" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) // TestHelp tests functionality of help command diff --git a/internal/security/bootstrapper/command/listen/command.go b/internal/security/bootstrapper/command/listen/command.go index d1758021b9..85364e30d0 100644 --- a/internal/security/bootstrapper/command/listen/command.go +++ b/internal/security/bootstrapper/command/listen/command.go @@ -27,7 +27,7 @@ import ( "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/tcp" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) const ( @@ -76,7 +76,7 @@ func NewCommand( } // Execute implements Command and runs this command -// command listTcp starts a TCP listener with configured port and host +// command listenTcp starts a TCP listener with configured port and host func (c *cmd) Execute() (int, error) { c.loggingClient.Infof("Security bootstrapper running %s", CommandName) diff --git a/internal/security/bootstrapper/command/listen/command_test.go b/internal/security/bootstrapper/command/listen/command_test.go index 281de5b7eb..ab5ebf76bb 100644 --- a/internal/security/bootstrapper/command/listen/command_test.go +++ b/internal/security/bootstrapper/command/listen/command_test.go @@ -22,13 +22,13 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/tcp" - "github.com/stretchr/testify/require" - - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) func TestNewCommand(t *testing.T) { diff --git a/internal/security/bootstrapper/command/ping/command.go b/internal/security/bootstrapper/command/ping/command.go index 08bcd90523..3daa5fa9ec 100644 --- a/internal/security/bootstrapper/command/ping/command.go +++ b/internal/security/bootstrapper/command/ping/command.go @@ -25,14 +25,14 @@ import ( "strings" "sync" + _ "github.com/lib/pq" + "github.com/edgexfoundry/edgex-go/internal" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" "github.com/edgexfoundry/edgex-go/internal/security/secretstoreclient" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" - - _ "github.com/lib/pq" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) const ( @@ -71,11 +71,11 @@ func NewCommand( flagSet := flag.NewFlagSet(CommandName, flag.ContinueOnError) flagSet.StringVar(&dummy, "confdir", "", "") // handled by bootstrap; duplicated here to prevent arg parsing errors - flagSet.StringVar(&cmd.host, "host", cmd.configuration.StageGate.PG.Host, "the hostname of postgres database; "+ - cmd.configuration.StageGate.PG.Host+" will be use if omitted") + flagSet.StringVar(&cmd.host, "host", cmd.configuration.StageGate.KongDB.Host, "the hostname of postgres database; "+ + cmd.configuration.StageGate.KongDB.Host+" will be use if omitted") - flagSet.IntVar(&cmd.port, "port", cmd.configuration.StageGate.PG.Port, "the port number of postgres database; "+ - strconv.Itoa(configuration.StageGate.PG.Port)+" will be use if omitted") + flagSet.IntVar(&cmd.port, "port", cmd.configuration.StageGate.KongDB.Port, "the port number of postgres database; "+ + strconv.Itoa(configuration.StageGate.KongDB.Port)+" will be use if omitted") flagSet.StringVar(&cmd.username, "username", "postgres", "the username of postgres database; "+ "postgres will be use if omitted") diff --git a/internal/security/bootstrapper/command/ping/command_test.go b/internal/security/bootstrapper/command/ping/command_test.go index 870df609ca..322265961c 100644 --- a/internal/security/bootstrapper/command/ping/command_test.go +++ b/internal/security/bootstrapper/command/ping/command_test.go @@ -20,11 +20,11 @@ import ( "sync" "testing" - "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" - "github.com/stretchr/testify/require" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" + + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) func TestNewCommand(t *testing.T) { diff --git a/internal/security/bootstrapper/config/config.go b/internal/security/bootstrapper/config/config.go index 63d9113457..9001def76c 100644 --- a/internal/security/bootstrapper/config/config.go +++ b/internal/security/bootstrapper/config/config.go @@ -16,7 +16,7 @@ package config import ( - bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config" + bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/v2/config" ) type ConfigurationStruct struct { @@ -25,8 +25,7 @@ type ConfigurationStruct struct { } type WritableInfo struct { - LogLevel string - InsecureSecrets bootstrapConfig.InsecureSecrets + LogLevel string } // UpdateFromRaw converts configuration received from the registry to a service-specific configuration struct which is diff --git a/internal/security/bootstrapper/config/types.go b/internal/security/bootstrapper/config/types.go index 78bcad9a89..18d285f522 100644 --- a/internal/security/bootstrapper/config/types.go +++ b/internal/security/bootstrapper/config/types.go @@ -30,37 +30,37 @@ type ReadyInfo struct { } // TokensInfo defines the tokens ready stage gate info -// for the secretstore (aka. vault-worker) +// for the secretstore setup (formerly known as vault-worker) type TokensInfo struct { ReadyPort int } -// VaultWorkerInfo defines the fields related to -// stage gating the secretstore, vault-worker -type VaultWorkerInfo struct { +// SecretStoreSetupInfo defines the fields related to +// stage gating the secretstore setup (formerly known as vault-worker) bootstrapping +type SecretStoreSetupInfo struct { Host string Tokens TokensInfo } -// RedisInfo defines the fields related to -// stage gating the redis db -type RedisInfo struct { +// DatabaseInfo defines the fields related to +// stage gating the database bootstrapping +type DatabaseInfo struct { Host string Port int ReadyPort int } -// ConsulInfo defines the fields related to -// stage gating the Consul registry -type ConsulInfo struct { +// RegistryInfo defines the fields related to +// stage gating the registry bootstrapping +type RegistryInfo struct { Host string Port int ReadyPort int } -// PostgresInfo defines the fields related to -// stage gating the Postgres db -type PostgresInfo struct { +// KongDBInfo defines the fields related to +// stage gating the Kong's database bootstrapping +type KongDBInfo struct { Host string Port int ReadyPort int @@ -71,10 +71,10 @@ type PostgresInfo struct { // it is segmented in the way that environment variables are easier // to read when they become all upper cases in the environment override. type StageGateInfo struct { - BootStrapper BootStrapperInfo - Ready ReadyInfo - VaultWorker VaultWorkerInfo - Redis RedisInfo - Consul ConsulInfo - PG PostgresInfo + BootStrapper BootStrapperInfo + Ready ReadyInfo + SecretStoreSetup SecretStoreSetupInfo + Database DatabaseInfo + Registry RegistryInfo + KongDB KongDBInfo } diff --git a/internal/security/bootstrapper/container/container.go b/internal/security/bootstrapper/container/container.go index 070c197165..7a8c366c80 100644 --- a/internal/security/bootstrapper/container/container.go +++ b/internal/security/bootstrapper/container/container.go @@ -17,7 +17,8 @@ package container import ( "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/config" - "github.com/edgexfoundry/go-mod-bootstrap/di" + + "github.com/edgexfoundry/go-mod-bootstrap/v2/di" ) // ConfigurationName contains the name of the config.ConfigurationStruct implementation in the DIC. diff --git a/internal/security/bootstrapper/handlers/init.go b/internal/security/bootstrapper/handlers/init.go index e3a18ca2d8..3f03e435b6 100644 --- a/internal/security/bootstrapper/handlers/init.go +++ b/internal/security/bootstrapper/handlers/init.go @@ -26,9 +26,9 @@ import ( "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/container" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/interfaces" - bootstrapContainer "github.com/edgexfoundry/go-mod-bootstrap/bootstrap/container" - "github.com/edgexfoundry/go-mod-bootstrap/bootstrap/startup" - "github.com/edgexfoundry/go-mod-bootstrap/di" + bootstrapContainer "github.com/edgexfoundry/go-mod-bootstrap/v2/bootstrap/container" + "github.com/edgexfoundry/go-mod-bootstrap/v2/bootstrap/startup" + "github.com/edgexfoundry/go-mod-bootstrap/v2/di" ) // Bootstrap is to implement BootstrapHandler diff --git a/internal/security/bootstrapper/main.go b/internal/security/bootstrapper/main.go index adf9761097..3acdae818f 100644 --- a/internal/security/bootstrapper/main.go +++ b/internal/security/bootstrapper/main.go @@ -27,10 +27,10 @@ import ( "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/container" "github.com/edgexfoundry/edgex-go/internal/security/bootstrapper/handlers" - "github.com/edgexfoundry/go-mod-bootstrap/bootstrap" - "github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces" - "github.com/edgexfoundry/go-mod-bootstrap/bootstrap/startup" - "github.com/edgexfoundry/go-mod-bootstrap/di" + "github.com/edgexfoundry/go-mod-bootstrap/v2/bootstrap" + "github.com/edgexfoundry/go-mod-bootstrap/v2/bootstrap/interfaces" + "github.com/edgexfoundry/go-mod-bootstrap/v2/bootstrap/startup" + "github.com/edgexfoundry/go-mod-bootstrap/v2/di" ) const ( diff --git a/internal/security/bootstrapper/tcp/client.go b/internal/security/bootstrapper/tcp/client.go index 140747c83e..9cc4550012 100644 --- a/internal/security/bootstrapper/tcp/client.go +++ b/internal/security/bootstrapper/tcp/client.go @@ -23,7 +23,7 @@ import ( "strings" "time" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) const ( diff --git a/internal/security/bootstrapper/tcp/client_test.go b/internal/security/bootstrapper/tcp/client_test.go index f8efcc04d6..abb978b660 100644 --- a/internal/security/bootstrapper/tcp/client_test.go +++ b/internal/security/bootstrapper/tcp/client_test.go @@ -20,9 +20,9 @@ import ( "testing" "time" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" - "github.com/stretchr/testify/require" + + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) func TestDialTcpClient(t *testing.T) { diff --git a/internal/security/bootstrapper/tcp/listener.go b/internal/security/bootstrapper/tcp/listener.go index 2c34c3a691..9a53b24516 100644 --- a/internal/security/bootstrapper/tcp/listener.go +++ b/internal/security/bootstrapper/tcp/listener.go @@ -23,7 +23,7 @@ import ( "strings" "time" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) const ( diff --git a/internal/security/bootstrapper/tcp/listener_test.go b/internal/security/bootstrapper/tcp/listener_test.go index 997a0a9fca..b7ff9ba168 100644 --- a/internal/security/bootstrapper/tcp/listener_test.go +++ b/internal/security/bootstrapper/tcp/listener_test.go @@ -19,9 +19,9 @@ import ( "testing" "time" - "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" - "github.com/stretchr/testify/require" + + "github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger" ) func TestStartListener(t *testing.T) {