Commit Graph

344 Commits

Author SHA1 Message Date
Michael Bridgen 8478fd9778
Merge pull request #143 from fluxcd/push-branch-second-commit
Fix problem with pushing further commits to a "push branch"
2021-04-05 09:08:03 +01:00
Michael Bridgen 40fb66a217 Fetch remote branch before switching to it
For the "push to branch" feature, the controller must either switch to
the branch given, or create it starting at the checked-out HEAD. The
func `switchBranch` encapsulates this decision -- but it assumes that
if the branch exists at the remote, it will have been fetched when
cloning, and this is not always true. In particular, cloning with
go-git avoids fetching all refs:

    https://github.com/fluxcd/source-controller/blob/v0.11.0/pkg/git/gogit/checkout.go

This commit adds a step to fetch the remote branch to a local branch,
before attempting to switch to the local branch. This makes
`switchBranch` a little simpler, and doesn't rely on any refs having
been fetched ahead of time.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-04-03 15:11:20 +01:00
Michael Bridgen ddd0a8d8ed Watch ImagePolicy objects
Prior to #27, controller indexed the automation objects against image
policies, since an automation could depend on a specific image
policy. That PR removed the references and the watch; however,
automation objects still depend on image policy objects, just
indirectly through the git repo.

This commit reinstates the watch, and makes sure the generation change
/ reconcile request predicate applies only to the watch on automation
object themselves.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-04-02 20:12:13 +01:00
Michael Bridgen cc3bd7e1da Test further commits to push branch
This adds a test to check that should there be a further update to
make, another commit is pushed to the "push branch". In this case, the
image policy gets a new latest image.

The test fails at present because the controller is not watching image
policies (and will not run again on the long interval specified).

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-04-02 19:45:37 +01:00
Stefan Prodan 89733c608e
Merge pull request #141 from fluxcd/kyaml-v0.10.16
Update kyaml to v0.10.16
2021-03-31 15:16:58 +03:00
Stefan Prodan d6d2b55525
Update kyaml to v0.10.16
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-31 15:00:19 +03:00
Michael Bridgen a4f5b8f38a
Merge pull request #136 from LWJ/commit_signing
Enable GPG Signing of Commits
2021-03-30 13:55:29 +01:00
LWJ b63b5b2771 Catch OpenPGP failures in test
Signed-off-by: LWJ <lwjames1996@gmail.com>
2021-03-30 13:42:12 +01:00
LWJ d1cfabf793 Fix nil pointer dereference and minor refactor
Signed-off-by: LWJ <lwjames1996@gmail.com>
2021-03-29 18:16:37 +01:00
Luke 610bb14a2b
Merge branch 'main' into commit_signing 2021-03-25 15:18:14 +00:00
Stefan Prodan 3d533a95e0
Merge pull request #137 from fluxcd/le-config
Set leader election deadline to 30s
2021-03-25 16:19:22 +02:00
Stefan Prodan 299d874b9e
Use controller name in LeaderElectionID
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-25 14:22:02 +02:00
Stefan Prodan cdd4cb03f6
Set leader election deadline to 30s
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-25 14:04:15 +02:00
LWJ d71e0499ef Fix SigningKey secret key in test
Signed-off-by: LWJ <lwjames1996@gmail.com>
2021-03-24 21:54:31 +00: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 daad724ad2
Merge pull request #132 from bigkevmcd/patch-status-fix
Update ImageUpdateAutomation Status with Patch.
2021-03-23 10:15:34 +02:00
Kevin McDermott 09616174f3 Update ImageUpdateAutomation Status with Patch.
This changes the functionality when updating the status to use Patch
rather than Updating, which is more resilient to changes.

Signed-off-by: Kevin McDermott <bigkevmcd@gmail.com>
2021-03-22 09:45:00 +00:00
Stefan Prodan d25c0d0f38
Merge pull request #130 from jasonraimondi/main
Fix typo in template code example
2021-03-19 11:02:53 +02:00
Jason Raimondi 22fd7a0c77
Fix typo in template code example
Signed-off-by: Jason Raimondi <jason@raimondi.us>
2021-03-18 14:28:56 -07:00
Stefan Prodan 696e06f175
Merge pull request #129 from SomtochiAma/suspend-metrics
Record suspension metrics
2021-03-17 19:13:15 +02:00
Somtochi Onyekwere ace1fbc263 Record suspension metrics
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-03-17 17:51:33 +01:00
Stefan Prodan cea06a926d
Merge pull request #128 from fluxcd/release-v0.7.0
Release v0.7.0
2021-03-17 14:00:13 +02:00
Stefan Prodan e116663fe7
Release v0.7.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-17 12:56:30 +02:00
Stefan Prodan 70ed80ed39
Merge pull request #127 from fluxcd/codeql
Add CodeQL scanning to CI
2021-03-16 18:58:26 +02:00
Stefan Prodan d732f55955
Update image-reflector-controller/api to v0.7.1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-16 18:39:07 +02:00
Stefan Prodan 1e87ebdcc1
Add REFLECTOR_VER to Makefile
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-16 18:05:22 +02:00
Stefan Prodan 715f443dbf
Add CodeQL scanning to CI
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-16 18:04:05 +02:00
Stefan Prodan a1f05d9510
Merge pull request #126 from fluxcd/update-path
Allow specifying the path for manifests updates
2021-03-16 16:46:27 +02:00
Stefan Prodan 7c5d7b81a6
Add update path test
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-16 15:31:34 +02: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 43d9d39d9e
Merge pull request #125 from fluxcd/push-to-branch-doc
Explain how the push field works
2021-03-15 16:10:39 +00:00
Michael Bridgen 340d1a4462 Give an example of {checkout,push}.branch
As a YAML example, this also shows the YAML/JSON field names. Since
field names are different in the Go types, it can be confusing.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-15 15:24:09 +00:00
Michael Bridgen 076758aec7 Explain how the push field works
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-15 15:08:06 +00:00
Stefan Prodan 8f3e35805e
Merge pull request #124 from fluxcd/update-sigs.k8s.io-deps
Update dependencies
2021-03-12 12:36:35 +02:00
Stefan Prodan 4661519e64
Update dependencies
- sigs.k8s.io/kustomize/kyaml v0.10.15
- sigs.k8s.io/controller-runtime v0.8.2

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-12 12:07:27 +02:00
Michael Bridgen e0d66b2f9c
Merge pull request #121 from fluxcd/push-to-branch
Push to branch
2021-03-12 10:05:56 +00:00
Michael Bridgen f90846b247 Implement .spec.push.branch most simply
This adapts the controller so that it will honour the
`.spec.push.branch` field.

The behaviour _without_ that field is to check out the branch given in
`.spec.checkout.branch`, commit, and push to the origin.

With `.spec.push.branch` present, it will try to check out that
branch; if it doesn't exist, it'll create it, starting from
`.spec.checkout.branch`. Either way it'll commit to that branch and
push to the origin.

The effect is that all automation will happen on the "push" branch,
and (most likely) not be applied into the cluster until merged into
whichever branch is synced. When the push branch is deleted, it'll be
created anew; otherwise, commits will pile up there as more changes
are made.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-05 15:17:28 +00: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
Michael Bridgen f45e4a1ebc
Merge pull request #119 from fluxcd/data-for-commit-msg
Supply update result value to the commit message template
2021-03-04 14:49:52 +00:00
Michael Bridgen cfa5a9c574 Phrase the message template example as YAML not go
The message template is used in YAML files, not in go code. I've also
explained up-front that it's a text template -- something not
mentioned to this point.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-04 13:28:37 +00:00
Michael Bridgen 2eebaa46c7 Make the image policy name available to templates
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-03 13:01:29 +00:00
Michael Bridgen df7d570ae5 Give details of template data in spec docs
This explains the data available to the commit message template in the
API guide. While writing it, I realised it could be made more
convenient, so:

 - mask external types by embedding them
 - make the most useful parts of an image ref available using a
   wrapper struct and interface

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-03 11:08:53 +00:00
Michael Bridgen 908f8b775c Supply values to the commit message template
This commit:

 - passes a value including the update result to the commit message
   template
 - gives the template result a method for enumerating the
   objects regardless of file

This means you can access the images updated either by file
(`.Files`), by object (`.Objects()`), or just as a list
(`.Images()`). The additional test case shows how to use these.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-01 22:25:25 +00:00
Michael Bridgen 8daa6491a3 Rearrange the protocol x implementation tests
There is a core chuck of testing that is repeated for {SSH,HTTP} x
{go-git,libgit2}, which is done by repeating a func value in different
contexts. Instead of mutating variables in the func's closure, it's a
bit clearer (and shorter) to pass them to a higher-order func.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-01 19:09:37 +00:00
Michael Bridgen 9c375c582d Move defaulting test so it's run once
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-01 18:44:10 +00:00
Michael Bridgen fbdfa78e87 Adapt pkg/update so it returns a report of updates
It's desirable (see #6) to be able to enumerate the updates that were
made by automation, in the commit message and perhaps in an event
announcing success.

Doing this is counter-intuitively difficult. A `kyaml.setters2.Set`
filter will keep a count of the times its used. Previously, one `Set`
was used with the `SetAll` flag set, which would replace any marker
that corresponded to an image, in one traversal. But to keep track of
images individually, you need to have a setter for _each_ image (and
its tag, and its name, since those can be used separately). This means
`3 x policies` traversals of each node! The saving grace, possibly, is
that only files with a marker in them are considered.

Since you might want to dice the results in different ways, the result
returned is a nested map of file->object->image.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-03-01 17:38:31 +00:00
Hidde Beydals 351b7b6fb6
Merge pull request #116 from fluxcd/release-v0.6.1
Release v0.6.1
2021-02-25 17:13:29 +01:00
Hidde Beydals 00293211fd Release v0.6.1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-02-25 16:15:51 +01:00
Michael Bridgen a56b44b481
Merge pull request #115 from fluxcd/better-push-message
Better error messages from `git push`
2021-02-25 14:55:18 +00:00