Commit Graph

33 Commits

Author SHA1 Message Date
LWJ d1cfabf793 Fix nil pointer dereference and minor refactor
Signed-off-by: LWJ <lwjames1996@gmail.com>
2021-03-29 18:16:37 +01:00
LWJ b668e99a91 SigningKey modifications to align process with SOPS
Signed-off-by: LWJ <lwjames1996@gmail.com>
2021-03-24 21:54:31 +00:00
LWJ 4aa56f1013 Add SigningKey to CommitSpec
Signed-off-by: LWJ <lwjames1996@gmail.com>
2021-03-24 21:54:31 +00:00
Stefan Prodan 2e53745a03
Allow specifying the path for manifests updates
- Add optional `path` field to `spec.update`, defaults to the git repo root
- Restrict updates to the specified `spec.update.path`

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-16 11:58:21 +02:00
Michael Bridgen 97c7510d2e Add PushSpec to image update automation type
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-04 17:35:58 +00:00
Stefan Prodan f5a8b922b9
Update fluxcd/pkg/runtime to v0.8.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-01-21 19:57:12 +02:00
Michael Bridgen 6dfb1e84ee Default .strategy as well, to help migration
The `.spec.update` field has a default, which means you can leave it
out of new objects, and it will still be a valid spec. However,
existing objects will not be valid, because they will have a value for
`.spec.update` (so it won't get the default) which doesn't have a
value for `.strategy` (which is required, and an enum).

So: default the strategy field as well, so that existing objects are
still valid. This doesn't change the meaning of any existing objects,
since the outcome is the default, which is the only possible value
anyway.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-20 14:30:24 +00:00
Michael Bridgen bd76267be5 Reform update strategy types
It's convenient to be able to leave out the update strategy, since
there is only one possible value at present; and if there were
alternatives, the present choice would still be a reasonable
default. However, with the format as it is, this doesn't work with
OpenAPIv3 schema, so you have to supply a value, even though there are
no parameters:

```yaml
spec:
  update:
    setters: {}
```

A more self-explanatory format which _does_ work with defaulting is to
name the strategy rather than relying on the presence of a field:

```yaml
spec:
  update:
    strategy: Setters
```

The whole `update` field can be elided and left to default. This
doesn't preclude having other strategies later, even those with
parameters, e.g.,

```yaml
spec:
  update:
    strategy: Foo
    fooParam: 5
```

This commit changes the API types and code that uses them, and the CRD
manifest, and adds a test that checks the defaulting actually works.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-20 13:16:18 +00:00
Michael Bridgen eb7ca1f3bd Record the last pushed SHA1 and the time it was pushed
This adds fields to the ImageUpdateAutomation status for recording the
commit last pushed; handy to see when you are expecting a change.

It also adapts the "steady state" message of the ready condition to
mention the last commit, in case that's where people are looking.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-05 17:01:13 +00:00
Michael Bridgen 308748f515 Make the branch field mandatory
Instead of having an arbitrary default branch, make the checkout
branch mandatory. This needed a little finessing in the tests, since
they did not cover using different branches (though did cover using a
non-standard branch).

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-05 11:33:52 +00:00
Michael Bridgen 9a4fe520c6 Remove paths field from update.setters
The paths field in update.setters is to restrict the update to files
in particular paths.

But this is not implemented, and although it sounds useful, it's not
clear it's necessary. Until there's a known problem to be solved by
it, I'm removing it.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-12-09 11:10:54 +00:00
Michael Bridgen 5b4e93ebe4 Define const for ImageUpdateAutomation kind
This is handy for the CLI, among other places.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-12-07 14:59:25 +00:00
Michael Bridgen c069305a42 Change optional RunInterval to required Interval
This is to line up better with the other GitOps Toolkit API types.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-12-07 14:58:13 +00:00
Michael Bridgen a582871a79 Make sure reconcile request annotation works
The convention among GOTK controllers is to use a "reconcile request"
annotation to force a reconcilation, outside of spec or dependency
changes. This is used by e.g., the incoming webhooks handler. The
predicate `ChangePredicate`, already used by this controller, takes
this into account by allowing events that either caused the generation
to increment, _or_ changed the reconcile request annotation.

This commit adds a test that the automation will indeed run when the
annotation is set. This is a little delicate, because I have to rule
out _other_ reasons it might run. To do so, the test makes a change to
the git repo that will be overwritten by an automation run -- a commit
will not trigger a Reconcile call since it's entirely outside
Kubernetes.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-30 15:15:34 +00:00
Michael Bridgen 5cac345a43 Add Suspend field to spec
Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-30 15:15:34 +00:00
Michael Bridgen 0cf879abd2 Add generated API docs
Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-30 14:19:55 +00:00
Michael Bridgen a036d00db1 Add target for API docs generation to Makefile
This adapts the API docs generation, minimally, from
kustomize-controller to work here.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-30 14:17:03 +00:00
Michael Bridgen 38b7d2e8aa Document extra ready condition reasons
Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-26 12:17:09 +00:00
Michael Bridgen a09ac3f9d4 Make controller update ready condition
This gives ImageUpdateAutomation objects .status.conditions and
.status.observedGeneration fields, which are maintained by the
controller in the GOTK-standard way.

The only condition used is a Ready condition, compatible with kstatus
(and in common with other GOTK controllers). An object is marked Ready
if the reconciliation exits without an error, whether or not changes
were actually made. If the automation run cannot proceed, e.g.,
because the git repository referred to does not exist, or is not
cloneable, it will be marked as not ready.

This means the condition is a reliable guide to whether the particular
automation is operating or not; new objects will be marked ready as
soon as they have been run through successfully, and will stay ready
until there's a problem. Generally, if there _is_ a problem, the
object will be requeued with a backoff, or left to wait until
circumstances change (e.g., the object itself is edited); one way or
another, there will be a retry, and thereby an opportunity to
transition to ready.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-25 14:59:14 +00:00
Hidde Beydals 29c60ecc6e Change copyright to Flux authors
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-10-27 17:57:31 +01:00
Michael Bridgen da2f23caf1 Remove proof-of-concept update mode
The initial implementation of image updates required a single image
policy, and updated every image field that used the image, in the git
repo. This mode has limited practical value, and rather than
elaborating on it, it would be better to concentrate on making the
more carefully thought-through "setters" mode.
2020-10-22 14:53:41 +01:00
Michael Bridgen fd4b139dec Add setters strategy to ImageUpdateAutomation type
This is the means for telling the controller to use kyaml setters, per
the design in
https://github.com/fluxcd/toolkit/discussions/107#discussioncomment-82746
2020-09-28 11:06:18 +01:00
Michael Bridgen 48aac78343 Reassign copyright to Flux project 2020-08-10 17:48:24 +01:00
Michael Bridgen a1a204b613 Make comments match field names, in post 2020-08-05 19:49:31 +01:00
Michael Bridgen ccee0af7f0 Rename .ImagePolicy -> .ImagePolicyRef
.. to be in line with gitops-toolkit convention.
2020-08-05 19:09:52 +01:00
Michael Bridgen 140360f327 Move GitRepository -> Checkout.GitRepositoryRef
This moves the specificiation for the checkout of the git repo to a
struct `GitCheckoutSpec`; and, renames the field that's a reference to
a GitRepository so it has the suffix `Ref` per gitops-toolkit
convention.
2020-08-05 19:09:09 +01:00
Michael Bridgen 6dea89456b Use a specific git branch to sidestep assumptions
When I set my default branch for `git init` in ~/.gitconfig, tests
start failing. This is because go-git assumes a default of `master`
when e.g., pulling commits, but exec'ing git (as the test server does,
via gitkit) will get you a different branch.

The answer is to be explicit about the branch created in tests, and in
all operations like cloning. The natural end point is that the
automation object specifies a branch to use (or an empty value,
meaning let it default).
2020-08-03 13:34:14 +01:00
Michael Bridgen db373c5b22 Add runInterval and lastAutomationRunTime fields
The runInterval spec field gives a period for scheduled automation
runs, so it'll get done regularly whether or not the dependencies
appear to have changed.

The lastAutomationRunTime status field records the last time the
particular automation completed a run, whether or not it made
changes. This is informational, and will help with scheduling periodic
automations.
2020-08-02 21:29:25 +01:00
Hidde Beydals 8dc836e604 Change CRDs domain to 'image.toolkit.fluxcd.io'
This includes changes to the `README.md`, and a bump of the
`source-controller` dependency.
2020-07-31 17:05:56 +02:00
Michael Bridgen 71cf370dc8 Commit and push changes after running update
This makes the controller commit changes and push to the origin, when
it's run the update. There's some new fields in the
ImageUpdateAutomation type for specifying the commit message and
author.
2020-07-23 18:20:35 +01:00
Michael Bridgen 739f3c1770 Add update strategy that uses image policy
Just to get points on the board, this gives ImageUpdateAutomation an
`update` field into which you can plug the name of an ImagePolicy
resource (from the image reflector controller). The idea is that the
automation will then replace the image in the policy, anywhere it's
used, with its latest version.
2020-07-23 18:20:35 +01:00
Michael Bridgen 166ad7e3aa Refer to a git repository in ImageUpdateAutomation
This adds the field GitRepository in the ImageUpdateAutomation, for
referring to the git repository in which to make updates.
2020-07-23 18:14:28 +01:00
Michael Bridgen a048169819 Add ImageUpdateAutomation type and controller
kubebuilder create api --group image --version v1alpha1 \
      --kind ImageUpdateAutomation
2020-07-23 18:14:28 +01:00