diff --git a/chef/provider.go b/chef/provider.go index c1b2d8f4..1e4e7927 100644 --- a/chef/provider.go +++ b/chef/provider.go @@ -22,6 +22,7 @@ func Provider() terraform.ResourceProvider { Required: true, DefaultFunc: schema.EnvDefaultFunc("CHEF_SERVER_URL", nil), Description: "URL of the root of the target Chef server or organization.", + ValidateFunc: validateServerURL, }, "client_name": { Type: schema.TypeString, @@ -63,6 +64,14 @@ func Provider() terraform.ResourceProvider { } } +func validateServerURL(val interface{}, key string) (warns []string, errs []error) { + url := val.(string) + if !strings.HasSuffix(url, "/") { + errs = append(errs, fmt.Errorf("Chef Server URL %s must end with a slash", url)) + } + return +} + func providerConfigure(d *schema.ResourceData) (interface{}, error) { config := &chefc.Config{ Name: d.Get("client_name").(string),