e2e: move funs of framework/viperconfig to e2e

Signed-off-by: clarklee92 <clarklee1992@hotmail.com>
This commit is contained in:
clarklee92 2019-12-31 16:22:10 +08:00
parent 36db62cd73
commit 4d43e9e39b
6 changed files with 16 additions and 47 deletions

View File

@ -8,7 +8,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_test(
name = "go_default_test",
srcs = ["e2e_test.go"],
srcs = [
"e2e_test.go",
"viperconfig_test.go",
],
out = "e2e.test",
embed = [":go_default_library"],
tags = ["e2e"],
@ -22,7 +25,6 @@ go_test(
"//test/e2e/framework:go_default_library",
"//test/e2e/framework/config:go_default_library",
"//test/e2e/framework/testfiles:go_default_library",
"//test/e2e/framework/viperconfig:go_default_library",
"//test/e2e/generated:go_default_library",
"//test/e2e/instrumentation:go_default_library",
"//test/e2e/kubectl:go_default_library",
@ -37,6 +39,7 @@ go_test(
"//test/e2e/ui:go_default_library",
"//test/e2e/windows:go_default_library",
"//test/utils/image:go_default_library",
"//vendor/github.com/stretchr/testify/require:go_default_library",
],
)
@ -48,6 +51,7 @@ go_library(
"gke_local_ssd.go",
"gke_node_pools.go",
"suites.go",
"viperconfig.go",
],
importpath = "k8s.io/kubernetes/test/e2e",
deps = [
@ -85,6 +89,8 @@ go_library(
"//vendor/github.com/onsi/ginkgo/config:go_default_library",
"//vendor/github.com/onsi/ginkgo/reporters:go_default_library",
"//vendor/github.com/onsi/gomega:go_default_library",
"//vendor/github.com/pkg/errors:go_default_library",
"//vendor/github.com/spf13/viper:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/utils/net:go_default_library",
],

View File

@ -33,7 +33,6 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework/config"
"k8s.io/kubernetes/test/e2e/framework/testfiles"
"k8s.io/kubernetes/test/e2e/framework/viperconfig"
"k8s.io/kubernetes/test/e2e/generated"
"k8s.io/kubernetes/test/utils/image"
@ -75,7 +74,7 @@ func TestMain(m *testing.M) {
// Now that we know which Viper config (if any) was chosen,
// parse it and update those options which weren't already set via command line flags
// (which have higher priority).
if err := viperconfig.ViperizeFlags(*viperConfig, "e2e", flag.CommandLine); err != nil {
if err := viperizeFlags(*viperConfig, "e2e", flag.CommandLine); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

View File

@ -149,7 +149,6 @@ filegroup(
"//test/e2e/framework/statefulset:all-srcs",
"//test/e2e/framework/testfiles:all-srcs",
"//test/e2e/framework/timer:all-srcs",
"//test/e2e/framework/viperconfig:all-srcs",
"//test/e2e/framework/volume:all-srcs",
],
tags = ["automanaged"],

View File

@ -1,36 +0,0 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["viperconfig.go"],
importpath = "k8s.io/kubernetes/test/e2e/framework/viperconfig",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/pkg/errors:go_default_library",
"//vendor/github.com/spf13/viper:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
go_test(
name = "go_default_test",
srcs = ["viperconfig_test.go"],
embed = [":go_default_library"],
deps = [
"//test/e2e/framework/config:go_default_library",
"//vendor/github.com/stretchr/testify/require:go_default_library",
],
)

View File

@ -14,18 +14,19 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package viperconfig
package e2e
import (
"flag"
"fmt"
"github.com/pkg/errors"
"path/filepath"
"github.com/pkg/errors"
"github.com/spf13/viper"
)
// ViperizeFlags checks whether a configuration file was specified,
// viperizeFlags checks whether a configuration file was specified,
// reads it, and updates the configuration variables in the specified
// flag set accordingly. Must be called after framework.HandleFlags()
// and before framework.AfterReadingAllFlags().
@ -35,7 +36,7 @@ import (
//
// Files can be specified with just a base name ("e2e", matches "e2e.json/yaml/..." in
// the current directory) or with path and suffix.
func ViperizeFlags(requiredConfig, optionalConfig string, flags *flag.FlagSet) error {
func viperizeFlags(requiredConfig, optionalConfig string, flags *flag.FlagSet) error {
viperConfig := optionalConfig
required := false
if requiredConfig != "" {

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package viperconfig
package e2e
import (
"flag"
@ -62,7 +62,7 @@ uint64: 9123456789012345678
}
require.NoError(t, tmpfile.Close(), "close temp file")
require.NoError(t, ViperizeFlags(tmpfile.Name(), "", flags), "read config file")
require.NoError(t, viperizeFlags(tmpfile.Name(), "", flags), "read config file")
require.Equal(t,
Context{false, time.Second, -1.23456789, "pong",
-2, -9123456789012345678, 2, 9123456789012345678,