From 0125aad5def1caaf10d7ae2cd71d9b14e0778929 Mon Sep 17 00:00:00 2001 From: rot1024 Date: Tue, 1 Jun 2021 17:57:39 +0900 Subject: [PATCH] chore: print config --- .env | 6 ------ .gitignore | 3 ++- internal/app/config.go | 13 +++++++++++++ internal/app/main.go | 1 + internal/usecase/interactor/user.go | 3 --- 5 files changed, 16 insertions(+), 10 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 89a0c0cc..00000000 --- a/.env +++ /dev/null @@ -1,6 +0,0 @@ -# PLEASE COPY THIS TO .env.local AND EDIT IT. DO NOT EDIT THIS FILE. -REEARTH_AUTH0_DOMAIN= -REEARTH_AUTH0_AUDIENCE= -REEARTH_AUTH0_CLIENTID= -REEARTH_AUTH0_CLIENTSECRET= -REEARTH_AUTH0_WEBCLIENTID= diff --git a/.gitignore b/.gitignore index b2965e26..27eed16d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ __debug_bin /bin /debug /mongo -.env.local +/.env +/.env.local /coverage.txt /web diff --git a/internal/app/config.go b/internal/app/config.go index c2c8205b..4fb0bf28 100644 --- a/internal/app/config.go +++ b/internal/app/config.go @@ -1,7 +1,9 @@ package app import ( + "fmt" "os" + "strings" "github.com/joho/godotenv" "github.com/kelseyhightower/envconfig" @@ -58,3 +60,14 @@ func ReadConfig(debug bool) (*Config, error) { return &c, err } + +func (c Config) Print() string { + s := fmt.Sprintf("%+v", c) + for _, secret := range []string{c.DB, c.Auth0.ClientSecret} { + if secret == "" { + continue + } + s = strings.ReplaceAll(s, secret, "***") + } + return s +} diff --git a/internal/app/main.go b/internal/app/main.go index 3e091525..b76c9488 100644 --- a/internal/app/main.go +++ b/internal/app/main.go @@ -16,6 +16,7 @@ func Start(debug bool, version string) { if cerr != nil { log.Fatal(cerr) } + log.Infof("config: %s", conf.Print()) // Init profiler initProfiler(conf.Profiler, version) diff --git a/internal/usecase/interactor/user.go b/internal/usecase/interactor/user.go index 09be865f..57af3774 100644 --- a/internal/usecase/interactor/user.go +++ b/internal/usecase/interactor/user.go @@ -152,7 +152,6 @@ func (i *User) Signup(ctx context.Context, inp interfaces.SignupParam) (u *user. } func (i *User) UpdateMe(ctx context.Context, p interfaces.UpdateMeParam, operator *usecase.Operator) (u *user.User, err error) { - tx, err := i.transaction.Begin() if err != nil { return @@ -242,7 +241,6 @@ func (i *User) UpdateMe(ctx context.Context, p interfaces.UpdateMeParam, operato } func (i *User) RemoveMyAuth(ctx context.Context, authProvider string, operator *usecase.Operator) (u *user.User, err error) { - tx, err := i.transaction.Begin() if err != nil { return @@ -280,7 +278,6 @@ func (i *User) SearchUser(ctx context.Context, nameOrEmail string, operator *use } func (i *User) DeleteMe(ctx context.Context, userID id.UserID, operator *usecase.Operator) (err error) { - tx, err := i.transaction.Begin() if err != nil { return