Commit Graph

30002 Commits

Author SHA1 Message Date
Sebastian Rivera
b191faf8a4 Add skip test if missing vars helper 2022-04-12 17:32:39 -04:00
Kevin Wang
8eaf7fe85e
chore: vercel config (#30831)
- follows: https://github.com/hashicorp/terraform-cdk/pull/1611
2022-04-12 12:19:28 -04:00
Sebastian Rivera
34114286ff Cloud e2e tests for configuring with env vars 2022-04-11 15:19:17 -04:00
Sebastian Rivera
8040dfec34
Merge pull request #30787 from hashicorp/sebasslash/tf-workspace-cloud-config
Add cloud config support for TF_WORKSPACE
2022-04-11 14:38:23 -04:00
Sebastian Rivera
f95c7935c9
Update website/docs/cli/cloud/settings.mdx
Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>
2022-04-11 14:33:13 -04:00
Sebastian Rivera
4c3429f1a0 Update docs to explain new TF_WORKSPACE behavior for cloud config 2022-04-11 14:09:24 -04:00
Sebastian Rivera
dd864b1bac Add TF_WORKSPACE validation method 2022-04-11 13:59:02 -04:00
James Bardin
74885b1108 remove data sources from state read and upgrade
Data sources should not require reading the previous versions. While we
previously skipped the decoding if it were to fail, this removes the
need for any prior state at all.

The only place where the prior state was functionally used was in the
destroy path. Because a data source destroy is only for cleanup purposes
to clean out the state using the same code paths as a managed resource,
we can substitute the prior state in the change change with a null value
to maintain the same behavior.
2022-04-11 11:55:53 -04:00
James Bardin
29ecac0808 remove the use of data source prior state entirely
After data source handling was moved from a separate refresh phase into
the planning phase, reading the existing state was only used for
informational purposes. This had been reduced to reporting warnings when
the provider returned an unexpected value to try and help locate legacy
provider bugs, but any actual issues located from those warnings were
very few and far between.

Because the prior state cannot be reliably decoded when faced with
incompatible provider schema upgrades, and there is no longer any
significant reason to try and get the prior state at all, we can skip
the process entirely.
2022-04-11 10:19:45 -04:00
James Bardin
a7987dec9f remove redundant readResourceInstanceState 2022-04-11 10:12:44 -04:00
James Bardin
01628f0d50 data schema changes may prevent state decoding
Data sources do not have state migrations, so there may be no way to
decode the prior state when faced with incompatible type changes.

Because prior state is only informational to the plan, and its existence
should not effect the planning process, we can skip decoding when faced
with errors.
2022-04-11 09:45:10 -04:00
Alisdair McDiarmid
51178958f3
Merge pull request #30825 from hashicorp/alisdair/fix-nested-attr-sensitive-collections
cli: Fix plan diff for sensitive nested attributes
2022-04-11 08:05:19 -04:00
Alisdair McDiarmid
d23f0998fb cli: Fix plan diff for sensitive nested attributes
When rendering diffs for resources which use nested attribute types, we
must cope with collections backing those attributes which are entirely
sensitive. The most common way this will be seen is through sensitive
values being present in sets, which will result in the entire set being
marked sensitive.
2022-04-08 16:16:52 -04:00
Eng Zer Jun
fedd315275
test: use T.TempDir to create temporary test directory (#30803)
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-04-08 17:34:16 +01:00
Martin Atkins
5b615882e2
build: "Quick Checks" to run for external contributions
The "push" event is only for pushes to branches within the same repository.

Since external contributors make commits in their own repositories rather than directly in the target repository, we also need the pull_request event to react to opening a pull request and to pushing new code to an external branch associated with a pull request.

Since internal pull requests would in principle trigger both "push" _and_ "pull_request", we also constrain the push event only to the branches we typically release from, on the assumption that all other branches will merge into those via pull requests. This avoids redundantly running the same checks in response to two events at the same time.
2022-04-07 17:00:44 -07:00
Laura Pacilio
f9462d5d51 Update links to say "Custom Condition Checks" 2022-04-07 16:25:09 -04:00
Laura Pacilio
3ed8c5c467 Fix in-text link 2022-04-07 13:51:56 -04:00
Laura Pacilio
4c097842df Move conditionals information to conditional expressions page 2022-04-07 13:48:44 -04:00
Laura Pacilio
375b3583fd APply suggestions from PR review 2022-04-07 12:12:13 -04:00
Sebastian Rivera
9c0a8f7e35 Update env variable docs section to include TF_WORKSPACE 2022-04-07 11:46:36 -04:00
Sebastian Rivera
995ef15ab9 Add cloud configuration support for TF_WORKSPACE
TF_WORKSPACE can now be used for your cloud configuration, effectively serving as an alternative
to setting the name attribute in your workspaces configuration.
2022-04-07 11:46:36 -04:00
Laura Pacilio
3bc3bc52f8
Update website/docs/language/expressions/custom-conditions.mdx
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2022-04-07 11:40:01 -04:00
Laura Pacilio
b997c983a5
Update website/docs/language/expressions/custom-conditions.mdx
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2022-04-07 11:39:41 -04:00
Laura Pacilio
4ab955eeab
Update website/docs/language/expressions/custom-conditions.mdx
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2022-04-07 10:13:41 -04:00
Laura Pacilio
6b986c94bc
Update website/docs/language/expressions/custom-conditions.mdx
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2022-04-07 10:12:49 -04:00
Laura Pacilio
d69cb58ff5 Add additional sections to condition expressions section 2022-04-06 17:01:04 -04:00
Laura Pacilio
eea860e0cf Fixing typos and doing a read through 2022-04-06 16:55:43 -04:00
Laura Pacilio
04d329a9e1 Add references to custom conditions on related pages 2022-04-06 16:11:36 -04:00
Laura Pacilio
5803963be8 more nitpicks 2022-04-06 15:45:27 -04:00
Laura Pacilio
62a7b51ba7 more edits 2022-04-06 15:41:02 -04:00
Laura Pacilio
3ae238a448 More language edits 2022-04-06 14:57:20 -04:00
Alisdair McDiarmid
6d03303b79
Merge pull request #30792 from hashicorp/alisdair/conclude-preconditions-postconditions-experiment
Conclude preconditions/postconditions experiment
2022-04-06 13:01:50 -04:00
Laura Pacilio
af7e688859 more language cleanup for clarity 2022-04-05 17:01:21 -04:00
Laura Pacilio
b2576a3df3 Update page name to Custom Conditions per feedback 2022-04-05 15:50:24 -04:00
Alisdair McDiarmid
bb35f02c95 Conclude preconditions/postconditions experiment 2022-04-04 15:54:40 -04:00
Alisdair McDiarmid
3fbedf2543
Merge pull request #30752 from hashicorp/alisdair/condition-blocks-results-in-plan
core: Store condition block results in plan
2022-04-04 15:54:28 -04:00
Alisdair McDiarmid
c5d10bdef1 core: Store condition block results in plan
In order to include condition block results in the JSON plan output, we
must store them in the plan and its serialization.

Terraform can evaluate condition blocks multiple times, so we must be
able to update the result. Accordingly, the plan.Conditions object is a
map with keys representing the condition block's address. Condition
blocks are not referenceable in any other context, so this address form
cannot be used anywhere in the configuration.

The commit includes a new test case for the JSON output of a
refresh-only plan, which is currently the only way for a failing
condition result to be rendered through this path.
2022-04-04 15:36:29 -04:00
Martin Atkins
1e56e1fe0f build: Remove our CircleCI configuration for PR checks
We will henceforth use the "checks.yml" GitHub Actions workflow instead of
CircleCI, because we're standardizing on using GitHub Actions for all of
our automation in this repository so that everything is in a consistent
language and we have as few external dependencies as possible.

The checks.yml workflow alone does not actually replace everything this
CircleCI configuration did. Reworking things for GitHub Actions was a good
opportunity to revisit the cost/benefit of the various steps here and my
conclusions were:
- Unit tests and consistency checks give the best signal about the
  correctness of new code, with broad coverage over all of our packages.
  These are the most important things we want to run before reviewing a
  pull request, although our unit test run is currently relatively slow
  and would probably be worth optimizing in future commits.
- Our existing build.yml workflow already runs the E2E tests across
  various platforms and so I considered removing those but elected to keep
  the same single-platform (Linux) E2E test run in the pre-review checks
  because in practice those tests are typically faster than the full
  unit test run anyway and so they don't delay a green check result and
  can serve as a reasonable proxy for whether the cross-platform E2E tests
  will all succeed when we eventually check in build.yml, after merge.
- We've long had a special exception to our usual rule of not running
  acceptance tests in CI specifically for the Consul backend. In practice
  the Consul backend is essentially "done" and doesn't change much, so
  I don't think the cost of installing and launching Consul just to test
  that one backend has sufficient benefit to preserve. Our unit tests do
  still exercise all of the generic backend machinery via the inmem and
  local backends, and in the event that someone does make changes to the
  Consul backend they can still run the acceptance tests locally as we'd
  expect for a change to any other backend.
- We previously included jobs to run "go build" across various different
  platforms. Although that can occasionally help catch platform-specific
  issues, most code in Terraform is platform-agnostic and so it's rare
  to encounter single-platform build errors. These jobs were typically
  the long pole for completion of the CI checks before and so I've removed
  them here in favor of relying on similar checks already happening inside
  the build.yml workflow, which runs only after a PR is merged. This does
  increase the risk of a platform-specific error landing in a release
  branch before we catch it, but since platform-specific problems are
  rare this feels like a reasonable tradeoff. Anyone working on
  explicitly-platform-specific code in Terraform should typically test
  locally on the relevant platform anyway, and so catching these with our
  build step is a last gate just to make sure mistakes don't end up in
  production releases.
2022-04-04 08:12:44 -07:00
Martin Atkins
bbf540e0e3 build: "Quick Checks" caches protoc between runs
Building our protobuf files requires the protoc tool, which takes a little
while to download and install. Hopefully downloading it out of the GitHub
Actions cache will make it a little faster in the common case where we're
still using the same version as the previous run.
2022-04-04 08:12:44 -07:00
Martin Atkins
42a618f7c1 build: "Quick Checks" runs consistency checks concurrently with others
Originally we had this running as part of the Unit Tests job because most
of the checks are relatively fast. However, the addition of the protobuf
generation check made that no longer be true because it needs to download
and run protoc.

With that extra overhead it now _is_ productive to spend the time booting
and installing Go on third worker, as long as GitHub Actions continues
to let us run all three of these jobs concurrently most of the time.
2022-04-04 08:12:44 -07:00
Martin Atkins
95f26b340b build: "Quick Checks" no longer uses goenv
goenv was making things more complicated than needed since it's really
designed to help with interactive use in a shell more than automated use
like this.

Instead, we'll follow the same strategy that our build.yml was doing of
just reading the .go-version file directly and then using the official
actions/setup-go action to do the actual installation. The key advantage
here is that Go ends up installed in a way where just running "go" will
do the right thing, and we no longer need to fuss with shims and
version-based path prefixes.

Rather than duplicating the logic from build.yml, instead it's factored
out into a separate composite action which both build.yml and checks.yml
will now share, in case we want to change the Go version selection
methodology in the future.
2022-04-04 08:12:44 -07:00
Martin Atkins
67fedd48a6 build: "Quick Checks" avoid repeating Install Go
This factors out the "Install Go" step into a separate composite action
which we can then call from both of the jobs that need it.

We can't factor out the "Cache Go Modules" because GitHub doesn't allow
composite actions to refer to other external actions.
2022-04-04 08:12:44 -07:00
Martin Atkins
9210ce6cdd build: GitHub Actions "Quick Checks" workflow
This is intended to eventually replace the CircleCI-based checks we use
as part of the PR process in this repository. We're already using GitHub
Actions for various other processes in this repository, so this change is
motivated by consistency of having all of our automation running in the
same system and written in the same language.

This is not a complete replacement for our CircleCI workflow yet, and
probably won't ever be because the CircleCI workflow contains some steps
that are arguably redundant with other processes we follow elsewhere.
However, the CircleCI workflow remains for now and won't be removed until
we're satisfied that enough of it is replicated by this GitHub Actions
workflow.
2022-04-04 08:12:44 -07:00
Martin Atkins
49d7c879ac Fix problems caught by staticcheck v0.3.0
This will allow us to upgrade to this version in a later commit without
causing the our build checks to fail.
2022-04-04 08:12:44 -07:00
kmoe
58b563e440
Update CHANGELOG.md 2022-04-01 10:12:25 +01:00
kmoe
5907a86301
command/format: Correctly quote diff object keys (#30766)
When rendering a diff, we should quote object attribute names if the
string representation is not a valid identifier. While this is not
strictly necessary, it makes the diff output more closely resemble the
configuration language, which is less confusing.

This commit applies to both top-level schema attributes and any object
value attributes. We use a simplistic "%q" Go format string to quote the
strings, which is not strictly identical to HCL's quoting requirements,
but is the pattern used elsewhere in HCL and Terraform.

Co-Authored-By: Katy Moe <katy@katy.moe>

Co-authored-by: Alisdair McDiarmid <alisdair@users.noreply.github.com>
2022-04-01 10:09:28 +01:00
Lars Lehtonen
88c9b90c93
internal/backend/remote-state/oss: fix dropped error (#30352) 2022-04-01 08:07:31 +01:00
Jane
8d490aad9f
Merge pull request #30774 from hashicorp/janehojy-patch-1
Add `hostname` argument to cloud block
2022-04-01 14:22:38 +08:00
Jane
4de27fc52b
Update website/docs/language/settings/terraform-cloud.mdx
Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>
2022-04-01 14:22:14 +08:00
James Bardin
0bd59238d6
Merge pull request #30765 from hashicorp/jbardin/contributing-attributes
improve the contributing attributes filter
2022-03-31 16:56:09 -04:00