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. 17 May, 2021 3 commits
    • Martin Atkins's avatar
      Move command/ to internal/command/ · ffe056ba
      Martin Atkins authored
      This is part of a general effort to move all of Terraform's non-library
      package surface under internal in order to reinforce that these are for
      internal use within Terraform only.
      
      If you were previously importing packages under this prefix into an
      external codebase, you could pin to an earlier release tag as an interim
      solution until you've make a plan to achieve the same functionality some
      other way.
      ffe056ba
    • Martin Atkins's avatar
      Move addrs/ to internal/addrs/ · b9a93a0f
      Martin Atkins authored
      This is part of a general effort to move all of Terraform's non-library
      package surface under internal in order to reinforce that these are for
      internal use within Terraform only.
      
      If you were previously importing packages under this prefix into an
      external codebase, you could pin to an earlier release tag as an interim
      solution until you've make a plan to achieve the same functionality some
      other way.
      b9a93a0f
    • Martin Atkins's avatar
      Move providers/ to internal/providers/ · 1409f30f
      Martin Atkins authored
      This is part of a general effort to move all of Terraform's non-library
      package surface under internal in order to reinforce that these are for
      internal use within Terraform only.
      
      If you were previously importing packages under this prefix into an
      external codebase, you could pin to an earlier release tag as an interim
      solution until you've make a plan to achieve the same functionality some
      other way.
      1409f30f
  2. 22 Feb, 2021 1 commit
  3. 18 Feb, 2021 2 commits
    • Alisdair McDiarmid's avatar
      backend/local: Replace CLI with view instance · 68558ccd
      Alisdair McDiarmid authored
      This commit extracts the remaining UI logic from the local backend,
      and removes access to the direct CLI output. This is replaced with an
      instance of a `views.Operation` interface, which codifies the current
      requirements for the local backend to interact with the user.
      
      The exception to this at present is interactivity: approving a plan
      still depends on the `UIIn` field for the backend. This is out of scope
      for this commit and can be revisited separately, at which time the
      `UIOut` field can also be removed.
      
      Changes in support of this:
      
      - Some instances of direct error output have been replaced with
        diagnostics, most notably in the emergency state backup handler. This
        requires reformatting the error messages to allow the diagnostic
        renderer to line-wrap them;
      - The "in-automation" logic has moved out of the backend and into the
        view implementation;
      - The plan, apply, refresh, and import commands instantiate a view and
        set it on the `backend.Operation` struct, as these are the only code
        paths which call the `local.Operation()` method that requires it;
      - The show command requires the plan rendering code which is now in the
        views package, so there is a stub implementation of a `views.Show`
        interface there.
      
      Other refactoring work in support of migrating these commands to the
      common views code structure will come in follow-up PRs, at which point
      we will be able to remove the UI instances from the unit tests for those
      commands.
      68558ccd
    • Kristin Laemmert's avatar
      Mildwonkey/providers interface renaming (#27805) · f6505870
      Kristin Laemmert authored
      * providers.Interface: huge renamification
      
      This commit renames a handful of functions in the providers.Interface to
      match changes made in protocol v6. The following commit implements this
      change across the rest of the codebase; I put this in a separate commit
      for ease of reviewing and will squash these together when merging.
      
      One noteworthy detail: protocol v6 removes the config from the
      ValidateProviderConfigResponse, since it's never been used. I chose to
      leave that in place in the interface until we deprecate support for
      protocol v5 entirely.
      
      Note that none of these changes impact current providers using protocol
      v5; the protocol is unchanged. Only the translation layer between the
      proto and terraform have changed.
      f6505870
  4. 11 Feb, 2021 1 commit
    • Alisdair McDiarmid's avatar
      cli: Add initial command views abstraction · c5a6aa31
      Alisdair McDiarmid authored
      Terraform supports multiple output formats for several sub-commands.
      The default format is user-readable text, but many sub-commands support
      a `-json` flag to output a machine-readable format for the result. The
      output command also supports a `-raw` flag for a simpler, scripting-
      focused machine readable format.
      
      This commit adds a "views" abstraction, intended to help ensure
      consistency between the various output formats. This extracts the render
      specific code from the command package, and moves it into a views
      package. Each command is expected to create an interface for its view,
      and one or more implementations of that interface.
      
      By doing so, we separate the concerns of generating the sub-command
      result from rendering the result in the specified output format. This
      should make it easier to ensure that all output formats will be updated
      together when changes occur in the result-generating phase.
      
      There are some other consequences of this restructuring:
      
      - Views now directly access the terminal streams, rather than the
        now-redundant cli.Ui instance;
      - With the reorganization of commands, parsing CLI arguments is now the
        responsibility of a separate "arguments" package.
      
      For now, views are added only for the output sub-command, as an example.
      Because this command uses code which is shared with the apply and
      refresh commands, those are also partially updated.
      c5a6aa31
  5. 08 Feb, 2021 1 commit
    • Alisdair McDiarmid's avatar
      cli: Improve error for invalid -target flags · 4991cc48
      Alisdair McDiarmid authored
      Errors encountered when parsing flags for apply, plan, and refresh were
      being suppressed. This resulted in a generic usage error when using an
      invalid `-target` flag.
      
      This commit makes several changes to address this. First, these commands
      now output the flag parse error before exiting, leaving at least some
      hint about the error. You can verify this manually with something like:
      
          terraform apply -invalid-flag
      
      We also change how target attributes are parsed, moving the
      responsibility from the flags instance to the command. This allows us to
      customize the diagnostic output to be more user friendly. The
      diagnostics now look like:
      
      ```shellsession
      $ terraform apply -no-color -target=foo
      
      Error: Invalid target "foo"
      
      Resource specification must include a resource type and name.
      ```
      
      Finally, we add test coverage for both parsing of target flags, and at
      the command level for successful use of resource targeting. These tests
      focus on the UI output (via the change summary and refresh logs), as the
      functionality of targeting is covered by the context tests in the
      terraform package.
      4991cc48
  6. 04 Feb, 2021 1 commit
    • Alisdair McDiarmid's avatar
      cli: Better diagnostics for apply positional args · d7613a0a
      Alisdair McDiarmid authored
      The previous changes removing support for using the trailing positional
      argument as a working directory missed a spot in the apply/destroy
      command implementation. We still support this argument for applying a
      saved plan:
      
          terraform apply foo.tfplan
      
      However, if you pass a positional path which doesn't "look like" a plan
      (for example, the path to a configuration directory), Terraform would
      silently ignore it and continue.
      
      This commit fixes that by adding an error message if the user specifies
      a path which the plan loader rejects as not "looking like" a plan. This
      message includes a reference to the `-chdir` flag as a pointer about
      what to do next.
      
      We also rearrange the error message when calling `terraform destroy`
      with a plan file argument, and add test coverage for the above. While
      we're here, update the destroy tests to copy the fixture directory,
      chdir, and defer cleanup.
      d7613a0a
  7. 03 Feb, 2021 1 commit
  8. 12 Jan, 2021 1 commit
  9. 06 Apr, 2020 1 commit
  10. 25 Mar, 2020 1 commit
  11. 11 Mar, 2020 1 commit
  12. 13 Feb, 2020 2 commits
    • James Bardin's avatar
      add missing deps to targeted destroy test · dc8cdd26
      James Bardin authored
      dc8cdd26
    • Kristin Laemmert's avatar
      addrs: embed Provider in AbsProviderConfig instead of Type · 47a16b09
      Kristin Laemmert authored
      a large refactor to addrs.AbsProviderConfig, embedding the addrs.Provider instead of a Type string. I've added and updated tests, added some Legacy functions to support older state formats and shims, and added a normalization step when reading v4 (current) state files (not the added tests under states/statefile/roundtrip which work with both current and legacy-style AbsProviderConfig strings).
      
      The remaining 'fixme' and 'todo' comments are mostly going to be addressed in a subsequent PR and involve looking up a given local provider config's FQN. This is fine for now as we are only working with default assumption.
      47a16b09
  13. 31 Jan, 2020 1 commit
    • Martin Atkins's avatar
      Initial steps towards AbsProviderConfig/LocalProviderConfig separation (#23978) · 8b511524
      Martin Atkins authored
      
      * Introduce "Local" terminology for non-absolute provider config addresses
      
      In a future change AbsProviderConfig and LocalProviderConfig are going to
      become two entirely distinct types, rather than Abs embedding Local as
      written here. This naming change is in preparation for that subsequent
      work, which will also include introducing a new "ProviderConfig" type
      that is an interface that AbsProviderConfig and LocalProviderConfig both
      implement.
      
      This is intended to be largely just a naming change to get started, so
      we can deal with all of the messy renaming. However, this did also require
      a slight change in modeling where the Resource.DefaultProviderConfig
      method has become Resource.DefaultProvider returning a Provider address
      directly, because this method doesn't have enough information to construct
      a true and accurate LocalProviderConfig -- it would need to refer to the
      configuration to know what this module is calling the provider it has
      selected.
      
      In order to leave a trail to follow for subsequent work, all of the
      changes here are intended to ensure that remaining work will become
      obvious via compile-time errors when all of the following changes happen:
      - The concept of "legacy" provider addresses is removed from the addrs
        package, including removing addrs.NewLegacyProvider and
        addrs.Provider.LegacyString.
      - addrs.AbsProviderConfig stops having addrs.LocalProviderConfig embedded
        in it and has an addrs.Provider and a string alias directly instead.
      - The provider-schema-handling parts of Terraform core are updated to
        work with addrs.Provider to identify providers, rather than legacy
        strings.
      
      In particular, there are still several codepaths here making legacy
      provider address assumptions (in order to limit the scope of this change)
      but I've made sure each one is doing something that relies on at least
      one of the above changes not having been made yet.
      
      * addrs: ProviderConfig interface
      
      In a (very) few special situations in the main "terraform" package we need
      to make runtime decisions about whether a provider config is absolute
      or local.
      
      We currently do that by exploiting the fact that AbsProviderConfig has
      LocalProviderConfig nested inside of it and so in the local case we can
      just ignore the wrapping AbsProviderConfig and use the embedded value.
      
      In a future change we'll be moving away from that embedding and making
      these two types distinct in order to represent that mapping between them
      requires consulting a lookup table in the configuration, and so here we
      introduce a new interface type ProviderConfig that can represent either
      AbsProviderConfig or LocalProviderConfig decided dynamically at runtime.
      
      This also includes the Config.ResolveAbsProviderAddr method that will
      eventually be responsible for that local-to-absolute translation, so
      that callers with access to the configuration can normalize to an
      addrs.AbsProviderConfig given a non-nil addrs.ProviderConfig. That's
      currently unused because existing callers are still relying on the
      simplistic structural transform, but we'll switch them over in a later
      commit.
      
      * rename LocalType to LocalName
      Co-authored-by: default avatarKristin Laemmert <mildwonkey@users.noreply.github.com>
      8b511524
  14. 28 Jan, 2020 1 commit
  15. 06 Dec, 2019 1 commit
  16. 20 Nov, 2018 1 commit
    • Sander van Harmelen's avatar
      command/state: lock when pushing state · 79a9a158
      Sander van Harmelen authored
      Next to adding the locking for the `state push` command, this commit also fixes a small bug where the lock would not be propertly released when running the `state show` command.
      
      And finally it renames some variables in the `[un]taint` code in order to try to standardize the var names of a few frequently used variables (e.g. statemgr.Full, states.State, states.SyncState).
      79a9a158
  17. 17 Oct, 2018 6 commits
    • Martin Atkins's avatar
      command: go fmt · 73318a43
      Martin Atkins authored
      73318a43
    • Martin Atkins's avatar
    • Martin Atkins's avatar
    • 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
    • Martin Atkins's avatar
      move "configschema" from "config" to "configs" · 479c6b24
      Martin Atkins authored
      The "config" package is no longer used and will be removed as part
      of the 0.12 release cleanup. Since configschema is part of the
      "new world" of configuration modelling, it makes more sense for
      it to live as a subdirectory of the newer "configs" package.
      479c6b24
    • Martin Atkins's avatar
      command: Update tests for changes in "terraform" package · a270a18a
      Martin Atkins authored
      This is not exhaustive, but it gets the tests in this package compiling
      again and gets most of them working.
      a270a18a
  18. 01 Feb, 2018 1 commit
    • Laura Martin's avatar
      Change -force to -auto-approve when destroying · 6e1e614a
      Laura Martin authored
      Since an early version of Terraform, the `destroy` command has always
      had the `-force` flag to allow an auto approval of the interactive
      prompt. 0.11 introduced `-auto-approve` as default to `false` when using
      the `apply` command.
      
      The `-auto-approve` flag was introduced to reduce ambiguity of it's
      function, but the `-force` flag was never updated for a destroy.
      
      People often use wrappers when automating commands in Terraform, and the
      inconsistency between `apply` and `destroy` means that additional logic
      must be added to the wrappers to do similar functions. Both commands are
      more or less able to run with similar syntax, and also heavily share
      their code.
      
      This commit updates the command in `destroy` to use the `-auto-approve` flag
      making working with the Terraform CLI a more consistent experience.
      
      We leave in `-force` in `destroy` for the time-being and flag it as
      deprecated to ensure a safe switchover period.
      6e1e614a
  19. 09 Jun, 2017 1 commit
    • Martin Atkins's avatar
      Push plugin discovery down into command package · 8364383c
      Martin Atkins authored
      Previously we did plugin discovery in the main package, but as we move
      towards versioned plugins we need more information available in order to
      resolve plugins, so we move this responsibility into the command package
      itself.
      
      For the moment this is just preserving the existing behavior as long as
      there are only internal and unversioned plugins present. This is the
      final state for provisioners in 0.10, since we don't want to support
      versioned provisioners yet. For providers this is just a checkpoint along
      the way, since further work is required to apply version constraints from
      configuration and support additional plugin search directories.
      
      The automatic plugin discovery behavior is not desirable for tests because
      we want to mock the plugins there, so we add a new backdoor for the tests
      to use to skip the plugin discovery and just provide their own mock
      implementations. Most of this diff is thus noisy rework of the tests to
      use this new mechanism.
      8364383c
  20. 15 Feb, 2017 2 commits
  21. 06 Feb, 2017 1 commit
    • James Bardin's avatar
      Add source path argument to testLockState · b80ae5e1
      James Bardin authored
      The new test pattern is to chdir into a temp location for the test, but
      the prevents us from locating the testdata directory in the source. Add
      a source path to testLockState so we can find the statelocker.go source.
      b80ae5e1
  22. 03 Feb, 2017 1 commit
  23. 11 Nov, 2016 1 commit
    • Mitchell Hashimoto's avatar
      terraform: default new graphs on, old graphs behind -Xlegacy-graph · 785cc7b7
      Mitchell Hashimoto authored
      This turns the new graphs on by default and puts the old graphs behind a
      flag `-Xlegacy-graph`. This effectively inverts the current 0.7.x
      behavior with the new graphs.
      
      We've incubated most of these for a few weeks now. We've found issues
      and we've fixed them and we've been using these graphs internally for
      awhile without any major issue. Its time to default them on and get them
      part of a beta.
      785cc7b7
  24. 11 Sep, 2015 1 commit
  25. 31 Mar, 2015 1 commit
    • Paul Hinze's avatar
      core: targeted operations · 97acccd3
      Paul Hinze authored
      Add `-target=resource` flag to core operations, allowing users to
      target specific resources in their infrastructure. When `-target` is
      used, the operation will only apply to that resource and its
      dependencies.
      
      The calculated dependencies are different depending on whether we're
      running a normal operation or a `terraform destroy`.
      
      Generally, "dependencies" refers to ancestors: resources falling
      _before_ the target in the graph, because their changes are required to
      accurately act on the target.
      
      For destroys, "dependencies" are descendents: those resources which fall
      _after_ the target. These resources depend on our target, which is going
      to be destroyed, so they should also be destroyed.
      97acccd3
  26. 03 Oct, 2014 1 commit
  27. 01 Oct, 2014 1 commit