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
      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
    • Martin Atkins's avatar
    • Martin Atkins's avatar
      core: update Stringer implementations for GraphType and walkOperation · c9bfbf58
      Martin Atkins authored
      These are no longer correct due to the input walk being removed in an
      earlier commit.
      c9bfbf58
    • Martin Atkins's avatar
      core: remove TestContext2Apply_outputInvalid · 368a76ea
      Martin Atkins authored
      This was testing that returning a number as an output would be reported as
      an error, but that is intentionally allowed now.
      368a76ea
    • Martin Atkins's avatar
      core: Fix TestContextImport_providerVarConfig · 44c88dc9
      Martin Atkins authored
      I updated the "Variables" map incorrectly in earlier commit 10fe50bbdb
      while making bulk updates to get the tests compiling again with the
      changed underlying APIs.
      
      The original value here was "bar", incorrectly changed to "foo" in that
      commit. Here we return it back to "bar".
      44c88dc9
    • James Bardin's avatar
      core: attach provisioner schemas in subgraphs · 5b66703c
      James Bardin authored
      DynamicExpand also needs to add the provisioner schemas to make sure all
      references are found in the subgraph.
      5b66703c
    • Martin Atkins's avatar
      core: Don't save provider input for non-root module · edb56a7e
      Martin Atkins authored
      We only support provider input for the root module. This is already
      checked in ProviderInput, but was not checked in SetProviderInput. We
      can't actually do anything particularly clever with an invalid call here,
      but we will at least generate a WARN log to help with debugging.
      
      Also need to update TestBuiltinEvalContextProviderInput to expect this
      new behavior of ignoring input for non-root modules.
      edb56a7e
    • Martin Atkins's avatar
      core: Correct schema for TestContext2Apply_issue5254 · d216b2aa
      Martin Atkins authored
      This test is now failing due to the fact that WritePlan is currently
      disabled pending a rewrite. This will be addressed in a subsequent commit.
      d216b2aa
    • Martin Atkins's avatar
      core: Fix TestContext2Refresh_dataState · 3895b23f
      Martin Atkins authored
      Now that we fetch schemas during NewContext, we need to configure the
      mock GetSchema method before constructing the context.
      3895b23f
    • James Bardin's avatar
      core: TestContext2Apply_dataDependsOn · acd5e224
      James Bardin authored
      acd5e224
    • James Bardin's avatar
      core: TestContext2Validate_interpolateMap · 56be68f6
      James Bardin authored
      56be68f6
    • Martin Atkins's avatar
      core: Don't create indirect provider dependencies for references · 824efdde
      Martin Atkins authored
      The prior commit changed the schema-access model so that all schemas are
      fetched up front during context creation and are then readily available
      for use throughout graph building and evaluation.
      
      As a result, we no longer need to create dependency edges to a provider
      when one of its resources is referenced by another node, and so the
      ProviderTransformer needs only to worry about direct ownership
      dependencies.
      
      This also avoids the need for us to run AttachSchemaTransformer twice,
      since ProviderTransformer no longer needs schema and we can therefore
      defer attaching until just before ReferenceTransformer, when all of the
      referencable and referencing nodes are already present in the graph.
      824efdde
    • Martin Atkins's avatar
    • Martin Atkins's avatar
      core: Stop loading provider schema during graph walk · 733e3b32
      Martin Atkins authored
      We now fetch all of the necessary schemas during context creation, so we
      can just thread that repository of schemas through into EvalContext and
      Evaluator and access the schemas as needed without any further fetching.
      
      This requires updating a few tests to have a valid Provider address in
      their state objects, because we need that in order to trigger the loading
      of the relevant schema.
      733e3b32
    • James Bardin's avatar
      core: TestContext2Validate_interpolateMap · 75b9077c
      James Bardin authored
      75b9077c
    • Martin Atkins's avatar
      core: Schema for TestContext2Apply_multiProviderDestroy · 5b000eee
      Martin Atkins authored
      This test depends on having a correct schema, so we'll specify the minimum
      schema for its fixture inline here rather than using the superset schema
      returned by testProvider.
      5b000eee
    • Martin Atkins's avatar
      core: Remove machinery for the "input" walk · 9ae44977
      Martin Atkins authored
      Provider input is now longer handled with a graph walk, so the code
      related to the input graph and walk are no longer needed.
      
      For now the Input method is retained on the ResourceProvider interface,
      but it will never be called. Subsequent work to revamp the provider API
      will remove this method.
      9ae44977
    • James Bardin's avatar
      core: TestContext2Apply_createBeforeDestroy_hook · 6d4b3d79
      James Bardin authored
      The instnace info ID has changed, and no longer reflects the type of
      node. Record the state to determine apply order for this test.
      6d4b3d79
    • James Bardin's avatar
      core: TestContext2Apply_createBeforeDestroyUpdate · 1a58b185
      James Bardin authored
      The test fixture no longer changes the ID on updates.
      1a58b185
    • James Bardin's avatar
      core: GraphNodeAttachDestroyer · 6257a81f
      James Bardin authored
      Add a graphNodeAttachDestroy interface, so destroy nodes can be attached
      to their companion create node. The creator can then reference the
      CreateBeforeDestroy status of the destroyer, determining  if the current
      state needs to be replaced or deposed.
      
      This is needed when a node is forced to become CreateBeforeDestroy by a
      dependency rather than the config, since because the config is
      immutable, only the destroyer is aware that it has been forced
      CreateBeforeDestroy.
      6257a81f
    • Martin Atkins's avatar
      core: EvalDiffDestroy only update state if requested · b87063ca
      Martin Atkins authored
      The earlier change 5f07201a made it so that the state is always rewritten
      by EvalDiffDestroy, but that was too disruptive to other users of
      EvalDiffDestroy.
      
      Now we follow the lead of EvalDiff and have a separate pointer for the
      _output_ state, which allows the caller to opt in to having its state
      pointer updated to reflect the new (nil) state.
      
      NodePlannableResourceInstanceOrphan is the only caller that currently opts
      in to this, since that was the focus of 5f07201a. We may need to make a
      similar change to other plannable resource destroy nodes, but we'll wait
      to see if that needs to be done in a subsequent commit.
      b87063ca