Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Terraform
Commits
0eea4e7c
Commit
0eea4e7c
authored
5 years ago
by
CJ Horton
Browse files
Options
Download
Email Patches
Plain Diff
prevent targeting for unsupported API versions
parent
650a272a
main
0.15.3
26258
MatthewTestBranch
add-cont-valid-callout
add-internals-to-sidebar
add-jsonstate-to-cloudbackendstate
add-jsonstate-to-cloudbackendstate2
add-learn-callout-moved-blocks
add-new-intro-docs
add-note-about-spaces
add-page-metadata
add-tutorial-custom-conditions
add-version-notes-1.2
add-warnings-backends
alisdair/alpine-latest
alisdair/are-consul-tests-running
alisdair/backend-config-override-fix-remote-test
alisdair/concise-diff-experiment
alisdair/disable-preconditions-postconditions
alisdair/duplicate-no-color
alisdair/fix-configload-snapshot-panic
alisdair/fix-remote-backend-migrate-version-check
alisdair/metadata-functions-command
alisdair/mildwonkey/type-func
alisdair/plan-summary-after-changes
alisdair/prototype-moved-actions
alisdair/providers-list
alisdair/remote-input-variable-unset
alisdair/resource-instance-object-dependencies
alisdair/still-applying-consolidation
alisdair/version-should-include-prerelease
b-1.1-module-source-git
b-check-output-multi-expand
b-check-resource-multi-expand
b-dev-overrides-plan-warning
b-diags-sensitive-value
b-flatten-panic
b-miekg-dns-upgrade
b-module-instance-resource-deps
b-move-implied-cross-package
b-tf-builtin-provider-parser-fix
b-type-conversion-funcs-null
b-yamldecode-emptydoc-null
backport/29156_do_not_log_sensitive_values/nearly-safe-bullfrog
backport/4th-alternate-mirror-directory-fix/closely-key-civet
backport/add-cont-valid-callout/luckily-golden-wildcat
backport/add-format-function-guidance/ultimately-lucky-halibut
backport/add-internals-to-sidebar/willingly-bright-sunbird
backport/add-learn-callout-moved-blocks/multiply-awaited-cub
backport/add-new-intro-docs/strangely-lucky-bluegill
backport/add-powershell-warning/certainly-amazing-lemur
backport/add-version-notes-1.2/amazingly-premium-woodcock
backport/add-warnings-backends/physically-many-mantis
backport/alisdair/cty-1.8.3/seriously-tidy-foal
backport/alisdair/fix-30641/firmly-musical-lemming
backport/alisdair/fix-show-plan-against-non-default-state/blatantly-balanced-porpoise
backport/alisdair/fix-stuck-lock-when-applying-state-plan/enormously-refined-sheepdog
backport/alisdair/json-ui-resource-drift/broadly-careful-rooster
backport/alisdair/pre-convert-optional-defaults/virtually-able-mouse
backport/alisdair/redact-sensitive-values-from-function-errors/definitely-assured-mantis
backport/alisdair/sensitive-attribute-forces-replacement/mildly-optimal-platypus
backport/b-check-resource-multi-expand/extremely-key-sheep
backport/backport/cstella84/patch-add-hyperlink-for-referenced-argument/manually-patient-locust
backport/barrettclark/update-go-slug/severely-destined-crow
backport/bugfix_typos/hardly-sharp-mosquito
backport/clarify-backend-state-storage/ultimately-causal-ladybird
backport/consul-size-limit/amazingly-innocent-python
backport/cstella84/patch-add-hyperlink-for-referenced-argument
backport/description-metadata-language-docs/frankly-desired-penguin
backport/doc-provisioner-scp/definitely-capital-bug
backport/doc-refactoring-nav-link/honestly-sweet-sawfly
backport/doc-s3-fix/utterly-close-rabbit
backport/docs-fix-typo/usefully-blessed-monkey
backport/docs-for-each-list-toset/basically-still-zebra
backport/docs/unknwon-value/completely-musical-lionfish
backport/f-build-go1.19.3/largely-peaceful-grouper
backport/f-cty-funcs-marks/poorly-mutual-walleye
backport/f-non-existing-module-instance-crash/neatly-perfect-kiwi
backport/f-plan-action-reason/incredibly-concrete-jackal
backport/f-plan-refresh-only-and-replace/really-absolute-silkworm
backport/file-provisioner-powershell-warning/noticeably-adequate-mullet
backport/fix-apt-page/abnormally-relative-quagga
backport/fix-backends-link/strangely-emerging-crane
backport/fix-backends-link/vertically-noble-hornet
backport/fix-broken-link/certainly-measured-chipmunk
backport/fix-broken-links-1-10/firmly-equal-rabbit
backport/fix-cdktf-link/highly-pumped-snapper
backport/fix-glossary-table-contents/uniquely-pro-garfish
backport/fix-grammar/precisely-polite-tortoise
backport/fix-internals-overview/globally-allowed-kid
backport/fix-internals-overview/noticeably-up-rodent
backport/fix-intro-page-images/constantly-capable-shiner
backport/fix-last-intro-nits/infinitely-workable-redfish
backport/fix-links-devdot/strictly-notable-sparrow
backport/fix-links-release/seemingly-living-dinosaur
backport/fix-remote-backend-references/primarily-tops-mite
backport/fix-workspace-name-docs/ideally-uncommon-pheasant
backport/jbardin/cancel-auto-approve/extremely-brave-bear
backport/jbardin/coerce-value-nested-types/certainly-rested-chigger
backport/jbardin/format-empty-nested-attrs/rightly-uncommon-bluegill
backport/jbardin/format-id-name-marks/perfectly-boss-bass
backport/jbardin/ignore-changes-marks/formerly-new-insect
backport/jbardin/k8s-mod-update/likely-probable-falcon
backport/jbardin/optional-attrs/obviously-growing-duck
backport/jbardin/static-validate-nested-types/possibly-crack-mouse
backport/k8s-backend-credentials/radically-decent-mite
backport/kevin/rewrite-internal-redirects/quietly-helped-pelican
backport/laura-add-mrui-to-sidebar/highly-resolved-blowfish
backport/main/absolutely-sterling-whippet
backport/main/cleanly-mature-scorpion
backport/mg_no_code_prov_followup/marginally-relevant-eagle
backport/mktg-tf-76ef54dc3c574e032725e0341be8e1d2/constantly-smart-kingfish
backport/mktg-tf-76ef54dc3c574e032725e0341be8e1d2/distinctly-sharp-ferret
backport/mktg-tf-76ef54dc3c574e032725e0341be8e1d2/friendly-evident-grouse
backport/module-invocation-warning/fully-fitting-buzzard
backport/nvanthao/update-docs-implicit-provider/locally-neutral-lemur
backport/optional-type-attributes-note/inherently-dear-goat
backport/patch-1/gladly-mature-oarfish
backport/patch-1/manually-fine-mantis
backport/patch-1/nationally-working-kite
backport/patch-1/noticeably-comic-manatee
backport/patch-1/rarely-informed-gopher
backport/patch-1/sensibly-saving-swine
backport/patch-1/usually-clear-shad
backport/patch-1/vaguely-deciding-beagle
backport/patch-1/virtually-more-rhino
backport/patch-1/wholly-verified-racer
backport/patch-1/willingly-usable-husky
backport/patch-1/yearly-rich-skunk
backport/patch-2/badly-game-spider
backport/patch-2/finally-amazed-catfish
backport/patch-2/openly-clean-tick
backport/patch-2/weekly-selected-tiger
backport/rar-docs-update-add-anchor/cheaply-sincere-escargot
backport/remove-future-statement-import/briefly-viable-glowworm
backport/remove-provisioners/readily-correct-ferret
backport/remove-provisioners/widely-singular-hound
backport/replace-flag-clarifications/definitely-saved-elf
backport/replace-flag-updates/nominally-assured-weevil
backport/startsswith-to-startswith/highly-gorgeous-katydid
backport/system-parameter/infinitely-open-bluebird
backport/tf-integration-program-guide/briefly-certain-quail
backport/tweak-multi-to-multi-migration-tfc/suddenly-real-duckling
backport/update-cloud-block-pages/verbally-key-kangaroo
backport/update-console-docs/closely-genuine-javelin
backport/update-for-each-example/early-crucial-piranha
backport/update-plan-page/lightly-outgoing-halibut
backport/update-run-task-result/factually-star-sunfish
backport/update_docs_for_30072/gradually-trusting-wahoo
backport/workspaces-confusion-fixes/secondly-huge-titmouse
barrettclark/fix-state-outputs-read-permissions
brandonc/changelog_nested_sensitive
brandonc/changelog_sensitive_diff_fixes
brandonc/cloud_upgrade_013
brandonc/nested_attr_sensitive
brandonc/output_cloud_reads
brandonc/providers-estimate
brandonc/run_variables_types
brandonc/scheme_override_cloud
brandonc/variable_parsing_refactor
build-pr-checks
build-workflow-dev/cgo-enabled
build-workflow-dev/liamcervante/equivalence-test-action
bump-gcp-storage-dependency
bump-gcp-storage-dependency-2
cgriggs01-tpdp-default
cloud-e2e-fix
cloud-integration-changelog-entry
cmd-fmt-parens-error
dependabot/go_modules/github.com/bmatcuk/doublestar-1.3.4
dependabot/go_modules/github.com/mattn/go-shellwords-1.0.12
dev-portal-updates-docs
dividers-devdot-fixes
doc-config-refactoring
doc-provisioner-scp
doc-refactoring-nav-link
doc-s3-backend-dynamodb-locks
doc-unicode-hcl
doc-yamlencode-stable
docs-for-each-list-toset
docs-readme-updates-versioned-docs
docs/top-pages-gloss
ds.submodule-nav-main
f-addrs-static-checkable
f-build-go1.19.3
f-cli-hide-fast-refresh
f-cmd-output-raw
f-cmd-web
f-config-refcount
f-cty-funcs-marks
f-debugger
f-decode-moved
f-depfile-pkg
f-derived-values-tracking
f-diagnostics-cli-reorg
f-dynamic-provider-assignment
f-e2etest-deps-forbidden
f-expand-root-outputs
f-exprstress
f-fewer-apply-updates
f-fileexists-errmsg
f-func-expandnull
f-functions-in-providers
f-gen-integration-tests
f-implied-move-module-call
f-init-provider-source-feedback
f-jsonstate-2
f-moduletest-2
f-moved-again
f-new-build-pipeline
f-new-plan-modes
f-ng-workflow
f-nix-legacy-providers
f-output-value-types
f-outputs-plan
f-partial-plan-on-error
f-partial-plan-on-error-ui
f-persistent-checks-old
f-plan-immediate-ops
f-plan-reads
f-plan-refresh-only-and-replace
f-playground
f-plugin-finder
f-preconditions-postconditions
f-prototype-drift
f-prototype-workspaces-are-states
f-provider-http-mirrors
f-providers-mirror-2
f-rpcplugin-interface
f-skip-attrs-as-blocks
f-submodule-outputs-inferred-sensitive
f-svcauth-environment
f-temp-without-provider-blocks
f-template-values
f-terraform-version-lock
f-testing-with-conditions
f-tfaddr-lib
f-unused-attr
f-validate-lint
f/azurerm-backend-msal
fix-apt-page
fix-broken-link
fix-broken-links-1-10
fix-cdktf-link
fix-dividers-for-devdot
fix-future-facing-language
fix-future-lang-2
fix-internals-overview
fix-intro-page-images
fix-last-intro-nits
fix-links-devdot
fix-links-release
fix-postconditions-example
fix-preconditions
fix-provisioners-content
fix-readme-again
fix-value-assertion-errors
gcs-backend-add-kms
gcs-backend-add-private-connect-support
gcs-refactor-credential-handling
gitrgoliveira-patch-1
go-get1.5.2
gs/add-pre-plan-run-tasks
jan21_language_urls
jan21_test_broken_link_check
jan21_url_rfc
jbardin/1.3-destroy-perf
jbardin/backport-29017
jbardin/backport-29167
jbardin/backport-29559
jbardin/backport-31576
jbardin/call-plan-destroy
jbardin/data-source-destroy-edges
jbardin/go-getter-update
jbardin/lookup-objects
jbardin/null-variable
jbardin/output-perf
jbardin/plan-orphan-deleted
jbardin/remove-deprecated-backends
jbardin/resolved-provided-by
jbardin/terraform-data
jbardin/terraform-null
jbardin/trigger-replacement
jbardin/variable-eval
json-schema-export-crash
k8s-backend-credentials
kevin/local-preview-post-split
kevin/preview
kevin/remove-guides-docs
kevin/vercel-config
kmoe/http-backend-debug-log
kmoe/init-checksum-miss-error
kmoe/misc-help-text
kmoe/unused-resource-attributes
lafentres/autolabel-dependabot-prs
lafentres/refactor-show-command
laura-fix-jsonencode-note
laura-update-docs-readme
laura-update-pre-post-conditions
liamcervante/cicd-go-vet
liamcervante/structured-run-output
link_multicloud_tutorial_from_use_cases
link_to_refresh_tutorial
link_workflow_tutorials
megan_invalid_creds
megan_update_msg
migrate-go-tfe-1_0
mnomitch/varialbe-errors-on-remote-backend
nf/nov21-migrate-away-from-cloud
nq.content-update
nq.docs-content-update
omarismail/run-vars
paddy_backport_proto6_download
paddy_protocol_six_registry
paddy_tf_log_json
pault/0.14-tfce-continue-on-error
preapply-runtasks-cli-output
preapply-runtasks-clioutput
prototype-implicit-graph
pselle/env_delete
rar-docs-update-add-anchor
release-notes-env-credentials
remote-backend-refresh-alias
replace-flag-updates
res-add-learn-link-debug
res-add-learn-link-debug-1
res-lifecycle-tutorial
revamp-cli-config
revert-29088-minify_jsonencode
review-1.0-docs
rln-add-versions-tutorials-links
rt-backport-changelog
rt-changelog-entry-1.1
run-tasks-backport
sebasslash/add-cloud-e2e-test-workflow
sebasslash/add-tf-hostname-env-var
sebasslash/add-tf-org-env-var
sebasslash/env-cloud-e2e-tests
sebasslash/err-approval-input-false
sebasslash/resolve-flaky-env-var-test
sebasslash/tf-workspace-cloud-config
solutiongeek-patch-1
stable-website
tags-reconfigure-msg
tchupp/override-local-vars
test-branch-protection-workflow
tf-swift-backend-swauth
tfc-integration-docs
uk1288/backport-cloud-integration-panic-fix
uk1288/fix-for-cloud-integration-panic
uk1288/update-changelog-md
uk1288/update-changelog-md-v1-1
update-TF-WORKSPACE-variable
update-cidrnetmask-docs
update-depends-on-docs
update-for-each-example
update-packaging-action-name
update-tfe-login-flow
update_gen_meta
uturunku1-patch-1
uturunku1-patch-2
v0.13
v0.14
v0.15
v1.0
v1.1
v1.4.0-alpha20221109
v1.3.5
v1.3.4
v1.3.3
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc1
v1.3.0-dev
v1.3.0-beta1
v1.3.0-alpha20220817
v1.3.0-alpha20220803
v1.3.0-alpha20220706
v1.3.0-alpha20220622
v1.3.0-alpha20220608
v1.2.9
v1.2.8
v1.2.7
v1.2.6
v1.2.5
v1.2.4
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc2
v1.2.0-rc1
v1.2.0-beta1
v1.2.0-alpha20220413
v1.2.0-alpha-20220328
v1.1.9
v1.1.8
v1.1.7
v1.1.6
v1.1.5
v1.1.4
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.1.0-rc1
v1.1.0-beta2
v1.1.0-beta1
v1.1.0-alpha20211029
v1.1.0-alpha20211020
v1.1.0-alpha20211006
v1.1.0-alpha20210922
v1.1.0-alpha20210908
v1.1.0-alpha20210811
v1.1.0-alpha20210728
v1.1.0-alpha20210714
v1.1.0-alpha20210630
v1.1.0-alpha20210616
v1.0.11
v1.0.10
v1.0.9
v1.0.8
v1.0.7
v1.0.6
v1.0.5
v1.0.4
v1.0.3
v1.0.2
v1.0.1
v1.0.0
v0.15.5
v0.15.4
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.15.0-rc2
v0.15.0-rc1
v0.15.0-beta2
v0.15.0-beta1
v0.15.0-alpha20210210
v0.15.0-alpha20210127
v0.15.0-alpha20210107
v0.14.11
v0.14.10
v0.14.9
v0.14.8
v0.14.7
v0.14.6
v0.14.5
v0.14.4
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.14.0-rc1
v0.14.0-beta2
v0.14.0-beta1
v0.14.0-alpha20201007
v0.14.0-alpha20200923
v0.14.0-alpha20200910
v0.13.7
v0.13.6
v0.13.5
v0.13.4
v0.13.3
v0.13.2
v0.13.1
v0.13.0
v0.13.0-rc1
v0.13.0-beta3
v0.13.0-beta2
v0.13.0-beta1
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/remote/backend_apply.go
+21
-0
backend/remote/backend_apply.go
backend/remote/backend_plan.go
+21
-0
backend/remote/backend_plan.go
backend/remote/testing.go
+6
-0
backend/remote/testing.go
with
48 additions
and
0 deletions
+48
-0
backend/remote/backend_apply.go
+
21
-
0
View file @
0eea4e7c
...
...
@@ -8,6 +8,7 @@ import (
"log"
tfe
"github.com/hashicorp/go-tfe"
version
"github.com/hashicorp/go-version"
"github.com/hashicorp/terraform/backend"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform/tfdiags"
...
...
@@ -94,6 +95,26 @@ func (b *Remote) opApply(stopCtx, cancelCtx context.Context, op *backend.Operati
))
}
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
()
...
...
This diff is collapsed.
Click to expand it.
backend/remote/backend_plan.go
+
21
-
0
View file @
0eea4e7c
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
backend/remote/testing.go
+
6
-
0
View file @
0eea4e7c
...
...
@@ -207,6 +207,12 @@ func testServer(t *testing.T) *httptest.Server {
}`
,
path
.
Base
(
r
.
URL
.
Path
)))
})
// Respond to pings to get the API version header.
mux
.
HandleFunc
(
"/api/v2/ping"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
Header
()
.
Set
(
"TFP-API-Version"
,
"2.3"
)
})
// Respond to the initial query to read the hashicorp org entitlements.
mux
.
HandleFunc
(
"/api/v2/organizations/hashicorp/entitlement-set"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/vnd.api+json"
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help