diff --git a/pkg/app/pipectl/client/application.go b/pkg/app/pipectl/client/application.go index 6d7e2ec3ae..4d985c9c0a 100644 --- a/pkg/app/pipectl/client/application.go +++ b/pkg/app/pipectl/client/application.go @@ -51,8 +51,6 @@ func SyncApplication( defer ticker.Stop() check := func() (deploymentID string, shouldRetry bool) { - const triggeredDeploymentIDKey = "TriggeredDeploymentID" - cmd, err := getCommand(ctx, cli, resp.CommandId) if err != nil { logger.Error(fmt.Sprintf("Failed while retrieving command information. Try again. (%v)", err)) @@ -67,7 +65,7 @@ func SyncApplication( switch cmd.Status { case model.CommandStatus_COMMAND_SUCCEEDED: - deploymentID = cmd.Metadata[triggeredDeploymentIDKey] + deploymentID = cmd.Metadata[model.MetadataKeyTriggeredDeploymentID] return case model.CommandStatus_COMMAND_FAILED: diff --git a/pkg/app/piped/trigger/trigger.go b/pkg/app/piped/trigger/trigger.go index a9ce25ef1c..01fee3f6b2 100644 --- a/pkg/app/piped/trigger/trigger.go +++ b/pkg/app/piped/trigger/trigger.go @@ -37,7 +37,6 @@ import ( const ( ondemandCheckInterval = 10 * time.Second defaultLastTriggeredCommitCacheSize = 500 - triggeredDeploymentIDKey = "TriggeredDeploymentID" ) type apiClient interface { @@ -286,7 +285,7 @@ func (t *Trigger) checkRepoCandidates(ctx context.Context, repoID string, cs []c // Mask command as handled since the deployment has been triggered successfully. if c.kind == model.TriggerKind_ON_COMMAND { metadata := map[string]string{ - triggeredDeploymentIDKey: deployment.Id, + model.MetadataKeyTriggeredDeploymentID: deployment.Id, } if err := c.command.Report(ctx, model.CommandStatus_COMMAND_SUCCEEDED, metadata, nil); err != nil { t.logger.Error("failed to report command status", zap.Error(err)) diff --git a/pkg/model/command.go b/pkg/model/command.go index c8c1a8921a..c1b81d2bba 100644 --- a/pkg/model/command.go +++ b/pkg/model/command.go @@ -16,6 +16,10 @@ package model import "context" +const ( + MetadataKeyTriggeredDeploymentID = "TriggeredDeploymentID" +) + type ReportableCommand struct { *Command Report func(ctx context.Context, status CommandStatus, metadata map[string]string, output []byte) error