Skip to content

Commit

Permalink
feat: add capability to configure the ledger on the generator
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Nov 14, 2024
1 parent 391d894 commit 52ad994
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 46 deletions.
2 changes: 2 additions & 0 deletions deployments/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ spec:
value: ":{{ .Values.service.port }}"
- name: DEBUG
value: "{{ .Values.debug }}"
- name: EXPERIMENTAL_FEATURES
value: "{{ .Values.experimentalFeatures }}"
{{- if not (eq .Values.gracePeriod "") }}
# https://freecontent.manning.com/handling-client-requests-properly-with-kubernetes/
- name: GRACE_PERIOD
Expand Down
4 changes: 3 additions & 1 deletion deployments/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@ postgres:

debug: false

gracePeriod: "5s"
gracePeriod: "5s"

experimentalFeatures: false
2 changes: 2 additions & 0 deletions deployments/pulumi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func deployLedger(ctx *pulumi.Context) error {
imagePullPolicy, _ := conf.Try("image.pullPolicy")

replicaCount, _ := conf.TryInt("replicaCount")
experimentalFeatures, _ := conf.TryBool("experimentalFeatures")

rel, err := helm.NewRelease(ctx, "ledger", &helm.ReleaseArgs{
Chart: pulumi.String("../helm"),
Expand All @@ -57,6 +58,7 @@ func deployLedger(ctx *pulumi.Context) error {
},
"debug": pulumi.Bool(debug),
"replicaCount": pulumi.Int(replicaCount),
"experimentalFeatures": pulumi.Bool(experimentalFeatures),
}),
})
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions internal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import "github.com/formancehq/ledger/internal"
- [func \(e ErrInvalidLedgerName\) Error\(\) string](<#ErrInvalidLedgerName.Error>)
- [func \(e ErrInvalidLedgerName\) Is\(err error\) bool](<#ErrInvalidLedgerName.Is>)
- [type FeatureSet](<#FeatureSet>)
- [func \(f FeatureSet\) SortedKeys\(\) \[\]string](<#FeatureSet.SortedKeys>)
- [func \(f FeatureSet\) String\(\) string](<#FeatureSet.String>)
- [func \(f FeatureSet\) With\(feature, value string\) FeatureSet](<#FeatureSet.With>)
- [type Ledger](<#Ledger>)
Expand Down Expand Up @@ -440,6 +441,15 @@ func (e ErrInvalidLedgerName) Is(err error) bool
type FeatureSet map[string]string
```

<a name="FeatureSet.SortedKeys"></a>
### func \(FeatureSet\) SortedKeys

```go
func (f FeatureSet) SortedKeys() []string
```



<a name="FeatureSet.String"></a>
### func \(FeatureSet\) String

Expand Down
11 changes: 8 additions & 3 deletions internal/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,20 @@ func (f FeatureSet) With(feature, value string) FeatureSet {
return ret
}

func (f FeatureSet) SortedKeys() []string {
ret := Keys(f)
slices.Sort(ret)

return ret
}

func (f FeatureSet) String() string {
if len(f) == 0 {
return ""
}
keys := Keys(f)
slices.Sort(keys)

ret := ""
for _, key := range keys {
for _, key := range f.SortedKeys() {
ret = ret + "," + shortenFeature(key) + "=" + f[key]
}

Expand Down
7 changes: 5 additions & 2 deletions test/rolling-upgrades/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ image-current:

sources:
FROM core+builder-image
WORKDIR /src
COPY ../..+sources/src /src
WORKDIR /src/test/rolling-upgrades
COPY go.* *.go .

SAVE ARTIFACT /src
Expand Down Expand Up @@ -75,9 +76,11 @@ run:
CACHE --id go-mod-cache /go/pkg/mod
CACHE --id go-cache /root/.cache/go-build

WORKDIR /src/test/rolling-upgrades
COPY +sources/src /src
COPY ../../deployments/pulumi+sources/src /src/deployments/pulumi
COPY ../../deployments/helm+sources/src /src/deployments/helm

WORKDIR /src/test/rolling-upgrades
COPY go.* *.go .

ARG NO_CLEANUP=false
Expand Down
33 changes: 29 additions & 4 deletions test/rolling-upgrades/go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
module github.com/formancehq/ledger/test/rolling-upgrades

go 1.22.0
go 1.22.1

toolchain go1.23.2

replace github.com/formancehq/ledger/pkg/client => ../../pkg/client

replace github.com/formancehq/ledger => ../..

require (
github.com/formancehq/go-libs/v2 v2.0.0
github.com/formancehq/go-libs/v2 v2.0.1-0.20241107141636-5509ff77294e
github.com/formancehq/ledger v0.0.0-00010101000000-000000000000
github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.12.0
github.com/pulumi/pulumi/sdk/v3 v3.117.0
github.com/stretchr/testify v1.9.0
Expand All @@ -23,7 +26,9 @@ require (
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/charmbracelet/bubbles v0.16.1 // indirect
github.com/charmbracelet/bubbletea v0.24.2 // indirect
github.com/charmbracelet/lipgloss v0.7.1 // indirect
Expand All @@ -34,23 +39,31 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/djherbis/times v1.5.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.12.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/invopop/jsonschema v0.12.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/lithammer/shortuuid/v3 v3.0.7 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // 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.15 // indirect
Expand All @@ -71,6 +84,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
github.com/pulumi/esc v0.6.2 // indirect
github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
Expand All @@ -82,22 +96,33 @@ require (
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/uptrace/bun v1.2.5 // indirect
github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2 // indirect
github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.2 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/zclconf/go-cty v1.13.2 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/log v0.7.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
Expand Down
Loading

0 comments on commit 52ad994

Please sign in to comment.