Merge pull request #4757 from hashicorp/f-cloudinitconfig-update

provider/template: Allow update in `template_cloudinit_config`
This commit is contained in:
James Nugent 2016-01-20 11:22:57 -05:00
commit 644a52c473
2 changed files with 47 additions and 1 deletions

View File

@ -19,6 +19,7 @@ func resourceCloudinitConfig() *schema.Resource {
return &schema.Resource{
Create: resourceCloudinitConfigCreate,
Delete: resourceCloudinitConfigDelete,
Update: resourceCloudinitConfigCreate,
Exists: resourceCloudinitConfigExists,
Read: resourceCloudinitConfigRead,
@ -26,7 +27,6 @@ func resourceCloudinitConfig() *schema.Resource {
"part": &schema.Schema{
Type: schema.TypeList,
Required: true,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"content_type": &schema.Schema{

View File

@ -85,3 +85,49 @@ func TestRender(t *testing.T) {
})
}
}
func TestCloudConfig_update(t *testing.T) {
r.Test(t, r.TestCase{
Providers: testProviders,
Steps: []r.TestStep{
r.TestStep{
Config: testCloudInitConfig_basic,
Check: r.ComposeTestCheckFunc(
r.TestCheckResourceAttr("template_cloudinit_config.config", "rendered", testCloudInitConfig_basic_expected),
),
},
r.TestStep{
Config: testCloudInitConfig_update,
Check: r.ComposeTestCheckFunc(
r.TestCheckResourceAttr("template_cloudinit_config.config", "rendered", testCloudInitConfig_update_expected),
),
},
},
})
}
var testCloudInitConfig_basic = `
resource "template_cloudinit_config" "config" {
part {
content_type = "text/x-shellscript"
content = "baz"
}
}`
var testCloudInitConfig_basic_expected = `Content-Type: multipart/mixed; boundary=\"MIMEBOUNDRY\"\nMIME-Version: 1.0\r\n--MIMEBOUNDRY\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type: text/x-shellscript\r\nMime-Version: 1.0\r\n\r\nbaz\r\n--MIMEBOUNDRY--\r\n`
var testCloudInitConfig_update = `
resource "template_cloudinit_config" "config" {
part {
content_type = "text/x-shellscript"
content = "baz"
}
part {
content_type = "text/x-shellscript"
content = "ffbaz"
}
}`
var testCloudInitConfig_update_expected = `Content-Type: multipart/mixed; boundary=\"MIMEBOUNDRY\"\nMIME-Version: 1.0\r\n--MIMEBOUNDRY\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type: text/x-shellscript\r\nMime-Version: 1.0\r\n\r\nbaz\r\n--MIMEBOUNDRY\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type: text/x-shellscript\r\nMime-Version: 1.0\r\n\r\nffbaz\r\n--MIMEBOUNDRY--\r\n`