@@ -4,6 +4,16 @@ import (
44 "encoding/json"
55 "errors"
66 "fmt"
7+ "reflect"
8+ "time"
9+
10+ "github.com/formancehq/ledger/deployments/pulumi/pkg/utils"
11+ "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rds"
12+ "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
13+ "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
14+ "github.com/pulumi/pulumi/sdk/v3/go/pulumix"
15+ "gopkg.in/yaml.v3"
16+
717 . "github.com/formancehq/go-libs/v3/collectionutils"
818 pulumi_ledger "github.com/formancehq/ledger/deployments/pulumi/pkg"
919 "github.com/formancehq/ledger/deployments/pulumi/pkg/api"
@@ -14,13 +24,6 @@ import (
1424 "github.com/formancehq/ledger/deployments/pulumi/pkg/provision"
1525 "github.com/formancehq/ledger/deployments/pulumi/pkg/storage"
1626 "github.com/formancehq/ledger/deployments/pulumi/pkg/worker"
17- "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rds"
18- "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
19- "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
20- "github.com/pulumi/pulumi/sdk/v3/go/pulumix"
21- "gopkg.in/yaml.v3"
22- "reflect"
23- "time"
2427)
2528
2629type Ingress struct {
@@ -183,8 +186,8 @@ func (a *PostgresDatabase) toInput() *storage.PostgresDatabaseArgs {
183186
184187 return & storage.PostgresDatabaseArgs {
185188 Install : & storage.PostgresInstallArgs {
186- Username : pulumix .Val (a .Install .Username ),
187- Password : pulumix .Val (a .Install .Password ),
189+ Username : pulumix .Val (a .Install .Username ),
190+ Password : pulumix .Val (a .Install .Password ),
188191 ChartVersion : pulumix .Val (a .Install .ChartVersion ),
189192 },
190193 }
@@ -572,8 +575,12 @@ type Common struct {
572575 Monitoring * Monitoring `json:"monitoring,omitempty" yaml:"monitoring,omitempty"`
573576
574577 // Tag is the version tag for the ledger
578+ // deprecated
575579 Tag string `json:"version,omitempty" yaml:"version,omitempty"`
576580
581+ // Image configuration
582+ Image * ImageConfiguration `json:"image"`
583+
577584 // ImagePullPolicy is the image pull policy for the ledger
578585 ImagePullPolicy string `json:"image-pull-policy,omitempty" yaml:"image-pull-policy,omitempty"`
579586
@@ -583,11 +590,11 @@ type Common struct {
583590
584591func (c Common ) toInput () common.CommonArgs {
585592 return common.CommonArgs {
586- Namespace : pulumix .Val (c .Namespace ),
587- Monitoring : c .Monitoring .ToInput (),
588- Tag : pulumix . Val ( c .Tag ),
589- ImagePullPolicy : pulumix .Val (c .ImagePullPolicy ),
590- Debug : pulumix .Val (c .Debug ),
593+ Namespace : pulumix .Val (c .Namespace ),
594+ Monitoring : c .Monitoring .ToInput (),
595+ ImageConfiguration : imageConfigurationOrTag ( c . Image , c .Tag ),
596+ ImagePullPolicy : pulumix .Val (c .ImagePullPolicy ),
597+ Debug : pulumix .Val (c .Debug ),
591598 }
592599}
593600
@@ -662,6 +669,7 @@ func (g GeneratorLedgerConfiguration) toInput() generator.LedgerConfiguration {
662669
663670type Generator struct {
664671 // GeneratorVersion is the version of the generator
672+ // deprecated
665673 GeneratorVersion string `json:"generator-version" yaml:"generator-version"`
666674
667675 // Ledgers are the ledgers to run the generator against
@@ -725,6 +733,12 @@ func (cfg Config) ToInput() pulumi_ledger.ComponentArgs {
725733 }
726734}
727735
736+ type ImageConfiguration struct {
737+ Registry string `json:"registry" yaml:"registry"`
738+ Repository string `json:"repository" yaml:"repository"`
739+ Tag string `json:"version" yaml:"version"`
740+ }
741+
728742func Load (ctx * pulumi.Context ) (* Config , error ) {
729743 cfg := config .New (ctx , "" )
730744
@@ -795,6 +809,13 @@ func Load(ctx *pulumi.Context) (*Config, error) {
795809 generator = nil
796810 }
797811
812+ image := & ImageConfiguration {}
813+ if err := cfg .TryObject ("image" , image ); err != nil {
814+ if ! errors .Is (err , config .ErrMissingVar ) {
815+ return nil , fmt .Errorf ("error reading generator config: %w" , err )
816+ }
817+ }
818+
798819 namespace := cfg .Get ("namespace" )
799820 if namespace == "" {
800821 namespace = ctx .Stack ()
@@ -807,6 +828,7 @@ func Load(ctx *pulumi.Context) (*Config, error) {
807828 Namespace : namespace ,
808829 Tag : cfg .Get ("version" ),
809830 Monitoring : monitoring ,
831+ Image : image ,
810832 ImagePullPolicy : cfg .Get ("image-pull-policy" ),
811833 },
812834 InstallDevBox : cfg .GetBool ("install-dev-box" ),
@@ -819,3 +841,21 @@ func Load(ctx *pulumi.Context) (*Config, error) {
819841 Generator : generator ,
820842 }, nil
821843}
844+
845+ func imageConfigurationOrTag (configuration * ImageConfiguration , tag string ) utils.ImageConfiguration {
846+ if configuration == nil {
847+ return utils.ImageConfiguration {
848+ Tag : pulumix .Val (tag ),
849+ }
850+ }
851+
852+ if configuration .Tag != "" {
853+ tag = configuration .Tag
854+ }
855+
856+ return utils.ImageConfiguration {
857+ Registry : pulumix .Val (configuration .Registry ),
858+ Repository : pulumix .Val (configuration .Repository ),
859+ Tag : pulumix .Val (tag ),
860+ }
861+ }
0 commit comments