From 125e9d69d49528e1f58c5098b4b18102eca6cd1c Mon Sep 17 00:00:00 2001 From: Kristin Laemmert Date: Mon, 22 Mar 2021 10:51:03 -0400 Subject: [PATCH] terraform-bundle: return an error if "versions" argument is omitted (#28158) --- tools/terraform-bundle/config.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/terraform-bundle/config.go b/tools/terraform-bundle/config.go index 20dd61a3a..268df65d3 100644 --- a/tools/terraform-bundle/config.go +++ b/tools/terraform-bundle/config.go @@ -72,10 +72,14 @@ func (c *Config) validate() error { return fmt.Errorf("providers.%s: %s", k, diags.Err().Error()) } } - for _, c := range cs.Versions { - if _, err := getproviders.ParseVersionConstraints(c); err != nil { - return fmt.Errorf("providers.%s: %s", k, err) + if len(cs.Versions) > 0 { + for _, c := range cs.Versions { + if _, err := getproviders.ParseVersionConstraints(c); err != nil { + return fmt.Errorf("providers.%s: %s", k, err) + } } + } else { + return fmt.Errorf("provider.%s: required \"versions\" argument not found", k) } }