Merge pull request #10318 from hashicorp/b-ds-prov

config: validate that data sources don't have provisioners
This commit is contained in:
Mitchell Hashimoto 2016-11-23 08:48:52 -08:00 committed by GitHub
commit a017482981
3 changed files with 19 additions and 0 deletions

View File

@ -610,6 +610,15 @@ func (c *Config) Validate() error {
"%s: lifecycle ignore_changes cannot contain interpolations",
n))
}
// If it is a data source then it can't have provisioners
if r.Mode == DataResourceMode {
if _, ok := r.RawConfig.Raw["provisioner"]; ok {
errs = append(errs, fmt.Errorf(
"%s: data sources cannot have provisioners",
n))
}
}
}
for source, vs := range vars {

View File

@ -161,6 +161,13 @@ func TestConfigValidate_table(t *testing.T) {
true,
"non-existent module 'foo'",
},
{
"data source with provisioners",
"validate-data-provisioner",
true,
"data sources cannot have",
},
}
for i, tc := range cases {

View File

@ -0,0 +1,3 @@
data "foo" "bar" {
provisioner "local-exec" {}
}