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 Jun, 2018 40 commits
    • Martin Atkins's avatar
      command: 0.12upgrade command · c2987cd2
      Martin Atkins authored
      This is the frontend to the work-in-progress codepath for upgrading the
      source code for a module written for Terraform v0.11 or earlier to use
      the new syntax and idiom of v0.12.
      
      The underlying upgrade code is not yet complete as of this commit, and
      so the command is not yet very useful. We will continue to iterate on
      the upgrade code in subsequent commits.
      c2987cd2
    • Martin Atkins's avatar
      configupgrade: Basic expression formatting · ca487512
      Martin Atkins authored
      This covers all of the expression node types in HIL's AST, and also
      includes initial support for some of our top-level blocks so that we can
      easily test that.
      
      The initial implementations of the "variable" and "output" blocks are
      pretty redundant and messy, so we can hopefully improve on these in a
      later pass.
      ca487512
    • Martin Atkins's avatar
      configupgrade: Beginnings of Upgrade function · 1c5d05b1
      Martin Atkins authored
      This function is the main functionality of this package. So far it just
      deals with detecting and renaming JSON files that are mislabeled as
      native syntax files. Other functionality will follow in later commits.
      1c5d05b1
    • Martin Atkins's avatar
      configupgrade: Load source code for a module and detect already upgraded · 79b36116
      Martin Atkins authored
      This package will do all of its work in-memory so that it can avoid making
      partial updates and then failing, so we need to be able to load the
      sources files from a particular directory into memory.
      
      The upgrade process isn't idempotent, so we also attempt to detect
      heuristically whether an upgrade has already been performed (can parse
      with the new parser and has a version constraint that prevents versions
      earlier than 0.12) so that the CLI tool that will eventually wrap this
      will be able to produce a warning and prompt for confirmation in that
      case.
      79b36116
    • Martin Atkins's avatar
      configupgrade: new package for upgrading configs for 0.12 · 34b0a20e
      Martin Atkins authored
      Although the new HCL implementation and configuration loader is broadly
      compatible with the prior implementation, it has a number of new idiomatic
      forms and it also cannot parse some more extreme non-idiomatic usages
      that were possible under the old parser.
      
      To help users migrate to the new implementation, this package will rewrite
      configuration to comply with the new idiom and fix as many cases as
      possible where the legacy parser was too liberal or exposed implementation
      details.
      34b0a20e
    • Martin Atkins's avatar
      configload: Don't download the same module source multiple times · 2b124a1d
      Martin Atkins authored
      It is common for the same module source package to be referenced multiple
      times in the same configuration, either because there are literally
      multiple instances of the same module source or because a single package
      (or repository) contains multiple modules in sub-directories and many
      of them are referenced.
      
      To optimize this, here we introduce a simple caching behavior where the
      module installer will detect if it's asked to install multiple times from
      the same source and produce the second and subsequent directories by
      copying the first, rather than by downloading again over the network.
      
      This optimization is applied once all of the go-getter detection has
      completed and sub-directory portions have been trimmed, so it is also
      able to normalize differently-specified source addresses that all
      ultimately detect to the same resolved address. When installing, we
      always extract the entire specified package (or repository) and then
      reference the specified sub-directory, so we can safely re-use existing
      directories when the base package is the same, even if the sub-directory
      is different.
      
      However, as a result we do not yet address the fact that the same package
      will be stored multiple times _on disk_, which may still be problematic
      when referencing large repositories multiple times in
      disk-storage-constrained environments. We could address this in a
      subsequent change by investigating the use of symlinks where possible.
      
      Since the Registry installer is implemented just as an extra resolution
      step in front of go-getter, this optimization applies to registry
      modules too. This does not apply to local relative references, which will
      continue to just resolve into the already-prepared directory of their
      parent module.
      
      The cache of previously installed paths lives only for the duration of
      one call to InstallModules, so we will never re-use directories that
      were created by previous runs of "terraform init" and there is no risk
      that older versions will pollute the cache when attempting an upgrade
      from a source address that doesn't explicitly specify a version.
      
      No additional tests are added here because the existing module installer
      tests (when TF_ACC=1) already cover the case of installing multiple
      modules from the same source.
      2b124a1d
    • James Bardin's avatar
      add GetSchema to provisioner interface · 119665ec
      James Bardin authored
      119665ec
    • James Bardin's avatar
      Add ImportedResource type · 661848d3
      James Bardin authored
      The ImportResourceStateResponse command can return mutliple types.
      ImportedResource maps the state to the appropriate type name, and also
      allows providers to return Private data for each resource.
      661848d3
    • James Bardin's avatar
      use cty.Value for connection info · b385c862
      James Bardin authored
      For now this will be an encoded map, but it allows for a more complex
      schema in the future.
      b385c862
    • James Bardin's avatar
      rename UpgradedState · 483490f8
      James Bardin authored
      483490f8
    • James Bardin's avatar
      split PriorStateRaw into JSON and Flatmap · d694076f
      James Bardin authored
      This way the provider doesn't need to be concerned with determining the
      state encoding.
      d694076f
    • James Bardin's avatar
      add versions to the provider schemas · 39650828
      James Bardin authored
      We need to know the schema version for all resources. This is stored in
      order to allow providers to upgrade the state from a known previous
      version.
      39650828
    • James Bardin's avatar
      rename provider and provisioner packages · b942eb7f
      James Bardin authored
      Using plural names to avoid collisions in existing code.
      b942eb7f
    • Martin Atkins's avatar
      tfdiags: Sort order for diagnostics · 3d304efd
      Martin Atkins authored
      Because we gather together diagnostics from many different parts of the
      codebase, the list often ends up being in a non-ideal order. Here we
      define a partial ordering for diagnostics that should hopefully make them
      easier to scan when many are present, by grouping together diagnostics
      that are of the same severity and belong to the same file.
      
      We use sort.Stable here because we have a partial order and so we need
      to make sure that diagnostics that do not have a relative ordering will
      remain in their original order.
      
      This sorting is applied just in time before rendering the diagnostics
      in command.Meta.showDiagnostics.
      3d304efd
    • James Bardin's avatar
      Add provider plugin interface and types · 2b5ae042
      James Bardin authored
      This adds the new interface for the resource providers. The methods here
      closely follow the grpc service methods, using the types expected in
      terraform core
      2b5ae042
    • James Bardin's avatar
      Add provisioner interface and request types · 56a9af82
      James Bardin authored
      This adds the interface for the new resource provisioners.
      The methods closely follow the grpc service methods, using the type
      expected within terraform core.
      56a9af82
    • Martin Atkins's avatar
      plans/planfile: Reading and writing the new plan format · 4466754b
      Martin Atkins authored
      The new format is radically different in than the old in physical
      structure, but still has the same logical parts: the plan itself, a
      snapshot of the input configuration, and a snapshot of the state as it
      existed when the plan was created.
      
      Rather than creating plan-specific serializations of state and config, the
      new format instead leans on the existing file formats implemented
      elsewhere, wrapping the result up in a zip archive with some internal file
      naming conventions.
      
      The plan portion of the file is serialized with protobuf, consistent with
      our general strategy of replacing all use of encoding/gob with protobuf
      moving forward.
      4466754b
    • Martin Atkins's avatar
      plans: New package for in-memory plan models · ab3dccff
      Martin Atkins authored
      The types in this package are intended to replace plan- and diff-related
      types from the "terraform" package, although those older types must remain
      for now so that they can be used to implement shims for older codepaths.
      
      type "Changes" is approximately equivalent to terraform.Diff, but renamed
      since it now describes whole objects before and after rather than an
      attribute-level diff as before. The term "diff" is now reserved for the
      visual rendition of the changes we'll display to the user, although
      rendering of this new Changes model is not yet implemented.
      ab3dccff
    • Martin Atkins's avatar
      configload: Configuration snapshots · 628a846b
      Martin Atkins authored
      Here we introduce a new idea of a "configuration snapshot", which is an
      in-memory copy of the source code of each of the files that make up
      the configuration. The primary intended purpose for this is as an
      intermediate step before writing the configuration files into a plan file,
      and then reading them out when that plan file is later applied.
      
      During earlier configs package development we expected to use an afero vfs
      implementation to read directly from the zip file, but that doesn't work
      in practice because we need to preserve module paths from the source file
      system that might include parent directory traversals (../) while
      retaining the original path for use in error messages.
      
      The result, for now, is a bit of an abstraction inversion: we implement
      a specialized afero vfs implementation that makes the sparse filesystem
      representation from a snapshot appear like a normal filesystem just well
      enough that the config loader and parser can work with it.
      
      In future we may wish to rework the internals here so that the main
      abstraction is at a similar level to the snapshot and then that API is
      mapped to the native filesystem in the normal case, removing afero. For
      now though, this approach avoids the need for a significant redesign
      of the parser/loader internals, at the expense of some trickiness in the
      case where we're reading from a snapshot.
      
      This commit does not yet include the reading and writing of snapshots into
      plan files. That will follow in a subsequent commit.
      628a846b
    • Martin Atkins's avatar
      govendor fetch github.com/zclconf/go-cty/cty/... · f98ca58f
      Martin Atkins authored
      This allows automatic conversions between different object types as long
      as the target type is a subset of the given type.
      f98ca58f
    • Martin Atkins's avatar
      govendor fetch github.com/zclconf/go-cty/cty/... · 2a5d6348
      Martin Atkins authored
      The existing cty packages were already at the latest version, but we were
      not yet vendoring the msgpack package.
      
      This also imports some dependencies from:
          github.com/vmihailenco/msgpack
      2a5d6348
    • Martin Atkins's avatar
      40816dcd
    • Martin Atkins's avatar
      states: New SyncState type · 8f45d020
      Martin Atkins authored
      This is a wrapper around State that is able to perform higher-level
      manipulations (at the granularity of the entire state) in a
      concurrency-safe manner, using the lower-level APIs exposed by State and
      all of the types it contains.
      
      The granularity of a SyncState operation roughly matches the granularity
      off a state-related EvalNode in the "terraform" package, performing a
      sequence of more primitive operations while guaranteeing atomicity of the
      entire change.
      
      As a compromise for convenience of usage, it's still possible to access
      the individual state data objects via this API, but they are always copied
      before returning to ensure that two distinct callers cannot have data
      races. Callers should access the most granular object possible for their
      operation.
      8f45d020
    • Martin Atkins's avatar
      statemgr: New package for state managers · 1235b69f
      Martin Atkins authored
      This idea of a "state manager" was previously modelled via the
      confusingly-named state.State interface, which we've been calling a "state
      manager" only in some local variable names in situations where there were
      also *terraform.State variables.
      
      As part of reworking our state models to make room for the new type
      system, we also need to change what was previously the state.StateReader
      interface. Since we've found the previous organization confusing anyway,
      here we just copy all of those interfaces over into statemgr where we can
      make the relationship to states.State hopefully a little clearer.
      
      This is not yet a complete move of the functionality from "state", since
      we're not yet ready to break existing callers. In a future commit we'll
      turn the interfaces in the old "state" package into aliases of the
      interfaces in this package, and update all the implementers of what will
      by then be statemgr.Reader to use *states.State instead of
      *terraform.State.
      
      This also includes an adaptation of what was previously state.LocalState
      into statemgr.FileSystem, using the new state serialization functionality
      from package statefile instead of the old terraform.ReadState and
      terraform.WriteState.
      1235b69f
    • Martin Atkins's avatar
      statefile: New package for loading and saving state files · cb8225d2
      Martin Atkins authored
      Whereas the parent directory "states" contains the models that represent
      state in memory, this package's responsibility is in serializing a subset
      of that data to a JSON-based file format and then reloading that data
      back into memory later.
      
      For reading, this package supports state file formats going back to
      version 1, using lightly-adapted versions of the migration code previously
      used in the "terraform" package. State data is upgraded to the latest
      version step by step and then transformed into the in-memory state
      representation, which is distinct from any of the file format structs in
      this package to enable these to evolve separately.
      
      For writing, only the latest version (4) is supported, which is a new
      format that is a slightly-flattened version of the new in-memory state
      models introduced in the prior commit. This format retains the outputs
      from only the root module and it flattens out the module and instance
      parts of the hierarchy by including the identifiers for these inside
      the child object. The loader then reconstructs the multi-layer structure
      we use for more convenient access in memory.
      
      For now, the only testing in this package is of round-tripping different
      versions of state through a read and a write, ensuring the output is
      as desired. This exercises all of the reading, upgrading, and writing
      functions but should be augmented in later commits to improve coverage
      and introduce more focused tests for specific parts of the functionality.
      cb8225d2
    • Martin Atkins's avatar
      states: New package with modern models for Terraform state · 60ac0956
      Martin Atkins authored
      Our previous state models in the "terraform" package had a few limitations
      that are addressed here:
      
      - Instance attributes were stored as map[string]string with dot-separated
        keys representing traversals through a data structure. Now that we have
        a full type system, it's preferable to store it as a real data
        structure.
      
      - The existing state structures skipped over the "resource" concept and
        went straight to resource instance, requiring heuristics to decide
        whether a particular resource should appear as a single object or as
        a list of objects when used in configuration expressions.
      
      - Related to the previous point, the state models also used incorrect
        terminology where "ResourceState" was really a resource instance state
        and "InstanceState" was really the state of a particular remote object
        associated with an instance. These new models use the correct names for
        each of these, introducing the idea of a "ResourceInstanceObject" as
        the local record of a remote object associated with an instance.
      
      This is a first pass at fleshing out a new model for state. Undoubtedly
      there will be further iterations of this as we work on integrating these
      new models into the "terraform" package.
      
      These new model types no longer serve double-duty as a description of the
      JSON state file format, since they are for in-memory use only. A
      subsequent commit will introduce a separate package that deals with
      persisting state to files and reloading those files later.
      60ac0956
    • Martin Atkins's avatar
      addrs: More string parsing helpers for addresses · 92dca163
      Martin Atkins authored
      Our main "parse" methods in this package work with hcl.Traversals, but
      we're gradually adding helpers to parse these directly froms strings since
      the visual noise of doing the traversal parse first is inconvenient in
      situations where addresses are coming from non-config locations where
      no source information is available anyway.
      92dca163
    • Martin Atkins's avatar
      addrs: "Less" comparison method for resource and module instances · 05d295eb
      Martin Atkins authored
      This can be used to sort lists of resource instance and module instance
      addresses, such as in a rendered plan.
      05d295eb
    • Kristin Laemmert's avatar
      minor fixes · 013d5146
      Kristin Laemmert authored
      013d5146
    • Kristin Laemmert's avatar
      2a28480c
    • Kristin Laemmert's avatar
      99c6aff0
    • Kristin Laemmert's avatar
      functions: pr feedback fixes · 825cd882
      Kristin Laemmert authored
      825cd882
    • Kristin Laemmert's avatar
    • Kristin Laemmert's avatar
      functions: ZipmapFunc · c4e42da7
      Kristin Laemmert authored
      c4e42da7
    • Martin Atkins's avatar
      Fix up some missed "go fmt" · 7f205645
      Martin Atkins authored
      Because of the size of some of these files, automatic format-on-save was
      implicitly disabled in my editor, which I didn't notice before committing.
      7f205645
    • James Bardin's avatar
      core: use absolute address in CloserProvider · 63ca238c
      James Bardin authored
      Otherwsie relative addresses may collide and close the incorrect
      provider.
      63ca238c
    • James Bardin's avatar
      core: run ProvisionerTransformer during plan · bd124410
      James Bardin authored
      This makes sure the graph is complete for validation
      bd124410
    • Martin Atkins's avatar
      website: "functions" layout "Terraform Language" is back · d65dfcdd
      Martin Atkins authored
      In the heirarchy, both "Terraform Language" and "Functions" are "up" from
      the individual function reference pages, so we'll class them as such to
      use the back-facing arrow instead of the forward-facing arrow.
      d65dfcdd
    • Martin Atkins's avatar
      website: document the functions "keys", "lookup", and "values" · e405b58c
      Martin Atkins authored
      I missed these on the first pass because in the legacy function table they
      are, for some reason, added in a different place than the others.
      e405b58c
    • Martin Atkins's avatar
      helper/schema: Tolerate incorrectly-specified collection elems · fa9d7f4d
      Martin Atkins authored
      We historically tolerated this, so we need to tolerate it here too in
      order to work correctly with existing provider code.
      fa9d7f4d