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. 19 Nov, 2018 26 commits
    • Martin Atkins's avatar
      plugin: Establish our current plugin protocol as version 5 · 4fe9632f
      Martin Atkins authored
      The main significant change here is that the package name for the proto
      definition is "tfplugin5", which is important because this name is part
      of the wire protocol for references to types defined in our package.
      
      Along with that, we also move the generated package into "internal" to
      make it explicit that importing the generated Go package from elsewhere is
      not the right approach for externally-implemented SDKs, which should
      instead vendor the proto definition they are using and generate their
      own stubs to ensure that the wire protocol is the only hard dependency
      between Terraform Core and plugins.
      
      After this is merged, any provider binaries built against our
      helper/schema package will need to be rebuilt so that they use the new
      "tfplugin5" package name instead of "proto".
      
      In a future commit we will include more elaborate and organized
      documentation on how an external codebase might make use of our RPC
      interface definition to implement an SDK, b...
      4fe9632f
    • Martin Atkins's avatar
      build: Temporarily disable the website tests for Travis-CI · 1ff9a540
      Martin Atkins authored
      There are some known broken links right now because this repository has
      been updated ahead of some necessary changes in the terraform-website
      repository. We'll need to wait until the end of the v0.12 release process
      to re-enable this because the terraform-website repository is currently
      set up for the v0.11 content and will continue to be until v0.12.0 final
      is ready for release.
      1ff9a540
    • Martin Atkins's avatar
      build: Update most things for Go 1.11 modules · c133de86
      Martin Atkins authored
      We're still using vendoring for now until we get _all_ of our tooling
      updated, so the main idea here is to force use of the vendor directory
      when running tests and building for development so we can quickly find
      situations where we forget to run "go mod vendor".
      
      We also setting GO111MODULE=off for installation of tools. Right now this
      is the best way to install a tool in GOBIN without also interfering with
      go.mod and go.sum, until a better pattern for managing tool dependencies
      is devised by the Go team.
      
      Finally, we run "go mod download" before launching "gox" in the main
      build process, to prime the local module cache once so that the concurrent
      "go build" processes won't race to populate it redundantly. This means
      that we'll be producing final builds from the module cache rather than
      from vendor as with everything else -- there's currently no way to tell
      gox to use -mod=vendor -- but that should be fine in practice since
      our go.sum file will ensure that we ...
      c133de86
    • Martin Atkins's avatar
      "go fmt" fixups · 5255e852
      Martin Atkins authored
      Apparently my editor is still not reliably formatting on save, so I missed
      a few formatting quirks in these files.
      5255e852
    • Martin Atkins's avatar
      command/e2etest: Temporarily disable tests that access network · 73c9521a
      Martin Atkins authored
      Several of these tests rely on external services (e.g. Terraform Registry)
      that have not yet been updated to support the needs of Terraform v0.12.0,
      so for now we'll skip all of these tests and wait until those systems have
      been updated.
      
      This should be removed before Terraform v0.12.0 final to enable these
      tests to be used as part of pre-release smoke testing.
      73c9521a
    • Martin Atkins's avatar
      plans/planfile: fix TestRoundtrip · 300eceeb
      Martin Atkins authored
      This was broken by an earlier change to verify the Terraform version
      number when reading a state file. To fix it, we'll use our current version
      in our constructed file which should then match when it's read back in.
      300eceeb
    • Martin Atkins's avatar
      states/statemgr: Local locks meta is near output path, not input path · 6cb3b0f4
      Martin Atkins authored
      This was a mistake while adapting this code from the old state.LocalState.
      Since the lock is held on the output file (s.path) the metadata should
      live adjacent to that rather than being built from the read path
      (s.readPath) that is used only as the initial snapshot on first
      instantiation.
      
      This also includes more logging, continuing the trend of other recent
      commits in these files. The local state behavior is sufficiently complex
      that these trace logs are a great help in debugging issues such as this
      one with the wrong files being used or actions being taken in the wrong
      order.
      6cb3b0f4
    • Martin Atkins's avatar
      command: "terraform output" mustn't panic when no state is present · 37bc187f
      Martin Atkins authored
      This is verified by TestOutput_noArgs.
      37bc187f
    • Martin Atkins's avatar
      command: Fix TestRefresh_backup · 53b5b95e
      Martin Atkins authored
      The local filesystem state manager no longer creates backup files eagerly,
      instead creating them only if on first write there is already a snapshot
      present in the target file.
      
      Therefore for this test to exercise the codepaths it intends to we must
      create an initial state snapshot for it to overwrite, creating the backup
      in the process.
      
      There are several other tests for this behavior elsewhere, so this test
      is primarily to verify that the refresh command is configuring the backend
      appropriately to get the backups written in the desired location.
      53b5b95e
    • Martin Atkins's avatar
      command: Fix TestRefresh_outPath · 762a173c
      Martin Atkins authored
      We now only create a backup state file if the given output file already
      exists, which it does not in this test.
      
      (The behavior of creating the backup files is already covered by other
      tests, so no need for this one go out of its way to do it.)
      762a173c
    • Martin Atkins's avatar
      command: Fix TestMetaBackend_planLocalMatch · e2ba90fd
      Martin Atkins authored
      We now don't create a local state backup until the first snapshot write,
      so we don't expect there to be a backup file until the end of the test.
      (There is already a check at the end there, unmodified by this change.)
      e2ba90fd
    • Martin Atkins's avatar
      states/statemgr: In Filesystem, back up output file, not input file · 48601d26
      Martin Atkins authored
      The filesystem backend has the option of using a different file for its
      initial read.
      
      Previously we were incorrectly writing the contents of that file out into
      the backup file, rather than the prior contents of the output file. Now
      we will always read the output file in RefreshState in order to decide
      what we will back up but then we will optionally additionally read the
      input file and prefer its content as the "current" state snapshot.
      
      This is verified by command.TestMetaBackend_planLocalStatePath and
      TestMetaBackend_configureNew, which are both now passing.
      48601d26
    • Martin Atkins's avatar
      command: Fix TestMetaBackend_localDoesNotDeleteLocal · 27abd9c6
      Martin Atkins authored
      The changes to how we handle setting the state path on the local backend
      broke the heuristic we were using here for detecting migration from one
      local backend to another with the same state path, which would by default
      end up deleting the state altogether after migration.
      
      We now use the StatePaths method to do this, which takes into account
      both the default values and any settings that have been set.
      
      Additionally this addresses a flaw in the old method which could
      potentially have deleted all non-default workspace state files if the
      "path" setting were changed without also changing the "workspace_dir"
      setting. This new approach is conservative because it will preserve all
      of the files if any one overlaps.
      27abd9c6
    • Martin Atkins's avatar
      command: Fix TestPlan_outBackend · be79bf04
      Martin Atkins authored
      In an earlier change we fixed the "backendFromConfig" codepath to be
      able to properly detect changes to the -backend-config arguments during
      "terraform init", but this detection is too strict for the normal case
      of running an operation in a previously-initialized directory.
      
      Before any of the recent changes, the logic here was to selectively update
      the hash to include -backend-config settings in the init case. Since
      that late hash recalculation was confusing, here we take the alternative
      path of using the hash only in the normal case and full value comparison
      in the init case. Treating both of these cases separately makes things
      marginally easier to follow here.
      be79bf04
    • Martin Atkins's avatar
      command: Fix TestImport_remoteState · b316e4ab
      Martin Atkins authored
      The import command was imposing the default state path at the CLI level,
      rather than leaving that to be handled by the backend. As a result, the
      output state was always forced to be terraform.tfstate, regardless of
      the backend settings.
      b316e4ab
    • Martin Atkins's avatar
      command: Partially fix TestMetaBackend_planLocalStatePath · 2b9f92be
      Martin Atkins authored
      This test is testing some strange implementation details of the old
      local backend which do not hold with the new filesystem state manager.
      Specifically, it was expecting state to be read from the stateOutPath
      rather than the statePath, which makes no sense here because the backend
      is configured to read from the default terraform.tfstate file (which does
      not exist.)
      
      There is another problem with this test which will be addressed in a
      subsequent commit.
      2b9f92be
    • Martin Atkins's avatar
      command: Fix TestMetaBackend_configuredChangeCopy_multiToNoDefaultWithoutDefault · aecb66d3
      Martin Atkins authored
      As part of integrating the new "remote" backend we relaxed the requirement
      that a "default" workspace must exist in all backends and now skip
      migrating empty workspace states to avoid creating unnecessary "default"
      workspaces when switching between backends that require it and backends
      that don't, such as when switching from the local backend (which always
      has a "default" workspace) to Terraform Enterprise.
      aecb66d3
    • Martin Atkins's avatar
      command: Fix TestMetaBackend_configuredChangeCopy_multiToMulti · ec27526c
      Martin Atkins authored
      This was failing because we now handle the settings for the local backend
      a little differently as a result of decoding it with the HCL2 machinery.
      
      Specifically, the backend.State* fields are now assumed to be what is
      given in configuration, and any CLI overrides are maintained separately
      in OverrideState* fields so that they can be imposed "just in time" in
      StatePaths.
      
      This is particularly important because OverrideStatePath (when set) is
      used regardless of workspace name, while StatePath is a suitable value
      only for the "default" workspace, with others needing to be constructed
      from StateWorkspaceDir instead.
      ec27526c
    • 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 various TestMetaBackend-prefix tests · f39a5d09
      Martin Atkins authored
      Our new state model has a different implementation of "empty" that doesn't
      consider lineage/serial, so we need to have some actual content in these
      state fixtures to avoid them being skipped during state migrations.
      f39a5d09
    • Martin Atkins's avatar
      command: Use statemgr.Import and statemgr.Export for state push and pull · 22c84c71
      Martin Atkins authored
      We previously hacked around the import/export functionality being missing
      in the statemgr layer after refactoring, but now it's been reintroduced
      to fix functionality elsewhere we should use the centralized Import and
      Export functions to ensure consistent behavior.
      
      In particular, this pushes the logic for checking lineage and serial
      during push down into the state manager itself, which is better because
      all other details about lineage and serial are managed within the state
      managers.
      22c84c71
    • Martin Atkins's avatar
      states/statemgr: Fix the Filesystem state manager tests · 985b414d
      Martin Atkins authored
      Now that we're verifying the Terraform version during state loading, we
      need to force a particular Terraform version to use during these tests.
      985b414d
    • 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
    • Martin Atkins's avatar
    • Martin Atkins's avatar
      states/statemgr: Migrate, Import, and Export functions · 94510bc1
      Martin Atkins authored
      In our recent refactoring of the state manager interfaces we made serial
      and lineage management the responsibility of the state managers
      themselves, not exposing them at all to most callers, and allowing for
      simple state managers that don't implement them at all.
      
      However, we do have some specific cases where we need to preserve these
      properly when available, such as migration between backends, and the
      "terraform state push" and "terraform state pull" commands.
      
      These new functions and their associated optional interface allow the
      logic here to be captured in one place and access via some simple
      calls. Separating this from the main interface leaves things simple for
      the normal uses of state managers.
      
      Since these functions are mostly just thin wrappers around other
      functionality, they are not yet well-tested directly, but will be
      indirectly tested through the tests of their callers. A subsequent commit
      will add more unit tests here.
      94510bc1
    • Martin Atkins's avatar
      command: Fix TestMetaBackend_emptyWithExplicitState · 22933912
      Martin Atkins authored
      This test was incorrectly updated in a previous iteration, with it
      creating a modified state to write but then not actually writing it,
      writing an empty test state instead.
      
      This made the test fail because a backup state file is created only if
      the new state snapshot is different to the old when written.
      22933912
  2. 17 Nov, 2018 1 commit
  3. 16 Nov, 2018 13 commits