Skip to content

Commit d1164ab

Browse files
authored
Merge pull request #35287 from windsonsea/extest
[zh-cn] sync comments in /examples/examples_test.go
2 parents 0e69e36 + 574dc44 commit d1164ab

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

content/zh-cn/examples/examples_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import (
6161
"k8s.io/kubernetes/pkg/capabilities"
6262
"k8s.io/kubernetes/pkg/registry/batch/job"
6363

64-
// initialize install packages
64+
// 初始化安装包
6565
_ "k8s.io/kubernetes/pkg/apis/apps/install"
6666
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
6767
_ "k8s.io/kubernetes/pkg/apis/batch/install"
@@ -77,18 +77,18 @@ var (
7777
serializer runtime.SerializerInfo
7878
)
7979

80-
// TestGroup contains GroupVersion to uniquely identify the API
80+
// TestGroup 包含 GroupVersion 以唯一地标识该 API
8181
type TestGroup struct {
8282
externalGroupVersion schema.GroupVersion
8383
}
8484

85-
// GroupVersion makes copy of schema.GroupVersion
85+
// GroupVersion 制作 schema.GroupVersion 的副本
8686
func (g TestGroup) GroupVersion() *schema.GroupVersion {
8787
copyOfGroupVersion := g.externalGroupVersion
8888
return &copyOfGroupVersion
8989
}
9090

91-
// Codec returns the codec for the API version to test against
91+
// Codec 为要测试的 API 版本返回编解码器
9292
func (g TestGroup) Codec() runtime.Codec {
9393
if serializer.Serializer == nil {
9494
return legacyscheme.Codecs.LegacyCodec(g.externalGroupVersion)
@@ -136,7 +136,7 @@ func getCodecForObject(obj runtime.Object) (runtime.Codec, error) {
136136
return group.Codec(), nil
137137
}
138138
}
139-
// Codec used for unversioned types
139+
// 还未版本化的类别所用的 Codec
140140
if legacyscheme.Scheme.Recognizes(kind) {
141141
serializer, ok := runtime.SerializerInfoForMediaType(legacyscheme.Codecs.SupportedMediaTypes(), runtime.ContentTypeJSON)
142142
if !ok {
@@ -160,7 +160,7 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
160160
AllowPodAffinityNamespaceSelector: true,
161161
}
162162

163-
// Enable CustomPodDNS for testing
163+
// 为测试启用 CustomPodDNS
164164
// feature.DefaultFeatureGate.Set("CustomPodDNS=true")
165165
switch t := obj.(type) {
166166
case *api.ConfigMap:
@@ -230,7 +230,7 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
230230
if t.Namespace == "" {
231231
t.Namespace = api.NamespaceDefault
232232
}
233-
// handle clusterIPs, logic copied from service strategy
233+
// 处理几个 ClusterIP,根据服务策略进行逻辑复制
234234
if len(t.Spec.ClusterIP) > 0 && len(t.Spec.ClusterIPs) == 0 {
235235
t.Spec.ClusterIPs = []string{t.Spec.ClusterIP}
236236
}
@@ -258,8 +258,8 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
258258
if t.Namespace == "" {
259259
t.Namespace = api.NamespaceDefault
260260
}
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
263263
t.ObjectMeta.UID = types.UID("fakeuid")
264264
if strings.Index(t.ObjectMeta.Name, "$") > -1 {
265265
t.ObjectMeta.Name = "skip-for-good"
@@ -315,13 +315,13 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
315315
}
316316
errors = policy_validation.ValidatePodDisruptionBudget(t)
317317
case *rbac.ClusterRole:
318-
// clusterole does not accept namespace
318+
// ClusterRole 不接受名字空间
319319
errors = rbac_validation.ValidateClusterRole(t)
320320
case *rbac.ClusterRoleBinding:
321-
// clusterolebinding does not accept namespace
321+
// ClusterRoleBinding 不接受名字空间
322322
errors = rbac_validation.ValidateClusterRoleBinding(t)
323323
case *storage.StorageClass:
324-
// storageclass does not accept namespace
324+
// StorageClass 不接受名字空间
325325
errors = storage_validation.ValidateStorageClass(t)
326326
default:
327327
errors = field.ErrorList{}
@@ -330,8 +330,8 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
330330
return errors
331331
}
332332

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。
335335
func walkConfigFiles(inDir string, t *testing.T, fn func(name, path string, data [][]byte)) error {
336336
return filepath.Walk(inDir, func(path string, info os.FileInfo, err error) error {
337337
if err != nil {
@@ -352,7 +352,7 @@ func walkConfigFiles(inDir string, t *testing.T, fn func(name, path string, data
352352

353353
var docs [][]byte
354354
if ext == ".yaml" {
355-
// YAML can contain multiple documents.
355+
// YAML 可以包含多个文档。
356356
splitter := yaml.NewYAMLReader(bufio.NewReader(bytes.NewBuffer(data)))
357357
for {
358358
doc, err := splitter.Read()
@@ -366,7 +366,7 @@ func walkConfigFiles(inDir string, t *testing.T, fn func(name, path string, data
366366
if err != nil {
367367
return fmt.Errorf("%s: %v", path, err)
368368
}
369-
// deal with "empty" document (e.g. pure comments)
369+
// 处理 "空白" 文档(例如纯注释)
370370
if string(out) != "null" {
371371
docs = append(docs, out)
372372
}
@@ -385,7 +385,7 @@ func walkConfigFiles(inDir string, t *testing.T, fn func(name, path string, data
385385
func TestExampleObjectSchemas(t *testing.T) {
386386
initGroups()
387387

388-
// Please help maintain the alphabeta order in the map
388+
// 请帮助保持映射图中的 alphabeta 顺序
389389
cases := map[string]map[string][]runtime.Object{
390390
"admin": {
391391
"namespace-dev": {&api.Namespace{}},
@@ -691,7 +691,7 @@ func TestExampleObjectSchemas(t *testing.T) {
691691
},
692692
}
693693

694-
// Note a key in the following map has to be complete relative path
694+
// 请注意,以下映射中的某个键必须是完整的相对路径
695695
filesIgnore := map[string]map[string]bool{
696696
"audit": {
697697
"audit-policy": true,
@@ -705,7 +705,7 @@ func TestExampleObjectSchemas(t *testing.T) {
705705
tested := 0
706706
numExpected := 0
707707
path := dir
708-
// Test if artifacts do exist
708+
// 测试这些工件是否存在
709709
for name := range expected {
710710
fn := path + "/" + name
711711
_, err1 := os.Stat(fn + ".yaml")

0 commit comments

Comments
 (0)