-
Notifications
You must be signed in to change notification settings - Fork 188
fix(app/sandbox): fix marketplace install and billing profile provisioning #4505
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
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,11 +4,14 @@ import ( | |
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/samber/lo" | ||
|
|
||
| "github.com/openmeterio/openmeter/openmeter/app" | ||
| "github.com/openmeterio/openmeter/openmeter/billing" | ||
| "github.com/openmeterio/openmeter/openmeter/customer" | ||
| customerapp "github.com/openmeterio/openmeter/openmeter/customer/app" | ||
| "github.com/openmeterio/openmeter/pkg/clock" | ||
| "github.com/openmeterio/openmeter/pkg/models" | ||
| ) | ||
|
|
||
| const ( | ||
|
|
@@ -214,12 +217,25 @@ func (a *Factory) NewApp(_ context.Context, appBase app.AppBase) (app.App, error | |
| }, nil | ||
| } | ||
|
|
||
| func (a *Factory) InstallAppWithAPIKey(ctx context.Context, input app.AppFactoryInstallAppWithAPIKeyInput) (app.App, error) { | ||
| // Validate input | ||
| func (a *Factory) InstallApp(ctx context.Context, input app.AppFactoryInstallAppInput) (app.App, error) { | ||
| if err := input.Validate(); err != nil { | ||
| return nil, fmt.Errorf("invalid input: %w", err) | ||
| } | ||
|
|
||
| // Sandbox is a singleton per namespace — only one instance makes sense since all | ||
| // instances are functionally identical (no credentials, no external state). | ||
| existing, err := a.appService.ListApps(ctx, app.ListAppInput{ | ||
| Namespace: input.Namespace, | ||
| Type: lo.ToPtr(app.AppTypeSandbox), | ||
| }) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to list sandbox apps: %w", err) | ||
| } | ||
|
|
||
| if existing.TotalCount > 0 { | ||
| return nil, models.NewGenericConflictError(fmt.Errorf("sandbox app: %s already exists", existing.Items[0].GetName())) | ||
| } | ||
|
Comment on lines
+225
to
+237
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.
The list-then-create pattern is not atomic: two concurrent |
||
|
|
||
| appBase, err := a.appService.CreateApp(ctx, app.CreateAppInput{ | ||
| Namespace: input.Namespace, | ||
| Name: input.Name, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.