Skip to content

Commit 4d43e9e

Browse files
committed
e2e: move funs of framework/viperconfig to e2e
Signed-off-by: clarklee92 <[email protected]>
1 parent 36db62c commit 4d43e9e

File tree

6 files changed

+16
-47
lines changed

6 files changed

+16
-47
lines changed

test/e2e/BUILD

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
88

99
go_test(
1010
name = "go_default_test",
11-
srcs = ["e2e_test.go"],
11+
srcs = [
12+
"e2e_test.go",
13+
"viperconfig_test.go",
14+
],
1215
out = "e2e.test",
1316
embed = [":go_default_library"],
1417
tags = ["e2e"],
@@ -22,7 +25,6 @@ go_test(
2225
"//test/e2e/framework:go_default_library",
2326
"//test/e2e/framework/config:go_default_library",
2427
"//test/e2e/framework/testfiles:go_default_library",
25-
"//test/e2e/framework/viperconfig:go_default_library",
2628
"//test/e2e/generated:go_default_library",
2729
"//test/e2e/instrumentation:go_default_library",
2830
"//test/e2e/kubectl:go_default_library",
@@ -37,6 +39,7 @@ go_test(
3739
"//test/e2e/ui:go_default_library",
3840
"//test/e2e/windows:go_default_library",
3941
"//test/utils/image:go_default_library",
42+
"//vendor/github.com/stretchr/testify/require:go_default_library",
4043
],
4144
)
4245

@@ -48,6 +51,7 @@ go_library(
4851
"gke_local_ssd.go",
4952
"gke_node_pools.go",
5053
"suites.go",
54+
"viperconfig.go",
5155
],
5256
importpath = "k8s.io/kubernetes/test/e2e",
5357
deps = [
@@ -85,6 +89,8 @@ go_library(
8589
"//vendor/github.com/onsi/ginkgo/config:go_default_library",
8690
"//vendor/github.com/onsi/ginkgo/reporters:go_default_library",
8791
"//vendor/github.com/onsi/gomega:go_default_library",
92+
"//vendor/github.com/pkg/errors:go_default_library",
93+
"//vendor/github.com/spf13/viper:go_default_library",
8894
"//vendor/k8s.io/klog:go_default_library",
8995
"//vendor/k8s.io/utils/net:go_default_library",
9096
],

test/e2e/e2e_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"k8s.io/kubernetes/test/e2e/framework"
3434
"k8s.io/kubernetes/test/e2e/framework/config"
3535
"k8s.io/kubernetes/test/e2e/framework/testfiles"
36-
"k8s.io/kubernetes/test/e2e/framework/viperconfig"
3736
"k8s.io/kubernetes/test/e2e/generated"
3837
"k8s.io/kubernetes/test/utils/image"
3938

@@ -75,7 +74,7 @@ func TestMain(m *testing.M) {
7574
// Now that we know which Viper config (if any) was chosen,
7675
// parse it and update those options which weren't already set via command line flags
7776
// (which have higher priority).
78-
if err := viperconfig.ViperizeFlags(*viperConfig, "e2e", flag.CommandLine); err != nil {
77+
if err := viperizeFlags(*viperConfig, "e2e", flag.CommandLine); err != nil {
7978
fmt.Fprintln(os.Stderr, err)
8079
os.Exit(1)
8180
}

test/e2e/framework/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ filegroup(
149149
"//test/e2e/framework/statefulset:all-srcs",
150150
"//test/e2e/framework/testfiles:all-srcs",
151151
"//test/e2e/framework/timer:all-srcs",
152-
"//test/e2e/framework/viperconfig:all-srcs",
153152
"//test/e2e/framework/volume:all-srcs",
154153
],
155154
tags = ["automanaged"],

test/e2e/framework/viperconfig/BUILD

Lines changed: 0 additions & 36 deletions
This file was deleted.

test/e2e/framework/viperconfig/viperconfig.go renamed to test/e2e/viperconfig.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package viperconfig
17+
package e2e
1818

1919
import (
2020
"flag"
2121
"fmt"
22-
"github.com/pkg/errors"
2322
"path/filepath"
2423

24+
"github.com/pkg/errors"
25+
2526
"github.com/spf13/viper"
2627
)
2728

28-
// ViperizeFlags checks whether a configuration file was specified,
29+
// viperizeFlags checks whether a configuration file was specified,
2930
// reads it, and updates the configuration variables in the specified
3031
// flag set accordingly. Must be called after framework.HandleFlags()
3132
// and before framework.AfterReadingAllFlags().
@@ -35,7 +36,7 @@ import (
3536
//
3637
// Files can be specified with just a base name ("e2e", matches "e2e.json/yaml/..." in
3738
// the current directory) or with path and suffix.
38-
func ViperizeFlags(requiredConfig, optionalConfig string, flags *flag.FlagSet) error {
39+
func viperizeFlags(requiredConfig, optionalConfig string, flags *flag.FlagSet) error {
3940
viperConfig := optionalConfig
4041
required := false
4142
if requiredConfig != "" {

test/e2e/framework/viperconfig/viperconfig_test.go renamed to test/e2e/viperconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package viperconfig
17+
package e2e
1818

1919
import (
2020
"flag"
@@ -62,7 +62,7 @@ uint64: 9123456789012345678
6262
}
6363
require.NoError(t, tmpfile.Close(), "close temp file")
6464

65-
require.NoError(t, ViperizeFlags(tmpfile.Name(), "", flags), "read config file")
65+
require.NoError(t, viperizeFlags(tmpfile.Name(), "", flags), "read config file")
6666
require.Equal(t,
6767
Context{false, time.Second, -1.23456789, "pong",
6868
-2, -9123456789012345678, 2, 9123456789012345678,

0 commit comments

Comments
 (0)