Skip to content

Commit

Permalink
refactor: change viper to koanf
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Dec 26, 2024
1 parent 80699fc commit 286e448
Show file tree
Hide file tree
Showing 50 changed files with 260 additions and 210 deletions.
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ init:

install-tools:
@go install golang.org/x/tools/cmd/godoc@latest
@go install golang.org/x/tools/cmd/goimports@latest
@go install honnef.co/go/tools/cmd/staticcheck@latest

install-modules:
@for dir in $(MODULE_DIRS); do \
Expand Down Expand Up @@ -57,7 +59,7 @@ clean-cache:
sync:
@go work sync

check: lint test
check: lint test staticcheck

test:
@for dir in $(MODULE_DIRS); do \
Expand All @@ -75,18 +77,23 @@ benchmark:
cd $$dir && go test -run="-" -bench=".*" -benchmem $(test-options) ./...; \
done

lint: fmt vet
lint: fmt vet staticcheck

fmt:
@for dir in $(MODULE_DIRS); do \
cd $$dir && go fmt ./...; \
cd $$dir && goimports -w .; \
done

vet:
@for dir in $(MODULE_DIRS); do \
cd $$dir && go vet ./...; \
done

staticcheck:
@for dir in $(MODULE_DIRS); do \
cd $$dir && staticcheck ./...; \
done

doc: init
@godoc -http=:6060

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ pong#

Adjust settings through `.uniflow.toml` or environment variables.

| TOML Key | Environment Variable Key | Example |
|----------------------|--------------------------|---------------------------|
| `database.url` | `DATABASE.URL` | `mem://` or `mongodb://` |
| `database.name` | `DATABASE.NAME` | - |
| `collection.specs` | `COLLECTION.SPECS` | `nodes` |
| `collection.secrets` | `COLLECTION.SECRETS` | `secrets` |
| TOML Key | Environment Variable Key | Example |
|----------------------|--------------------------|--------------------------|
| `database.url` | `DATABASE_URL` | `mem://` or `mongodb://` |
| `database.name` | `DATABASE_NAME` | - |
| `collection.specs` | `COLLECTION_SPECS` | `nodes` |
| `collection.secrets` | `COLLECTION_SECRETS` | `secrets` |

## 📊 Benchmark

Expand Down
12 changes: 6 additions & 6 deletions README_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ pong#

환경 설정은 `.uniflow.toml` 파일 또는 시스템 환경 변수를 통해 관리할 수 있습니다.

| TOML 키 | 환경 변수 키 | 예시 |
|----------------------|--------------------------|---------------------------|
| `database.url` | `DATABASE.URL` | `mem://` 또는 `mongodb://` |
| `database.name` | `DATABASE.NAME` | - |
| `collection.specs` | `COLLECTION.SPECS` | `nodes` |
| `collection.secrets` | `COLLECTION.SECRETS` | `secrets` |
| TOML 키 | 환경 변수 키 | 예시 |
|----------------------|----------------------|--------------------------|
| `database.url` | `DATABASE_URL` | `mem://` 또는 `mongodb://` |
| `database.name` | `DATABASE_NAME` | - |
| `collection.specs` | `COLLECTION_SPECS` | `nodes` |
| `collection.secrets` | `COLLECTION_SECRETS` | `secrets` |

## 📊 벤치마크

Expand Down
14 changes: 7 additions & 7 deletions cmd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Effectively manage your workflows using the versatile Command Line Interface (CL

Settings can be modified using the `.uniflow.toml` file or system environment variables. The key configuration options are:

| TOML Key | Environment Variable Key | Example |
|----------------------|--------------------------|-----------------------------|
| `database.url` | `DATABASE.URL` | `mem://` or `mongodb://` |
| `database.name` | `DATABASE.NAME` | - |
| `collection.charts` | `COLLECTION.CHARTS` | `charts` |
| `collection.specs` | `COLLECTION.SPECS` | `nodes` |
| `collection.secrets` | `COLLECTION.SECRETS` | `secrets` |
| TOML Key | Environment Variable Key | Example |
|----------------------|--------------------------|--------------------------|
| `database.url` | `DATABASE_URL` | `mem://` or `mongodb://` |
| `database.name` | `DATABASE_NAME` | - |
| `collection.charts` | `COLLECTION_CHARTS` | `charts` |
| `collection.specs` | `COLLECTION_SPECS` | `nodes` |
| `collection.secrets` | `COLLECTION_SECRETS` | `secrets` |

If you are using [MongoDB](https://www.mongodb.com/), enable [Change Streams](https://www.mongodb.com/docs/manual/changeStreams/) to track resource changes in real time. This requires setting up a [replica set](https://www.mongodb.com/docs/manual/replication/).

Expand Down
14 changes: 7 additions & 7 deletions cmd/README_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

설정은 `.uniflow.toml` 파일이나 시스템 환경 변수를 사용해 유연하게 변경할 수 있습니다. 주요 설정 항목은 다음과 같습니다:

| TOML 키 | 환경 변수 키 | 예시 |
|----------------------|-------------------------|----------------------------|
| `database.url` | `DATABASE.URL` | `mem://` 또는 `mongodb://` |
| `database.name` | `DATABASE.NAME` | - |
| `collection.charts` | `COLLECTION.CHARTS` | `charts` |
| `collection.specs` | `COLLECTION.SPECS` | `nodes` |
| `collection.secrets` | `COLLECTION.SECRETS` | `secrets` |
| TOML 키 | 환경 변수 키 | 예시 |
|----------------------|----------------------|--------------------------|
| `database.url` | `DATABASE_URL` | `mem://` 또는 `mongodb://` |
| `database.name` | `DATABASE_NAME` | - |
| `collection.charts` | `COLLECTION_CHARTS` | `charts` |
| `collection.specs` | `COLLECTION_SPECS` | `nodes` |
| `collection.secrets` | `COLLECTION_SECRETS` | `secrets` |

만약 [MongoDB](https://www.mongodb.com/)를 사용한다면, 리소스의 변경 사항을 실시간으로 추적하기 위해 [변경 스트림](https://www.mongodb.com/docs/manual/changeStreams/)을 활성화해야 합니다. 이를 위해서는 [복제 세트](https://www.mongodb.com/docs/manual/replication/) 설정이 필요합니다.

Expand Down
23 changes: 10 additions & 13 deletions cmd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ require (
github.com/charmbracelet/bubbletea v1.2.4
github.com/go-faker/faker/v4 v4.5.0
github.com/gofrs/uuid v4.4.0+incompatible
github.com/iancoleman/strcase v0.3.0
github.com/jedib0t/go-pretty/v6 v6.6.5
github.com/knadh/koanf/parsers/toml v0.1.0
github.com/knadh/koanf/providers/env v1.0.0
github.com/knadh/koanf/providers/file v1.1.2
github.com/knadh/koanf/v2 v2.1.2
github.com/mattn/go-sqlite3 v1.14.24
github.com/siyul-park/uniflow v0.12.0
github.com/siyul-park/uniflow/driver/mongo v0.12.1
github.com/siyul-park/uniflow/ext v0.12.0
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
github.com/tryvium-travels/memongo v0.12.0
go.mongodb.org/mongo-driver/v2 v2.0.0
Expand Down Expand Up @@ -44,43 +48,37 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.23.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/cel-go v0.22.1 // indirect
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.mongodb.org/mongo-driver v1.17.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
golang.org/x/net v0.33.0 // indirect
Expand All @@ -90,5 +88,4 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20241223144023-3abc09e42ca8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
google.golang.org/protobuf v1.36.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
Loading

0 comments on commit 286e448

Please sign in to comment.