-
Notifications
You must be signed in to change notification settings - Fork 114
feat(tools): add pulumi app to start a complete testing platform #683
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
Conversation
gfyrag
commented
Feb 13, 2025
- wip
- feat: add k8s-stack pulumi app
WalkthroughThe pull request updates the Kubernetes stack tools by adding new Pulumi-based infrastructure components and modifying configuration management. A new ignore rule in the Changes
Sequence Diagram(s)sequenceDiagram
participant Main as main.go
participant Pulumi as Pulumi Engine
participant Stack as StackComponent (NewStack)
participant PG as PostgresComponent (NewPostgresComponent)
Main ->> Pulumi: Execute Pulumi program
Pulumi ->> Main: Invoke main()
Main ->> Main: Retrieve configuration & optional telemetry setup
Main ->> Stack: Call NewStack with stack configuration
Stack ->> Stack: Generate/validate Kubernetes namespace
Stack ->> PG: Call NewPostgresComponent with namespace details
PG -->> Stack: Return Postgres outputs (username, password, etc.)
Stack -->> Main: Return deployed stack outputs (including ledger URL)
Main ->> Pulumi: Export outputs for the infrastructure stack
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
89c7458
to
febd1c0
Compare
febd1c0
to
84b3451
Compare
84b3451
to
c8583ff
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #683 +/- ##
==========================================
- Coverage 81.63% 81.57% -0.06%
==========================================
Files 131 131
Lines 7061 7071 +10
==========================================
+ Hits 5764 5768 +4
- Misses 994 998 +4
- Partials 303 305 +2 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tools/k8s-stack/pkg/postgres.go (1)
30-31
: Avoid storing credentials in plain textHardcoding database credentials can pose security risks. Consider using Pulumi config secrets, environment variables, or a credentials management approach for better security and maintainability.
tools/k8s-stack/main.go (1)
73-74
: Handle parse errors for durations
time.ParseDuration
silently defaults to zero on invalid inputs. Consider handlingerr
or logging warnings to avoid unexpected behavior or silently misconfiguring time-based settings.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
tools/k8s-stack/Pulumi.yaml
is excluded by!**/*.yaml
tools/k8s-stack/go.mod
is excluded by!**/*.mod
tools/k8s-stack/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (4)
tools/k8s-stack/.gitignore
(1 hunks)tools/k8s-stack/main.go
(1 hunks)tools/k8s-stack/pkg/postgres.go
(1 hunks)tools/k8s-stack/pkg/stack.go
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- tools/k8s-stack/.gitignore
🧰 Additional context used
🪛 golangci-lint (1.62.2)
tools/k8s-stack/pkg/stack.go
75-75: ineffectual assignment to err
(ineffassign)
cmp.Ledger, err = pulumi_ledger.NewComponent(ctx, "ledger", &pulumi_ledger.ComponentArgs{ | ||
Timeout: pulumi.Int(30), | ||
Debug: args.Debug, | ||
Tag: args.Ledger.Version, | ||
ImagePullPolicy: pulumi.String("Always"), | ||
Postgres: pulumi_ledger.PostgresArgs{ | ||
URI: pulumi.Sprintf( | ||
"postgres://%s:%s@%s:%d/postgres?sslmode=disable", | ||
cmp.Postgres.Username, | ||
cmp.Postgres.Password, | ||
cmp.Postgres.Host, | ||
cmp.Postgres.Port, | ||
), | ||
MaxIdleConns: pulumix.Val(pointer.For(100)), | ||
MaxOpenConns: pulumix.Val(pointer.For(100)), | ||
ConnMaxIdleTime: pulumix.Val(pointer.For(time.Minute)), | ||
}, | ||
ExperimentalFeatures: pulumi.Bool(true), | ||
Namespace: pulumix.Apply(namespace.Metadata.Name().ToOutput(ctx.Context()).Untyped().(pulumi.StringPtrOutput), func(ns *string) string { | ||
return *ns | ||
}), | ||
GracePeriod: args.Ledger.GracePeriod, | ||
Upgrade: args.Ledger.Upgrade, | ||
Otel: args.Ledger.Otel, | ||
}, | ||
append(resourceOptions, pulumi.DependsOn([]pulumi.Resource{ | ||
cmp.Postgres, | ||
}))..., | ||
) | ||
|
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.
Handle overshadowed error after Ledger creation
The err
assigned by pulumi_ledger.NewComponent
is never checked because at line 105 you're introducing a new err
variable in the if err := ...
block, overshadowing the previous one. This can silently ignore critical errors if the ledger creation fails.
Consider applying this fix to properly handle errors:
cmp.Ledger, err = pulumi_ledger.NewComponent(ctx, "ledger", &pulumi_ledger.ComponentArgs{
// existing ledger args...
})
+if err != nil {
+ return nil, fmt.Errorf("creating ledger component: %w", err)
+}
if err := ctx.RegisterResourceOutputs(cmp, pulumi.Map{}); err != nil {
return nil, fmt.Errorf("registering outputs: %w", err)
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
cmp.Ledger, err = pulumi_ledger.NewComponent(ctx, "ledger", &pulumi_ledger.ComponentArgs{ | |
Timeout: pulumi.Int(30), | |
Debug: args.Debug, | |
Tag: args.Ledger.Version, | |
ImagePullPolicy: pulumi.String("Always"), | |
Postgres: pulumi_ledger.PostgresArgs{ | |
URI: pulumi.Sprintf( | |
"postgres://%s:%s@%s:%d/postgres?sslmode=disable", | |
cmp.Postgres.Username, | |
cmp.Postgres.Password, | |
cmp.Postgres.Host, | |
cmp.Postgres.Port, | |
), | |
MaxIdleConns: pulumix.Val(pointer.For(100)), | |
MaxOpenConns: pulumix.Val(pointer.For(100)), | |
ConnMaxIdleTime: pulumix.Val(pointer.For(time.Minute)), | |
}, | |
ExperimentalFeatures: pulumi.Bool(true), | |
Namespace: pulumix.Apply(namespace.Metadata.Name().ToOutput(ctx.Context()).Untyped().(pulumi.StringPtrOutput), func(ns *string) string { | |
return *ns | |
}), | |
GracePeriod: args.Ledger.GracePeriod, | |
Upgrade: args.Ledger.Upgrade, | |
Otel: args.Ledger.Otel, | |
}, | |
append(resourceOptions, pulumi.DependsOn([]pulumi.Resource{ | |
cmp.Postgres, | |
}))..., | |
) | |
cmp.Ledger, err = pulumi_ledger.NewComponent(ctx, "ledger", &pulumi_ledger.ComponentArgs{ | |
Timeout: pulumi.Int(30), | |
Debug: args.Debug, | |
Tag: args.Ledger.Version, | |
ImagePullPolicy: pulumi.String("Always"), | |
Postgres: pulumi_ledger.PostgresArgs{ | |
URI: pulumi.Sprintf( | |
"postgres://%s:%s@%s:%d/postgres?sslmode=disable", | |
cmp.Postgres.Username, | |
cmp.Postgres.Password, | |
cmp.Postgres.Host, | |
cmp.Postgres.Port, | |
), | |
MaxIdleConns: pulumix.Val(pointer.For(100)), | |
MaxOpenConns: pulumix.Val(pointer.For(100)), | |
ConnMaxIdleTime: pulumix.Val(pointer.For(time.Minute)), | |
}, | |
ExperimentalFeatures: pulumi.Bool(true), | |
Namespace: pulumix.Apply(namespace.Metadata.Name().ToOutput(ctx.Context()).Untyped().(pulumi.StringPtrOutput), func(ns *string) string { | |
return *ns | |
}), | |
GracePeriod: args.Ledger.GracePeriod, | |
Upgrade: args.Ledger.Upgrade, | |
Otel: args.Ledger.Otel, | |
}, | |
append(resourceOptions, pulumi.DependsOn([]pulumi.Resource{ | |
cmp.Postgres, | |
}))..., | |
) | |
if err != nil { | |
return nil, fmt.Errorf("creating ledger component: %w", err) | |
} | |
if err := ctx.RegisterResourceOutputs(cmp, pulumi.Map{}); err != nil { | |
return nil, fmt.Errorf("registering outputs: %w", err) | |
} |
🧰 Tools
🪛 golangci-lint (1.62.2)
75-75: ineffectual assignment to err
(ineffassign)