Commit Graph

344 Commits

Author SHA1 Message Date
Michael Bridgen a39bf26567 Bump go to 1.14 2020-08-06 09:07:46 +01:00
Michael Bridgen 36c242bc2b
Merge pull request #14 from squaremo/ref-for-object-refs
Rerun CRD generation to get field docs
2020-08-06 08:58:24 +01:00
Michael Bridgen 0429f323a2 Rerun CRD generation to get field docs 2020-08-06 08:57:38 +01:00
Michael Bridgen 92091637e4
Merge pull request #13 from squaremo/ref-for-object-refs
Use *Ref name for fields containing object refs
2020-08-05 20:12:18 +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 a6c0a3a7a9
Merge pull request #11 from squaremo/moving-to-main
Change build workflow trigger to main branch
2020-08-05 18:13:47 +01:00
Michael Bridgen ea9f7c0c58 Change build workflow trigger to main branch
The default branch is now `main`, so trigger builds from that branch.
Also: use a specific version of the action from fluxcd/pkg, to avoid
just getting the latest commit, whatever that is.
2020-08-05 18:03:11 +01:00
Michael Bridgen 83a86af323
Merge pull request #9 from squaremo/watch-repo-and-policy
Watch repo and policy objects
2020-08-03 21:55:02 +01:00
Michael Bridgen d7bf21cef4 Avoid reconcile tight loop
A resource will be queued whenever it changes, so if you change each
resource every time you see it, you will spin through all of them
continually.

To avoid that situation, this commit changes the reconcile logic so
that the resource status is updated only

 - if it actually make a commit; or,
 - if `interval` has passed since it last updated the status

In a steady state, this means it'll run twice (once for whatever
triggered it, and once because it updated itself) then be requeued
`interval` later.
2020-08-03 21:43:28 +01:00
Michael Bridgen 9328b2c284 Make target for cleaning CRDs used for test 2020-08-03 17:53:16 +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 6d656d108c Run on a schedule
This uses the pattern of recording when last run, then requeuing for
an interval.
2020-08-02 21:30:22 +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
Michael Bridgen a5f891c919 Watch gitrepositories and imagepolicies
An ImageUpdateAutomation refers to a git repository and may refer to
an image policy. Watch both of these kinds, and react to either
changing by queueing any automations that refer to them.
2020-08-02 21:27:09 +01:00
Michael Bridgen d9c204bc20
Merge pull request #8 from hiddeco/spec/domain-change
Change CRDs domain to 'image.toolkit.fluxcd.io'
2020-08-02 21:26:12 +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 f61aee4f97 Remember to create the automation object 2020-07-28 08:33:49 +01:00
Michael Bridgen c10df15184
Merge pull request #4 from squaremo/describe-use
Describe use with a run-through
2020-07-28 07:56:20 +01:00
Michael Bridgen 292d457124 Fill out run-through in README.md
The README now gives a full run-through, starting with installing the
controllers, and ending with the automation making a commit.
2020-07-28 07:54:00 +01:00
Michael Bridgen 36e5d709ed Installation instructions 2020-07-27 16:12:41 +01:00
Michael Bridgen 8449e72702 Make patches work with kustomize build
kustomize build ./config/default hiccoughs on the patches (due to a
mismatch of namespace), while `kubectl apply -k` doesn't. I think this
change will make both work.
2020-07-27 16:06:03 +01:00
Michael Bridgen ddf988b974 Line up default config
- create the namespace that's part of the kustomization
 - get names right in the patches
 - don't use a name prefix, it just confuses things
2020-07-27 13:36:30 +01:00
Michael Bridgen 7931c12aa2 Use fluxcd/pkg definition for github action
(they have all been collected in fluxcd/pkg)
2020-07-27 13:22:21 +01:00
Michael Bridgen a0e26cee85
Merge pull request #1 from squaremo/automation-type
Implement automation type and controller, at the local minima
2020-07-23 18:26:21 +01:00
Michael Bridgen 7c6e87d06a Test the result of the automated commit
This factors out the function that checks directories for equivalence,
and uses it to check that the upstream repo has the expected update
when the controller has pushed its commit.
2020-07-23 18:20:35 +01:00
Michael Bridgen 97393366da Test controller to the point of committing changes
This adds a test for the controller, checking that it will commit and
push a change, with the given commit message. I think checking it made
the right change will need a bit of rejigging tests elsewhere, so I
can compare directory contents (as with pkg/update tests).
2020-07-23 18:20:35 +01:00
Michael Bridgen c7d5511f1e Start test scaffolding
- start a test git server (thanks Stefan and Hidde!)
 - initialise it from a fixture (directory with repo contents)

This is the basics to build on.
2020-07-23 18:20:35 +01:00
Michael Bridgen c4e94d2b17 Change name of deployment 2020-07-23 18:20:35 +01: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 bae999a03b Use the git package from source-controller
It's now exported, so I can use that instead of copypesto.
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 c5ae8f8812 Implement controller up to cloning the git repo
This is enough to clone the repo that's referenced in the
ImageUpdateAutomation resource. It reproduces a bunch of code from the
source-controller which is internal there, to avoid writing it from
scratch.
2020-07-23 18:20:35 +01:00
Michael Bridgen 860b831563 Manifests for ImageUpdateAutomation CRD 2020-07-23 18:20:24 +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
Michael Bridgen a527a739a7
Merge pull request #3 from squaremo/ci-test
Prototype GitHub Actions CI
2020-07-23 18:13:53 +01:00
Michael Bridgen d8b85a50c2 Prototype GitHub Actions CI 2020-07-23 18:10:51 +01:00
Michael Bridgen 3e3c1e7153
Merge pull request #2 from squaremo/better-config
Give the image and configs less generic names
2020-07-21 12:38:24 +01:00
Michael Bridgen 258468cf14 Give the image and configs less generic names 2020-07-21 12:26:24 +01:00
Michael Bridgen d20e803cb3 Ignore notes scratch file 2020-07-20 12:53:38 +01:00
Michael Bridgen baf50cd4fc Initialise controller scaffolding
go mod init github.com/squaremo/image-automation-controller
    kubebuilder init --domain=fluxcd.io
    $EDITOR hack/boilerplate.go.txt
2020-07-18 15:23:13 +01:00
Michael Bridgen ac4cf07715 Initial revision with README 2020-07-18 15:18:39 +01:00