~jameinel/juju-core/api-registry-tracks-type

« back to all changes in this revision

Viewing changes to cloudinit/options.go

  • Committer: Roger Peppe
  • Date: 2011-12-07 17:03:34 UTC
  • mto: (25.3.4 go-trunk)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: roger.peppe@canonical.com-20111207170334-soasb88g2x5mpkf5
add cloudinit package

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package cloudinit
 
2
 
 
3
func User(x string) Option {
 
4
        // common
 
5
        return Option{"user", maybe(x != "", x)}
 
6
}
 
7
 
 
8
func AptUpgrade(yes bool) Option {
 
9
        // apt_update_upgrade
 
10
        return Option{"apt_upgrade", maybe(yes, yes)}
 
11
}
 
12
 
 
13
func AptUpdate(yes bool) Option {
 
14
        // apt_update_upgrade
 
15
        return Option{"apt_update", maybe(yes, yes)}
 
16
}
 
17
 
 
18
func AptMirror(url string) Option {
 
19
        // apt_update_upgrade
 
20
        return Option{"apt_mirror", maybe(url != "", url)}
 
21
}
 
22
 
 
23
func AptPreserveSourcesList(yes bool) Option {
 
24
        // apt_update_upgrade
 
25
        return Option{"apt_mirror", maybe(yes, yes)}
 
26
}
 
27
 
 
28
func AptOldMirror(url string) Option {
 
29
        // apt_update_upgrade
 
30
        return Option{"apt_old_mirror", maybe(url != "", url)}
 
31
}
 
32
 
 
33
func AptSources(x ...*Source) Option {
 
34
        // apt_update_upgrade
 
35
        if len(x) == 0 {
 
36
                return Option{"apt_sources", nil}
 
37
        }
 
38
        ss := make([]*source, len(x))
 
39
        for i, s := range x {
 
40
                ss[i] = &s.source
 
41
        }
 
42
        return Option{"apt_sources", ss}
 
43
}
 
44
 
 
45
func DebConfSelections(x bool) Option {
 
46
        // apt_update_upgrade
 
47
        return Option{"debconf_selections", maybe(x, x)}
 
48
}
 
49
 
 
50
func Packages(x ...string) Option {
 
51
        // apt_update_upgrade
 
52
        return Option{"packages", maybe(len(x) > 0, x)}
 
53
}
 
54
 
 
55
func BootCmd(x ...*Command) Option {
 
56
        // bootcmd
 
57
        return Option{"bootcmd", maybe(len(x) > 0, x)}
 
58
}
 
59
 
 
60
func DisableEC2Metadata(x bool) Option {
 
61
        // disable_ec2_metadata
 
62
        return Option{"disable_ec2_metadata", maybe(x, x)}
 
63
}
 
64
 
 
65
func FinalMessage(x string) Option {
 
66
        // final_message
 
67
        return Option{"final_message", maybe(x != "", x)}
 
68
}
 
69
 
 
70
func Locale(x string) Option {
 
71
        // locale
 
72
        return Option{"locale", maybe(x != "", x)}
 
73
}
 
74
 
 
75
func Mounts(x [][]string) Option {
 
76
        // mounts
 
77
        return Option{"mounts", maybe(len(x) > 0, x)}
 
78
}
 
79
 
 
80
// Output specifies destination for command output.
 
81
// Valid values for the string keys are "init", "config", "final" and "all".
 
82
func Output(specs map[string]OutputSpec) Option {
 
83
        return Option{"output", maybe(len(specs) > 0, specs)}
 
84
}
 
85
 
 
86
func SSHKeys(x []Key) Option {
 
87
        // ssh
 
88
        return Option{"ssh_keys", maybe(len(x) > 0, x)}
 
89
}
 
90
 
 
91
func DisableRoot(x bool) Option {
 
92
        // ssh
 
93
        // note that disable_root defaults to true, so we include
 
94
        // the option only if x is false.
 
95
        return Option{"disable_root", maybe(!x, x)}
 
96
}
 
97
 
 
98
func SSHAuthorizedKeys(x ...string) Option {
 
99
        // ssh
 
100
        return Option{"ssh_authorized_keys", maybe(len(x) > 0, x)}
 
101
}
 
102
 
 
103
func RunCmd(x ...*Command) Option {
 
104
        // runcmd
 
105
        return Option{"runcmd", maybe(len(x) > 0, x)}
 
106
}
 
107
 
 
108
// TODO
 
109
// byobu
 
110
// grub_dpkg
 
111
// mcollective
 
112
// phone_home
 
113
// puppet
 
114
// resizefs
 
115
// rightscale_userdata
 
116
// rsyslog
 
117
// scripts_per_boot
 
118
// scripts_per_instance
 
119
// scripts_per_once
 
120
// scripts_user
 
121
// set_hostname
 
122
// set_passwords
 
123
// ssh_import_id
 
124
// timezone
 
125
// update_etc_hosts
 
126
// update_hostname