From 1c1f373ba01c6d9bc64aa9cb6b6f9da2e5a21bc8 Mon Sep 17 00:00:00 2001 From: Pratham Khodwe Date: Wed, 13 May 2026 14:13:08 +0530 Subject: [PATCH] feat(config): add credits configuration and update docker-compose ports --- app/config/config_test.go | 25 +++++++++++++++++++++++++ app/config/credits.go | 4 ++-- docker-compose.base.yaml | 6 ++++++ quickstart/config.yaml | 4 ++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/app/config/config_test.go b/app/config/config_test.go index 2cb684c6d6..caa51c8a21 100644 --- a/app/config/config_test.go +++ b/app/config/config_test.go @@ -4,6 +4,7 @@ import ( "errors" "log/slog" "os" + "strings" "testing" "time" @@ -451,3 +452,27 @@ func TestComplete(t *testing.T) { assert.Equal(t, expected, actual) } + +func TestCreditsConfigurationUnmarshal(t *testing.T) { + v, flags := viper.New(), pflag.NewFlagSet("OpenMeter", pflag.ExitOnError) + SetViperDefaults(v, flags) + + v.SetConfigType("yaml") + err := v.ReadConfig(strings.NewReader(` +credits: + enabled: true + enable_credit_then_invoice: true +`)) + if err != nil { + t.Fatal(err) + } + + var actual Configuration + err = v.Unmarshal(&actual, viper.DecodeHook(DecodeHook())) + if err != nil { + t.Fatal(err) + } + + assert.True(t, actual.Credits.Enabled) + assert.True(t, actual.Credits.EnableCreditThenInvoice) +} diff --git a/app/config/credits.go b/app/config/credits.go index 0c1b5d623f..8b49dc5592 100644 --- a/app/config/credits.go +++ b/app/config/credits.go @@ -7,8 +7,8 @@ import ( ) type CreditsConfiguration struct { - Enabled bool `yaml:"enabled"` - EnableCreditThenInvoice bool `yaml:"enable_credit_then_invoice"` + Enabled bool `yaml:"enabled" mapstructure:"enabled"` + EnableCreditThenInvoice bool `yaml:"enable_credit_then_invoice" mapstructure:"enable_credit_then_invoice"` } func (c CreditsConfiguration) Validate() error { diff --git a/docker-compose.base.yaml b/docker-compose.base.yaml index 4c3689efed..1209f56eb6 100644 --- a/docker-compose.base.yaml +++ b/docker-compose.base.yaml @@ -49,6 +49,10 @@ services: nofile: soft: 262144 hard: 262144 + ports: + - "127.0.0.1:8123:8123" + - "127.0.0.1:9000:9000" + - "127.0.0.1:9009:9009" healthcheck: test: ["CMD", "wget", "--spider", "http://clickhouse:8123/ping"] interval: 5s @@ -118,6 +122,8 @@ services: target: /docker-entrypoint-initdb.d/svix.sql mode: 0444 command: ["postgres", "-c", "wal_level=logical"] + ports: + - "127.0.0.1:5432:5432" healthcheck: test: ["CMD", "pg_isready", "-d", "postgres", "-U", "postgres"] interval: 10s diff --git a/quickstart/config.yaml b/quickstart/config.yaml index 92e6e4cdaa..98565b71ba 100644 --- a/quickstart/config.yaml +++ b/quickstart/config.yaml @@ -9,6 +9,10 @@ aggregation: clickhouse: address: clickhouse:9000 +credits: + enabled: true + enable_credit_then_invoice: true + sink: minCommitCount: 1 namespaceRefetch: 1s