Change message sent to remote backend if -target used

This commit is contained in:
Mike Nomitch 2020-05-13 10:05:22 -05:00 committed by Martin Atkins
parent 16f1f3b739
commit 650a272a1d
3 changed files with 14 additions and 1 deletions

View File

@ -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}
}

View File

@ -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,
}

View File

@ -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)
}
}
}