1
// The cloudinit package implements a way of creating
2
// a cloud-init configuration file.
3
// See https://help.ubuntu.com/community/CloudInit.
7
yaml "launchpad.net/goyaml"
10
// Config represents a set of cloud-init configuration options.
12
attrs map[string]interface{}
15
// New returns a new Config with no options set.
17
return &Config{make(map[string]interface{})}
20
// Render returns the cloud-init configuration as a YAML file.
21
func (cfg *Config) Render() ([]byte, error) {
22
data, err := yaml.Marshal(cfg.attrs)
26
return append([]byte("#cloud-config\n"), data...), nil
29
func (cfg *Config) set(opt string, yes bool, value interface{}) {
31
cfg.attrs[opt] = value
33
delete(cfg.attrs, opt)
37
// source is Key, or KeyId and KeyServer
39
Source string `yaml:"source"`
40
Key string `yaml:"key,omitempty"`
41
KeyId string `yaml:"keyid,omitempty"`
42
KeyServer string `yaml:"keyserver,omitempty"`
45
// command represents a shell command.
51
// GetYAML implements yaml.Getter
52
func (t *command) GetYAML() (tag string, value interface{}) {
59
type SSHKeyType string
62
RSAPrivate SSHKeyType = "rsa_private"
63
RSAPublic SSHKeyType = "rsa_public"
64
DSAPrivate SSHKeyType = "dsa_private"
65
DSAPublic SSHKeyType = "dsa_public"