]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/github.com/hashicorp/terraform/terraform/interpolate.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / terraform / interpolate.go
index 4f4e178cf390e9efdc4d9c548e0343a43c125fe1..26c185751a69a14e99efe7d335c376acfd93e934 100644 (file)
@@ -45,65 +45,7 @@ type InterpolationScope struct {
 func (i *Interpolater) Values(
        scope *InterpolationScope,
        vars map[string]config.InterpolatedVariable) (map[string]ast.Variable, error) {
-       if scope == nil {
-               scope = &InterpolationScope{}
-       }
-
-       result := make(map[string]ast.Variable, len(vars))
-
-       // Copy the default variables
-       if i.Module != nil && scope != nil {
-               mod := i.Module
-               if len(scope.Path) > 1 {
-                       mod = i.Module.Child(scope.Path[1:])
-               }
-               for _, v := range mod.Config().Variables {
-                       // Set default variables
-                       if v.Default == nil {
-                               continue
-                       }
-
-                       n := fmt.Sprintf("var.%s", v.Name)
-                       variable, err := hil.InterfaceToVariable(v.Default)
-                       if err != nil {
-                               return nil, fmt.Errorf("invalid default map value for %s: %v", v.Name, v.Default)
-                       }
-
-                       result[n] = variable
-               }
-       }
-
-       for n, rawV := range vars {
-               var err error
-               switch v := rawV.(type) {
-               case *config.CountVariable:
-                       err = i.valueCountVar(scope, n, v, result)
-               case *config.ModuleVariable:
-                       err = i.valueModuleVar(scope, n, v, result)
-               case *config.PathVariable:
-                       err = i.valuePathVar(scope, n, v, result)
-               case *config.ResourceVariable:
-                       err = i.valueResourceVar(scope, n, v, result)
-               case *config.SelfVariable:
-                       err = i.valueSelfVar(scope, n, v, result)
-               case *config.SimpleVariable:
-                       err = i.valueSimpleVar(scope, n, v, result)
-               case *config.TerraformVariable:
-                       err = i.valueTerraformVar(scope, n, v, result)
-               case *config.LocalVariable:
-                       err = i.valueLocalVar(scope, n, v, result)
-               case *config.UserVariable:
-                       err = i.valueUserVar(scope, n, v, result)
-               default:
-                       err = fmt.Errorf("%s: unknown variable type: %T", n, rawV)
-               }
-
-               if err != nil {
-                       return nil, err
-               }
-       }
-
-       return result, nil
+       return nil, fmt.Errorf("type Interpolator is no longer supported; use the evaluator API instead")
 }
 
 func (i *Interpolater) valueCountVar(
@@ -153,7 +95,7 @@ func (i *Interpolater) valueModuleVar(
        defer i.StateLock.RUnlock()
 
        // Get the module where we're looking for the value
-       mod := i.State.ModuleByPath(path)
+       mod := i.State.ModuleByPath(normalizeModulePath(path))
        if mod == nil {
                // If the module doesn't exist, then we can return an empty string.
                // This happens usually only in Refresh() when we haven't populated
@@ -257,13 +199,13 @@ func (i *Interpolater) valueResourceVar(
        }
 
        if variable == nil {
-               // During the input walk we tolerate missing variables because
+               // During the refresh walk we tolerate missing variables because
                // we haven't yet had a chance to refresh state, so dynamic data may
                // not yet be complete.
                // If it truly is missing, we'll catch it on a later walk.
                // This applies only to graph nodes that interpolate during the
-               // config walk, e.g. providers.
-               if i.Operation == walkInput || i.Operation == walkRefresh {
+               // refresh walk, e.g. providers.
+               if i.Operation == walkRefresh {
                        result[n] = unknownVariable()
                        return nil
                }
@@ -365,7 +307,7 @@ func (i *Interpolater) valueLocalVar(
        }
 
        // Get the relevant module
-       module := i.State.ModuleByPath(scope.Path)
+       module := i.State.ModuleByPath(normalizeModulePath(scope.Path))
        if module == nil {
                result[n] = unknownVariable()
                return nil
@@ -584,10 +526,7 @@ MISSING:
        //
        // For a Destroy, we're also fine with computed values, since our goal is
        // only to get destroy nodes for existing resources.
-       //
-       // For an input walk, computed values are okay to return because we're only
-       // looking for missing variables to prompt the user for.
-       if i.Operation == walkRefresh || i.Operation == walkPlanDestroy || i.Operation == walkInput {
+       if i.Operation == walkRefresh || i.Operation == walkPlanDestroy {
                return &unknownVariable, nil
        }
 
@@ -607,13 +546,6 @@ func (i *Interpolater) computeResourceMultiVariable(
 
        unknownVariable := unknownVariable()
 
-       // If we're only looking for input, we don't need to expand a
-       // multi-variable. This prevents us from encountering things that should be
-       // known but aren't because the state has yet to be refreshed.
-       if i.Operation == walkInput {
-               return &unknownVariable, nil
-       }
-
        // Get the information about this resource variable, and verify
        // that it exists and such.
        module, cr, err := i.resourceVariableInfo(scope, v)
@@ -695,7 +627,7 @@ func (i *Interpolater) computeResourceMultiVariable(
                //
                // For an input walk, computed values are okay to return because we're only
                // looking for missing variables to prompt the user for.
-               if i.Operation == walkRefresh || i.Operation == walkPlanDestroy || i.Operation == walkDestroy || i.Operation == walkInput {
+               if i.Operation == walkRefresh || i.Operation == walkPlanDestroy || i.Operation == walkDestroy {
                        return &unknownVariable, nil
                }
 
@@ -776,7 +708,7 @@ func (i *Interpolater) resourceVariableInfo(
        }
 
        // Get the relevant module
-       module := i.State.ModuleByPath(scope.Path)
+       module := i.State.ModuleByPath(normalizeModulePath(scope.Path))
        return module, cr, nil
 }