@@ -61,7 +61,7 @@ import (
61
61
"k8s.io/kubernetes/pkg/capabilities"
62
62
"k8s.io/kubernetes/pkg/registry/batch/job"
63
63
64
- // initialize install packages
64
+ // 初始化安装包
65
65
_ "k8s.io/kubernetes/pkg/apis/apps/install"
66
66
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
67
67
_ "k8s.io/kubernetes/pkg/apis/batch/install"
@@ -77,18 +77,18 @@ var (
77
77
serializer runtime.SerializerInfo
78
78
)
79
79
80
- // TestGroup contains GroupVersion to uniquely identify the API
80
+ // TestGroup 包含 GroupVersion 以唯一地标识该 API
81
81
type TestGroup struct {
82
82
externalGroupVersion schema.GroupVersion
83
83
}
84
84
85
- // GroupVersion makes copy of schema.GroupVersion
85
+ // GroupVersion 制作 schema.GroupVersion 的副本
86
86
func (g TestGroup ) GroupVersion () * schema.GroupVersion {
87
87
copyOfGroupVersion := g .externalGroupVersion
88
88
return & copyOfGroupVersion
89
89
}
90
90
91
- // Codec returns the codec for the API version to test against
91
+ // Codec 为要测试的 API 版本返回编解码器
92
92
func (g TestGroup ) Codec () runtime.Codec {
93
93
if serializer .Serializer == nil {
94
94
return legacyscheme .Codecs .LegacyCodec (g .externalGroupVersion )
@@ -136,7 +136,7 @@ func getCodecForObject(obj runtime.Object) (runtime.Codec, error) {
136
136
return group .Codec (), nil
137
137
}
138
138
}
139
- // Codec used for unversioned types
139
+ // 还未版本化的类别所用的 Codec
140
140
if legacyscheme .Scheme .Recognizes (kind ) {
141
141
serializer , ok := runtime .SerializerInfoForMediaType (legacyscheme .Codecs .SupportedMediaTypes (), runtime .ContentTypeJSON )
142
142
if ! ok {
@@ -160,7 +160,7 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
160
160
AllowPodAffinityNamespaceSelector : true ,
161
161
}
162
162
163
- // Enable CustomPodDNS for testing
163
+ // 为测试启用 CustomPodDNS
164
164
// feature.DefaultFeatureGate.Set("CustomPodDNS=true")
165
165
switch t := obj .(type ) {
166
166
case * api.ConfigMap :
@@ -230,7 +230,7 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
230
230
if t .Namespace == "" {
231
231
t .Namespace = api .NamespaceDefault
232
232
}
233
- // handle clusterIPs, logic copied from service strategy
233
+ // 处理几个 ClusterIP,根据服务策略进行逻辑复制
234
234
if len (t .Spec .ClusterIP ) > 0 && len (t .Spec .ClusterIPs ) == 0 {
235
235
t .Spec .ClusterIPs = []string {t .Spec .ClusterIP }
236
236
}
@@ -258,8 +258,8 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
258
258
if t .Namespace == "" {
259
259
t .Namespace = api .NamespaceDefault
260
260
}
261
- // Job needs generateSelector called before validation, and job.Validate does this.
262
- // See: https://github.com/kubernetes/kubernetes/issues/20951#issuecomment-187787040
261
+ // Job 需要在校验前调用 generateSelector,然后 job.Validate 执行校验。
262
+ // 请参阅: https://github.com/kubernetes/kubernetes/issues/20951#issuecomment-187787040
263
263
t .ObjectMeta .UID = types .UID ("fakeuid" )
264
264
if strings .Index (t .ObjectMeta .Name , "$" ) > - 1 {
265
265
t .ObjectMeta .Name = "skip-for-good"
@@ -315,13 +315,13 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
315
315
}
316
316
errors = policy_validation .ValidatePodDisruptionBudget (t )
317
317
case * rbac.ClusterRole :
318
- // clusterole does not accept namespace
318
+ // ClusterRole 不接受名字空间
319
319
errors = rbac_validation .ValidateClusterRole (t )
320
320
case * rbac.ClusterRoleBinding :
321
- // clusterolebinding does not accept namespace
321
+ // ClusterRoleBinding 不接受名字空间
322
322
errors = rbac_validation .ValidateClusterRoleBinding (t )
323
323
case * storage.StorageClass :
324
- // storageclass does not accept namespace
324
+ // StorageClass 不接受名字空间
325
325
errors = storage_validation .ValidateStorageClass (t )
326
326
default :
327
327
errors = field.ErrorList {}
@@ -330,8 +330,8 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
330
330
return errors
331
331
}
332
332
333
- // Walks inDir for any json/yaml files. Converts yaml to json, and calls fn for
334
- // each file found with the contents in data.
333
+ // 遍历 inDir 目录查找所有 json/yaml 文件。将 yaml 转换为 json,
334
+ // 并根据 data 中的内容找到的每个文件来调用 fn。
335
335
func walkConfigFiles (inDir string , t * testing.T , fn func (name , path string , data [][]byte )) error {
336
336
return filepath .Walk (inDir , func (path string , info os.FileInfo , err error ) error {
337
337
if err != nil {
@@ -352,7 +352,7 @@ func walkConfigFiles(inDir string, t *testing.T, fn func(name, path string, data
352
352
353
353
var docs [][]byte
354
354
if ext == ".yaml" {
355
- // YAML can contain multiple documents.
355
+ // YAML 可以包含多个文档。
356
356
splitter := yaml .NewYAMLReader (bufio .NewReader (bytes .NewBuffer (data )))
357
357
for {
358
358
doc , err := splitter .Read ()
@@ -366,7 +366,7 @@ func walkConfigFiles(inDir string, t *testing.T, fn func(name, path string, data
366
366
if err != nil {
367
367
return fmt .Errorf ("%s: %v" , path , err )
368
368
}
369
- // deal with "empty" document (e.g. pure comments)
369
+ // 处理 "空白" 文档(例如纯注释)
370
370
if string (out ) != "null" {
371
371
docs = append (docs , out )
372
372
}
@@ -385,7 +385,7 @@ func walkConfigFiles(inDir string, t *testing.T, fn func(name, path string, data
385
385
func TestExampleObjectSchemas (t * testing.T ) {
386
386
initGroups ()
387
387
388
- // Please help maintain the alphabeta order in the map
388
+ // 请帮助保持映射图中的 alphabeta 顺序
389
389
cases := map [string ]map [string ][]runtime.Object {
390
390
"admin" : {
391
391
"namespace-dev" : {& api.Namespace {}},
@@ -691,7 +691,7 @@ func TestExampleObjectSchemas(t *testing.T) {
691
691
},
692
692
}
693
693
694
- // Note a key in the following map has to be complete relative path
694
+ // 请注意,以下映射中的某个键必须是完整的相对路径
695
695
filesIgnore := map [string ]map [string ]bool {
696
696
"audit" : {
697
697
"audit-policy" : true ,
@@ -705,7 +705,7 @@ func TestExampleObjectSchemas(t *testing.T) {
705
705
tested := 0
706
706
numExpected := 0
707
707
path := dir
708
- // Test if artifacts do exist
708
+ // 测试这些工件是否存在
709
709
for name := range expected {
710
710
fn := path + "/" + name
711
711
_ , err1 := os .Stat (fn + ".yaml" )
0 commit comments