diff --git a/docs/book/src/cronjob-tutorial/other-api-files.md b/docs/book/src/cronjob-tutorial/other-api-files.md index 82c6362db92..81fb19cdc39 100644 --- a/docs/book/src/cronjob-tutorial/other-api-files.md +++ b/docs/book/src/cronjob-tutorial/other-api-files.md @@ -1,28 +1,22 @@ -# A Brief Aside: What's the rest of this stuff? +# 简要说明: 剩下文件的作用? -If you've taken a peek at the rest of the files in the -[`api/v1/`](https://sigs.k8s.io/kubebuilder/docs/book/src/cronjob-tutorial/testdata/project/api/v1) -directory, you might have noticed two additional files beyond -`cronjob_types.go`: `groupversion_info.go` and `zz_generated.deepcopy.go`. +如果你在 [`api/v1/`](https://sigs.k8s.io/kubebuilder/docs/book/src/cronjob-tutorial/testdata/project/api/v1) 目录下看到了其他文件, +你可能会注意到除了 `cronjob_types.go` 这个文件外,还有两个文件:`groupversion_info.go` 和 `zz_generated.deepcopy.go`。 -Neither of these files ever needs to be edited (the former stays the same -and the latter is autogenerated), but it's useful to know what's in them. + +虽然这些文件都不需要编辑(前者保持原样,而后者是自动生成的),但是如果知道这些文件的内容,那么将是非常有用的。 ## `groupversion_info.go` -`groupversion_info.go` contains common metadata about the group-version: +`groupversion_info.go` 包含了关于 group-version 的一些元数据: {{#literatego ./testdata/project/api/v1/groupversion_info.go}} ## `zz_generated.deepcopy.go` -`zz_generated.deepcopy.go` contains the autogenerated implementation of -the aforementioned `runtime.Object` interface, which marks all of our root -types as representing Kinds. +`zz_generated.deepcopy.go` 包含了前述 `runtime.Object` 接口的自动实现,这些实现标记了代表 `Kinds` 的所有根类型。 -The core of the `runtime.Object` interface is a deep-copy method, -`DeepCopyObject`. +`runtime.Object` 接口的核心是一个深拷贝方法,即 `DeepCopyObject`。 -The `object` generator in controller-tools also generates two other handy -methods for each root type and all its sub-types: `DeepCopy` and -`DeepCopyInto`. +controller-tools 中的 `object` 生成器也能够为每一个根类型以及其子类型生成另外两个易用的方法:`DeepCopy` 和 +`DeepCopyInto`。 diff --git a/docs/book/src/cronjob-tutorial/testdata/project/api/v1/groupversion_info.go b/docs/book/src/cronjob-tutorial/testdata/project/api/v1/groupversion_info.go index 61089dc1713..b4fc920fb70 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/api/v1/groupversion_info.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/api/v1/groupversion_info.go @@ -14,15 +14,11 @@ limitations under the License. */ // +kubebuilder:docs-gen:collapse=Apache License -/* -First, we have some *package-level* markers that denote that there are -Kubernetes objects in this package, and that this package represents the group -`batch.tutorial.kubebuilder.io`. The `object` generator makes use of the -former, while the latter is used by the CRD generator to generate the right -metadata for the CRDs it creates from this package. +/* +首先,我们有一些*包*级别的标记的标记,表示存在这个包中的 Kubernetes 对象,并且这个包表示 `batch.tutorial.kubebuilder.io` 组。`object` 生成器使用前者,而后者是由 CRD 生成器来生成的,它会从这个包创建 CRD 的元数据。 */ -// Package v1 contains API Schema definitions for the batch v1 API group +// 包 v1 包含了 batch v1 API 这个组的 API Schema 定义。 // +kubebuilder:object:generate=true // +groupName=batch.tutorial.kubebuilder.io package v1 @@ -33,18 +29,17 @@ import ( ) /* -Then, we have the commonly useful variables that help us set up our Scheme. -Since we need to use all the types in this package in our controller, it's -helpful (and the convention) to have a convenient method to add all the types to -some other `Scheme`. SchemeBuilder makes this easy for us. +然后,我们有一些常见且常用的变量来帮助我们设置我们的 Scheme 。因为我们需要在这个包的 controller 中用到所有的类型, +用一个方便的方法给其他 `Scheme` 来添加所有的类型,是非常有用的(而且也是一种惯例)。SchemeBuilder 能够帮助我们轻松的实现这个事情。 */ + var ( - // GroupVersion is group version used to register these objects + // GroupVersion 是用来注册这些对象的 group version。 GroupVersion = schema.GroupVersion{Group: "batch.tutorial.kubebuilder.io", Version: "v1"} - // SchemeBuilder is used to add go types to the GroupVersionKind scheme + // SchemeBuilder 被用来给 GroupVersionKind scheme 添加 go 类型。 SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - // AddToScheme adds the types in this group-version to the given scheme. + // AddToScheme 将 group-version 中的类型添加到指定的 scheme 中。 AddToScheme = SchemeBuilder.AddToScheme )