Skip to content

Commit 38671db

Browse files
authored
Merge pull request #62 from fluxcd/runinterval-interval
RunInterval -> Interval
2 parents 32380fb + 5b4e93e commit 38671db

File tree

6 files changed

+62
-26
lines changed

6 files changed

+62
-26
lines changed

api/v1alpha1/imageupdateautomation_types.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ import (
2323
"github.com/fluxcd/pkg/apis/meta"
2424
)
2525

26+
const ImageUpdateAutomationKind = "ImageUpdateAutomation"
27+
2628
// ImageUpdateAutomationSpec defines the desired state of ImageUpdateAutomation
2729
type ImageUpdateAutomationSpec struct {
2830
// Checkout gives the parameters for cloning the git repository,
2931
// ready to make changes.
3032
// +required
3133
Checkout GitCheckoutSpec `json:"checkout"`
32-
// RunInterval gives a lower bound for how often the automation
33-
// run should be attempted. Otherwise it will default.
34-
// +optional
35-
RunInterval *metav1.Duration `json:"minimumRunInterval,omitempty"`
34+
// Interval gives an lower bound for how often the automation
35+
// run should be attempted.
36+
// +required
37+
Interval metav1.Duration `json:"interval"`
3638
// Update gives the specification for how to update the files in
3739
// the repository
3840
// +required

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ spec:
8282
- authorEmail
8383
- authorName
8484
type: object
85-
minimumRunInterval:
86-
description: RunInterval gives a lower bound for how often the automation
87-
run should be attempted. Otherwise it will default.
85+
interval:
86+
description: Interval gives an lower bound for how often the automation
87+
run should be attempted.
8888
type: string
8989
suspend:
9090
description: Suspend tells the controller to not run this automation,
@@ -110,6 +110,7 @@ spec:
110110
required:
111111
- checkout
112112
- commit
113+
- interval
113114
- update
114115
type: object
115116
status:

controllers/imageupdateautomation_controller.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ import (
5757
"github.com/fluxcd/image-automation-controller/pkg/update"
5858
)
5959

60-
const defaultInterval = 2 * time.Minute
61-
6260
// log level for debug info
6361
const debug = 1
6462
const originRemote = "origin"
@@ -249,10 +247,10 @@ func (r *ImageUpdateAutomationReconciler) SetupWithManager(mgr ctrl.Manager) err
249247

250248
// intervalOrDefault gives the interval specified, or if missing, the default
251249
func intervalOrDefault(auto *imagev1.ImageUpdateAutomation) time.Duration {
252-
if auto.Spec.RunInterval != nil {
253-
return auto.Spec.RunInterval.Duration
250+
if auto.Spec.Interval.Duration < time.Second {
251+
return time.Second
254252
}
255-
return defaultInterval
253+
return auto.Spec.Interval.Duration
256254
}
257255

258256
// durationSinceLastRun calculates how long it's been since the last

controllers/update_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ var _ = Describe("ImageUpdateAutomation", func() {
210210
Namespace: updateKey.Namespace,
211211
},
212212
Spec: imagev1.ImageUpdateAutomationSpec{
213-
RunInterval: &metav1.Duration{Duration: 2 * time.Hour}, // this is to ensure any subsequent run should be outside the scope of the testing
213+
Interval: metav1.Duration{Duration: 2 * time.Hour}, // this is to ensure any subsequent run should be outside the scope of the testing
214214
Checkout: imagev1.GitCheckoutSpec{
215215
GitRepositoryRef: corev1.LocalObjectReference{
216216
Name: gitRepoKey.Name,

docs/api/image-automation.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,16 @@ ready to make changes.</p>
172172
</tr>
173173
<tr>
174174
<td>
175-
<code>minimumRunInterval</code><br>
175+
<code>interval</code><br>
176176
<em>
177177
<a href="https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#Duration">
178178
Kubernetes meta/v1.Duration
179179
</a>
180180
</em>
181181
</td>
182182
<td>
183-
<em>(Optional)</em>
184-
<p>RunInterval gives a lower bound for how often the automation
185-
run should be attempted. Otherwise it will default.</p>
183+
<p>Interval gives an lower bound for how often the automation
184+
run should be attempted.</p>
186185
</td>
187186
</tr>
188187
<tr>
@@ -212,6 +211,19 @@ CommitSpec
212211
<p>Commit specifies how to commit to the git repo</p>
213212
</td>
214213
</tr>
214+
<tr>
215+
<td>
216+
<code>suspend</code><br>
217+
<em>
218+
bool
219+
</em>
220+
</td>
221+
<td>
222+
<em>(Optional)</em>
223+
<p>Suspend tells the controller to not run this automation, until
224+
it is unset (or set to false). Defaults to false.</p>
225+
</td>
226+
</tr>
215227
</table>
216228
</td>
217229
</tr>
@@ -264,17 +276,16 @@ ready to make changes.</p>
264276
</tr>
265277
<tr>
266278
<td>
267-
<code>minimumRunInterval</code><br>
279+
<code>interval</code><br>
268280
<em>
269281
<a href="https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#Duration">
270282
Kubernetes meta/v1.Duration
271283
</a>
272284
</em>
273285
</td>
274286
<td>
275-
<em>(Optional)</em>
276-
<p>RunInterval gives a lower bound for how often the automation
277-
run should be attempted. Otherwise it will default.</p>
287+
<p>Interval gives an lower bound for how often the automation
288+
run should be attempted.</p>
278289
</td>
279290
</tr>
280291
<tr>
@@ -304,6 +315,19 @@ CommitSpec
304315
<p>Commit specifies how to commit to the git repo</p>
305316
</td>
306317
</tr>
318+
<tr>
319+
<td>
320+
<code>suspend</code><br>
321+
<em>
322+
bool
323+
</em>
324+
</td>
325+
<td>
326+
<em>(Optional)</em>
327+
<p>Suspend tells the controller to not run this automation, until
328+
it is unset (or set to false). Defaults to false.</p>
329+
</td>
330+
</tr>
307331
</tbody>
308332
</table>
309333
</div>
@@ -365,6 +389,21 @@ int64
365389
<em>(Optional)</em>
366390
</td>
367391
</tr>
392+
<tr>
393+
<td>
394+
<code>ReconcileRequestStatus</code><br>
395+
<em>
396+
<a href="https://godoc.org/github.com/fluxcd/pkg/apis/meta#ReconcileRequestStatus">
397+
github.com/fluxcd/pkg/apis/meta.ReconcileRequestStatus
398+
</a>
399+
</em>
400+
</td>
401+
<td>
402+
<p>
403+
(Members of <code>ReconcileRequestStatus</code> are embedded into this type.)
404+
</p>
405+
</td>
406+
</tr>
368407
</tbody>
369408
</table>
370409
</div>

0 commit comments

Comments
 (0)