Add viper support to core e2es

rebase
This commit is contained in:
jayunit100 2016-08-24 21:39:50 -04:00
parent 30edeaefc7
commit 97396a34fa
4 changed files with 37 additions and 11 deletions

12
Godeps/Godeps.json generated
View File

@ -1403,10 +1403,6 @@
"ImportPath": "github.com/hashicorp/hcl/json/token", "ImportPath": "github.com/hashicorp/hcl/json/token",
"Rev": "d8c773c4cba11b11539e3d45f93daeaa5dcf1fa1" "Rev": "d8c773c4cba11b11539e3d45f93daeaa5dcf1fa1"
}, },
{
"ImportPath": "github.com/hashicorp/raft-boltdb",
"Rev": "d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee"
},
{ {
"ImportPath": "github.com/hawkular/hawkular-client-go/metrics", "ImportPath": "github.com/hawkular/hawkular-client-go/metrics",
"Comment": "v0.5.1-1-g1d46ce7", "Comment": "v0.5.1-1-g1d46ce7",
@ -2160,6 +2156,10 @@
"ImportPath": "github.com/spf13/pflag", "ImportPath": "github.com/spf13/pflag",
"Rev": "1560c1005499d61b80f865c04d39ca7505bf7f0b" "Rev": "1560c1005499d61b80f865c04d39ca7505bf7f0b"
}, },
{
"ImportPath": "github.com/spf13/viper",
"Rev": "7fb2782df3d83e0036cc89f461ed0422628776f4"
},
{ {
"ImportPath": "github.com/square/go-jose", "ImportPath": "github.com/square/go-jose",
"Rev": "789a4c4bd4c118f7564954f441b29c153ccd6a96" "Rev": "789a4c4bd4c118f7564954f441b29c153ccd6a96"
@ -2172,10 +2172,6 @@
"ImportPath": "github.com/square/go-jose/json", "ImportPath": "github.com/square/go-jose/json",
"Rev": "789a4c4bd4c118f7564954f441b29c153ccd6a96" "Rev": "789a4c4bd4c118f7564954f441b29c153ccd6a96"
}, },
{
"ImportPath": "github.com/spf13/viper",
"Rev": "7fb2782df3d83e0036cc89f461ed0422628776f4"
},
{ {
"ImportPath": "github.com/stretchr/objx", "ImportPath": "github.com/stretchr/objx",
"Rev": "1a9d0bb9f541897e62256577b352fdbc1fb4fd94" "Rev": "1a9d0bb9f541897e62256577b352fdbc1fb4fd94"

View File

@ -0,0 +1,3 @@
{
"provider":"local"
}

View File

@ -23,8 +23,7 @@ import (
) )
func init() { func init() {
framework.RegisterCommonFlags() framework.ViperizeFlags()
framework.RegisterClusterFlags()
} }
func TestE2E(t *testing.T) { func TestE2E(t *testing.T) {

View File

@ -21,7 +21,9 @@ import (
"os" "os"
"time" "time"
glog "github.com/golang/glog"
"github.com/onsi/ginkgo/config" "github.com/onsi/ginkgo/config"
"github.com/spf13/viper"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd" "k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/cloudprovider" "k8s.io/kubernetes/pkg/cloudprovider"
) )
@ -34,7 +36,8 @@ type TestContextType struct {
CertDir string CertDir string
Host string Host string
// TODO: Deprecating this over time... instead just use gobindata_util.go , see #23987. // TODO: Deprecating this over time... instead just use gobindata_util.go , see #23987.
RepoRoot string RepoRoot string
Provider string Provider string
CloudConfig CloudConfig CloudConfig CloudConfig
KubectlPath string KubectlPath string
@ -181,3 +184,28 @@ func RegisterNodeFlags() {
flag.StringVar(&TestContext.EvictionHard, "eviction-hard", "memory.available<250Mi,imagefs.available<10%", "The hard eviction thresholds. If set, pods get evicted when the specified resources drop below the thresholds.") flag.StringVar(&TestContext.EvictionHard, "eviction-hard", "memory.available<250Mi,imagefs.available<10%", "The hard eviction thresholds. If set, pods get evicted when the specified resources drop below the thresholds.")
flag.StringVar(&TestContext.ManifestPath, "manifest-path", "", "The path to the static pod manifest file.") flag.StringVar(&TestContext.ManifestPath, "manifest-path", "", "The path to the static pod manifest file.")
} }
// Enable viper configuration management of flags.
func ViperizeFlags() {
// Add viper in a minimal way.
// Flag interop isnt possible, since 'go test' coupling to flag.Parse.
viper.SetConfigName("e2e")
viper.AddConfigPath(".")
viper.ReadInConfig()
// TODO @jayunit100: Maybe a more elegant viper-flag integration for the future?
// For now, we layer it on top, because 'flag' deps of 'go test' make pflag wrappers
// fragile, seeming to force 'flag' to have deep awareness of pflag params.
RegisterCommonFlags()
RegisterClusterFlags()
flag.Parse()
viperFlagSetter := func(f *flag.Flag) {
if viper.IsSet(f.Name) {
glog.V(4).Infof("[viper config] Overwriting, found a settting for %v %v", f.Name, f.Value)
f.Value.Set(viper.GetString(f.Name))
}
}
// Each flag that we've declared can be set via viper.
flag.VisitAll(viperFlagSetter)
}