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

Remove mime type validation #4873

Merged
merged 1 commit into from
Jan 28, 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
23 changes: 1 addition & 22 deletions builtin/providers/template/resource_cloudinit_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ func resourceCloudinitConfig() *schema.Resource {
"content_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)

if _, supported := supportedContentTypes[value]; !supported {
errors = append(errors, fmt.Errorf("Part has an unsupported content type: %s", v))
}

return
},
},
"content": &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -166,7 +157,7 @@ func renderPartsToWriter(parts cloudInitParts, writer io.Writer) error {

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

Expand Down Expand Up @@ -214,15 +205,3 @@ type cloudInitPart struct {
}

type cloudInitParts []cloudInitPart

// Support content types as specified by http://cloudinit.readthedocs.org/en/latest/topics/format.html
var supportedContentTypes = map[string]bool{
"text/x-include-once-url": true,
"text/x-include-url": true,
"text/cloud-config-archive": true,
"text/upstart-job": true,
"text/cloud-config": true,
"text/part-handler": true,
"text/x-shellscript": true,
"text/cloud-boothook": true,
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ resource "template_cloudinit_config" "config" {
}
}`

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`
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`