Allow specifying a set of metadata providers
run with `cmd: ["metadata", "aws"]` to just check for AWS metadata for example.
@@ -40,12 +40,26 @@ var netProviders []Provider
// cdromProviders is a list of Providers offering metadata/userdata data via CDROM
var cdromProviders []Provider
-func init() {
- netProviders = []Provider{NewGCP(), NewVultr(), NewAWS()}
+func main() {
+ providers := []string{"aws", "gcp", "vultr", "cdrom"}
+ if len(os.Args) > 1 {
+ providers = os.Args[1:]
+ }
+ for _, p := range providers {
+ switch p {
+ case "aws":
+ netProviders = append(netProviders, NewAWS())
+ case "gcp":
+ netProviders = append(netProviders, NewGCP())
+ case "vultr":
+ netProviders = append(netProviders, NewVultr())
+ case "cdrom":
cdromProviders = ListCDROMs()
+ default:
+ log.Fatalf("Unrecognised metadata provider: %s", p)
+ }
}
-func main() {
if err := os.MkdirAll(ConfigPath, 0755); err != nil {
log.Fatalf("Could not create %s: %s", ConfigPath, err)
}
