Skip to content

Commit 35221b4

Browse files
cronjob-tutorial: fix issue faced after upgrade of controller-runtime
1 parent 1f2e54f commit 35221b4

File tree

3 files changed

+115
-9
lines changed

3 files changed

+115
-9
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ type CronJobSpec struct {
107107
FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"`
108108
}
109109

110+
// PodSpec is a description of a pod
111+
type PodSpec struct {
112+
// List of references to secrets in the same namespace to use for pulling any of the images used by this pod.
113+
// +kubebuilder:validation:Required
114+
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets"`
115+
116+
// HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified.
117+
// +kubebuilder:validation:Required
118+
HostAliases []corev1.HostAlias `json:"hostAliases"`
119+
}
120+
121+
// LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
122+
type LocalObjectReference struct {
123+
// Name of the referent.
124+
// +kubebuilder:validation:Required
125+
Name string `json:"name"`
126+
}
127+
128+
// HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file.
129+
type HostAlias struct {
130+
// IP address of the host file entry.
131+
// +kubebuilder:validation:Required
132+
IP string `json:"ip"`
133+
}
134+
110135
/*
111136
We define a custom type to hold our concurrency policy. It's actually
112137
just a string under the hood, but the type gives extra documentation,

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

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/docs/internal/cronjob-tutorial/api_design.go

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,49 +48,73 @@ const CronjobSpecExplaination = `
4848
the fields.
4949
*/
5050
`
51-
5251
const CronjobSpecStruct = `
5352
//+kubebuilder:validation:MinLength=0
5453
5554
// The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
56-
Schedule string` + " `" + `json:"schedule"` + "`" + `
55+
Schedule string ` + "`json:\"schedule\"`" + `
5756
5857
//+kubebuilder:validation:Minimum=0
5958
6059
// Optional deadline in seconds for starting the job if it misses scheduled
6160
// time for any reason. Missed jobs executions will be counted as failed ones.
6261
// +optional
63-
StartingDeadlineSeconds *int64` + " `" + `json:"startingDeadlineSeconds,omitempty"` + "`" + `
62+
StartingDeadlineSeconds *int64 ` + "`json:\"startingDeadlineSeconds,omitempty\"`" + `
6463
6564
// Specifies how to treat concurrent executions of a Job.
6665
// Valid values are:
6766
// - "Allow" (default): allows CronJobs to run concurrently;
6867
// - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet;
6968
// - "Replace": cancels currently running job and replaces it with a new one
7069
// +optional
71-
ConcurrencyPolicy ConcurrencyPolicy` + " `" + `json:"concurrencyPolicy,omitempty"` + "`" + `
70+
ConcurrencyPolicy ConcurrencyPolicy ` + "`json:\"concurrencyPolicy,omitempty\"`" + `
7271
7372
// This flag tells the controller to suspend subsequent executions, it does
7473
// not apply to already started executions. Defaults to false.
7574
// +optional
76-
Suspend *bool` + " `" + `json:"suspend,omitempty"` + "`" + `
75+
Suspend *bool ` + "`json:\"suspend,omitempty\"`" + `
7776
7877
// Specifies the job that will be created when executing a CronJob.
79-
JobTemplate batchv1.JobTemplateSpec` + " `" + `json:"jobTemplate"` + "`" + `
78+
JobTemplate batchv1.JobTemplateSpec ` + "`json:\"jobTemplate\"`" + `
8079
8180
//+kubebuilder:validation:Minimum=0
8281
8382
// The number of successful finished jobs to retain.
8483
// This is a pointer to distinguish between explicit zero and not specified.
8584
// +optional
86-
SuccessfulJobsHistoryLimit *int32` + " `" + `json:"successfulJobsHistoryLimit,omitempty"` + "`" + `
85+
SuccessfulJobsHistoryLimit *int32 ` + "`json:\"successfulJobsHistoryLimit,omitempty\"`" + `
8786
8887
//+kubebuilder:validation:Minimum=0
8988
9089
// The number of failed finished jobs to retain.
9190
// This is a pointer to distinguish between explicit zero and not specified.
9291
// +optional
93-
FailedJobsHistoryLimit *int32` + " `" + `json:"failedJobsHistoryLimit,omitempty"` + "`" + `
92+
FailedJobsHistoryLimit *int32 ` + "`json:\"failedJobsHistoryLimit,omitempty\"`" + `
93+
}
94+
95+
// PodSpec is a description of a pod
96+
type PodSpec struct {
97+
// List of references to secrets in the same namespace to use for pulling any of the images used by this pod.
98+
// +kubebuilder:validation:Required
99+
ImagePullSecrets []corev1.LocalObjectReference ` + "`json:\"imagePullSecrets\"`" + `
100+
101+
// HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified.
102+
// +kubebuilder:validation:Required
103+
HostAliases []corev1.HostAlias ` + "`json:\"hostAliases\"`" + `
104+
}
105+
106+
// LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
107+
type LocalObjectReference struct {
108+
// Name of the referent.
109+
// +kubebuilder:validation:Required
110+
Name string ` + "`json:\"name\"`" + `
111+
}
112+
113+
// HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file.
114+
type HostAlias struct {
115+
// IP address of the host file entry.
116+
// +kubebuilder:validation:Required
117+
IP string ` + "`json:\"ip\"`" + `
94118
}
95119
96120
/*
@@ -124,7 +148,7 @@ const (
124148
we want users or other controllers to be able to easily obtain.
125149
126150
We'll keep a list of actively running jobs, as well as the last time that we successfully
127-
ran our job. Notice that we use` + " `" + `metav1.Time` + "`" + ` instead of` + " `" + `time.Time` + "`" + ` to get the stable
151+
ran our job. Notice that we use ` + "`metav1.Time`" + ` instead of ` + "`time.Time`" + ` to get the stable
128152
serialization, as mentioned above.
129153
*/`
130154

0 commit comments

Comments
 (0)