pulumi/pkg/backend
Abhinav Gupta e47c5823c0
filestate: Track a state metadata file (.pulumi/Pulumi.yaml)
We want the filestate backend to support project-scoped stacks,
but we can't make the change as-is because it would break old states
with new CLIs.

To differentiate between old and new states,
we've decided to introduce the concept of state metadata.
This is a file under the path .pulumi/Pulumi.yaml
that tracks metadata necessary for the filestate backend to operate.

Initially, this contains just one field: `version`,
with the initial value of 0 representing non-project or "legacy mode".

This changes the filestate layout to track such a file,
creating it if it doesn't exist with the default value of 0.

In a future change, we'll introduce "version 1",
which adds support for project-scoped stacks.

If we ever need to make breaking changes to the layout,
the version in this file will help the CLI decide
whether it's allowed to handle that state bucket
without corrupting it.

Note that this differs slightly
from the initial implementation of this functionality in #12134.
Particularly, this idempotently ensures that a Pulumi.yaml exists,
allowing `version: 0` to indicate legacy mode,
versus the original implementation that treated absence of the file
in a non-empty bucket as legacy mode.

This drops the bucket.IsAccessible check from filestate.New
because accessibility is now verified
when we try to read the metadata file.

Extracted from #12437
2023-03-22 12:25:13 -07:00
..
display all: Fix revive issues 2023-03-21 08:55:11 -07:00
filestate filestate: Track a state metadata file (.pulumi/Pulumi.yaml) 2023-03-22 12:25:13 -07:00
httpstate Merge #11974 2023-03-21 19:36:53 +00:00
state [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
apply.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
backend.go CreateStackOptions: interface => struct 2023-03-20 14:32:14 -07:00
backend_test.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
doc.go Document Go packages (#6009) 2021-01-11 11:07:59 -07:00
errors.go Add a link to docs for the 409 Conflict error message (#3207) 2019-09-10 13:25:08 -07:00
mock.go CreateStackOptions: interface => struct 2023-03-20 14:32:14 -07:00
policypack.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
query.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
snapshot.go pkg/backend: Prefer contract.Assertf over Assert 2023-02-21 15:13:16 -08:00
snapshot_test.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
stack.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
updates.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
watch.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00