config: validate that data sources don't have provisioners
This commit is contained in:
parent
758322a1f8
commit
3665fea2db
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
data "foo" "bar" {
|
||||
provisioner "local-exec" {}
|
||||
}
|
Loading…
Reference in New Issue