diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/config/config.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/config/config.go | 64 |
1 files changed, 1 insertions, 63 deletions
diff --git a/vendor/github.com/hashicorp/terraform/config/config.go b/vendor/github.com/hashicorp/terraform/config/config.go index 9a764ac..a157824 100644 --- a/vendor/github.com/hashicorp/terraform/config/config.go +++ b/vendor/github.com/hashicorp/terraform/config/config.go | |||
@@ -545,7 +545,7 @@ func (c *Config) Validate() error { | |||
545 | 545 | ||
546 | // Verify provisioners | 546 | // Verify provisioners |
547 | for _, p := range r.Provisioners { | 547 | for _, p := range r.Provisioners { |
548 | // This validation checks that there are now splat variables | 548 | // This validation checks that there are no splat variables |
549 | // referencing ourself. This currently is not allowed. | 549 | // referencing ourself. This currently is not allowed. |
550 | 550 | ||
551 | for _, v := range p.ConnInfo.Variables { | 551 | for _, v := range p.ConnInfo.Variables { |
@@ -705,17 +705,6 @@ func (c *Config) Validate() error { | |||
705 | } | 705 | } |
706 | } | 706 | } |
707 | 707 | ||
708 | // Check that all variables are in the proper context | ||
709 | for source, rc := range c.rawConfigs() { | ||
710 | walker := &interpolationWalker{ | ||
711 | ContextF: c.validateVarContextFn(source, &errs), | ||
712 | } | ||
713 | if err := reflectwalk.Walk(rc.Raw, walker); err != nil { | ||
714 | errs = append(errs, fmt.Errorf( | ||
715 | "%s: error reading config: %s", source, err)) | ||
716 | } | ||
717 | } | ||
718 | |||
719 | // Validate the self variable | 708 | // Validate the self variable |
720 | for source, rc := range c.rawConfigs() { | 709 | for source, rc := range c.rawConfigs() { |
721 | // Ignore provisioners. This is a pretty brittle way to do this, | 710 | // Ignore provisioners. This is a pretty brittle way to do this, |
@@ -787,57 +776,6 @@ func (c *Config) rawConfigs() map[string]*RawConfig { | |||
787 | return result | 776 | return result |
788 | } | 777 | } |
789 | 778 | ||
790 | func (c *Config) validateVarContextFn( | ||
791 | source string, errs *[]error) interpolationWalkerContextFunc { | ||
792 | return func(loc reflectwalk.Location, node ast.Node) { | ||
793 | // If we're in a slice element, then its fine, since you can do | ||
794 | // anything in there. | ||
795 | if loc == reflectwalk.SliceElem { | ||
796 | return | ||
797 | } | ||
798 | |||
799 | // Otherwise, let's check if there is a splat resource variable | ||
800 | // at the top level in here. We do this by doing a transform that | ||
801 | // replaces everything with a noop node unless its a variable | ||
802 | // access or concat. This should turn the AST into a flat tree | ||
803 | // of Concat(Noop, ...). If there are any variables left that are | ||
804 | // multi-access, then its still broken. | ||
805 | node = node.Accept(func(n ast.Node) ast.Node { | ||
806 | // If it is a concat or variable access, we allow it. | ||
807 | switch n.(type) { | ||
808 | case *ast.Output: | ||
809 | return n | ||
810 | case *ast.VariableAccess: | ||
811 | return n | ||
812 | } | ||
813 | |||
814 | // Otherwise, noop | ||
815 | return &noopNode{} | ||
816 | }) | ||
817 | |||
818 | vars, err := DetectVariables(node) | ||
819 | if err != nil { | ||
820 | // Ignore it since this will be caught during parse. This | ||
821 | // actually probably should never happen by the time this | ||
822 | // is called, but its okay. | ||
823 | return | ||
824 | } | ||
825 | |||
826 | for _, v := range vars { | ||
827 | rv, ok := v.(*ResourceVariable) | ||
828 | if !ok { | ||
829 | return | ||
830 | } | ||
831 | |||
832 | if rv.Multi && rv.Index == -1 { | ||
833 | *errs = append(*errs, fmt.Errorf( | ||
834 | "%s: use of the splat ('*') operator must be wrapped in a list declaration", | ||
835 | source)) | ||
836 | } | ||
837 | } | ||
838 | } | ||
839 | } | ||
840 | |||
841 | func (c *Config) validateDependsOn( | 779 | func (c *Config) validateDependsOn( |
842 | n string, | 780 | n string, |
843 | v []string, | 781 | v []string, |