This project is mirrored from https://:*****@github.com/hashicorp/terraform.git. Pull mirroring failed .
Repository mirroring has been paused due to too many failed attempts. It can be resumed by a project maintainer.
  1. 26 Jan, 2021 1 commit
  2. 19 Jan, 2021 1 commit
    • Alisdair McDiarmid's avatar
      cli: Fix state migration remote version check · 212a97c3
      Alisdair McDiarmid authored
      Previously the state migration process was using the fallback strict
      error check when migrating to or from a Terraform Cloud workspace. This
      resulted in an error when running init if the local and remote Terraform
      versions did not exactly match.
      
      This was excessively strict. When migrating from a remote Terraform
      Cloud workspace to local state, there is no need for a version check at
      all, as we cannot break the Terraform Cloud workspace. When migrating
      to Terraform Cloud, we should use the more forgiving check, rather than
      the strict equality.
      
      This commit fixes both of these cases accordingly, and allows migrating
      state to and from Terraform Cloud remote workspaces without errors.
      212a97c3
  3. 11 Aug, 2020 2 commits
    • Alisdair McDiarmid's avatar
      command: Always validate workspace name · b239570a
      Alisdair McDiarmid authored
      The workspace name can be overridden by setting a TF_WORKSPACE
      environment variable. If this is done, we should still validate the
      resulting workspace name; otherwise, we could end up with an invalid and
      unselectable workspace.
      
      This change updates the Meta.Workspace function to return an error, and
      handles that error wherever necessary.
      b239570a
    • Kristin Laemmert's avatar
      state: remove deprecated state package (#25490) · 6621501a
      Kristin Laemmert authored
      Most of the state package has been deprecated by the states package.
      This PR replaces all the references to the old state package that
      can be done simply - the low-hanging fruit.
      
      * states: move state.Locker to statemgr
      
      The state.Locker interface was a wrapper around a statemgr.Full, so
      moving this was relatively straightforward.
      
      * command: remove unnecessary use of state package for writing local terraform state files
      
      * move state.LocalState into terraform package
      
      state.LocalState is responsible for managing terraform.States, so it
      made sense (to me) to move it into the terraform package.
      
      * slight change of heart: move state.LocalState into clistate instead of
      terraform
      6621501a
  4. 24 May, 2019 1 commit
    • James Bardin's avatar
      don't store prepared backend config · c017149b
      James Bardin authored
      The backend gets to "prepare" the configuration before Configure is
      called, in order to validate the values and insert defaults. We don't
      want to store this value in the "config state", because it will often
      not match the raw config after it is prepared, forcing unecessary
      backend migrations during init.
      
      Since PrepareConfig is always called before Configure, we can store the
      config value directly, and assume that it will be prepared in the same
      manner each time.
      c017149b
  5. 23 May, 2019 1 commit
  6. 08 Mar, 2019 1 commit
  7. 19 Nov, 2018 2 commits
    • Martin Atkins's avatar
      command: More logging during migration · 6c7cecfb
      Martin Atkins authored
      This just finishes off the logging added in earlier commits to get all
      the way through to the actual migration call.
      6c7cecfb
    • Martin Atkins's avatar
      command: Fix TestMetaBackend_configureNewWithState · aacbe1d1
      Martin Atkins authored
      This test was initially failing because its fixture had a state which our
      new state models consider to be "empty", and thus it was not migrated.
      
      After fixing that (by adding an output to the fixture), this revealed a
      bug that the lineage was not being persisted through the migration. This
      is fixed by using the statemgr.Migrate method instead of writing via the
      normal Writer interface, which allows two cooperating state managers to
      properly transfer the lineage and serial along with the state snapshot.
      aacbe1d1
  8. 12 Nov, 2018 2 commits
    • Martin Atkins's avatar
      command: Fix TestInit_inputFalse · f6d468ff
      Martin Atkins authored
      This test was using old-style state files as its input, differing only by
      lineage. Since lineages are now managed within the state manager itself,
      the test can't use that to distinguish the two files and so we put a
      different output in each one instead.
      
      This also introduces some TRACE logging to the migration codepaths.
      There's some hard-to-follow control flow here and so this extra logging
      helps to understand the reason for a particular outcome, and since this
      codepath is visited only in "terraform init" anyway it doesn't hurt to
      be a bit more verbose here.
      f6d468ff
    • Sander van Harmelen's avatar
      backend/migrations: only select workspaces if supported · 5e9414bf
      Sander van Harmelen authored
      If the backend does not support workspaces, we don't have to try to
      select a workspace and we should not return an error.
      5e9414bf
  9. 06 Nov, 2018 1 commit
  10. 17 Oct, 2018 2 commits
    • Martin Atkins's avatar
      Revert some work that happened since v0.12-dev branched · 541952bb
      Martin Atkins authored
      This work was done against APIs that were already changed in the branch
      before work began, and so it doesn't apply to the v0.12 development work.
      
      To allow v0.12 to merge down to master, we'll revert this work out for now
      and then re-introduce equivalent functionality in later commits that works
      against the new APIs.
      541952bb
    • Martin Atkins's avatar
      terraform: Ugly huge change to weave in new State and Plan types · a3403f27
      Martin Atkins authored
      Due to how often the state and plan types are referenced throughout
      Terraform, there isn't a great way to switch them out gradually. As a
      consequence, this huge commit gets us from the old world to a _compilable_
      new world, but still has a large number of known test failures due to
      key functionality being stubbed out.
      
      The stubs here are for anything that interacts with providers, since we
      now need to do the follow-up work to similarly replace the old
      terraform.ResourceProvider interface with its replacement in the new
      "providers" package. That work, along with work to fix the remaining
      failing tests, will follow in subsequent commits.
      
      The aim here was to replace all references to terraform.State and its
      downstream types with states.State, terraform.Plan with plans.Plan,
      state.State with statemgr.State, and switch to the new implementations of
      the state and plan file formats. However, due to the number of times those
      types are used, this also ended up affecting numerous other parts of core
      such as terraform.Hook, the backend.Backend interface, and most of the CLI
      commands.
      
      Just as with 5861dbf3 before, I apologize
      in advance to the person who inevitably just found this huge commit while
      spelunking through the commit history.
      a3403f27
  11. 29 Aug, 2018 1 commit
    • Sander van Harmelen's avatar
      backend/migrations: migrate the default state · f410a5bb
      Sander van Harmelen authored
      Certain backends (currently only the `remote` backend) do not support using both the default and named workspaces at the same time.
      
      To make the migration easier for users that currently use both types of workspaces, this commit adds logic to ask the user for a new workspace name during the migration process.
      f410a5bb
  12. 03 Aug, 2018 1 commit
  13. 23 Feb, 2018 6 commits
    • James Bardin's avatar
      use the new clistate.Locker in commands · bdd475e1
      James Bardin authored
      Use the new StateLocker field to provide a wrapper for locking the state
      during terraform.Context creation in the commands that directly
      manipulate the state.
      bdd475e1
    • James Bardin's avatar
      create clistate.Locker interface · e9a76808
      James Bardin authored
      Simplify the use of clistate.Lock by creating a clistate.Locker
      instance, which stores the context of locking a state, to allow unlock
      to be called without knowledge of how the state was locked.
      
      This alows the backend code to bring the needed UI methods to the point
      where the state is locked, and still unlock the state from an outer
      scope.
      
      Provide a NoopLocker as well, so that callers can always call Unlock
      without verifying the status of the lock.
      
      Add the StateLocker field to the backend.Operation, so that the state
      lock can be carried between the different function scopes of the backend
      code. This will allow the backend context to lock the state before it's
      read, while allowing the different operations to unlock the state when
      they complete.
      e9a76808
    • James Bardin's avatar
      Revert "create clistate.Locker interface" · 12bda535
      James Bardin authored
      This reverts commit e88bd74b.
      12bda535
    • James Bardin's avatar
      Revert "use the new clistate.Locker in commands" · 3de0d245
      James Bardin authored
      This reverts commit 400f6ca4.
      3de0d245
    • James Bardin's avatar
      use the new clistate.Locker in commands · 400f6ca4
      James Bardin authored
      Use the new StateLocker field to provide a wrapper for locking the state
      during terraform.Context creation in the commands that directly
      manipulate the state.
      400f6ca4
    • James Bardin's avatar
      create clistate.Locker interface · e88bd74b
      James Bardin authored
      Simplify the use of clistate.Lock by creating a clistate.Locker
      instance, which stores the context of locking a state, to allow unlock
      to be called without knowledge of how the state was locked.
      
      This alows the backend code to bring the needed UI methods to the point
      where the state is locked, and still unlock the state from an outer
      scope.
      e88bd74b
  14. 04 Jan, 2018 1 commit
    • James Bardin's avatar
      re-word state migration prompts · f45205fe
      James Bardin authored
      The existing prompts were worded as if backend configurations were
      named, but they can only really be referenced by their type. Change the
      wording to reference them as type "X backend". When migrating state,
      refer to the backends as the "previously configured" and "newly
      configured", since they will often have the same type.
      f45205fe
  15. 18 Dec, 2017 1 commit
    • James Bardin's avatar
      don't loop indefinitely in confirm method · 885e4cde
      James Bardin authored
      Only check for input twice in the meta.confirm method. This prevents an
      errant newline from aborting the run while allowing Terraform to exit if
      there is no input available. We don't just check for a tty, since we
      still rely on being able to pipe input in for testing.
      
      Remove the redundant confirmation loops in the migration code, and only
      use the confirm method.
      885e4cde
  16. 09 Jun, 2017 2 commits
    • Martin Atkins's avatar
      command + backend: rename various API objects to "Workspace" terminology · 418a8a8b
      Martin Atkins authored
      We're shifting terminology from "environment" to "workspace". This takes
      care of some of the main internal API surface that was using the old
      terminology, though is not intended to be entirely comprehensive and is
      mainly just to minimize the amount of confusion for maintainers as we
      continue moving towards eliminating the old terminology.
      418a8a8b
    • Martin Atkins's avatar
      command: shallow UI-focused rename of "environment" to "workspace" · 31d55689
      Martin Atkins authored
      Feedback after 0.9 was that the term "environment" was confusing due to
      it colliding with several other concepts, such as OS environment
      variables, a non-aligned Terraform Enterprise concept, and differing ideas
      of "environment" within various organizations.
      
      This new term "workspace" is intended to ease some of that confusion. This
      term is not used anywhere else in Terraform today, and we expect it to not
      be used in a manner that would be confusing within user organizations.
      
      This begins a deprecation cycle for the "terraform env" family of commands,
      instead moving to an equivalent set of "terraform workspace" commands.
      
      There are some remaining references to the old "environment" concept in
      the code, which will be cleaned up in a separate change. This change is
      instead focused on text visible in the UI and wording within code comments
      for the benefit of human maintainers of the code.
      31d55689
  17. 24 May, 2017 1 commit
  18. 11 Apr, 2017 1 commit
  19. 04 Apr, 2017 1 commit
    • James Bardin's avatar
      noop migrate copy, add -lock and -input · fb4a365d
      James Bardin authored
      A couple commits got rebased together here, and it's easier to enumerate
      them in a single commit.
      
      Skip copying of states during migration if they are the same state. This
      can happen when trying to reconfigure a backend's options, or if the
      state was manually transferred. This can fail unexpectedly with locking
      enabled.
      
      Honor the `-input` flag for all confirmations (the new test hit some
      more). Also unify where we reference the Meta.forceInitCopy and transfer
      the value to the existing backendMigrateOpts.force field.
      fb4a365d
  20. 01 Apr, 2017 2 commits
    • James Bardin's avatar
      provide contexts to clistate.Lock calls · 305ef43a
      James Bardin authored
      Add fields required to create an appropriate context for all calls to
      clistate.Lock.
      
      Add missing checks for Meta.stateLock, where we would attempt to lock,
      even if locking should be skipped.
      305ef43a
    • James Bardin's avatar
      Have the clistate Lock use LockWithContext · 3f0dcd13
      James Bardin authored
      - Have the ui Lock helper use state.LockWithContext.
      - Rename the message package to clistate, since that's how it's imported
        everywhere.
      - Use a more idiomatic placement of the Context in the LockWithContext
        args.
      3f0dcd13
  21. 22 Mar, 2017 1 commit
    • James Bardin's avatar
      add `-force-copy` option to init command · 54e536cf
      James Bardin authored
      The `-force-copy` option will suppress confirmation for copying state
      data.
      
      Modify some tests to use the option, making sure to leave coverage of
      the Input code path.
      54e536cf
  22. 20 Mar, 2017 1 commit
    • Mitchell Hashimoto's avatar
      command: remove legacy remote state on migration · d01886a6
      Mitchell Hashimoto authored
      Fixes #12871
      
      We were forgetting to remove the legacy remote state from the actual
      state value when migrating. This only causes an issue when saving a plan
      since the plan contains the state itself and causes an error where both
      a backend + legacy state exist.
      
      If saved plans aren't used this causes no noticable issue.
      
      Due to buggy upgrades already existing in the wild, I also added code to
      clear the remote section if it exists in a standard unchanged backend
      d01886a6
  23. 16 Mar, 2017 1 commit
    • James Bardin's avatar
      change to default state after backend migration · ea095eda
      James Bardin authored
      When migrating from a multi-state backend to a single-state backend, we
      have to ensure that our locally configured environment is changed back
      to "default", or we won't be able to access the new backend.
      ea095eda
  24. 01 Mar, 2017 5 commits
  25. 15 Feb, 2017 1 commit