Skip to content

Commit

Permalink
Remove configer and original config dependencies
Browse files Browse the repository at this point in the history
Previously, this was using quite a complex config solution with Viper,
which is a relatively stale package with a lot of old dependencies.
Nowadays, in a containerized environment, only using environment variables
is pretty much production-ready for configs, let alone for this personal
project. This change removes all the old configuration solution and its
dependencies, in favour of simply reading some env vars instead.
  • Loading branch information
Ozoniuss committed May 13, 2024
1 parent 791d6dd commit 386ff2b
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 562 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ casheer.e2e.db
default.json

account-statement*
configs/config.yml

/*.db
7 changes: 2 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ func run() error {
))
ctx := context.Background()

config, err := cfg.ParseConfig()
if err != nil {
return fmt.Errorf("could not parse config: %w", err)
}
log.InfoContext(ctx, fmt.Sprintf("parsed config: %+v\n", config))
config := cfg.NewInitializedConfig()
log.InfoContext(ctx, "parsed config", slog.Any("config", config))

conn, err := store.ConnectSqlite(config.SQLiteDatabase.File)
if err != nil {
Expand Down
12 changes: 0 additions & 12 deletions configs/config.test.yml

This file was deleted.

4 changes: 4 additions & 0 deletions configs/dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CASHEER_SERVER_SCHEME=http
CASHEER_SERVER_ADDRESS=0.0.0.0
CASHEER_SERVER_PORT=8033
CASHEER_SQLITE_FILE=/externaldeps/casheer.db
4 changes: 4 additions & 0 deletions configs/e2e.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CASHEER_SERVER_SCHEME=http
CASHEER_SERVER_ADDRESS=0.0.0.0
CASHEER_SERVER_PORT=6597
CASHEER_SQLITE_FILE=/externaldeps/casheer.db
8 changes: 3 additions & 5 deletions docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ services:
context: ./
dockerfile: ./Dockerfile
container_name: casheer-e2e

# Make sure ports from command and ports match. If desired, create a .env
# file for docker compose to not have to manage it manually.
command: --server-address 0.0.0.0 --server-port 6597 --sqlite-db /externaldeps/casheer.db
# Make sure ports from command and ports match.
env_file:
- ./configs/e2e.env
ports:
- 6597:6597

volumes:
- ./${DBNAME:-casheer.e2e.db}:/externaldeps/casheer.db
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
context: ./
dockerfile: ./Dockerfile
container_name: casheer-dev
command: --server-address 0.0.0.0 --server-port 8033 --sqlite-db /externaldeps/casheer.db
env_file:
- ./configs/dev.env
ports:
- 8033:8033
19 changes: 4 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/Ozoniuss/casheer
go 1.22

require (
github.com/Ozoniuss/configer v0.3.1
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.9.1
github.com/google/go-cmp v0.6.0
github.com/mattn/go-sqlite3 v1.14.19
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
gorm.io/driver/sqlite v1.5.4
gorm.io/gorm v1.25.5
)
Expand All @@ -16,42 +16,31 @@ require (
github.com/bytedance/sonic v1.10.2 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.17.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.5.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 386ff2b

Please sign in to comment.