-
Notifications
You must be signed in to change notification settings - Fork 135
feat: Add configuration for image registries #1166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/v2.3
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,16 @@ import ( | |||||||||||||||||||||||||
| "encoding/json" | ||||||||||||||||||||||||||
| "errors" | ||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||
| "reflect" | ||||||||||||||||||||||||||
| "time" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| "github.com/formancehq/ledger/deployments/pulumi/pkg/utils" | ||||||||||||||||||||||||||
| "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rds" | ||||||||||||||||||||||||||
| "github.com/pulumi/pulumi/sdk/v3/go/pulumi" | ||||||||||||||||||||||||||
| "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" | ||||||||||||||||||||||||||
| "github.com/pulumi/pulumi/sdk/v3/go/pulumix" | ||||||||||||||||||||||||||
| "gopkg.in/yaml.v3" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| . "github.com/formancehq/go-libs/v3/collectionutils" | ||||||||||||||||||||||||||
| pulumi_ledger "github.com/formancehq/ledger/deployments/pulumi/pkg" | ||||||||||||||||||||||||||
| "github.com/formancehq/ledger/deployments/pulumi/pkg/api" | ||||||||||||||||||||||||||
|
|
@@ -14,13 +24,6 @@ import ( | |||||||||||||||||||||||||
| "github.com/formancehq/ledger/deployments/pulumi/pkg/provision" | ||||||||||||||||||||||||||
| "github.com/formancehq/ledger/deployments/pulumi/pkg/storage" | ||||||||||||||||||||||||||
| "github.com/formancehq/ledger/deployments/pulumi/pkg/worker" | ||||||||||||||||||||||||||
| "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rds" | ||||||||||||||||||||||||||
| "github.com/pulumi/pulumi/sdk/v3/go/pulumi" | ||||||||||||||||||||||||||
| "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" | ||||||||||||||||||||||||||
| "github.com/pulumi/pulumi/sdk/v3/go/pulumix" | ||||||||||||||||||||||||||
| "gopkg.in/yaml.v3" | ||||||||||||||||||||||||||
| "reflect" | ||||||||||||||||||||||||||
| "time" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| type Ingress struct { | ||||||||||||||||||||||||||
|
|
@@ -183,8 +186,8 @@ func (a *PostgresDatabase) toInput() *storage.PostgresDatabaseArgs { | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return &storage.PostgresDatabaseArgs{ | ||||||||||||||||||||||||||
| Install: &storage.PostgresInstallArgs{ | ||||||||||||||||||||||||||
| Username: pulumix.Val(a.Install.Username), | ||||||||||||||||||||||||||
| Password: pulumix.Val(a.Install.Password), | ||||||||||||||||||||||||||
| Username: pulumix.Val(a.Install.Username), | ||||||||||||||||||||||||||
| Password: pulumix.Val(a.Install.Password), | ||||||||||||||||||||||||||
| ChartVersion: pulumix.Val(a.Install.ChartVersion), | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
@@ -572,8 +575,12 @@ type Common struct { | |||||||||||||||||||||||||
| Monitoring *Monitoring `json:"monitoring,omitempty" yaml:"monitoring,omitempty"` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Tag is the version tag for the ledger | ||||||||||||||||||||||||||
| // deprecated | ||||||||||||||||||||||||||
| Tag string `json:"version,omitempty" yaml:"version,omitempty"` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Image configuration | ||||||||||||||||||||||||||
| Image *ImageConfiguration `json:"image"` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // ImagePullPolicy is the image pull policy for the ledger | ||||||||||||||||||||||||||
| ImagePullPolicy string `json:"image-pull-policy,omitempty" yaml:"image-pull-policy,omitempty"` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -583,11 +590,11 @@ type Common struct { | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| func (c Common) toInput() common.CommonArgs { | ||||||||||||||||||||||||||
| return common.CommonArgs{ | ||||||||||||||||||||||||||
| Namespace: pulumix.Val(c.Namespace), | ||||||||||||||||||||||||||
| Monitoring: c.Monitoring.ToInput(), | ||||||||||||||||||||||||||
| Tag: pulumix.Val(c.Tag), | ||||||||||||||||||||||||||
| ImagePullPolicy: pulumix.Val(c.ImagePullPolicy), | ||||||||||||||||||||||||||
| Debug: pulumix.Val(c.Debug), | ||||||||||||||||||||||||||
| Namespace: pulumix.Val(c.Namespace), | ||||||||||||||||||||||||||
| Monitoring: c.Monitoring.ToInput(), | ||||||||||||||||||||||||||
| ImageConfiguration: imageConfigurationOrTag(c.Image, c.Tag), | ||||||||||||||||||||||||||
| ImagePullPolicy: pulumix.Val(c.ImagePullPolicy), | ||||||||||||||||||||||||||
| Debug: pulumix.Val(c.Debug), | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -662,6 +669,7 @@ func (g GeneratorLedgerConfiguration) toInput() generator.LedgerConfiguration { | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| type Generator struct { | ||||||||||||||||||||||||||
| // GeneratorVersion is the version of the generator | ||||||||||||||||||||||||||
| // deprecated | ||||||||||||||||||||||||||
| GeneratorVersion string `json:"generator-version" yaml:"generator-version"` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Ledgers are the ledgers to run the generator against | ||||||||||||||||||||||||||
|
|
@@ -725,6 +733,12 @@ func (cfg Config) ToInput() pulumi_ledger.ComponentArgs { | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| type ImageConfiguration struct { | ||||||||||||||||||||||||||
| Registry string `json:"registry" yaml:"registry"` | ||||||||||||||||||||||||||
| Repository string `json:"repository" yaml:"repository"` | ||||||||||||||||||||||||||
| Tag string `json:"version" yaml:"version"` | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| func Load(ctx *pulumi.Context) (*Config, error) { | ||||||||||||||||||||||||||
| cfg := config.New(ctx, "") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -795,6 +809,13 @@ func Load(ctx *pulumi.Context) (*Config, error) { | |||||||||||||||||||||||||
| generator = nil | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| image := &ImageConfiguration{} | ||||||||||||||||||||||||||
| if err := cfg.TryObject("image", image); err != nil { | ||||||||||||||||||||||||||
| if !errors.Is(err, config.ErrMissingVar) { | ||||||||||||||||||||||||||
| return nil, fmt.Errorf("error reading generator config: %w", err) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+812
to
+817
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix incorrect error message - copy-paste error. The error message references "generator config" but should reference "image config". image := &ImageConfiguration{}
if err := cfg.TryObject("image", image); err != nil {
if !errors.Is(err, config.ErrMissingVar) {
- return nil, fmt.Errorf("error reading generator config: %w", err)
+ return nil, fmt.Errorf("error reading image config: %w", err)
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| namespace := cfg.Get("namespace") | ||||||||||||||||||||||||||
| if namespace == "" { | ||||||||||||||||||||||||||
| namespace = ctx.Stack() | ||||||||||||||||||||||||||
|
|
@@ -807,6 +828,7 @@ func Load(ctx *pulumi.Context) (*Config, error) { | |||||||||||||||||||||||||
| Namespace: namespace, | ||||||||||||||||||||||||||
| Tag: cfg.Get("version"), | ||||||||||||||||||||||||||
| Monitoring: monitoring, | ||||||||||||||||||||||||||
| Image: image, | ||||||||||||||||||||||||||
| ImagePullPolicy: cfg.Get("image-pull-policy"), | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| InstallDevBox: cfg.GetBool("install-dev-box"), | ||||||||||||||||||||||||||
|
|
@@ -819,3 +841,21 @@ func Load(ctx *pulumi.Context) (*Config, error) { | |||||||||||||||||||||||||
| Generator: generator, | ||||||||||||||||||||||||||
| }, nil | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| func imageConfigurationOrTag(configuration *ImageConfiguration, tag string) utils.ImageConfiguration { | ||||||||||||||||||||||||||
| if configuration == nil { | ||||||||||||||||||||||||||
| return utils.ImageConfiguration{ | ||||||||||||||||||||||||||
| Tag: pulumix.Val(tag), | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if configuration.Tag != "" { | ||||||||||||||||||||||||||
| tag = configuration.Tag | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return utils.ImageConfiguration{ | ||||||||||||||||||||||||||
| Registry: pulumix.Val(configuration.Registry), | ||||||||||||||||||||||||||
| Repository: pulumix.Val(configuration.Repository), | ||||||||||||||||||||||||||
| Tag: pulumix.Val(tag), | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message incorrectly states "error reading generator config" when actually reading image configuration. This will mislead debugging efforts.
Fix:
Spotted by Graphite Agent

Is this helpful? React 👍 or 👎 to let us know.