-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Readd project support to filestate #12134
Commits on Mar 14, 2023
-
filestate/internal: Use stack reference, not name
filestate backend currently operates exclusively with stack names. All its internal pass around just the stack name, and nothing else. This makes it a bit difficult to add project support to the backend. This is a refactor in advance of adding project support, changing the internals of filestate to pass a stack reference around. It inspects the reference directly for all its operations. Note: This contains no behavioral changes. Name and FullyQualifiedName currently both return just the stack name. In a future change, once project name is incorporated into the object, FullyQualifiedName will be able to return `organization/$project/$name`. Extracted from #12134 Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
Configuration menu - View commit details
-
Copy full SHA for 14fd8f9 - Browse repository at this point
Copy the full SHA 14fd8f9View commit details
Commits on Mar 15, 2023
-
backend/filestate: Re-add project support
This re-adds project support back to the filestate backend. For backwards compatibility, and to plan for the future, this requires versioning the storage state. To do that, we introduce a .pulumi/Pulumi.yaml file where we hold metadata like the version of the filestate storage format. Version 1 is the initial version that introduces project support. # .pulumi/Pulumi.yaml version: 1 If we ever need to make breaking changes to the storage protocol we can bump the format version. Newly initialized states will use the new project-mode format. Existing states will continue to run in the old, non-project mode. State can be migrated to the new format with `pulumi state upgrade`, at which point they will become incompatible with older CLIs. For more graceful degradation, if an old CLI writes to an upgraded state the CLI will warn about these files, and recommend re-running upgrade. Testing: Some tests inside filestate/backend were duplicated for legacy and project variants.
Configuration menu - View commit details
-
Copy full SHA for 67208a3 - Browse repository at this point
Copy the full SHA 67208a3View commit details -
filestate/pulumiState: Move extraction into separate function
Moves pulumiState extraction from a bucket into a separate independent ensurePulumiMeta function, reanming the type to pulumiMeta, and adds unit tests for success and failure cases of this function.
Configuration menu - View commit details
-
Copy full SHA for 9b73977 - Browse repository at this point
Copy the full SHA 9b73977View commit details -
test(filestate/New): warnings for legacy files in project mode
Add a test that validates the warnings we print in project mode when there are legacy files in the bucket.
Configuration menu - View commit details
-
Copy full SHA for 3f2d7bf - Browse repository at this point
Copy the full SHA 3f2d7bfView commit details -
cmd/state upgrade: Drop unused required argument
The cobra command for 'state upgrade' specifies that it has one required positional argument. This isn't true--it takes no arguments, and it does nothing with 'args'. Switch to NoArgs and add a test.
Configuration menu - View commit details
-
Copy full SHA for 98a0625 - Browse repository at this point
Copy the full SHA 98a0625View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5663d93 - Browse repository at this point
Copy the full SHA 5663d93View commit details -
refactor: Remove if-project-mode branches
Instead of branching different code paths on whether we're in project mode or not, define an interface for those specific behaviors and extract code for those pieces into two separate implementations. This way, instead of: if projectMode { aProject() } else { aLegacy() } // ... if projectMode { bProject() } else { bLegacy() } // ... if projectMode { cProject() } else { cLegacy() } We do: var x X if projectMode { x = &projectX{} } else { x = &legacyX{} } x.a() x.b() x.c()
Configuration menu - View commit details
-
Copy full SHA for 94d8686 - Browse repository at this point
Copy the full SHA 94d8686View commit details -
Upgrade: Use existing logic to read old stacks
Instead of duplciating the logic to read legacy stack files from the bucket, use the legacyReferenceStore to re-read the old references and upgrade them to project-level references.
Configuration menu - View commit details
-
Copy full SHA for 29a9881 - Browse repository at this point
Copy the full SHA 29a9881View commit details -
New: Re-use legacyReferenceStore to warn about old files
Instead of looking for leftover legacy files in project mode manually, re-use the legacyReferenceStore logic to find them.
Configuration menu - View commit details
-
Copy full SHA for dbf2a69 - Browse repository at this point
Copy the full SHA dbf2a69View commit details -
localBackendReference: Don't track backend
localBackendReference keeps track of the backend so that it can determine the current project and shorten the String representation of the reference. As far as I can tell, this doesn't need to be "current project at the time of calling String" and can be "current project when the reference was constructed." This switch allows us to turn localBackendReference back into a data-only object.
Configuration menu - View commit details
-
Copy full SHA for 42f6a9e - Browse repository at this point
Copy the full SHA 42f6a9eView commit details -
referenceStore: More control over layout, track on localBackendReference
Let referenceStore decide paths of different files and directories rather than having the backend decide them based on whether localBackendReference.project is empty or not. To make renames from legacy to project-based stacks possible, we need localBackendReference to track the store that created it, and use that to determine old and new paths.
Configuration menu - View commit details
-
Copy full SHA for 355ecf8 - Browse repository at this point
Copy the full SHA 355ecf8View commit details -
Revert "localBackendReference: Don't track backend"
We actually need to track the localBackend because the current project for a localBackend does change after a reference is parsed. Includes a test for this change.
Configuration menu - View commit details
-
Copy full SHA for 6271c74 - Browse repository at this point
Copy the full SHA 6271c74View commit details -
Make .pulumi/{stacks,history,backup} into constants
These paths are calculated on-demand repeatedly, but they never change. There's no reason for these to be bound to the backend implemntation. Turn them into top-level variables. (They're not constants because the output of filepath.Join cannot be a const.)
Configuration menu - View commit details
-
Copy full SHA for 3a5ca77 - Browse repository at this point
Copy the full SHA 3a5ca77View commit details -
currentProject: use an atomic pointer
SetCurrentProject and localBackendReference.String have a data race in accessing the currentProject field. Turn it into an atomic.Pointer to address this data race.
Configuration menu - View commit details
-
Copy full SHA for c05fe58 - Browse repository at this point
Copy the full SHA c05fe58View commit details -
projectReferenceStore: add ListProjects
Adds a ListProjects methods to the projectReferenceStore which we re-use in DoesProjectExist and ListReferences rather than re-implementing that logic.
Configuration menu - View commit details
-
Copy full SHA for 8e8b544 - Browse repository at this point
Copy the full SHA 8e8b544View commit details -
test: Move replicated legacy tests to separate file
These don't need to pollute the primary file. Otherwise, future tests may feel compelled to duplicate for legacy and project variants.
Configuration menu - View commit details
-
Copy full SHA for 5083e82 - Browse repository at this point
Copy the full SHA 5083e82View commit details