diff --git a/backend/remote/backend_mock.go b/backend/remote/backend_mock.go index 0a57801e8..a856b0612 100644 --- a/backend/remote/backend_mock.go +++ b/backend/remote/backend_mock.go @@ -760,6 +760,10 @@ func (m *mockRuns) Create(ctx context.Context, options tfe.RunCreateOptions) (*t TargetAddrs: options.TargetAddrs, } + if options.Message != nil { + r.Message = *options.Message + } + if pc != nil { r.PolicyChecks = []*tfe.PolicyCheck{pc} } diff --git a/backend/remote/backend_plan.go b/backend/remote/backend_plan.go index 8b37f62e1..957b28aea 100644 --- a/backend/remote/backend_plan.go +++ b/backend/remote/backend_plan.go @@ -209,9 +209,14 @@ in order to capture the filesystem context the remote workspace expects: "Failed to upload configuration files", errors.New("operation timed out")) } + queueMessage := "Queued manually using Terraform" + if op.Targets != nil { + queueMessage = "Queued manually via Terraform using -target" + } + runOptions := tfe.RunCreateOptions{ IsDestroy: tfe.Bool(op.Destroy), - Message: tfe.String("Queued manually using Terraform"), + Message: tfe.String(queueMessage), ConfigurationVersion: cv, Workspace: w, } diff --git a/backend/remote/backend_plan_test.go b/backend/remote/backend_plan_test.go index 7ea84694b..89cdc1ff1 100644 --- a/backend/remote/backend_plan_test.go +++ b/backend/remote/backend_plan_test.go @@ -301,6 +301,10 @@ func TestRemote_planWithTarget(t *testing.T) { if diff := cmp.Diff([]string{"null_resource.foo"}, run.TargetAddrs); diff != "" { t.Errorf("wrong TargetAddrs in the created run\n%s", diff) } + + if !strings.Contains(run.Message, "using -target") { + t.Fatalf("incorrrect Message on the created run: %s", run.Message) + } } }