• Tiger's avatar
    Seed initial version for non-versioned terraform states · 874c9c92
    Tiger authored
    If a Terraform state was created before versioning support was
    introduced, it will have a single version record whose file
    uses a legacy naming scheme in object storage. To update
    these states and versions to use the new behaviour, we must do
    the following when creating the next version:
    
     * Read the current, non-versioned file from the old location.
     * Update the :versioning_enabled flag, which determines the
       naming scheme
     * Resave the existing file with the updated name and location,
       using a version number one prior to the new version
     * Create the new version as normal
    
    This migration only needs to happen once for each state, from
    then on the state will behave as if it was always versioned.
    
    This code can be removed in the next major version (14.0), after
    which any states that haven't been migrated will need to be
    recreated
    
    https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43665
    874c9c92
state_spec.rb 4.62 KB