Support building an allow-list of providers (#527)

* Add providers subcommand to verify providers

Allows users to check what providers are available

* Fix version output to add new line

This command was totally broken until we moved around the call to
`initConfig()`, this just fixes the output now that it works.

* Flip boolean of provider include tags

All providers are still included by default and fix tags using the old
format.
This commit is contained in:
Brian Goff
2019-03-02 11:25:47 -08:00
committed by GitHub
parent a5d7400232
commit f8c51004d4
17 changed files with 162 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
// +build !no_alibabacloud_provider
// +build alibabacloud_provider
package register

View File

@@ -1,4 +1,4 @@
// +build !no_aws_provider
// +build aws_provider
package register

View File

@@ -1,4 +1,4 @@
// +build !no_azure_provider
// +build azure_provider
package register

View File

@@ -1,4 +1,4 @@
// +build !no_azurebatch_provider
// +build azurebatch_provider
package register

View File

@@ -1,4 +1,4 @@
// +build linux,!no_cri_provider
// +build linux,cri_provider
package register

View File

@@ -1,4 +1,4 @@
// +build !no_huawei_provider
// +build huawei_provider
package register

View File

@@ -1,4 +1,4 @@
// +build !no_mock_provider
// +build mock_provider
package register

View File

@@ -1,4 +1,4 @@
// +build !no_nomad_provider
// +build nomad_provider
package register

View File

@@ -1,4 +1,4 @@
// +build !no_sfmesh_provider
// +build sfmesh_provider
package register

View File

@@ -1,4 +1,4 @@
// +build linux,!no_vic_provider
// +build linux,vic_provider
package register

View File

@@ -1,4 +1,4 @@
// +build !no_web_provider
// +build web_provider
package register

View File

@@ -1,6 +1,8 @@
package register
import (
"sort"
"github.com/cpuguy83/strongerrors"
"github.com/pkg/errors"
"github.com/virtual-kubelet/virtual-kubelet/manager"
@@ -30,6 +32,22 @@ func GetProvider(name string, cfg InitConfig) (providers.Provider, error) {
return f(cfg)
}
// Exists checks if a provider is regstered
func Exists(name string) bool {
_, ok := providerInits[name]
return ok
}
// List gets the list of all provider names
func List() []string {
ls := make([]string, 0, len(providerInits))
for name := range providerInits {
ls = append(ls, name)
}
sort.Strings(ls)
return ls
}
func register(name string, f initFunc) {
providerInits[name] = f
}