backend/remote: validate API version for refresh and replace
This commit is contained in:
parent
16bc8f6442
commit
eb1f113693
|
@ -108,6 +108,38 @@ func (b *Remote) opApply(stopCtx, cancelCtx context.Context, op *backend.Operati
|
|||
}
|
||||
}
|
||||
|
||||
if op.PlanMode == plans.RefreshOnlyMode {
|
||||
desiredAPIVersion, _ := version.NewVersion("2.4")
|
||||
|
||||
if parseErr != nil || currentAPIVersion.LessThan(desiredAPIVersion) {
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
"Refresh-only mode is not supported",
|
||||
fmt.Sprintf(
|
||||
`The host %s does not support -refresh-only mode for `+
|
||||
`remote plans.`,
|
||||
b.hostname,
|
||||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
if len(op.ForceReplace) != 0 {
|
||||
desiredAPIVersion, _ := version.NewVersion("2.4")
|
||||
|
||||
if parseErr != nil || currentAPIVersion.LessThan(desiredAPIVersion) {
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
"Planning resource replacements is not supported",
|
||||
fmt.Sprintf(
|
||||
`The host %s does not support the -replace option for `+
|
||||
`remote plans.`,
|
||||
b.hostname,
|
||||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
if len(op.Targets) != 0 {
|
||||
desiredAPIVersion, _ := version.NewVersion("2.3")
|
||||
|
||||
|
|
|
@ -146,6 +146,22 @@ func (b *Remote) opPlan(stopCtx, cancelCtx context.Context, op *backend.Operatio
|
|||
}
|
||||
}
|
||||
|
||||
if op.PlanMode == plans.RefreshOnlyMode {
|
||||
desiredAPIVersion, _ := version.NewVersion("2.4")
|
||||
|
||||
if parseErr != nil || currentAPIVersion.LessThan(desiredAPIVersion) {
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
"Refresh-only mode is not supported",
|
||||
fmt.Sprintf(
|
||||
`The host %s does not support -refresh-only mode for `+
|
||||
`remote plans.`,
|
||||
b.hostname,
|
||||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
// Return if there are any errors.
|
||||
if diags.HasErrors() {
|
||||
return nil, diags.Err()
|
||||
|
|
Loading…
Reference in New Issue