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 19:14:05 +00:00
|
|
|
// Copyright 2016-2023, Pulumi Corporation.
|
2018-05-22 19:43:36 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2017-11-01 20:34:19 +00:00
|
|
|
|
2018-09-04 19:38:58 +00:00
|
|
|
package filestate
|
2017-11-01 20:34:19 +00:00
|
|
|
|
|
|
|
import (
|
2024-01-30 15:53:10 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/v3/backend/diy"
|
2017-11-01 20:34:19 +00:00
|
|
|
)
|
|
|
|
|
2024-01-30 15:53:10 +00:00
|
|
|
// This is just a compat shim for ESC which calls this method as "filestate.IsFileStateBackendURL".
|
|
|
|
// Deprecated: Use diy.IsDIYBackendURL instead.
|
|
|
|
func IsFileStateBackendURL(url string) bool {
|
|
|
|
return diy.IsDIYBackendURL(url)
|
2022-03-03 17:07:05 +00:00
|
|
|
}
|