|
|
|
|
@ -15,6 +15,7 @@ import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
tfe "github.com/hashicorp/go-tfe"
|
|
|
|
|
version "github.com/hashicorp/go-version"
|
|
|
|
|
"github.com/hashicorp/terraform/backend"
|
|
|
|
|
"github.com/hashicorp/terraform/tfdiags"
|
|
|
|
|
)
|
|
|
|
|
@ -98,6 +99,26 @@ func (b *Remote) opPlan(stopCtx, cancelCtx context.Context, op *backend.Operatio
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(op.Targets) != 0 {
|
|
|
|
|
// For API versions prior to 2.3, RemoteAPIVersion will return an empty string,
|
|
|
|
|
// so if there's an error when parsing the RemoteAPIVersion, it's handled as
|
|
|
|
|
// equivalent to an API version < 2.3.
|
|
|
|
|
currentAPIVersion, parseErr := version.NewVersion(b.client.RemoteAPIVersion())
|
|
|
|
|
desiredAPIVersion, _ := version.NewVersion("2.3")
|
|
|
|
|
|
|
|
|
|
if parseErr != nil || currentAPIVersion.LessThan(desiredAPIVersion) {
|
|
|
|
|
diags = diags.Append(tfdiags.Sourceless(
|
|
|
|
|
tfdiags.Error,
|
|
|
|
|
"Resource targeting is not supported",
|
|
|
|
|
fmt.Sprintf(
|
|
|
|
|
`The host %s does not support the -target option for `+
|
|
|
|
|
`remote plans.`,
|
|
|
|
|
b.hostname,
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return if there are any errors.
|
|
|
|
|
if diags.HasErrors() {
|
|
|
|
|
return nil, diags.Err()
|
|
|
|
|
|