flags: add oem flag
The oem flag will allow each of the OEMs to specify one flag only, acting as a shortcut to their specific configuration. This will allow us to update which options each OEM uses when running cloudinit.
This commit is contained in:
parent
549806cf64
commit
cda037f9a5
@ -43,6 +43,7 @@ var (
|
|||||||
convertNetconf string
|
convertNetconf string
|
||||||
workspace string
|
workspace string
|
||||||
sshKeyName string
|
sshKeyName string
|
||||||
|
oem string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -56,16 +57,49 @@ func init() {
|
|||||||
flag.StringVar(&sources.digitalOceanMetadataService, "from-digitalocean-metadata", "", "Download DigitalOcean data from the provided url")
|
flag.StringVar(&sources.digitalOceanMetadataService, "from-digitalocean-metadata", "", "Download DigitalOcean data from the provided url")
|
||||||
flag.StringVar(&sources.url, "from-url", "", "Download user-data from provided url")
|
flag.StringVar(&sources.url, "from-url", "", "Download user-data from provided url")
|
||||||
flag.BoolVar(&sources.procCmdLine, "from-proc-cmdline", false, fmt.Sprintf("Parse %s for '%s=<url>', using the cloud-config served by an HTTP GET to <url>", proc_cmdline.ProcCmdlineLocation, proc_cmdline.ProcCmdlineCloudConfigFlag))
|
flag.BoolVar(&sources.procCmdLine, "from-proc-cmdline", false, fmt.Sprintf("Parse %s for '%s=<url>', using the cloud-config served by an HTTP GET to <url>", proc_cmdline.ProcCmdlineLocation, proc_cmdline.ProcCmdlineCloudConfigFlag))
|
||||||
|
flag.StringVar(&oem, "oem", "", "Use the settings specific to the provided OEM")
|
||||||
flag.StringVar(&convertNetconf, "convert-netconf", "", "Read the network config provided in cloud-drive and translate it from the specified format into networkd unit files")
|
flag.StringVar(&convertNetconf, "convert-netconf", "", "Read the network config provided in cloud-drive and translate it from the specified format into networkd unit files")
|
||||||
flag.StringVar(&workspace, "workspace", "/var/lib/coreos-cloudinit", "Base directory coreos-cloudinit should use to store data")
|
flag.StringVar(&workspace, "workspace", "/var/lib/coreos-cloudinit", "Base directory coreos-cloudinit should use to store data")
|
||||||
flag.StringVar(&sshKeyName, "ssh-key-name", initialize.DefaultSSHKeyName, "Add SSH keys to the system with the given name")
|
flag.StringVar(&sshKeyName, "ssh-key-name", initialize.DefaultSSHKeyName, "Add SSH keys to the system with the given name")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type oemConfig map[string]string
|
||||||
|
|
||||||
|
var (
|
||||||
|
oemConfigs = map[string]oemConfig{
|
||||||
|
"digitalocean": oemConfig{
|
||||||
|
"from-digitalocean-metadata": "http://169.254.169.254/",
|
||||||
|
"convert-netconf": "digitalocean",
|
||||||
|
},
|
||||||
|
"ec2-compat": oemConfig{
|
||||||
|
"from-ec2-metadata": "http://169.254.169.254/",
|
||||||
|
"from-configdrive": "/media/configdrive",
|
||||||
|
},
|
||||||
|
"rackspace-onmetal": oemConfig{
|
||||||
|
"from-configdrive": "/media/configdrive",
|
||||||
|
"convert-netconf": "debian",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
failure := false
|
failure := false
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if c, ok := oemConfigs[oem]; ok {
|
||||||
|
for k, v := range c {
|
||||||
|
flag.Set(k, v)
|
||||||
|
}
|
||||||
|
} else if flags.oem != "" {
|
||||||
|
oems := make([]string, 0, len(oemConfigs))
|
||||||
|
for k := range oemConfigs {
|
||||||
|
oems = append(oems, k)
|
||||||
|
}
|
||||||
|
fmt.Printf("Invalid option to --oem: %q. Supported options: %q\n", flags.oem, oems)
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
|
|
||||||
if printVersion == true {
|
if printVersion == true {
|
||||||
fmt.Printf("coreos-cloudinit version %s\n", version)
|
fmt.Printf("coreos-cloudinit version %s\n", version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user