Skip to content

Commit ee50f0e

Browse files
Michael NomitchMichael Nomitch
authored andcommitted
Change message sent to remote backend if -target used
1 parent e61f108 commit ee50f0e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

backend/remote/backend_mock.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ func (m *mockRuns) Create(ctx context.Context, options tfe.RunCreateOptions) (*t
758758
Plan: p,
759759
Status: tfe.RunPending,
760760
TargetAddrs: options.TargetAddrs,
761+
Message: *options.Message,
761762
}
762763

763764
if pc != nil {

backend/remote/backend_plan.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,14 @@ in order to capture the filesystem context the remote workspace expects:
209209
"Failed to upload configuration files", errors.New("operation timed out"))
210210
}
211211

212+
queueMessage := "Queued manually using Terraform"
213+
if op.Targets != nil {
214+
queueMessage = "Queued manually via Terraform using -target"
215+
}
216+
212217
runOptions := tfe.RunCreateOptions{
213218
IsDestroy: tfe.Bool(op.Destroy),
214-
Message: tfe.String("Queued manually using Terraform"),
219+
Message: tfe.String(queueMessage),
215220
ConfigurationVersion: cv,
216221
Workspace: w,
217222
}

backend/remote/backend_plan_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ func TestRemote_planWithTarget(t *testing.T) {
301301
if diff := cmp.Diff([]string{"null_resource.foo"}, run.TargetAddrs); diff != "" {
302302
t.Errorf("wrong TargetAddrs in the created run\n%s", diff)
303303
}
304+
305+
if !strings.Contains(run.Message, "using -target") {
306+
t.Fatalf("incorrrect Message on the created run: %s", run.Message)
307+
}
304308
}
305309
}
306310

0 commit comments

Comments
 (0)