Skip to content

Commit d0a1806

Browse files
🌱 Update cronjob-tutorial automatically (#3231)
* Bump github.com/onsi/ginkgo/v2 from 2.8.0 to 2.8.1 Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.8.0 to 2.8.1. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](onsi/ginkgo@v2.8.0...v2.8.1) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * feat: update cronjob-tutorial automatically --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 4920e55 commit d0a1806

File tree

20 files changed

+2142
-7
lines changed

20 files changed

+2142
-7
lines changed

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ issues:
1111
exclude-rules:
1212
- linters: [gosec]
1313
path: "test/e2e/*"
14+
- path: "hack/docs/*"
15+
linters:
16+
- lll
17+
- gosec
1418

1519
linters-settings:
1620
govet:

docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ limitations under the License.
1717

1818
/*
1919
*/
20+
2021
package v1
2122

2223
/*
2324
*/
25+
2426
import (
2527
batchv1 "k8s.io/api/batch/v1"
2628
corev1 "k8s.io/api/core/v1"

docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This marker is responsible for generating a mutating webhook manifest.
5454
The meaning of each marker can be found [here](/reference/markers/webhook.md).
5555
*/
5656

57-
//+kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob.kb.io,admissionReviewVersions=v1
57+
//+kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob.kb.io,sideEffects=None,admissionReviewVersions=v1
5858

5959
/*
6060
We use the `webhook.Defaulter` interface to set defaults to our CRD.

docs/book/src/cronjob-tutorial/testdata/project/api/v1/groupversion_info.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Since we need to use all the types in this package in our controller, it's
3939
helpful (and the convention) to have a convenient method to add all the types to
4040
some other `Scheme`. SchemeBuilder makes this easy for us.
4141
*/
42+
4243
var (
4344
// GroupVersion is group version used to register these objects
4445
GroupVersion = schema.GroupVersion{Group: "batch.tutorial.kubebuilder.io", Version: "v1"}

docs/book/src/cronjob-tutorial/testdata/project/cmd/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package main
2020
import (
2121
"flag"
2222
"os"
23-
"tutorial.kubebuilder.io/project/internal/controller"
2423

2524
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
2625
// to ensure that exec-entrypoint and run can make use of them.
@@ -34,6 +33,7 @@ import (
3433
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3534

3635
batchv1 "tutorial.kubebuilder.io/project/api/v1"
36+
"tutorial.kubebuilder.io/project/internal/controller"
3737
//+kubebuilder:scaffold:imports
3838
)
3939

@@ -47,6 +47,7 @@ objects in our controller.
4747
If we would be using any other CRD we would have to add their scheme the same way.
4848
Builtin types such as Job have their scheme added by `clientgoscheme`.
4949
*/
50+
5051
var (
5152
scheme = runtime.NewScheme()
5253
setupLog = ctrl.Log.WithName("setup")

docs/book/src/cronjob-tutorial/testdata/project/config/samples/batch_v1_cronjob.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ spec:
2323
- /bin/sh
2424
- -c
2525
- date; echo Hello from the Kubernetes cluster
26-
restartPolicy: OnFailure
26+
restartPolicy: OnFailure
27+

docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
We'll start out with some imports. You'll see below that we'll need a few more imports
2020
than those scaffolded for us. We'll talk about each one when we use it.
2121
*/
22+
2223
package controller
2324

2425
import (
@@ -547,6 +548,7 @@ var (
547548
apiGVStr = batchv1.GroupVersion.String()
548549
)
549550

551+
// SetupWithManager sets up the controller with the Manager.
550552
func (r *CronJobReconciler) SetupWithManager(mgr ctrl.Manager) error {
551553
// set up a real clock, since we're not in a test
552554
if r.Clock == nil {

docs/book/src/cronjob-tutorial/testdata/project/internal/controller/suite_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Kubebuilder scaffolded a `internal/controller/suite_test.go` file that does the
2222
First, it will contain the necessary imports.
2323
*/
2424

25+
2526
package controller
2627

2728
import (
@@ -33,6 +34,7 @@ import (
3334

3435
. "github.com/onsi/ginkgo/v2"
3536
. "github.com/onsi/gomega"
37+
3638
"k8s.io/client-go/kubernetes/scheme"
3739
"k8s.io/client-go/rest"
3840
"sigs.k8s.io/controller-runtime/pkg/client"

hack/docs/check.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
source "$(dirname "$0")/../../test/common.sh"
18+
19+
build_kb
1720

1821
check_directory="$(dirname "$0")/../../docs/book/src/"
1922

hack/docs/generate_samples.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ package main
1919
import (
2020
"fmt"
2121

22-
componentconfig "sigs.k8s.io/kubebuilder/v3/hack/docs/internal"
22+
componentconfig "sigs.k8s.io/kubebuilder/v3/hack/docs/internal/component-config-tutorial"
23+
cronjob "sigs.k8s.io/kubebuilder/v3/hack/docs/internal/cronjob-tutorial"
24+
"sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
2325
)
2426

2527
func main() {
@@ -28,13 +30,13 @@ func main() {
2830
fmt.Println("Generating component-config tutorial...")
2931
UpdateComponentConfigTutorial()
3032

31-
// TODO: Generate cronjob-tutorial
32-
33+
fmt.Println("Generating cronjob tutorial...")
34+
UpdateCronjobTutorial()
3335
// TODO: Generate multiversion-tutorial
3436
}
3537

3638
func UpdateComponentConfigTutorial() {
37-
binaryPath := "/tmp/kubebuilder/bin/kubebuilder"
39+
binaryPath := util.KubebuilderBinName
3840
samplePath := "docs/book/src/component-config-tutorial/testdata/project/"
3941

4042
sp := componentconfig.NewSample(binaryPath, samplePath)
@@ -47,3 +49,16 @@ func UpdateComponentConfigTutorial() {
4749

4850
sp.CodeGen()
4951
}
52+
53+
func UpdateCronjobTutorial() {
54+
binaryPath := util.KubebuilderBinName
55+
samplePath := "docs/book/src/cronjob-tutorial/testdata/project/"
56+
57+
sp := cronjob.NewSample(binaryPath, samplePath)
58+
59+
sp.Prepare()
60+
61+
sp.GenerateSampleProject()
62+
63+
sp.UpdateTutorial()
64+
}

0 commit comments

Comments
 (0)