From b12cfd800665c138699d1ebca085ea9c569d71e1 Mon Sep 17 00:00:00 2001 From: Seokho Son Date: Wed, 31 Jul 2024 11:12:54 +0900 Subject: [PATCH 1/3] Remove API_DOC_PATH env --- Dockerfile | 1 - docker-compose-custom.yaml | 1 - docker-compose.yaml | 1 - src/api/rest/server/common/utility.go | 31 --------------------------- 4 files changed, 34 deletions(-) diff --git a/Dockerfile b/Dockerfile index b0bb0c47f..ba1eceaa4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,7 +65,6 @@ ENV CBTUMBLEBUG_ROOT=/app \ API_PASSWORD=default \ AUTOCONTROL_DURATION_MS=10000 \ SELF_ENDPOINT=localhost:1323 \ - API_DOC_PATH=/app/src/api/rest/docs/swagger.json \ DEFAULT_NAMESPACE=ns01 \ DEFAULT_CREDENTIALHOLDER=admin \ LOGFILE_PATH=/app/log/tumblebug.log \ diff --git a/docker-compose-custom.yaml b/docker-compose-custom.yaml index 1baeb3548..84088d412 100644 --- a/docker-compose-custom.yaml +++ b/docker-compose-custom.yaml @@ -143,7 +143,6 @@ services: - API_PASSWORD=${COMPOSE_TB_API_PASSWORD} - AUTOCONTROL_DURATION_MS=${COMPOSE_TB_AUTOCONTROL_DURATION_MS} - SELF_ENDPOINT=${COMPOSE_TB_SELF_ENDPOINT} - - API_DOC_PATH=${COMPOSE_TB_API_DOC_PATH} - DEFAULT_NAMESPACE=${COMPOSE_TB_DEFAULT_NAMESPACE} - DEFAULT_CREDENTIALHOLDER=${COMPOSE_TB_DEFAULT_CREDENTIALHOLDER} - LOGFILE_PATH=${COMPOSE_TB_LOGFILE_PATH} diff --git a/docker-compose.yaml b/docker-compose.yaml index 098a8cac2..737b8435c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -141,7 +141,6 @@ services: # - API_PASSWORD=default # - AUTOCONTROL_DURATION_MS=10000 - SELF_ENDPOINT=localhost:1323 - # - API_DOC_PATH=/app/src/api/rest/docs/swagger.json # - DEFAULT_NAMESPACE=ns01 # - DEFAULT_CREDENTIALHOLDER=admin # - LOGFILE_PATH=/app/log/tumblebug.log diff --git a/src/api/rest/server/common/utility.go b/src/api/rest/server/common/utility.go index d898875ca..63b65d1a9 100644 --- a/src/api/rest/server/common/utility.go +++ b/src/api/rest/server/common/utility.go @@ -114,37 +114,6 @@ func RestCheckHTTPVersion(c echo.Context) error { return c.JSON(http.StatusOK, &okMessage) } -/* -// RestGetSwagger func is to get API document web. -// RestGetSwagger godoc -// @Summary Get API document web -// @Description Get API document web -// @Tags [Admin] System management -// @Accept json -// @Produce json -// @Success 200 {object} common.SimpleMsg -// @Failure 404 {object} common.SimpleMsg -// @Failure 500 {object} common.SimpleMsg -// @Router /swaggerActive [get] -func RestGetSwagger(c echo.Context) error { - docFile := os.Getenv("API_DOC_PATH") - - f, err := os.Open(docFile) - if err != nil { - return err - } - defer f.Close() - - dec := json.NewDecoder(f) - data := make(map[string]interface{}, 0) - if err := dec.Decode(&data); err != nil { - return err - } - data["host"] = os.Getenv("SELF_ENDPOINT") - return c.JSON(http.StatusOK, data) -} -*/ - // RestRegisterCredential func is a rest api wrapper for RegisterCredential. // RestRegisterCredential godoc // @ID RegisterCredential From ecd2e5793692b076e1c4bd6734745ca156909f92 Mon Sep 17 00:00:00 2001 From: Seokho Son Date: Wed, 31 Jul 2024 11:27:19 +0900 Subject: [PATCH 2/3] Change env key prefix DB_ to TB_SQLITE_ --- Dockerfile | 10 ++++------ docker-compose-custom.yaml | 10 ++++------ docker-compose.yaml | 10 ++++------ src/core/common/common.go | 16 ++++++++-------- src/core/common/config.go | 24 ++++++++++++------------ src/main.go | 8 ++++---- 6 files changed, 36 insertions(+), 42 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba1eceaa4..6edecbbc3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,14 +44,12 @@ COPY --from=builder /go/src/github.com/cloud-barista/cb-tumblebug/src/cb-tumbleb # Setting various environment variables required by the application ENV CBTUMBLEBUG_ROOT=/app \ - SPIDER_CALL_METHOD=REST \ - DRAGONFLY_CALL_METHOD=REST \ SPIDER_REST_URL=http://cb-spider:1024/spider \ DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly \ - DB_URL=localhost:3306 \ - DB_DATABASE=cb_tumblebug \ - DB_USER=cb_tumblebug \ - DB_PASSWORD=cb_tumblebug \ + TB_SQLITE_URL=localhost:3306 \ + TB_SQLITE_DATABASE=cb_tumblebug \ + TB_SQLITE_USER=cb_tumblebug \ + TB_SQLITE_PASSWORD=cb_tumblebug \ TB_ETCD_ENDPOINTS=http://etcd:2379 \ TB_ETCD_AUTH_ENABLED=true \ TB_ETCD_USERNAME=default \ diff --git a/docker-compose-custom.yaml b/docker-compose-custom.yaml index 84088d412..f891b778a 100644 --- a/docker-compose-custom.yaml +++ b/docker-compose-custom.yaml @@ -125,14 +125,12 @@ services: - ${COMPOSE_TB_VOLUME_HOST_PATH}/log/:${COMPOSE_TB_VOLUME_CONTAINTER_PATH}/log/ environment: - CBTUMBLEBUG_ROOT=${COMPOSE_TB_CBTUMBLEBUG_ROOT} - - SPIDER_CALL_METHOD=${COMPOSE_TB_SPIDER_CALL_METHOD} - SPIDER_REST_URL=${COMPOSE_TB_SPIDER_REST_URL} - - DRAGONFLY_CALL_METHOD=${COMPOSE_TB_DRAGONFLY_CALL_METHOD} - DRAGONFLY_REST_URL=${COMPOSE_TB_DRAGONFLY_REST_URL} - - DB_URL=${COMPOSE_TB_DB_URL} - - DB_DATABASE=${COMPOSE_TB_DB_DATABASE} - - DB_USER=${COMPOSE_TB_DB_USER} - - DB_PASSWORD=${COMPOSE_TB_DB_PASSWORD} + - TB_SQLITE_URL=${COMPOSE_TB_TB_SQLITE_URL} + - TB_SQLITE_DATABASE=${COMPOSE_TB_TB_SQLITE_DATABASE} + - TB_SQLITE_USER=${COMPOSE_TB_TB_SQLITE_USER} + - TB_SQLITE_PASSWORD=${COMPOSE_TB_TB_SQLITE_PASSWORD} - TB_ETCD_ENDPOINTS=${COMPOSE_TB_ETCD_ENDPOINTS} - TB_ETCD_AUTH_ENABLED=${COMPOSE_TB_ETCD_AUTH_ENABLED} - TB_ETCD_USERNAME=${COMPOSE_TB_ETCD_USERNAME} diff --git a/docker-compose.yaml b/docker-compose.yaml index 737b8435c..de7dc5b8a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -123,14 +123,12 @@ services: - ./container-volume/cb-tumblebug-container/log/:/app/log/ environment: # - CBTUMBLEBUG_ROOT=/app - # - SPIDER_CALL_METHOD=REST - SPIDER_REST_URL=http://cb-spider:1024/spider - # - DRAGONFLY_CALL_METHOD=REST - DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly - # - DB_URL=localhost:3306 - # - DB_DATABASE=cb_tumblebug - # - DB_USER=cb_tumblebug - # - DB_PASSWORD=cb_tumblebug + # - TB_SQLITE_URL=localhost:3306 + # - TB_SQLITE_DATABASE=cb_tumblebug + # - TB_SQLITE_USER=cb_tumblebug + # - TB_SQLITE_PASSWORD=cb_tumblebug - TB_ETCD_ENDPOINTS=http://etcd:2379 # - TB_ETCD_AUTH_ENABLED=true # - TB_ETCD_USERNAME=default diff --git a/src/core/common/common.go b/src/core/common/common.go index 6bdaf444d..4a35e6ad3 100644 --- a/src/core/common/common.go +++ b/src/core/common/common.go @@ -68,10 +68,10 @@ const ( StrSpiderRestUrl string = "SPIDER_REST_URL" StrDragonflyRestUrl string = "DRAGONFLY_REST_URL" StrTerrariumRestUrl string = "TERRARIUM_REST_URL" - StrDBUrl string = "DB_URL" - StrDBDatabase string = "DB_DATABASE" - StrDBUser string = "DB_USER" - StrDBPassword string = "DB_PASSWORD" + StrDBUrl string = "TB_SQLITE_URL" + StrDBDatabase string = "TB_SQLITE_DATABASE" + StrDBUser string = "TB_SQLITE_USER" + StrDBPassword string = "TB_SQLITE_PASSWORD" StrAutocontrolDurationMs string = "AUTOCONTROL_DURATION_MS" StrEtcdEndpoints string = "TB_ETCD_ENDPOINTS" ErrStrKeyNotFound string = "key not found" @@ -120,10 +120,10 @@ type SpiderConnectionName struct { func OpenSQL(path string) error { /* common.MYDB, err = sql.Open("mysql", //"root:pwd@tcp(127.0.0.1:3306)/testdb") - common.DB_USER+":"+ - common.DB_PASSWORD+"@tcp("+ - common.DB_URL+")/"+ - common.DB_DATABASE) + common.TB_SQLITE_USER+":"+ + common.TB_SQLITE_PASSWORD+"@tcp("+ + common.TB_SQLITE_URL+")/"+ + common.TB_SQLITE_DATABASE) */ fullPathString := "file:" + path diff --git a/src/core/common/config.go b/src/core/common/config.go index 2793133fd..051d9ef1b 100644 --- a/src/core/common/config.go +++ b/src/core/common/config.go @@ -340,16 +340,16 @@ func UpdateGlobalVariable(id string) error { log.Debug().Msg(" " + TerrariumRestUrl) case StrDBUrl: DBUrl = configInfo.Value - log.Debug().Msg(" " + DBUrl) + log.Debug().Msg(" " + DBUrl) case StrDBDatabase: DBDatabase = configInfo.Value - log.Debug().Msg(" " + DBDatabase) + log.Debug().Msg(" " + DBDatabase) case StrDBUser: DBUser = configInfo.Value - log.Debug().Msg(" " + DBUser) + log.Debug().Msg(" " + DBUser) case StrDBPassword: DBPassword = configInfo.Value - log.Debug().Msg(" " + DBPassword) + log.Debug().Msg(" " + DBPassword) case StrAutocontrolDurationMs: AutocontrolDurationMs = configInfo.Value log.Debug().Msg(" " + AutocontrolDurationMs) @@ -376,17 +376,17 @@ func InitConfig(id string) error { TerrariumRestUrl = NVL(os.Getenv("TERRARIUM_REST_URL"), "http://localhost:8888/terrarium") log.Debug().Msg(" " + TerrariumRestUrl) case StrDBUrl: - DBUrl = NVL(os.Getenv("DB_URL"), "localhost:3306") - log.Debug().Msg(" " + DBUrl) + DBUrl = NVL(os.Getenv("TB_SQLITE_URL"), "localhost:3306") + log.Debug().Msg(" " + DBUrl) case StrDBDatabase: - DBDatabase = NVL(os.Getenv("DB_DATABASE"), "cb_tumblebug") - log.Debug().Msg(" " + DBDatabase) + DBDatabase = NVL(os.Getenv("TB_SQLITE_DATABASE"), "cb_tumblebug") + log.Debug().Msg(" " + DBDatabase) case StrDBUser: - DBUser = NVL(os.Getenv("DB_USER"), "cb_tumblebug") - log.Debug().Msg(" " + DBUser) + DBUser = NVL(os.Getenv("TB_SQLITE_USER"), "cb_tumblebug") + log.Debug().Msg(" " + DBUser) case StrDBPassword: - DBPassword = NVL(os.Getenv("DB_PASSWORD"), "cb_tumblebug") - log.Debug().Msg(" " + DBPassword) + DBPassword = NVL(os.Getenv("TB_SQLITE_PASSWORD"), "cb_tumblebug") + log.Debug().Msg(" " + DBPassword) case StrAutocontrolDurationMs: AutocontrolDurationMs = NVL(os.Getenv("AUTOCONTROL_DURATION_MS"), "10000") log.Debug().Msg(" " + AutocontrolDurationMs) diff --git a/src/main.go b/src/main.go index 8a5ae4e19..3aa8a7d48 100644 --- a/src/main.go +++ b/src/main.go @@ -55,10 +55,10 @@ func init() { common.SpiderRestUrl = common.NVL(os.Getenv("SPIDER_REST_URL"), "http://localhost:1024/spider") common.DragonflyRestUrl = common.NVL(os.Getenv("DRAGONFLY_REST_URL"), "http://localhost:9090/dragonfly") common.TerrariumRestUrl = common.NVL(os.Getenv("TERRARIUM_REST_URL"), "http://localhost:8888/terrarium") - common.DBUrl = common.NVL(os.Getenv("DB_URL"), "localhost:3306") - common.DBDatabase = common.NVL(os.Getenv("DB_DATABASE"), "cb_tumblebug") - common.DBUser = common.NVL(os.Getenv("DB_USER"), "cb_tumblebug") - common.DBPassword = common.NVL(os.Getenv("DB_PASSWORD"), "cb_tumblebug") + common.DBUrl = common.NVL(os.Getenv("TB_SQLITE_URL"), "localhost:3306") + common.DBDatabase = common.NVL(os.Getenv("TB_SQLITE_DATABASE"), "cb_tumblebug") + common.DBUser = common.NVL(os.Getenv("TB_SQLITE_USER"), "cb_tumblebug") + common.DBPassword = common.NVL(os.Getenv("TB_SQLITE_PASSWORD"), "cb_tumblebug") common.AutocontrolDurationMs = common.NVL(os.Getenv("AUTOCONTROL_DURATION_MS"), "10000") common.DefaultNamespace = common.NVL(os.Getenv("DEFAULT_NAMESPACE"), "ns01") common.DefaultCredentialHolder = common.NVL(os.Getenv("DEFAULT_CREDENTIALHOLDER"), "admin") From 119a36dc4786be25a186ae5d8fd29dc5dc8c5e8f Mon Sep 17 00:00:00 2001 From: Seokho Son Date: Wed, 31 Jul 2024 15:12:18 +0900 Subject: [PATCH 3/3] Add TB_ prefix for all ENV variables --- .env | 66 ++++++++-------- Dockerfile | 44 +++++------ README.md | 2 +- conf/setup.env | 77 ++++++++----------- docker-compose-custom.yaml | 46 +++++------ docker-compose.yaml | 38 ++++----- scripts/cleanDB.sh | 12 +-- scripts/exportCredentials.sh | 6 +- scripts/init/README.md | 4 +- scripts/init/init.py | 10 +-- scripts/runContainer.sh | 12 +-- scripts/runTerrarium.sh | 6 +- scripts/runTumblebug.sh | 4 +- scripts/setPublicIP.sh | 12 +-- src/api/rest/server/common/config.go | 4 +- src/api/rest/server/mcis/network.go | 20 ++--- src/api/rest/server/server.go | 20 ++--- src/core/common/common.go | 8 +- src/core/common/config.go | 30 ++++---- src/core/common/logger/logger.go | 14 ++-- src/core/mcir/common.go | 4 +- src/main.go | 14 ++-- .../scripts/2.configureTumblebug/create-ns.sh | 2 +- .../2.configureTumblebug/get-config.sh | 2 +- .../2.configureTumblebug/init-config.sh | 2 +- src/testclient/scripts/init.sh | 4 +- .../deploy-dragonfly-docker.sh | 2 +- .../test-clis/vpn-tunnel/gcp-aws/README.md | 6 +- 28 files changed, 228 insertions(+), 243 deletions(-) diff --git a/.env b/.env index 460f32919..884e7cc9b 100644 --- a/.env +++ b/.env @@ -73,12 +73,12 @@ COMPOSE_SP_PLUGSIN_SW=${PLUGSIN_SW:-OFF} # default: COMPOSE_SP_PLUGSIN_SW COMPOSE_SP_SERVER_ADDRESS=${SERVER_ADDRESS:-localhost} # default: COMPOSE_SP_SERVER_ADDRESS=localhost -COMPOSE_SP_API_USERNAME=${SP_API_USERNAME:-} -# default: COMPOSE_SP_API_USERNAME= -# Note - Use SP_API_USERNAME instead of API_USERNAME because API_USERNAME is used in CB-Tumblebug +COMPOSE_SP_TB_API_USERNAME=${SP_TB_API_USERNAME:-} +# default: COMPOSE_SP_TB_API_USERNAME= +# Note - Use SP_TB_API_USERNAME instead of TB_API_USERNAME because TB_API_USERNAME is used in CB-Tumblebug COMPOSE_SP_API_PASSWORD=${SP_API_PASSWORD:-} # default: COMPOSE_SP_API_PASSWORD= -# Note - Use SP_API_PASSWORD instead of API_PASSWORD because API_PASSWORD is used in CB-Tumblebug +# Note - Use SP_API_PASSWORD instead of TB_API_PASSWORD because TB_API_PASSWORD is used in CB-Tumblebug COMPOSE_SP_LOG_LEVEL=${LOG_LEVEL:-error} # default: COMPOSE_SP_LOG_LEVEL=error COMPOSE_SP_HISCALL_LOG_LEVEL=${HISCALL_LOG_LEVEL:-error} @@ -96,24 +96,20 @@ COMPOSE_TB_VOLUME_HOST_PATH=${TB_VOLUME_HOST_PATH:-./container-volume/cb-tumbleb # default: COMPOSE_TB_VOLUME_HOST_PATH=./container-volume/cb-tumblebug-container COMPOSE_TB_VOLUME_CONTAINTER_PATH=${TB_VOLUME_CONTAINTER_PATH:-/app} # default: COMPOSE_TB_VOLUME_CONTAINTER_PATH=/app -COMPOSE_TB_CBTUMBLEBUG_ROOT=${CBTUMBLEBUG_ROOT:-/app} -# default: COMPOSE_TB_CBTUMBLEBUG_ROOT=/app -COMPOSE_TB_SPIDER_CALL_METHOD=${SPIDER_CALL_METHOD:-REST} -# default: COMPOSE_TB_SPIDER_CALL_METHOD=REST +COMPOSE_TB_ROOT_PATH=${TB_ROOT_PATH:-/app} +# default: COMPOSE_TB_ROOT_PATH=/app COMPOSE_TB_SPIDER_REST_URL=http://cb-spider:1024/spider # default: COMPOSE_TB_SPIDER_REST_URL=http://cb-spider:1024/spider -COMPOSE_TB_DRAGONFLY_CALL_METHOD=${DRAGONFLY_CALL_METHOD:-REST} -# default: COMPOSE_TB_DRAGONFLY_CALL_METHOD=REST COMPOSE_TB_DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly # default: COMPOSE_TB_DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly -COMPOSE_TB_DB_URL=${DB_URL:-localhost:3306} -# default: COMPOSE_TB_DB_URL=localhost:3306 -COMPOSE_TB_DB_DATABASE=${DB_DATABASE:-cb_tumblebug} -# default: COMPOSE_TB_DB_DATABASE=cb_tumblebug -COMPOSE_TB_DB_USER=${DB_USER:-cb_tumblebug} -# default: COMPOSE_TB_DB_USER=cb_tumblebug -COMPOSE_TB_DB_PASSWORD=${DB_PASSWORD:-cb_tumblebug} -# default: COMPOSE_TB_DB_PASSWORD=cb_tumblebug +COMPOSE_TB_SQLITE_URL=${TB_SQLITE_URL:-localhost:3306} +# default: COMPOSE_TB_SQLITE_URL=localhost:3306 +COMPOSE_TB_SQLITE_DATABASE=${TB_SQLITE_DATABASE:-cb_tumblebug} +# default: COMPOSE_TB_SQLITE_DATABASE=cb_tumblebug +COMPOSE_TB_SQLITE_USER=${TB_SQLITE_USER:-cb_tumblebug} +# default: COMPOSE_TB_SQLITE_USER=cb_tumblebug +COMPOSE_TB_SQLITE_PASSWORD=${TB_SQLITE_PASSWORD:-cb_tumblebug} +# default: COMPOSE_TB_SQLITE_PASSWORD=cb_tumblebug COMPOSE_TB_ETCD_ENDPOINTS=http://etcd:2379 # default: COMPOSE_TB_ETCD_ENDPOINTS=http://etcd:2379 COMPOSE_TB_ETCD_AUTH_ENABLED=${TB_ETCD_AUTH_ENABLED:-true} @@ -122,39 +118,37 @@ COMPOSE_TB_ETCD_USERNAME=${TB_ETCD_USERNAME:-default} # default: COMPOSE_TB_ETCD_USERNAME=default COMPOSE_TB_ETCD_PASSWORD=${TB_ETCD_PASSWORD:-default} # default: COMPOSE_TB_ETCD_PASSWORD=default -COMPOSE_TB_ALLOW_ORIGINS=${ALLOW_ORIGINS:-*} +COMPOSE_TB_ALLOW_ORIGINS=${TB_ALLOW_ORIGINS:-*} # default: COMPOSE_TB_ALLOW_ORIGINS=* -COMPOSE_TB_AUTH_ENABLED=${AUTH_ENABLED:-true} +COMPOSE_TB_AUTH_ENABLED=${TB_AUTH_ENABLED:-true} # default: COMPOSE_TB_AUTH_ENABLED=true -COMPOSE_TB_API_USERNAME=${API_USERNAME:-default} +COMPOSE_TB_API_USERNAME=${TB_API_USERNAME:-default} # default: COMPOSE_TB_API_USERNAME=default -COMPOSE_TB_API_PASSWORD=${API_PASSWORD:-default} +COMPOSE_TB_API_PASSWORD=${TB_API_PASSWORD:-default} # default: COMPOSE_TB_API_PASSWORD=default -COMPOSE_TB_AUTOCONTROL_DURATION_MS=${AUTOCONTROL_DURATION_MS:-10000} +COMPOSE_TB_AUTOCONTROL_DURATION_MS=${TB_AUTOCONTROL_DURATION_MS:-10000} # default: COMPOSE_TB_AUTOCONTROL_DURATION_MS=10000 -COMPOSE_TB_SELF_ENDPOINT=${SELF_ENDPOINT:-localhost:1323} +COMPOSE_TB_SELF_ENDPOINT=${TB_SELF_ENDPOINT:-localhost:1323} # default: COMPOSE_TB_SELF_ENDPOINT=localhost:1323 -COMPOSE_TB_API_DOC_PATH=${API_DOC_PATH:-/app/src/api/rest/docs/swagger.json} -# default: COMPOSE_TB_API_DOC_PATH=/app/src/api/rest/docs/swagger.json -COMPOSE_TB_DEFAULT_NAMESPACE=${DEFAULT_NAMESPACE:-ns01} +COMPOSE_TB_DEFAULT_NAMESPACE=${TB_DEFAULT_NAMESPACE:-ns01} # default: COMPOSE_TB_DEFAULT_NAMESPACE=ns01 -COMPOSE_TB_DEFAULT_CREDENTIALHOLDER=${DEFAULT_CREDENTIALHOLDER:-admin} +COMPOSE_TB_DEFAULT_CREDENTIALHOLDER=${TB_DEFAULT_CREDENTIALHOLDER:-admin} # default: COMPOSE_TB_DEFAULT_CREDENTIALHOLDER=admin -COMPOSE_TB_LOGFILE_PATH=${LOGFILE_PATH:-/app/log/tumblebug.log} +COMPOSE_TB_LOGFILE_PATH=${TB_LOGFILE_PATH:-/app/log/tumblebug.log} # default: COMPOSE_TB_LOGFILE_PATH=/app/log/tumblebug.log -COMPOSE_TB_LOGFILE_MAXSIZE=${LOGFILE_MAXSIZE:-10} +COMPOSE_TB_LOGFILE_MAXSIZE=${TB_LOGFILE_MAXSIZE:-10} # default: COMPOSE_TB_LOGFILE_MAXSIZE=10 -COMPOSE_TB_LOGFILE_MAXBACKUPS=${LOGFILE_MAXBACKUPS:-3} +COMPOSE_TB_LOGFILE_MAXBACKUPS=${TB_LOGFILE_MAXBACKUPS:-3} # default: COMPOSE_TB_LOGFILE_MAXBACKUPS=3 -COMPOSE_TB_LOGFILE_MAXAGE=${LOGFILE_MAXAGE:-30} +COMPOSE_TB_LOGFILE_MAXAGE=${TB_LOGFILE_MAXAGE:-30} # default: COMPOSE_TB_LOGFILE_MAXAGE=30 -COMPOSE_TB_LOGFILE_COMPRESS=${LOGFILE_COMPRESS:-false} +COMPOSE_TB_LOGFILE_COMPRESS=${TB_LOGFILE_COMPRESS:-false} # default: COMPOSE_TB_LOGFILE_COMPRESS=false -COMPOSE_TB_LOGLEVEL=${LOGLEVEL:-debug} +COMPOSE_TB_LOGLEVEL=${TB_LOGLEVEL:-debug} # default: COMPOSE_TB_LOGLEVEL=debug -COMPOSE_TB_LOGWRITER=${LOGWRITER:-both} +COMPOSE_TB_LOGWRITER=${TB_LOGWRITER:-both} # default: COMPOSE_TB_LOGWRITER=both -COMPOSE_TB_NODE_ENV=${NODE_ENV:-development} +COMPOSE_TB_NODE_ENV=${TB_NODE_ENV:-development} # default: COMPOSE_TB_NODE_ENV=development diff --git a/Dockerfile b/Dockerfile index 6edecbbc3..b369c7f00 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,9 +43,9 @@ COPY --from=builder /go/src/github.com/cloud-barista/cb-tumblebug/conf/ /app/con COPY --from=builder /go/src/github.com/cloud-barista/cb-tumblebug/src/cb-tumblebug /app/src/ # Setting various environment variables required by the application -ENV CBTUMBLEBUG_ROOT=/app \ - SPIDER_REST_URL=http://cb-spider:1024/spider \ - DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly \ +ENV TB_ROOT_PATH=/app \ + TB_SPIDER_REST_URL=http://cb-spider:1024/spider \ + TB_DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly \ TB_SQLITE_URL=localhost:3306 \ TB_SQLITE_DATABASE=cb_tumblebug \ TB_SQLITE_USER=cb_tumblebug \ @@ -54,25 +54,25 @@ ENV CBTUMBLEBUG_ROOT=/app \ TB_ETCD_AUTH_ENABLED=true \ TB_ETCD_USERNAME=default \ TB_ETCD_PASSWORD=default \ - ALLOW_ORIGINS=* \ - AUTH_ENABLED=true \ - AUTH_MODE=basic \ - AUTH_JWT_SIGNING_METHOD=RS256 \ - AUTH_JWT_PUBLICKEY= \ - API_USERNAME=default \ - API_PASSWORD=default \ - AUTOCONTROL_DURATION_MS=10000 \ - SELF_ENDPOINT=localhost:1323 \ - DEFAULT_NAMESPACE=ns01 \ - DEFAULT_CREDENTIALHOLDER=admin \ - LOGFILE_PATH=/app/log/tumblebug.log \ - LOGFILE_MAXSIZE=10 \ - LOGFILE_MAXBACKUPS=3 \ - LOGFILE_MAXAGE=30 \ - LOGFILE_COMPRESS=false \ - LOGLEVEL=debug \ - LOGWRITER=both \ - NODE_ENV=development + TB_ALLOW_ORIGINS=* \ + TB_AUTH_ENABLED=true \ + TB_AUTH_MODE=basic \ + TB_AUTH_JWT_SIGNING_METHOD=RS256 \ + TB_AUTH_JWT_PUBLICKEY= \ + TB_API_USERNAME=default \ + TB_API_PASSWORD=default \ + TB_AUTOCONTROL_DURATION_MS=10000 \ + TB_SELF_ENDPOINT=localhost:1323 \ + TB_DEFAULT_NAMESPACE=ns01 \ + TB_DEFAULT_CREDENTIALHOLDER=admin \ + TB_LOGFILE_PATH=/app/log/tumblebug.log \ + TB_LOGFILE_MAXSIZE=10 \ + TB_LOGFILE_MAXBACKUPS=3 \ + TB_LOGFILE_MAXAGE=30 \ + TB_LOGFILE_COMPRESS=false \ + TB_LOGLEVEL=debug \ + TB_LOGWRITER=both \ + TB_NODE_ENV=development # Setting the entrypoint for the application ENTRYPOINT [ "/app/src/cb-tumblebug" ] diff --git a/README.md b/README.md index 0946aa5b9..55b03d7d1 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,7 @@ Check out [CONTRIBUTING](https://github.com/cloud-barista/cb-tumblebug/blob/main cd ~/go/src/github.com/cloud-barista/cb-tumblebug source conf/setup.env ``` - - (Note) Automatically set the SELF_ENDPOINT environment variable (an externally accessible address) using a script if needed + - (Note) Automatically set the TB_SELF_ENDPOINT environment variable (an externally accessible address) using a script if needed - This is necessary if you want to access and control the Swagger API Dashboard from outside when CB-TB is running ```bash cd ~/go/src/github.com/cloud-barista/cb-tumblebug diff --git a/conf/setup.env b/conf/setup.env index f4c6926fc..eaac0206d 100644 --- a/conf/setup.env +++ b/conf/setup.env @@ -1,38 +1,33 @@ -# Set CBTUMBLEBUG_ROOT based on path of setup.env relatively +# Set TB_ROOT_PATH based on path of setup.env relatively SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}` -export CBTUMBLEBUG_ROOT=`cd $SCRIPT_DIR && cd .. && pwd` -# Use CBTUMBLEBUG_ROOT directly if the SCRIPT_DIR does not work -# export CBTUMBLEBUG_ROOT=$HOME/go/src/github.com/cloud-barista/cb-tumblebug +export TB_ROOT_PATH=`cd $SCRIPT_DIR && cd .. && pwd` +# Use TB_ROOT_PATH directly if the SCRIPT_DIR does not work +# export TB_ROOT_PATH=$HOME/go/src/github.com/cloud-barista/cb-tumblebug # Set API access config -export API_USERNAME=default -export API_PASSWORD=default -## ALLOW_ORIGINS (ex: https://cloud-barista.org,http://localhost:8080 or * for all) -export ALLOW_ORIGINS=* -## Set AUTH_ENABLED=true currently for basic auth for all routes (i.e., url or path) -export AUTH_ENABLED=true -## Set AUTH_MODE=basic or jwt -export AUTH_MODE=basic - -## Set SELF_ENDPOINT, to access Swagger API dashboard outside (Ex: export SELF_ENDPOINT=x.x.x.x:1323) -export SELF_ENDPOINT=localhost:1323 +export TB_API_USERNAME=default +export TB_API_PASSWORD=default +## TB_ALLOW_ORIGINS (ex: https://cloud-barista.org,http://localhost:8080 or * for all) +export TB_ALLOW_ORIGINS=* +## Set TB_AUTH_ENABLED=true currently for basic auth for all routes (i.e., url or path) +export TB_AUTH_ENABLED=true +## Set TB_AUTH_MODE=basic or jwt +export TB_AUTH_MODE=basic + +## Set TB_SELF_ENDPOINT, to access Swagger API dashboard outside (Ex: export TB_SELF_ENDPOINT=x.x.x.x:1323) +export TB_SELF_ENDPOINT=localhost:1323 # Set system endpoints -export SPIDER_CALL_METHOD=REST -export SPIDER_REST_URL=http://localhost:1024/spider -export DRAGONFLY_CALL_METHOD=REST -export DRAGONFLY_REST_URL=http://localhost:9090/dragonfly -export TERRARIUM_CALL_METHOD=REST -export TERRARIUM_REST_URL=http://localhost:8888/terrarium -export IAM_MANAGER_CALL_METHOD=REST -export IAM_MANAGER_REST_URL=https://localhost:5000 - +export TB_SPIDER_REST_URL=http://localhost:1024/spider +export TB_DRAGONFLY_REST_URL=http://localhost:9090/dragonfly +export TB_TERRARIUM_REST_URL=http://localhost:8888/terrarium +export TB_IAM_MANAGER_REST_URL=https://localhost:5000 ## Set internal DB config (SQLlite) -export DB_URL=localhost:3306 -export DB_DATABASE=cb_tumblebug -export DB_USER=cb_tumblebug -export DB_PASSWORD=cb_tumblebug +export TB_SQLITE_URL=localhost:3306 +export TB_SQLITE_DATABASE=cb_tumblebug +export TB_SQLITE_USER=cb_tumblebug +export TB_SQLITE_PASSWORD=cb_tumblebug ## Set etcd cluster export TB_ETCD_ENDPOINTS=http://localhost:2379 @@ -41,26 +36,22 @@ export TB_ETCD_USERNAME=default export TB_ETCD_PASSWORD=default ## Set period for auto control goroutine invocation -export AUTOCONTROL_DURATION_MS=10000 +export TB_AUTOCONTROL_DURATION_MS=10000 ## Set name of default objects -export DEFAULT_NAMESPACE=ns01 -export DEFAULT_CREDENTIALHOLDER=admin +export TB_DEFAULT_NAMESPACE=ns01 +export TB_DEFAULT_CREDENTIALHOLDER=admin ## Logger configuration # Set log file path (default logfile path: ./log/tumblebug.log) -export LOGFILE_PATH=$CBTUMBLEBUG_ROOT/log/tumblebug.log -export LOGFILE_MAXSIZE=10 -export LOGFILE_MAXBACKUPS=3 -export LOGFILE_MAXAGE=30 -export LOGFILE_COMPRESS=false +export TB_LOGFILE_PATH=$TB_ROOT_PATH/log/tumblebug.log +export TB_LOGFILE_MAXSIZE=10 +export TB_LOGFILE_MAXBACKUPS=3 +export TB_LOGFILE_MAXAGE=30 +export TB_LOGFILE_COMPRESS=false # Set log level, such as trace, debug, info, warn, error, fatal, and panic -export LOGLEVEL=debug +export TB_LOGLEVEL=debug # Set log writer, such as file, stdout, or both -export LOGWRITER=both +export TB_LOGWRITER=both # Set execution environment, such as development or production -export NODE_ENV=development - -# Environment variables that you don't need to touch -## Swagger UI API document file path -export API_DOC_PATH=$CBTUMBLEBUG_ROOT/src/api/rest/docs/swagger.json +export TB_NODE_ENV=development diff --git a/docker-compose-custom.yaml b/docker-compose-custom.yaml index f891b778a..b14bd55a2 100644 --- a/docker-compose-custom.yaml +++ b/docker-compose-custom.yaml @@ -124,33 +124,33 @@ services: - ${COMPOSE_TB_VOLUME_HOST_PATH}/meta_db/:${COMPOSE_TB_VOLUME_CONTAINTER_PATH}/meta_db/ - ${COMPOSE_TB_VOLUME_HOST_PATH}/log/:${COMPOSE_TB_VOLUME_CONTAINTER_PATH}/log/ environment: - - CBTUMBLEBUG_ROOT=${COMPOSE_TB_CBTUMBLEBUG_ROOT} - - SPIDER_REST_URL=${COMPOSE_TB_SPIDER_REST_URL} - - DRAGONFLY_REST_URL=${COMPOSE_TB_DRAGONFLY_REST_URL} - - TB_SQLITE_URL=${COMPOSE_TB_TB_SQLITE_URL} - - TB_SQLITE_DATABASE=${COMPOSE_TB_TB_SQLITE_DATABASE} - - TB_SQLITE_USER=${COMPOSE_TB_TB_SQLITE_USER} - - TB_SQLITE_PASSWORD=${COMPOSE_TB_TB_SQLITE_PASSWORD} + - TB_ROOT_PATH=${COMPOSE_TB_ROOT_PATH} + - TB_SPIDER_REST_URL=${COMPOSE_TB_SPIDER_REST_URL} + - TB_DRAGONFLY_REST_URL=${COMPOSE_TB_DRAGONFLY_REST_URL} + - TB_SQLITE_URL=${COMPOSE_TB_SQLITE_URL} + - TB_SQLITE_DATABASE=${COMPOSE_TB_SQLITE_DATABASE} + - TB_SQLITE_USER=${COMPOSE_TB_SQLITE_USER} + - TB_SQLITE_PASSWORD=${COMPOSE_TB_SQLITE_PASSWORD} - TB_ETCD_ENDPOINTS=${COMPOSE_TB_ETCD_ENDPOINTS} - TB_ETCD_AUTH_ENABLED=${COMPOSE_TB_ETCD_AUTH_ENABLED} - TB_ETCD_USERNAME=${COMPOSE_TB_ETCD_USERNAME} - TB_ETCD_PASSWORD=${COMPOSE_TB_ETCD_PASSWORD} - - ALLOW_ORIGINS=${COMPOSE_TB_ALLOW_ORIGINS} - - AUTH_ENABLED=${COMPOSE_TB_AUTH_ENABLED} - - API_USERNAME=${COMPOSE_TB_API_USERNAME} - - API_PASSWORD=${COMPOSE_TB_API_PASSWORD} - - AUTOCONTROL_DURATION_MS=${COMPOSE_TB_AUTOCONTROL_DURATION_MS} - - SELF_ENDPOINT=${COMPOSE_TB_SELF_ENDPOINT} - - DEFAULT_NAMESPACE=${COMPOSE_TB_DEFAULT_NAMESPACE} - - DEFAULT_CREDENTIALHOLDER=${COMPOSE_TB_DEFAULT_CREDENTIALHOLDER} - - LOGFILE_PATH=${COMPOSE_TB_LOGFILE_PATH} - - LOGFILE_MAXSIZE=${COMPOSE_TB_LOGFILE_MAXSIZE} - - LOGFILE_MAXBACKUPS=${COMPOSE_TB_LOGFILE_MAXBACKUPS} - - LOGFILE_MAXAGE=${COMPOSE_TB_LOGFILE_MAXAGE} - - LOGFILE_COMPRESS=${COMPOSE_TB_LOGFILE_COMPRESS} - - LOGLEVEL=${COMPOSE_TB_LOGLEVEL} - - LOGWRITER=${COMPOSE_TB_LOGWRITER} - - NODE_ENV=${COMPOSE_TB_NODE_ENV} + - TB_ALLOW_ORIGINS=${COMPOSE_TB_ALLOW_ORIGINS} + - TB_AUTH_ENABLED=${COMPOSE_TB_AUTH_ENABLED} + - TB_API_USERNAME=${COMPOSE_TB_API_USERNAME} + - TB_API_PASSWORD=${COMPOSE_TB_API_PASSWORD} + - TB_AUTOCONTROL_DURATION_MS=${COMPOSE_TB_AUTOCONTROL_DURATION_MS} + - TB_SELF_ENDPOINT=${COMPOSE_TB_SELF_ENDPOINT} + - TB_DEFAULT_NAMESPACE=${COMPOSE_TB_DEFAULT_NAMESPACE} + - TB_DEFAULT_CREDENTIALHOLDER=${COMPOSE_TB_DEFAULT_CREDENTIALHOLDER} + - TB_LOGFILE_PATH=${COMPOSE_TB_LOGFILE_PATH} + - TB_LOGFILE_MAXSIZE=${COMPOSE_TB_LOGFILE_MAXSIZE} + - TB_LOGFILE_MAXBACKUPS=${COMPOSE_TB_LOGFILE_MAXBACKUPS} + - TB_LOGFILE_MAXAGE=${COMPOSE_TB_LOGFILE_MAXAGE} + - TB_LOGFILE_COMPRESS=${COMPOSE_TB_LOGFILE_COMPRESS} + - TB_LOGLEVEL=${COMPOSE_TB_LOGLEVEL} + - TB_LOGWRITER=${COMPOSE_TB_LOGWRITER} + - TB_NODE_ENV=${COMPOSE_TB_NODE_ENV} healthcheck: # for CB-Tumblebug test: [ "CMD", "curl", "-f", "http://localhost:1323/tumblebug/readyz" ] interval: 1m diff --git a/docker-compose.yaml b/docker-compose.yaml index de7dc5b8a..7d1d839b9 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -122,9 +122,9 @@ services: - ./container-volume/cb-tumblebug-container/meta_db/:/app/meta_db/ - ./container-volume/cb-tumblebug-container/log/:/app/log/ environment: - # - CBTUMBLEBUG_ROOT=/app - - SPIDER_REST_URL=http://cb-spider:1024/spider - - DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly + # - TB_ROOT_PATH=/app + - TB_SPIDER_REST_URL=http://cb-spider:1024/spider + - TB_DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly # - TB_SQLITE_URL=localhost:3306 # - TB_SQLITE_DATABASE=cb_tumblebug # - TB_SQLITE_USER=cb_tumblebug @@ -133,22 +133,22 @@ services: # - TB_ETCD_AUTH_ENABLED=true # - TB_ETCD_USERNAME=default # - TB_ETCD_PASSWORD=default - # - ALLOW_ORIGINS=* - # - AUTH_ENABLED=true - # - API_USERNAME=default - # - API_PASSWORD=default - # - AUTOCONTROL_DURATION_MS=10000 - - SELF_ENDPOINT=localhost:1323 - # - DEFAULT_NAMESPACE=ns01 - # - DEFAULT_CREDENTIALHOLDER=admin - # - LOGFILE_PATH=/app/log/tumblebug.log - # - LOGFILE_MAXSIZE=10 - # - LOGFILE_MAXBACKUPS=3 - # - LOGFILE_MAXAGE=30 - # - LOGFILE_COMPRESS=false - # - LOGLEVEL=debug - # - LOGWRITER=both - # - NODE_ENV=development + # - TB_ALLOW_ORIGINS=* + # - TB_AUTH_ENABLED=true + # - TB_API_USERNAME=default + # - TB_API_PASSWORD=default + # - TB_AUTOCONTROL_DURATION_MS=10000 + - TB_SELF_ENDPOINT=localhost:1323 + # - TB_DEFAULT_NAMESPACE=ns01 + # - TB_DEFAULT_CREDENTIALHOLDER=admin + # - TB_LOGFILE_PATH=/app/log/tumblebug.log + # - TB_LOGFILE_MAXSIZE=10 + # - TB_LOGFILE_MAXBACKUPS=3 + # - TB_LOGFILE_MAXAGE=30 + # - TB_LOGFILE_COMPRESS=false + # - TB_LOGLEVEL=debug + # - TB_LOGWRITER=both + # - TB_NODE_ENV=development healthcheck: # for CB-Tumblebug test: [ "CMD", "curl", "-f", "http://localhost:1323/tumblebug/readyz" ] interval: 1m diff --git a/scripts/cleanDB.sh b/scripts/cleanDB.sh index 240eb3b5c..9f6717755 100755 --- a/scripts/cleanDB.sh +++ b/scripts/cleanDB.sh @@ -4,16 +4,16 @@ RED='\033[0;31m' LGREEN='\033[1;32m' NC='\033[0m' # No Color -if [ -z "$CBTUMBLEBUG_ROOT" ]; then +if [ -z "$TB_ROOT_PATH" ]; then SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}` - export CBTUMBLEBUG_ROOT=`cd $SCRIPT_DIR && cd .. && pwd` + export TB_ROOT_PATH=`cd $SCRIPT_DIR && cd .. && pwd` fi -TBMETAPATH="$CBTUMBLEBUG_ROOT/meta_db/dat" -VOL_TB_META_PATH="$CBTUMBLEBUG_ROOT/container-volume/cb-tumblebug-container" -VOL_SP_META_PATH="$CBTUMBLEBUG_ROOT/container-volume/cb-spider-container" -VOL_ETC_DATA_PATH="$CBTUMBLEBUG_ROOT/container-volume/etcd" +TBMETAPATH="$TB_ROOT_PATH/meta_db/dat" +VOL_TB_META_PATH="$TB_ROOT_PATH/container-volume/cb-tumblebug-container" +VOL_SP_META_PATH="$TB_ROOT_PATH/container-volume/cb-spider-container" +VOL_ETC_DATA_PATH="$TB_ROOT_PATH/container-volume/etcd" echo echo ========================================================== diff --git a/scripts/exportCredentials.sh b/scripts/exportCredentials.sh index 66a0b4de2..519dbec75 100755 --- a/scripts/exportCredentials.sh +++ b/scripts/exportCredentials.sh @@ -1,11 +1,11 @@ #!/bin/bash -if [ -z "$CBTUMBLEBUG_ROOT" ]; then +if [ -z "$TB_ROOT_PATH" ]; then SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]-$0}") - export CBTUMBLEBUG_ROOT=$(cd "$SCRIPT_DIR" && cd .. && pwd) + export TB_ROOT_PATH=$(cd "$SCRIPT_DIR" && cd .. && pwd) fi -credentialDir="$CBTUMBLEBUG_ROOT/conf" +credentialDir="$TB_ROOT_PATH/conf" credentialFile="$credentialDir/credentials.conf" saveTo="$credentialDir/.credtmp" diff --git a/scripts/init/README.md b/scripts/init/README.md index 12d63975f..f657eb48e 100644 --- a/scripts/init/README.md +++ b/scripts/init/README.md @@ -51,8 +51,8 @@ init.sh ## Configuration Before running the script, ensure the following environment variables are set according to your Tumblebug server configuration: - `TUMBLEBUG_SERVER`: The address of the Tumblebug server. -- `API_USERNAME`: Username for API authentication. -- `API_PASSWORD`: Password for API authentication. +- `TB_API_USERNAME`: Username for API authentication. +- `TB_API_PASSWORD`: Password for API authentication. ## Security Considerations To protect sensitive information, `credentials.yaml` is not used directly. Instead, it must be encrypted using `encCredential.sh`. The encrypted file `credentials.yaml.enc` is then used by `init.py`. This approach ensures that sensitive credentials are not stored in plain text. diff --git a/scripts/init/init.py b/scripts/init/init.py index 882c25383..45ec209d5 100755 --- a/scripts/init/init.py +++ b/scripts/init/init.py @@ -23,9 +23,9 @@ # Configuration TUMBLEBUG_SERVER = os.getenv('TUMBLEBUG_SERVER', 'localhost:1323') -API_USERNAME = os.getenv('API_USERNAME', 'default') -API_PASSWORD = os.getenv('API_PASSWORD', 'default') -AUTH = f"Basic {base64.b64encode(f'{API_USERNAME}:{API_PASSWORD}'.encode()).decode()}" +TB_API_USERNAME = os.getenv('TB_API_USERNAME', 'default') +TB_API_PASSWORD = os.getenv('TB_API_PASSWORD', 'default') +AUTH = f"Basic {base64.b64encode(f'{TB_API_USERNAME}:{TB_API_PASSWORD}'.encode()).decode()}" HEADERS = {'Authorization': AUTH, 'Content-Type': 'application/json'} CRED_FILE_NAME_ENC = "credentials.yaml.enc" @@ -85,8 +85,8 @@ def get_decryption_key(): # Print the current configuration print(Fore.YELLOW + "Current Configuration\nPlease set the corresponding environment variables to make changes.") print(" - " + Fore.CYAN + "TUMBLEBUG_SERVER:" + Fore.RESET + f" {TUMBLEBUG_SERVER}") -print(" - " + Fore.CYAN + "API_USERNAME:" + Fore.RESET + f" {API_USERNAME[0]}**********") -print(" - " + Fore.CYAN + "API_PASSWORD:" + Fore.RESET + f" {API_PASSWORD[0]}**********") +print(" - " + Fore.CYAN + "TB_API_USERNAME:" + Fore.RESET + f" {TB_API_USERNAME[0]}**********") +print(" - " + Fore.CYAN + "TB_API_PASSWORD:" + Fore.RESET + f" {TB_API_PASSWORD[0]}**********") print(" - " + Fore.CYAN + "CRED_PATH:" + Fore.RESET + f" {CRED_PATH}") print(" - " + Fore.CYAN + "CRED_FILE_NAME:" + Fore.RESET + f" {CRED_FILE_NAME_ENC}") print(" - " + Fore.CYAN + "expected completion time:" + Fore.RESET + f" {expected_completion_time_seconds} seconds\n") diff --git a/scripts/runContainer.sh b/scripts/runContainer.sh index 293382363..e01648a0d 100755 --- a/scripts/runContainer.sh +++ b/scripts/runContainer.sh @@ -10,13 +10,13 @@ CONTAINER_PORT=$3 CONTAINER_DATA_PATH=$4 CONTAINER_ENV=$5 -if [ -z "$CBTUMBLEBUG_ROOT" ]; then +if [ -z "$TB_ROOT_PATH" ]; then SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}` - export CBTUMBLEBUG_ROOT=`cd $SCRIPT_DIR && cd .. && pwd` + export TB_ROOT_PATH=`cd $SCRIPT_DIR && cd .. && pwd` fi CONTAINER_NAME=`echo $CONTAINER_NAME_READ | tr [:upper:] [:lower:]` -CONTAINER_VOLUME_PATH="$CBTUMBLEBUG_ROOT/container-volume/${CONTAINER_NAME}-container" +CONTAINER_VOLUME_PATH="$TB_ROOT_PATH/container-volume/${CONTAINER_NAME}-container" CONTAINER_VOLUME_OPTION="-v $CONTAINER_VOLUME_PATH:$CONTAINER_DATA_PATH" # If CONTAINER_DATA_PATH is not used, disable -v option if [ -z "$CONTAINER_DATA_PATH" ]; then @@ -54,14 +54,14 @@ while true; do esac done -if [ -z "$CBTUMBLEBUG_ROOT" ]; then +if [ -z "$TB_ROOT_PATH" ]; then echo echo ========================================================== echo "[Warning]" echo ========================================================== echo - echo "The environment variable for \$CBTUMBLEBUG_ROOT is empty." - echo "\$CBTUMBLEBUG_ROOT is the base path of persistent volume for $CONTAINER_NAME_READ." + echo "The environment variable for \$TB_ROOT_PATH is empty." + echo "\$TB_ROOT_PATH is the base path of persistent volume for $CONTAINER_NAME_READ." echo "(to show persistent volumes of the containers related to CB-Tumblebug in CB-Tumblebug directory)" echo echo "You need to execute [source conf/setup.env] before run $CONTAINER_NAME_READ container." diff --git a/scripts/runTerrarium.sh b/scripts/runTerrarium.sh index 27deb9e8c..11b41aaa0 100755 --- a/scripts/runTerrarium.sh +++ b/scripts/runTerrarium.sh @@ -5,16 +5,16 @@ CONTAINER_VERSION="0.0.6" CONTAINER_PORT="-p 8888:8888" CONTAINER_DATA_PATH="/app/.tofu" -if [ -z "$CBTUMBLEBUG_ROOT" ]; then +if [ -z "$TB_ROOT_PATH" ]; then SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]:-$0}") - export CBTUMBLEBUG_ROOT=$(cd "$SCRIPT_DIR" && cd .. && pwd) + export TB_ROOT_PATH=$(cd "$SCRIPT_DIR" && cd .. && pwd) fi parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) cd "$parent_path" # The credential directory and file path -credential_dir="$CBTUMBLEBUG_ROOT/conf/.credtmp" +credential_dir="$TB_ROOT_PATH/conf/.credtmp" aws_credential="$credential_dir/credentials" azure_credential="$credential_dir/credential-azure.env" gcp_credential="$credential_dir/credential-gcp.json" diff --git a/scripts/runTumblebug.sh b/scripts/runTumblebug.sh index 4671f08ef..caad5a038 100755 --- a/scripts/runTumblebug.sh +++ b/scripts/runTumblebug.sh @@ -56,9 +56,9 @@ echo "Note - this script assumes CB-Spider/CB-Dragonfly/MC-Terrarium container i echo if [ "$user_choice" != "1" ]; then - CONTAINER_ENV="--add-host host.docker.internal:host-gateway -e SPIDER_REST_URL=http://$EP_SPIDER:1024/spider -e DRAGONFLY_REST_URL=http://$EP_DRAGONFLY:9090/dragonfly -e TERRARIUM_REST_URL=http://$EP_TERRARIUM:8888/terrarium -e SELF_ENDPOINT=$EP_TUMBLEBUG:1323" + CONTAINER_ENV="--add-host host.docker.internal:host-gateway -e TB_SPIDER_REST_URL=http://$EP_SPIDER:1024/spider -e TB_DRAGONFLY_REST_URL=http://$EP_DRAGONFLY:9090/dragonfly -e TB_TERRARIUM_REST_URL=http://$EP_TERRARIUM:8888/terrarium -e TB_SELF_ENDPOINT=$EP_TUMBLEBUG:1323" else - CONTAINER_ENV="-e SPIDER_REST_URL=http://$EP_SPIDER:1024/spider -e DRAGONFLY_REST_URL=http://$EP_DRAGONFLY:9090/dragonfly -e SELF_ENDPOINT=$EP_TUMBLEBUG:1323" + CONTAINER_ENV="-e TB_SPIDER_REST_URL=http://$EP_SPIDER:1024/spider -e TB_DRAGONFLY_REST_URL=http://$EP_DRAGONFLY:9090/dragonfly -e TB_SELF_ENDPOINT=$EP_TUMBLEBUG:1323" fi ./runContainer.sh "$CONTAINER_NAME_READ" "$CONTAINER_VERSION" "$CONTAINER_PORT" "$CONTAINER_DATA_PATH" "$CONTAINER_ENV" diff --git a/scripts/setPublicIP.sh b/scripts/setPublicIP.sh index f01099e1a..1c8dd4355 100755 --- a/scripts/setPublicIP.sh +++ b/scripts/setPublicIP.sh @@ -1,10 +1,10 @@ #!/bin/bash echo "" -echo "Get IP of the current host and set SELF_ENDPOINT environment variable" +echo "Get IP of the current host and set TB_SELF_ENDPOINT environment variable" echo "(Default setting is in conf/setup.env)" echo "" -echo "Setting SELF_ENDPOINT allows outside users access to CB-Tumblebug Swagger API Dashboard." +echo "Setting TB_SELF_ENDPOINT allows outside users access to CB-Tumblebug Swagger API Dashboard." echo "" if [[ "$(basename -- "$0")" == "setPublicIP.sh" ]]; then @@ -23,13 +23,13 @@ str=$(curl https://api.ipify.org) if [ -z "$str" ] then echo "The result for IP lookup is empty." - echo "Set SELF_ENDPOINT=localhost:1323" + echo "Set TB_SELF_ENDPOINT=localhost:1323" str=localhost fi -export SELF_ENDPOINT=$str:1323 +export TB_SELF_ENDPOINT=$str:1323 echo "" -echo "SELF_ENDPOINT (CB-TB Swagger API Dashboard): $SELF_ENDPOINT" -echo "[Note] To apply \$SELF_ENDPOINT, CB-TB restart is required." +echo "TB_SELF_ENDPOINT (CB-TB Swagger API Dashboard): $TB_SELF_ENDPOINT" +echo "[Note] To apply \$TB_SELF_ENDPOINT, CB-TB restart is required." echo "" \ No newline at end of file diff --git a/src/api/rest/server/common/config.go b/src/api/rest/server/common/config.go index 0e52c4efb..8110cf217 100644 --- a/src/api/rest/server/common/config.go +++ b/src/api/rest/server/common/config.go @@ -126,7 +126,7 @@ func RestGetAllConfig(c echo.Context) error { // RestPostConfig godoc // @ID PostConfig // @Summary Create or Update config -// @Description Create or Update config (SPIDER_REST_URL, DRAGONFLY_REST_URL, ...) +// @Description Create or Update config (TB_SPIDER_REST_URL, TB_DRAGONFLY_REST_URL, ...) // @Tags [Admin] System environment // @Accept json // @Produce json @@ -237,7 +237,7 @@ func RestGetAllRequests(c echo.Context) error { // Option to save the result to a file if c.QueryParam("savefile") == "true" { - cbTumblebugRoot := os.Getenv("CBTUMBLEBUG_ROOT") + cbTumblebugRoot := os.Getenv("TB_ROOT_PATH") logPath := filepath.Join(cbTumblebugRoot, "log", "request_log_"+time.Now().Format("20060102_150405")+".log") file, err := os.Create(logPath) if err != nil { diff --git a/src/api/rest/server/mcis/network.go b/src/api/rest/server/mcis/network.go index 86340a27e..40f33e788 100644 --- a/src/api/rest/server/mcis/network.go +++ b/src/api/rest/server/mcis/network.go @@ -284,8 +284,8 @@ func RestPostSiteToSiteVpn(c echo.Context) error { // Initialize resty client with basic auth client := resty.New() - apiUser := os.Getenv("API_USERNAME") - apiPass := os.Getenv("API_PASSWORD") + apiUser := os.Getenv("TB_API_USERNAME") + apiPass := os.Getenv("TB_API_PASSWORD") client.SetBasicAuth(apiUser, apiPass) trId := fmt.Sprintf("%s-%s-%s", nsId, mcisId, vpnId) @@ -814,8 +814,8 @@ func RestDeleteSiteToSiteVpn(c echo.Context) error { // Initialize resty client with basic auth client := resty.New() - apiUser := os.Getenv("API_USERNAME") - apiPass := os.Getenv("API_PASSWORD") + apiUser := os.Getenv("TB_API_USERNAME") + apiPass := os.Getenv("TB_API_PASSWORD") client.SetBasicAuth(apiUser, apiPass) trId := fmt.Sprintf("%s-%s-%s", nsId, mcisId, vpnId) @@ -1070,8 +1070,8 @@ func RestPutSiteToSiteVpn(c echo.Context) error { // Initialize resty client with basic auth // client := resty.New() - // apiUser := os.Getenv("API_USERNAME") - // apiPass := os.Getenv("API_PASSWORD") + // apiUser := os.Getenv("TB_API_USERNAME") + // apiPass := os.Getenv("TB_API_PASSWORD") // client.SetBasicAuth(apiUser, apiPass) // epTerrarium := "http://localhost:8888/terrarium" @@ -1192,8 +1192,8 @@ func RestGetSiteToSiteVpn(c echo.Context) error { // Initialize resty client with basic auth client := resty.New() - apiUser := os.Getenv("API_USERNAME") - apiPass := os.Getenv("API_PASSWORD") + apiUser := os.Getenv("TB_API_USERNAME") + apiPass := os.Getenv("TB_API_PASSWORD") client.SetBasicAuth(apiUser, apiPass) trId := fmt.Sprintf("%s-%s-%s", nsId, mcisId, vpnId) @@ -1370,8 +1370,8 @@ func RestGetRequestStatusOfSiteToSiteVpn(c echo.Context) error { // Initialize resty client with basic auth client := resty.New() - apiUser := os.Getenv("API_USERNAME") - apiPass := os.Getenv("API_PASSWORD") + apiUser := os.Getenv("TB_API_USERNAME") + apiPass := os.Getenv("TB_API_PASSWORD") client.SetBasicAuth(apiUser, apiPass) trId := fmt.Sprintf("%s-%s-%s", nsId, mcisId, vpnId) diff --git a/src/api/rest/server/server.go b/src/api/rest/server/server.go index 851e3069d..59e1ca0ca 100644 --- a/src/api/rest/server/server.go +++ b/src/api/rest/server/server.go @@ -123,9 +123,9 @@ func RunServer(port string) { e.GET("/tumblebug/readyz", rest_common.RestGetReadyz) e.GET("/tumblebug/httpVersion", rest_common.RestCheckHTTPVersion) - allowedOrigins := os.Getenv("ALLOW_ORIGINS") + allowedOrigins := os.Getenv("TB_ALLOW_ORIGINS") if allowedOrigins == "" { - log.Fatal().Msgf("ALLOW_ORIGINS env variable for CORS is " + allowedOrigins + + log.Fatal().Msgf("TB_ALLOW_ORIGINS env variable for CORS is " + allowedOrigins + ". Please provide a proper value and source setup.env again. EXITING...") // allowedOrigins = "*" } @@ -135,11 +135,11 @@ func RunServer(port string) { })) // Conditions to prevent abnormal operation due to typos (e.g., ture, falss, etc.) - authEnabled := os.Getenv("AUTH_ENABLED") == "true" - authMode := os.Getenv("AUTH_MODE") + authEnabled := os.Getenv("TB_AUTH_ENABLED") == "true" + authMode := os.Getenv("TB_AUTH_MODE") - apiUser := os.Getenv("API_USERNAME") - apiPass := os.Getenv("API_PASSWORD") + apiUser := os.Getenv("TB_API_USERNAME") + apiPass := os.Getenv("TB_API_PASSWORD") // Setup Middlewares for auth var basicAuthMw echo.MiddlewareFunc @@ -169,7 +169,7 @@ func RunServer(port string) { log.Info().Msg("Basic Auth Middleware is initialized successfully") case "jwt": // Setup JWT Auth Middleware - err := authmw.InitJwtAuthMw(os.Getenv("IAM_MANAGER_REST_URL"), "/api/auth/certs") + err := authmw.InitJwtAuthMw(os.Getenv("TB_IAM_MANAGER_REST_URL"), "/api/auth/certs") if err != nil { log.Fatal().Err(err).Msg("Failed to initialize JWT Auth Middleware") } else { @@ -181,7 +181,7 @@ func RunServer(port string) { log.Info().Msg("JWT Auth Middleware is initialized successfully") } default: - log.Fatal().Msg("AUTH_MODE is not set properly. Please set it to 'basic' or 'jwt'. EXITING...") + log.Fatal().Msg("TB_AUTH_MODE is not set properly. Please set it to 'basic' or 'jwt'. EXITING...") } } @@ -486,7 +486,7 @@ func RunServer(port string) { g.PUT("/:nsId/testDeleteObjectAssociation/:resourceType/:resourceId", rest_mcir.RestTestDeleteObjectAssociation) g.GET("/:nsId/testGetAssociatedObjectCount/:resourceType/:resourceId", rest_mcir.RestTestGetAssociatedObjectCount) - selfEndpoint := os.Getenv("SELF_ENDPOINT") + selfEndpoint := os.Getenv("TB_SELF_ENDPOINT") apidashboard := " http://" + selfEndpoint + "/tumblebug/api" fmt.Println(" Default Namespace: " + common.DefaultNamespace) @@ -499,7 +499,7 @@ func RunServer(port string) { fmt.Printf(noticeColor, apidashboard) fmt.Println("\n ") - // A context for graceful shutdown (It is based on the signal package)selfEndpoint := os.Getenv("SELF_ENDPOINT") + // A context for graceful shutdown (It is based on the signal package)selfEndpoint := os.Getenv("TB_SELF_ENDPOINT") // NOTE - // Use os.Interrupt Ctrl+C or Ctrl+Break on Windows // Use syscall.KILL for Kill(can't be caught or ignored) (POSIX) diff --git a/src/core/common/common.go b/src/core/common/common.go index 4a35e6ad3..15cf7c8fb 100644 --- a/src/core/common/common.go +++ b/src/core/common/common.go @@ -65,14 +65,14 @@ var err error var ORM *xorm.Engine const ( - StrSpiderRestUrl string = "SPIDER_REST_URL" - StrDragonflyRestUrl string = "DRAGONFLY_REST_URL" - StrTerrariumRestUrl string = "TERRARIUM_REST_URL" + StrSpiderRestUrl string = "TB_SPIDER_REST_URL" + StrDragonflyRestUrl string = "TB_DRAGONFLY_REST_URL" + StrTerrariumRestUrl string = "TB_TERRARIUM_REST_URL" StrDBUrl string = "TB_SQLITE_URL" StrDBDatabase string = "TB_SQLITE_DATABASE" StrDBUser string = "TB_SQLITE_USER" StrDBPassword string = "TB_SQLITE_PASSWORD" - StrAutocontrolDurationMs string = "AUTOCONTROL_DURATION_MS" + StrAutocontrolDurationMs string = "TB_AUTOCONTROL_DURATION_MS" StrEtcdEndpoints string = "TB_ETCD_ENDPOINTS" ErrStrKeyNotFound string = "key not found" StrAdd string = "add" diff --git a/src/core/common/config.go b/src/core/common/config.go index 051d9ef1b..5c3e53608 100644 --- a/src/core/common/config.go +++ b/src/core/common/config.go @@ -279,14 +279,14 @@ const ( // swagger:request ConfigReq type ConfigReq struct { - Name string `json:"name" example:"SPIDER_REST_URL"` + Name string `json:"name" example:"TB_SPIDER_REST_URL"` Value string `json:"value" example:"http://localhost:1024/spider"` } // swagger:response ConfigInfo type ConfigInfo struct { - Id string `json:"id" example:"SPIDER_REST_URL"` - Name string `json:"name" example:"SPIDER_REST_URL"` + Id string `json:"id" example:"TB_SPIDER_REST_URL"` + Name string `json:"name" example:"TB_SPIDER_REST_URL"` Value string `json:"value" example:"http://localhost:1024/spider"` } @@ -331,13 +331,13 @@ func UpdateGlobalVariable(id string) error { switch id { case StrSpiderRestUrl: SpiderRestUrl = configInfo.Value - log.Debug().Msg(" " + SpiderRestUrl) + log.Debug().Msg(" " + SpiderRestUrl) case StrDragonflyRestUrl: DragonflyRestUrl = configInfo.Value - log.Debug().Msg(" " + DragonflyRestUrl) + log.Debug().Msg(" " + DragonflyRestUrl) case StrTerrariumRestUrl: TerrariumRestUrl = configInfo.Value - log.Debug().Msg(" " + TerrariumRestUrl) + log.Debug().Msg(" " + TerrariumRestUrl) case StrDBUrl: DBUrl = configInfo.Value log.Debug().Msg(" " + DBUrl) @@ -352,7 +352,7 @@ func UpdateGlobalVariable(id string) error { log.Debug().Msg(" " + DBPassword) case StrAutocontrolDurationMs: AutocontrolDurationMs = configInfo.Value - log.Debug().Msg(" " + AutocontrolDurationMs) + log.Debug().Msg(" " + AutocontrolDurationMs) case StrEtcdEndpoints: EtcdEndpoints = configInfo.Value log.Debug().Msg(" " + EtcdEndpoints) @@ -367,14 +367,14 @@ func InitConfig(id string) error { switch id { case StrSpiderRestUrl: - SpiderRestUrl = NVL(os.Getenv("SPIDER_REST_URL"), "http://localhost:1024/spider") - log.Debug().Msg(" " + SpiderRestUrl) + SpiderRestUrl = NVL(os.Getenv("TB_SPIDER_REST_URL"), "http://localhost:1024/spider") + log.Debug().Msg(" " + SpiderRestUrl) case StrDragonflyRestUrl: - DragonflyRestUrl = NVL(os.Getenv("DRAGONFLY_REST_URL"), "http://localhost:9090/dragonfly") - log.Debug().Msg(" " + DragonflyRestUrl) + DragonflyRestUrl = NVL(os.Getenv("TB_DRAGONFLY_REST_URL"), "http://localhost:9090/dragonfly") + log.Debug().Msg(" " + DragonflyRestUrl) case StrTerrariumRestUrl: - TerrariumRestUrl = NVL(os.Getenv("TERRARIUM_REST_URL"), "http://localhost:8888/terrarium") - log.Debug().Msg(" " + TerrariumRestUrl) + TerrariumRestUrl = NVL(os.Getenv("TB_TERRARIUM_REST_URL"), "http://localhost:8888/terrarium") + log.Debug().Msg(" " + TerrariumRestUrl) case StrDBUrl: DBUrl = NVL(os.Getenv("TB_SQLITE_URL"), "localhost:3306") log.Debug().Msg(" " + DBUrl) @@ -388,8 +388,8 @@ func InitConfig(id string) error { DBPassword = NVL(os.Getenv("TB_SQLITE_PASSWORD"), "cb_tumblebug") log.Debug().Msg(" " + DBPassword) case StrAutocontrolDurationMs: - AutocontrolDurationMs = NVL(os.Getenv("AUTOCONTROL_DURATION_MS"), "10000") - log.Debug().Msg(" " + AutocontrolDurationMs) + AutocontrolDurationMs = NVL(os.Getenv("TB_AUTOCONTROL_DURATION_MS"), "10000") + log.Debug().Msg(" " + AutocontrolDurationMs) default: } diff --git a/src/core/common/logger/logger.go b/src/core/common/logger/logger.go index 990dc06b0..27697efea 100644 --- a/src/core/common/logger/logger.go +++ b/src/core/common/logger/logger.go @@ -61,7 +61,7 @@ func init() { case "panic": level = zerolog.PanicLevel default: - log.Warn().Msgf("Invalid LOGLEVEL value: %s. Using default value: info", logLevel) + log.Warn().Msgf("Invalid TB_LOGLEVEL value: %s. Using default value: info", logLevel) level = zerolog.InfoLevel } @@ -108,7 +108,7 @@ func NewLogger(level zerolog.Level) *zerolog.Logger { // Apply ConsoleWriter to the global logger logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stdout}).Level(level).With().Timestamp().Caller().Logger() } else { - log.Warn().Msgf("Invalid LOGWRITER value: %s. Using default value: both", logwriter) + log.Warn().Msgf("Invalid TB_LOGWRITER value: %s. Using default value: both", logwriter) // Apply multi-writer to the global logger logger = zerolog.New(multi).Level(level).With().Timestamp().Caller().Logger() } @@ -145,35 +145,35 @@ func getLogFileConfig() (string, int, int, int, bool) { // Default: ./log/tumblebug.log if logFilePath == "" { - log.Warn().Msg("LOGFILE_PATH is not set. Using default value: ./log/tumblebug.log") + log.Warn().Msg("TB_LOGFILE_PATH is not set. Using default value: ./log/tumblebug.log") logFilePath = "./log/tumblebug.log" } // Default: 10 MB maxSize, err := strconv.Atoi(viper.GetString("logfile.maxsize")) if err != nil { - log.Warn().Msgf("Invalid LOGFILE_MAXSIZE value: %s. Using default value: 10 MB", viper.GetString("logfile.maxsize")) + log.Warn().Msgf("Invalid TB_LOGFILE_MAXSIZE value: %s. Using default value: 10 MB", viper.GetString("logfile.maxsize")) maxSize = 10 } // Default: 3 backups maxBackups, err := strconv.Atoi(viper.GetString("logfile.maxbackups")) if err != nil { - log.Warn().Msgf("Invalid LOGFILE_MAXBACKUPS value: %s. Using default value: 3 backups", viper.GetString("logfile.maxbackups")) + log.Warn().Msgf("Invalid TB_LOGFILE_MAXBACKUPS value: %s. Using default value: 3 backups", viper.GetString("logfile.maxbackups")) maxBackups = 3 } // Default: 30 days maxAge, err := strconv.Atoi(viper.GetString("logfile.maxage")) if err != nil { - log.Warn().Msgf("Invalid LOGFILE_MAXAGE value: %s. Using default value: 30 days", viper.GetString("logfile.maxage")) + log.Warn().Msgf("Invalid TB_LOGFILE_MAXAGE value: %s. Using default value: 30 days", viper.GetString("logfile.maxage")) maxAge = 30 } // Default: false compress, err := strconv.ParseBool(viper.GetString("logfile.compress")) if err != nil { - log.Warn().Msgf("Invalid LOGFILE_COMPRESS value: %s. Using default value: false", viper.GetString("logfile.compress")) + log.Warn().Msgf("Invalid TB_LOGFILE_COMPRESS value: %s. Using default value: false", viper.GetString("logfile.compress")) compress = false } diff --git a/src/core/mcir/common.go b/src/core/mcir/common.go index 60a48ebff..abc2d15b1 100644 --- a/src/core/mcir/common.go +++ b/src/core/mcir/common.go @@ -288,12 +288,12 @@ func DelResource(nsId string, resourceType string, resourceId string, forceFlag temp := publicIpInfo{} json.Unmarshal([]byte(keyValue.Value), &temp) requestBody.ConnectionName = temp.ConnectionName - url = common.SPIDER_REST_URL + "/publicip/" + temp.CspPublicIpName + url = common.TB_SPIDER_REST_URL + "/publicip/" + temp.CspPublicIpName case "vNic": temp := vNicInfo{} json.Unmarshal([]byte(keyValue.Value), &temp) requestBody.ConnectionName = temp.ConnectionName - url = common.SPIDER_REST_URL + "/vnic/" + temp.CspVNicName + url = common.TB_SPIDER_REST_URL + "/vnic/" + temp.CspVNicName */ default: err := fmt.Errorf("invalid resourceType") diff --git a/src/main.go b/src/main.go index 3aa8a7d48..942aa4002 100644 --- a/src/main.go +++ b/src/main.go @@ -52,16 +52,16 @@ import ( func init() { common.SystemReady = false - common.SpiderRestUrl = common.NVL(os.Getenv("SPIDER_REST_URL"), "http://localhost:1024/spider") - common.DragonflyRestUrl = common.NVL(os.Getenv("DRAGONFLY_REST_URL"), "http://localhost:9090/dragonfly") - common.TerrariumRestUrl = common.NVL(os.Getenv("TERRARIUM_REST_URL"), "http://localhost:8888/terrarium") + common.SpiderRestUrl = common.NVL(os.Getenv("TB_SPIDER_REST_URL"), "http://localhost:1024/spider") + common.DragonflyRestUrl = common.NVL(os.Getenv("TB_DRAGONFLY_REST_URL"), "http://localhost:9090/dragonfly") + common.TerrariumRestUrl = common.NVL(os.Getenv("TB_TERRARIUM_REST_URL"), "http://localhost:8888/terrarium") common.DBUrl = common.NVL(os.Getenv("TB_SQLITE_URL"), "localhost:3306") common.DBDatabase = common.NVL(os.Getenv("TB_SQLITE_DATABASE"), "cb_tumblebug") common.DBUser = common.NVL(os.Getenv("TB_SQLITE_USER"), "cb_tumblebug") common.DBPassword = common.NVL(os.Getenv("TB_SQLITE_PASSWORD"), "cb_tumblebug") - common.AutocontrolDurationMs = common.NVL(os.Getenv("AUTOCONTROL_DURATION_MS"), "10000") - common.DefaultNamespace = common.NVL(os.Getenv("DEFAULT_NAMESPACE"), "ns01") - common.DefaultCredentialHolder = common.NVL(os.Getenv("DEFAULT_CREDENTIALHOLDER"), "admin") + common.AutocontrolDurationMs = common.NVL(os.Getenv("TB_AUTOCONTROL_DURATION_MS"), "10000") + common.DefaultNamespace = common.NVL(os.Getenv("TB_DEFAULT_NAMESPACE"), "ns01") + common.DefaultCredentialHolder = common.NVL(os.Getenv("TB_DEFAULT_CREDENTIALHOLDER"), "admin") // Etcd common.EtcdEndpoints = common.NVL(os.Getenv("TB_ETCD_ENDPOINTS"), "localhost:2379") @@ -134,7 +134,7 @@ func init() { } } else { log.Error().Msg("Default namespace is not set") - panic("Default namespace is not set, please set DEFAULT_NAMESPACE in setup.env or environment variable") + panic("Default namespace is not set, please set TB_DEFAULT_NAMESPACE in setup.env or environment variable") } } } diff --git a/src/testclient/scripts/2.configureTumblebug/create-ns.sh b/src/testclient/scripts/2.configureTumblebug/create-ns.sh index e65449a10..8cff99a8f 100755 --- a/src/testclient/scripts/2.configureTumblebug/create-ns.sh +++ b/src/testclient/scripts/2.configureTumblebug/create-ns.sh @@ -7,7 +7,7 @@ echo "####################################################################" SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}` cd $SCRIPT_DIR -source $CBTUMBLEBUG_ROOT/src/testclient/scripts/init.sh +source $TB_ROOT_PATH/src/testclient/scripts/init.sh if [ ! -z "$OPTION01" ]; then NSID=$OPTION01 diff --git a/src/testclient/scripts/2.configureTumblebug/get-config.sh b/src/testclient/scripts/2.configureTumblebug/get-config.sh index 25943a047..3b43fe3e9 100755 --- a/src/testclient/scripts/2.configureTumblebug/get-config.sh +++ b/src/testclient/scripts/2.configureTumblebug/get-config.sh @@ -3,7 +3,7 @@ #function get_config() { echo "####################################################################" - echo "## 0. Config: Get (option: SPIDER_REST_URL, DRAGONFLY_REST_URL, ...)" + echo "## 0. Config: Get (option: TB_SPIDER_REST_URL, TB_DRAGONFLY_REST_URL, ...)" echo "####################################################################" source ../init.sh diff --git a/src/testclient/scripts/2.configureTumblebug/init-config.sh b/src/testclient/scripts/2.configureTumblebug/init-config.sh index f06a1ff18..6566584fa 100755 --- a/src/testclient/scripts/2.configureTumblebug/init-config.sh +++ b/src/testclient/scripts/2.configureTumblebug/init-config.sh @@ -3,7 +3,7 @@ #function init_config() { echo "####################################################################" - echo "## 0. Config: Init (option: SPIDER_REST_URL, DRAGONFLY_REST_URL, ...)" + echo "## 0. Config: Init (option: TB_SPIDER_REST_URL, TB_DRAGONFLY_REST_URL, ...)" echo "####################################################################" source ../init.sh diff --git a/src/testclient/scripts/init.sh b/src/testclient/scripts/init.sh index ecf959b04..612550552 100755 --- a/src/testclient/scripts/init.sh +++ b/src/testclient/scripts/init.sh @@ -1,6 +1,6 @@ #!/bin/bash -source $CBTUMBLEBUG_ROOT/src/testclient/scripts/common-functions.sh +source $TB_ROOT_PATH/src/testclient/scripts/common-functions.sh readParametersByName "$@" set -- "$CSP" "$REGION" "$POSTFIX" "$TestSetFile" "$OPTION01" "$OPTION02" "$OPTION03" @@ -9,7 +9,7 @@ if [ ! -f "$TestSetFile" ]; then exit fi source $TestSetFile -source $CBTUMBLEBUG_ROOT/src/testclient/scripts/conf.env +source $TB_ROOT_PATH/src/testclient/scripts/conf.env getCloudIndex $CSP MCISID=${POSTFIX} diff --git a/src/testclient/scripts/sequentialFullTest/deploy-dragonfly-docker.sh b/src/testclient/scripts/sequentialFullTest/deploy-dragonfly-docker.sh index eaa0b2e25..2b0c0b032 100755 --- a/src/testclient/scripts/sequentialFullTest/deploy-dragonfly-docker.sh +++ b/src/testclient/scripts/sequentialFullTest/deploy-dragonfly-docker.sh @@ -61,7 +61,7 @@ echo "CMD: $CMD" echo "" echo "[Update Tumblebug Environment for Dragonfly with following command]" - PARAM="-x DRAGONFLY_REST_URL -y http://${MASTERIP}:9090/dragonfly" + PARAM="-x TB_DRAGONFLY_REST_URL -y http://${MASTERIP}:9090/dragonfly" echo $PARAM ../2.configureTumblebug/update-config.sh $PARAM diff --git a/src/testclient/test-clis/vpn-tunnel/gcp-aws/README.md b/src/testclient/test-clis/vpn-tunnel/gcp-aws/README.md index d97a0ce45..a11537466 100644 --- a/src/testclient/test-clis/vpn-tunnel/gcp-aws/README.md +++ b/src/testclient/test-clis/vpn-tunnel/gcp-aws/README.md @@ -11,15 +11,15 @@ This test CLI includes to: #### Getting started ##### Setup environment variables -Note - `$CBTUMBLEBUG_ROOT` means your root directory of CB-Tumblebug +Note - `$TB_ROOT_PATH` means your root directory of CB-Tumblebug ```bash -cd $CBTUMBLEBUG_ROOT +cd $TB_ROOT_PATH source conf/setup.env ``` ##### Build the app ```bash -cd $CBTUMBLEBUG_ROOT/testclient/test-clis/vpn-tunnel/gcp-aws +cd $TB_ROOT_PATH/testclient/test-clis/vpn-tunnel/gcp-aws go build -o app ```