Merge pull request #379 from endocode/kayrus/trim_fix
cloudinit: trim trailing whitespaces in #cloud-config header
This commit is contained in:
commit
5f688a0a21
@ -19,6 +19,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
"github.com/coreos/coreos-cloudinit/Godeps/_workspace/src/github.com/coreos/yaml"
|
"github.com/coreos/coreos-cloudinit/Godeps/_workspace/src/github.com/coreos/yaml"
|
||||||
)
|
)
|
||||||
@ -49,10 +50,8 @@ type CoreOS struct {
|
|||||||
func IsCloudConfig(userdata string) bool {
|
func IsCloudConfig(userdata string) bool {
|
||||||
header := strings.SplitN(userdata, "\n", 2)[0]
|
header := strings.SplitN(userdata, "\n", 2)[0]
|
||||||
|
|
||||||
// Explicitly trim the header so we can handle user-data from
|
// Trim trailing whitespaces
|
||||||
// non-unix operating systems. The rest of the file is parsed
|
header = strings.TrimRightFunc(header, unicode.IsSpace)
|
||||||
// by yaml, which correctly handles CRLF.
|
|
||||||
header = strings.TrimSuffix(header, "\r")
|
|
||||||
|
|
||||||
return (header == "#cloud-config")
|
return (header == "#cloud-config")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user