Skip to content

Commit 548136c

Browse files
author
Simon Thulbourn
committed
Remove mime type validation
Remove the mime type validation since the part handler type allows for custom types. http://cloudinit.readthedocs.org/en/latest/topics/format.html#part-handler The docs specify that if a part handler type is specified, one could use custom mime types Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
1 parent 2dca1ea commit 548136c

2 files changed

Lines changed: 2 additions & 23 deletions

File tree

builtin/providers/template/resource_cloudinit_config.go

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ func resourceCloudinitConfig() *schema.Resource {
3232
"content_type": &schema.Schema{
3333
Type: schema.TypeString,
3434
Optional: true,
35-
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
36-
value := v.(string)
37-
38-
if _, supported := supportedContentTypes[value]; !supported {
39-
errors = append(errors, fmt.Errorf("Part has an unsupported content type: %s", v))
40-
}
41-
42-
return
43-
},
4435
},
4536
"content": &schema.Schema{
4637
Type: schema.TypeString,
@@ -166,7 +157,7 @@ func renderPartsToWriter(parts cloudInitParts, writer io.Writer) error {
166157

167158
// we need to set the boundary explictly, otherwise the boundary is random
168159
// and this causes terraform to complain about the resource being different
169-
if err := mimeWriter.SetBoundary("MIMEBOUNDRY"); err != nil {
160+
if err := mimeWriter.SetBoundary("MIMEBOUNDARY"); err != nil {
170161
return err
171162
}
172163

@@ -214,15 +205,3 @@ type cloudInitPart struct {
214205
}
215206

216207
type cloudInitParts []cloudInitPart
217-
218-
// Support content types as specified by http://cloudinit.readthedocs.org/en/latest/topics/format.html
219-
var supportedContentTypes = map[string]bool{
220-
"text/x-include-once-url": true,
221-
"text/x-include-url": true,
222-
"text/cloud-config-archive": true,
223-
"text/upstart-job": true,
224-
"text/cloud-config": true,
225-
"text/part-handler": true,
226-
"text/x-shellscript": true,
227-
"text/cloud-boothook": true,
228-
}

builtin/providers/template/resource_cloudinit_config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ resource "template_cloudinit_config" "config" {
130130
}
131131
}`
132132

133-
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`
133+
var testCloudInitConfig_update_expected = `Content-Type: multipart/mixed; boundary=\"MIMEBOUNDARY\"\nMIME-Version: 1.0\r\n--MIMEBOUNDARY\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type: text/x-shellscript\r\nMime-Version: 1.0\r\n\r\nbaz\r\n--MIMEBOUNDARY\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type: text/x-shellscript\r\nMime-Version: 1.0\r\n\r\nffbaz\r\n--MIMEBOUNDARY--\r\n`

0 commit comments

Comments
 (0)