Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"log/slog"
"os"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions app/config/credits.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ services:
nofile:
soft: 262144
hard: 262144
ports:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are coming from docker-compose.yaml, use that for local development please.

- "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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions quickstart/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ aggregation:
clickhouse:
address: clickhouse:9000

credits:
enabled: true
enable_credit_then_invoice: true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Credit then invoice is not supported yet, so let's not merge this until we are done with the implementation.


sink:
minCommitCount: 1
namespaceRefetch: 1s
Expand Down