Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(action): structured output map (#17355)
p0ny0c58a68cdeeb
diff --git a/action/command/rollout.go b/action/command/rollout.goindex 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 = releaseplanCreated, 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 = planCreatedw.Logger.Info("plan created", "url", fmt.Sprintf("%s/%s", client.url, plan.Name))}- w.OutputMap["plan"] = plan.Name+ w.OutputMap.Plan = plan.Nameif 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, pif err != nil {return errors.Wrapf(err, "failed to preview rollout")}- w.OutputMap["rollout"] = rolloutEmpty.Name+ w.OutputMap.Rollout = rolloutEmpty.Namew.Logger.Info("rollout created", "url", fmt.Sprintf("%s/%s", client.url, rolloutEmpty.Name))diff --git a/action/world/world.go b/action/world/world.goindex 7c25070965..840f373d15 100644--- a/action/world/world.go+++ b/action/world/world.go@@ -46,13 +46,16 @@ type World struct {TargetStage stringPlan 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.goindex 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.OutputMapoutputJSON := 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