diff --git a/cloudinit/cloud_config.go b/cloudinit/cloud_config.go index 712eddc..aa30aa9 100644 --- a/cloudinit/cloud_config.go +++ b/cloudinit/cloud_config.go @@ -16,8 +16,8 @@ type CloudConfig struct { Fleet struct{ Autostart bool } Units []Unit } - Write_Files []WriteFile - Hostname string + WriteFiles []WriteFile `yaml:"write_files"` + Hostname string } func NewCloudConfig(contents []byte) (*CloudConfig, error) { @@ -55,8 +55,8 @@ func ApplyCloudConfig(cfg CloudConfig, sshKeyName string) error { } } - if len(cfg.Write_Files) > 0 { - for _, file := range cfg.Write_Files { + if len(cfg.WriteFiles) > 0 { + for _, file := range cfg.WriteFiles { if err := ProcessWriteFile("/", &file); err != nil { return err } diff --git a/cloudinit/cloud_config_test.go b/cloudinit/cloud_config_test.go index 1fe9a4f..66b8af3 100644 --- a/cloudinit/cloud_config_test.go +++ b/cloudinit/cloud_config_test.go @@ -25,8 +25,8 @@ func TestCloudConfigEmpty(t *testing.T) { t.Error("Expected AutostartFleet not to be defined") } - if len(cfg.Write_Files) != 0 { - t.Error("Expected zero Write_Files") + if len(cfg.WriteFiles) != 0 { + t.Error("Expected zero WriteFiles") } if cfg.Hostname != "" { @@ -89,10 +89,10 @@ hostname: trontastic t.Error("Expected AutostartFleet to be true") } - if len(cfg.Write_Files) != 1 { + if len(cfg.WriteFiles) != 1 { t.Error("Failed to parse correct number of write_files") } else { - wf := cfg.Write_Files[0] + wf := cfg.WriteFiles[0] if wf.Content != "penny\nelroy\n" { t.Errorf("WriteFile has incorrect contents '%s'", wf.Content) }