Esempio n. 1
0
func (t *CloudInitTarget) Finish(taskMap map[string]fi.Task) error {
	d, err := utils.YamlMarshal(t.Config)
	if err != nil {
		return fmt.Errorf("error serializing config to yaml: %v", err)
	}

	conf := "#cloud-config\n" + string(d)

	_, err = t.out.Write([]byte(conf))
	if err != nil {
		return fmt.Errorf("error writing cloud-init data to output: %v", err)
	}
	return nil
}
Esempio n. 2
0
func (s *VFSStateStore) WriteConfig(path string, config interface{}) error {
	configPath := s.location.Join(path)

	data, err := utils.YamlMarshal(config)
	if err != nil {
		return fmt.Errorf("error marshalling configuration: %v", err)
	}

	err = configPath.WriteFile(data)
	if err != nil {
		return fmt.Errorf("error writing configuration file %s: %v", configPath, err)
	}
	return nil
}