Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#136 from dk-lockdown/trans86
Browse files Browse the repository at this point in the history
zh-translation: docs/book/src/cronjob-tutorial/main-revisited.md
  • Loading branch information
mergify[bot] committed Aug 4, 2020
2 parents b8a7938 + 813a34e commit e8304e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
8 changes: 3 additions & 5 deletions docs/book/src/cronjob-tutorial/main-revisited.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# You said something about main?
# 你还记得关于 main 函数的一些要点吗?

But first, remember how we said we'd [come back to `main.go`
again](/cronjob-tutorial/empty-main.md)? Let's take a look and see what's
changed, and what we need to add.
但首先,还记得我们之前说过的 [再次回顾 `main.go`](/cronjob-tutorial/empty-main.md) 吗?让我们看一下哪些地方改变了,哪些是需要添加的。

{{#literatego ./testdata/project/main.go}}

*Now* we can implement our controller.
*现在* 我们可以实现我们的控制器了。
17 changes: 5 additions & 12 deletions docs/book/src/cronjob-tutorial/testdata/project/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ import (
// +kubebuilder:docs-gen:collapse=Imports

/*
The first difference to notice is that kubebuilder has added the new API
group's package (`batchv1`) to our scheme. This means that we can use those
objects in our controller.
要注意的第一个区别是 kubebuilder 已经添加了一组新的 API 包(`batchv1`)到 scheme。这意味着可以在我们的控制器中使用这些对象。
If we would be using any other CRD we would have to add their scheme the same way.
Builtin types such as Job have their scheme added by `clientgoscheme`.
如果我们要使用任何其他的 CRD,我们必须用相同的方法添加它们的 scheme。内置的类型例如 Job 就添加了它自己的 scheme `clientgoscheme`。
*/
var (
scheme = runtime.NewScheme()
Expand All @@ -54,8 +51,7 @@ func init() {
}

/*
The other thing that's changed is that kubebuilder has added a block calling our
CronJob controller's `SetupWithManager` method.
另一个变化是 kubebuilder 已经添加了一个阻塞调用我们的 CornJob 控制器的 `SetupWithManager` 方法。
*/

func main() {
Expand Down Expand Up @@ -93,12 +89,9 @@ func main() {
}

/*
We'll also set up webhooks for our type, which we'll talk about next.
We just need to add them to the manager. Since we might want to run
the webhooks separately, or not run them when testing our controller
locally, we'll put them behind an environment variable.
我们也会为我们的类型设置 webhook,接下来我们会谈到它。我们只需要将他们添加到 manager。因为我们想分开运行 webhook,而不是在本地测试我们的控制器时运行它们,我们会将它们配置到环境变量中。
We'll just make sure to set `ENABLE_WEBHOOKS=false` when we run locally.
当我们本地运行的时候只需确保 `ENABLE_WEBHOOKS=false`
*/
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&batchv1.CronJob{}).SetupWebhookWithManager(mgr); err != nil {
Expand Down

0 comments on commit e8304e0

Please sign in to comment.