Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor(action): structured output map (#17355)

p0ny0c58a68cdeeb
diff --git a/action/command/rollout.go b/action/command/rollout.go
index fef01df076..97e438288b 100644
--- a/action/command/rollout.go
+++ b/action/command/rollout.go
@@ -105,7 +105,7 @@ func runRollout(w *world.World) func(command *cobra.Command, _ []string) error {
w.Logger.Info("release created", "url", fmt.Sprintf("%s/%s", client.url, createReleaseResponse.Name))
release = createReleaseResponse.Name
}
- w.OutputMap["release"] = release
+ w.OutputMap.Release = release
planCreated, err := client.CreatePlan(ctx, w.Project, &v1pb.Plan{
Title: "Release " + w.ReleaseTitle,
@@ -127,7 +127,7 @@ func runRollout(w *world.World) func(command *cobra.Command, _ []string) error {
plan = planCreated
w.Logger.Info("plan created", "url", fmt.Sprintf("%s/%s", client.url, plan.Name))
}
- w.OutputMap["plan"] = plan.Name
+ w.OutputMap.Plan = plan.Name
if err := runAndWaitForPlanChecks(ctx, w, client, plan.Name); err != nil {
return errors.Wrapf(err, "failed to run and wait for plan checks")
@@ -242,7 +242,7 @@ func runAndWaitForRollout(ctx context.Context, w *world.World, client *Client, p
if err != nil {
return errors.Wrapf(err, "failed to preview rollout")
}
- w.OutputMap["rollout"] = rolloutEmpty.Name
+ w.OutputMap.Rollout = rolloutEmpty.Name
w.Logger.Info("rollout created", "url", fmt.Sprintf("%s/%s", client.url, rolloutEmpty.Name))
diff --git a/action/world/world.go b/action/world/world.go
index 7c25070965..840f373d15 100644
--- a/action/world/world.go
+++ b/action/world/world.go
@@ -46,13 +46,16 @@ type World struct {
TargetStage string
Plan string
- OutputMap map[string]string
+ OutputMap struct {
+ Release string `json:"release,omitempty"`
+ Plan string `json:"plan,omitempty"`
+ Rollout string `json:"rollout,omitempty"`
+ }
}
func NewWorld() *World {
return &World{
CurrentTime: time.Now(),
Logger: slog.Default(),
- OutputMap: make(map[string]string),
}
}
diff --git a/backend/tests/action_test.go b/backend/tests/action_test.go
index fd699c17e4..e19ba7dea5 100644
--- a/backend/tests/action_test.go
+++ b/backend/tests/action_test.go
@@ -503,8 +503,10 @@ func executeActionCommand(ctx context.Context, args ...string) (*ActionResult, e
// Get output from world.OutputMap
outputJSON := make(map[string]any)
- for k, v := range w.OutputMap {
- outputJSON[k] = v
+ if j, err := json.Marshal(w.OutputMap); err == nil {
+ if err := json.Unmarshal(j, &outputJSON); err != nil {
+ return nil, err
+ }
}
// Also parse output file if specified