@@ -30,11 +30,11 @@ func TestKubeletConfigurationPathFields(t *testing.T) {
30
30
if i := kubeletConfigurationPathFieldPaths .Intersection (kubeletConfigurationNonPathFieldPaths ); len (i ) > 0 {
31
31
t .Fatalf ("expect the intersection of kubeletConfigurationPathFieldPaths and " +
32
32
"KubeletConfigurationNonPathFields to be empty, got:\n %s" ,
33
- strings .Join (i .List (), "\n " ))
33
+ strings .Join (sets .List (i ), "\n " ))
34
34
}
35
35
36
36
// ensure that kubeletConfigurationPathFields U kubeletConfigurationNonPathFields == allPrimitiveFieldPaths(KubeletConfiguration)
37
- expect := sets .NewString ().Union (kubeletConfigurationPathFieldPaths ).Union (kubeletConfigurationNonPathFieldPaths )
37
+ expect := sets .New [ string ] ().Union (kubeletConfigurationPathFieldPaths ).Union (kubeletConfigurationNonPathFieldPaths )
38
38
result := allPrimitiveFieldPaths (t , expect , reflect .TypeOf (& KubeletConfiguration {}), nil )
39
39
if ! expect .Equal (result ) {
40
40
// expected fields missing from result
@@ -46,38 +46,38 @@ func TestKubeletConfigurationPathFields(t *testing.T) {
46
46
"If the field has been removed, please remove it from the kubeletConfigurationPathFieldPaths set " +
47
47
"and the KubeletConfigurationPathRefs function, " +
48
48
"or remove it from the kubeletConfigurationNonPathFieldPaths set, as appropriate:\n %s" ,
49
- strings .Join (missing .List (), "\n " ))
49
+ strings .Join (sets .List (missing ), "\n " ))
50
50
}
51
51
if len (unexpected ) > 0 {
52
52
t .Errorf ("the following fields were in the result, but unexpected. " +
53
53
"If the field is new, please add it to the kubeletConfigurationPathFieldPaths set " +
54
54
"and the KubeletConfigurationPathRefs function, " +
55
55
"or add it to the kubeletConfigurationNonPathFieldPaths set, as appropriate:\n %s" ,
56
- strings .Join (unexpected .List (), "\n " ))
56
+ strings .Join (sets .List (unexpected ), "\n " ))
57
57
}
58
58
}
59
59
}
60
60
61
61
// allPrimitiveFieldPaths returns the set of field paths in type `tp`, rooted at `path`.
62
62
// It recursively descends into the definition of type `tp` accumulating paths to primitive leaf fields or paths in `skipRecurseList`.
63
- func allPrimitiveFieldPaths (t * testing.T , skipRecurseList sets.String , tp reflect.Type , path * field.Path ) sets.String {
63
+ func allPrimitiveFieldPaths (t * testing.T , skipRecurseList sets.Set [ string ] , tp reflect.Type , path * field.Path ) sets.Set [ string ] {
64
64
// if the current field path is in the list of paths we should not recurse into,
65
65
// return here rather than descending and accumulating child field paths
66
66
if pathStr := path .String (); len (pathStr ) > 0 && skipRecurseList .Has (pathStr ) {
67
- return sets .NewString (pathStr )
67
+ return sets.New [ string ] (pathStr )
68
68
}
69
69
70
- paths := sets .NewString ()
70
+ paths := sets .New [ string ] ()
71
71
switch tp .Kind () {
72
72
case reflect .Pointer :
73
- paths .Insert (allPrimitiveFieldPaths (t , skipRecurseList , tp .Elem (), path ). List ( )... )
73
+ paths .Insert (sets . List ( allPrimitiveFieldPaths (t , skipRecurseList , tp .Elem (), path ))... )
74
74
case reflect .Struct :
75
75
for i := 0 ; i < tp .NumField (); i ++ {
76
76
field := tp .Field (i )
77
- paths .Insert (allPrimitiveFieldPaths (t , skipRecurseList , field .Type , path .Child (field .Name )). List ( )... )
77
+ paths .Insert (sets . List ( allPrimitiveFieldPaths (t , skipRecurseList , field .Type , path .Child (field .Name )))... )
78
78
}
79
79
case reflect .Map , reflect .Slice :
80
- paths .Insert (allPrimitiveFieldPaths (t , skipRecurseList , tp .Elem (), path .Key ("*" )). List ( )... )
80
+ paths .Insert (sets . List ( allPrimitiveFieldPaths (t , skipRecurseList , tp .Elem (), path .Key ("*" )))... )
81
81
case reflect .Interface :
82
82
t .Fatalf ("unexpected interface{} field %s" , path .String ())
83
83
default :
@@ -115,7 +115,7 @@ type bar struct {
115
115
}
116
116
117
117
func TestAllPrimitiveFieldPaths (t * testing.T ) {
118
- expect := sets .NewString (
118
+ expect := sets .New [ string ] (
119
119
"str" ,
120
120
"strptr" ,
121
121
"ints[*]" ,
@@ -140,17 +140,17 @@ func TestAllPrimitiveFieldPaths(t *testing.T) {
140
140
unexpected := result .Difference (expect )
141
141
142
142
if len (missing ) > 0 {
143
- t .Errorf ("the following fields were expected, but missing from the result:\n %s" , strings .Join (missing .List (), "\n " ))
143
+ t .Errorf ("the following fields were expected, but missing from the result:\n %s" , strings .Join (sets .List (missing ), "\n " ))
144
144
}
145
145
if len (unexpected ) > 0 {
146
- t .Errorf ("the following fields were in the result, but unexpected:\n %s" , strings .Join (unexpected .List (), "\n " ))
146
+ t .Errorf ("the following fields were in the result, but unexpected:\n %s" , strings .Join (sets .List (unexpected ), "\n " ))
147
147
}
148
148
}
149
149
}
150
150
151
151
var (
152
152
// KubeletConfiguration fields that contain file paths. If you update this, also update KubeletConfigurationPathRefs!
153
- kubeletConfigurationPathFieldPaths = sets .NewString (
153
+ kubeletConfigurationPathFieldPaths = sets .New [ string ] (
154
154
"StaticPodPath" ,
155
155
"Authentication.X509.ClientCAFile" ,
156
156
"TLSCertFile" ,
@@ -160,7 +160,7 @@ var (
160
160
)
161
161
162
162
// KubeletConfiguration fields that do not contain file paths.
163
- kubeletConfigurationNonPathFieldPaths = sets .NewString (
163
+ kubeletConfigurationNonPathFieldPaths = sets .New [ string ] (
164
164
"Address" ,
165
165
"AllowedUnsafeSysctls[*]" ,
166
166
"Authentication.Anonymous.Enabled" ,
0 commit comments