Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: validate that data sources don't have provisioners #10318

Merged
merged 1 commit into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions config/test-fixtures/validate-data-provisioner/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "foo" "bar" {
provisioner "local-exec" {}
}