Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(action): allow empty target-stage to create an empty rollout (#16657)
p0nyc7530b259646
diff --git a/action/main.go b/action/main.goindex d7415f6e11..74debd2982 100644--- a/action/main.go+++ b/action/main.go@@ -148,10 +148,6 @@ func validateCheckFlags(*cobra.Command, []string) error {}func validateRolloutFlags(*cobra.Command, []string) error {- if Config.TargetStage == "" {- return errors.Errorf("target-stage is required and cannot be empty")- }-switch Config.CheckPlan {case "SKIP", "FAIL_ON_WARNING", "FAIL_ON_ERROR":default:@@ -415,19 +411,6 @@ func runAndWaitForRollout(ctx context.Context, client *Client, planName string)pendingStages = append(pendingStages, stage.Environment)}- var stages []string- var targetStageFound bool- for _, stage := range rolloutPreview.GetStages() {- stages = append(stages, stage.Environment)- if stage.Environment == Config.TargetStage {- targetStageFound = true- }- }- if !targetStageFound {- slog.Info("the target stage is not found in the rollout preview. exiting...", "targetStage", Config.TargetStage, "rolloutStages", stages, "hint", "make sure your target-stage input exists in the rollout stages")- return nil- }-// create rollout with no stages to obtain the rollout nameemptyTarget := ""rolloutEmpty, err := client.createRollout(&v1pb.CreateRolloutRequest{@@ -450,11 +433,10 @@ func runAndWaitForRollout(ctx context.Context, client *Client, planName string)}func waitForRollout(ctx context.Context, client *Client, pendingStages []string, rolloutName string) error {- if len(pendingStages) == 0 {+ if Config.TargetStage == "" {+ slog.Info("target stage is not specified, exiting...")return nil}- slog.Info("exit after the target stage is completed", "targetStage", Config.TargetStage)- slog.Info("the rollout has the following pending stages", "stageCount", len(pendingStages), "stages", pendingStages)defer func() {if ctx.Err() == nil {@@ -495,12 +477,43 @@ func waitForRollout(ctx context.Context, client *Client, pendingStages []string,if err != nil {return errors.Wrapf(err, "failed to get rollout")}++ slog.Info("exit after the target stage is completed", "targetStage", Config.TargetStage)+ slog.Info("the rollout has the following stages",+ "createdStages", slices.Collect(func(yield func(string) bool) {+ for _, stage := range rollout.GetStages() {+ if !yield(stage.Environment) {+ return+ }+ }+ }),+ "pendingStages", pendingStages)++ targetStageFound := false+ for _, stage := range rollout.GetStages() {+ if stage.Environment == Config.TargetStage {+ targetStageFound = true+ break+ }+ }+ for _, stage := range pendingStages {+ if stage == Config.TargetStage {+ targetStageFound = true+ break+ }+ }+ if !targetStageFound {+ slog.Info("the target stage is not found in the rollout. exiting...", "targetStage", Config.TargetStage)+ return nil+ }+// To make it more robust,// - remove pending stage that already in the rollout stage and call CreateRollout with latest rollout stage once so no new tasks will be missedif len(rollout.Stages) > 0 {latestStage := rollout.Stages[len(rollout.Stages)-1].Environmentindex := slices.Index(pendingStages, latestStage)if index != -1 {+ slog.Info("removing pending stage that already in the rollout stage", "latestStage", latestStage)pendingStages = pendingStages[index+1:]_, err := client.createRollout(&v1pb.CreateRolloutRequest{Parent: Config.Project,