@@ -3,6 +3,8 @@ package config
33import (
44 "errors"
55 "fmt"
6+ "time"
7+
68 . "github.com/formancehq/go-libs/v2/collectionutils"
79 pulumi_ledger "github.com/formancehq/ledger/deployments/pulumi/pkg"
810 "github.com/formancehq/ledger/deployments/pulumi/pkg/api"
@@ -11,11 +13,11 @@ import (
1113 "github.com/formancehq/ledger/deployments/pulumi/pkg/monitoring"
1214 "github.com/formancehq/ledger/deployments/pulumi/pkg/provision"
1315 "github.com/formancehq/ledger/deployments/pulumi/pkg/storage"
16+ "github.com/formancehq/ledger/deployments/pulumi/pkg/utils"
1417 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rds"
1518 "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
1619 "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
1720 "github.com/pulumi/pulumi/sdk/v3/go/pulumix"
18- "time"
1921)
2022
2123type Ingress struct {
@@ -181,8 +183,8 @@ func (a *PostgresDatabase) toInput() *storage.PostgresDatabaseArgs {
181183
182184 return & storage.PostgresDatabaseArgs {
183185 Install : & storage.PostgresInstallArgs {
184- Username : pulumix .Val (a .Install .Username ),
185- Password : pulumix .Val (a .Install .Password ),
186+ Username : pulumix .Val (a .Install .Username ),
187+ Password : pulumix .Val (a .Install .Password ),
186188 ChartVersion : pulumix .Val (a .Install .ChartVersion ),
187189 },
188190 }
@@ -460,8 +462,12 @@ type Common struct {
460462 Monitoring * Monitoring `json:"monitoring" yaml:"monitoring"`
461463
462464 // Tag is the version tag for the ledger
465+ // deprecated
463466 Tag string `json:"version" yaml:"version"`
464467
468+ // Image configuration
469+ Image * ImageConfiguration `json:"image"`
470+
465471 // ImagePullPolicy is the image pull policy for the ledger
466472 ImagePullPolicy string `json:"image-pull-policy" yaml:"image-pull-policy"`
467473
@@ -471,11 +477,11 @@ type Common struct {
471477
472478func (c Common ) toInput () common.CommonArgs {
473479 return common.CommonArgs {
474- Namespace : pulumix .Val (c .Namespace ),
475- Monitoring : c .Monitoring .ToInput (),
476- Tag : pulumix . Val ( c .Tag ),
477- ImagePullPolicy : pulumix .Val (c .ImagePullPolicy ),
478- Debug : pulumix .Val (c .Debug ),
480+ Namespace : pulumix .Val (c .Namespace ),
481+ Monitoring : c .Monitoring .ToInput (),
482+ ImageConfiguration : imageConfigurationOrTag ( c . Image , c .Tag ),
483+ ImagePullPolicy : pulumix .Val (c .ImagePullPolicy ),
484+ Debug : pulumix .Val (c .Debug ),
479485 }
480486}
481487
@@ -546,6 +552,7 @@ func (g GeneratorLedgerConfiguration) toInput() generator.LedgerConfiguration {
546552
547553type Generator struct {
548554 // GeneratorVersion is the version of the generator
555+ // deprecated
549556 GeneratorVersion string `json:"generator-version" yaml:"generator-version"`
550557
551558 // Ledgers are the ledgers to run the generator against
@@ -601,6 +608,12 @@ func (cfg Config) ToInput() pulumi_ledger.ComponentArgs {
601608 }
602609}
603610
611+ type ImageConfiguration struct {
612+ Registry string `json:"registry" yaml:"registry"`
613+ Repository string `json:"repository" yaml:"repository"`
614+ Tag string `json:"version" yaml:"version"`
615+ }
616+
604617func Load (ctx * pulumi.Context ) (* Config , error ) {
605618 cfg := config .New (ctx , "" )
606619
@@ -657,6 +670,13 @@ func Load(ctx *pulumi.Context) (*Config, error) {
657670 generator = nil
658671 }
659672
673+ image := & ImageConfiguration {}
674+ if err := cfg .TryObject ("image" , image ); err != nil {
675+ if ! errors .Is (err , config .ErrMissingVar ) {
676+ return nil , fmt .Errorf ("error reading generator config: %w" , err )
677+ }
678+ }
679+
660680 namespace := cfg .Get ("namespace" )
661681 if namespace == "" {
662682 namespace = ctx .Stack ()
@@ -669,6 +689,7 @@ func Load(ctx *pulumi.Context) (*Config, error) {
669689 Namespace : namespace ,
670690 Tag : cfg .Get ("version" ),
671691 Monitoring : monitoring ,
692+ Image : image ,
672693 ImagePullPolicy : cfg .Get ("image-pull-policy" ),
673694 },
674695 InstallDevBox : cfg .GetBool ("install-dev-box" ),
@@ -679,3 +700,21 @@ func Load(ctx *pulumi.Context) (*Config, error) {
679700 Generator : generator ,
680701 }, nil
681702}
703+
704+ func imageConfigurationOrTag (configuration * ImageConfiguration , tag string ) utils.ImageConfiguration {
705+ if configuration == nil {
706+ return utils.ImageConfiguration {
707+ Tag : pulumix .Val (tag ),
708+ }
709+ }
710+
711+ if configuration .Tag != "" {
712+ tag = configuration .Tag
713+ }
714+
715+ return utils.ImageConfiguration {
716+ Registry : pulumix .Val (configuration .Registry ),
717+ Repository : pulumix .Val (configuration .Repository ),
718+ Tag : pulumix .Val (tag ),
719+ }
720+ }
0 commit comments