Commit Graph

344 Commits

Author SHA1 Message Date
Michael Bridgen f0001de844 Test that error rewriting works as intended
This commit adds a handful of tests to make sure errors in the
problematic formats are rewritten, and other errors are left alone.

I'm reluctant to test against the actual git providers, since that
would introduce a dependency on them. Thus, these tests won't guard
against the providers changing their messages.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-02-25 14:22:08 +00:00
Michael Bridgen 12a339a0e6 Reformat git push errors from libgit2, go-git
libgit2 and go-git both have flaws in the way they treat errors from
the remote. go-git takes only the first line, meaning that it gets a
blank error message from GitLab which like to respond with a
banner. libgit2 returns the whole response, including blank lines and
fences ("=========...").

This commit corrects for both these flaws, by supplying a message if
go-git has taken a blank line, and stripping out blank lines and
fences from libgit2's error. This is unavoidably a brittle approach,
so I have limited it to just the situation that was reported as a
problem: pushing to the upstream git repo.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-02-25 11:17:36 +00:00
Stefan Prodan 3f82d6ce69
Merge pull request #114 from fluxcd/release-v0.6.0
Release v0.6.0
2021-02-24 16:29:09 +02:00
Stefan Prodan 22cb8a23f1
Release v0.6.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-24 16:22:23 +02:00
Stefan Prodan a7ebd004e3
Merge pull request #112 from fluxcd/release-ci
Refactor release workflow
2021-02-24 10:14:03 +02:00
Stefan Prodan 94d82b19c0
Refactor release workflow
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-23 18:04:19 +02:00
Stefan Prodan 22c9a47c7e
Merge pull request #111 from fluxcd/update-deps
Update dependencies
2021-02-23 17:41:36 +02:00
Stefan Prodan 4da2c82d23
Update dependencies
- sigs.k8s.io/controller-tools/cmd/controller-gen v0.4.1
- sigs.k8s.io/controller-runtime v0.8.2
- fluxcd/pkg/runtime v0.8.3
- fluxcd/source-controller v0.9.0

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-23 16:57:47 +02:00
Hidde Beydals eb9fbd3f10
Merge pull request #110 from fluxcd/release-v0.5.0
Release v0.5.0
2021-02-12 13:23:57 +01:00
Hidde Beydals a58b357bb4 Release v0.5.0
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-02-12 13:17:50 +01:00
Hidde Beydals b35b9e33ec
Merge pull request #109 from fluxcd/test-ssh-too 2021-02-12 12:44:22 +01:00
Hidde Beydals 1d3978709e Update source-controller dependencies to v0.8.0
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-02-12 12:38:14 +01:00
Michael Bridgen 172dec486c Test SSH as well as HTTP access to git
This commit rearranges update tests so that those that check that
updates are made can be run against a git server using SSH as well as
HTTP.

The local clone, used to provoke automated updates and to check
results, still uses HTTP. Those operations are not under test.

libgit2 wants to be asked for authentication when using SSH, and will
balk if it's not requested by the server. To avoid that, auth must be
switched on for the git test server.

This also switches auth on for HTTP, so it's necessary to use a git
URL that includes credentials for setting things up with a local
clone. I have also used that URL for the git-over-HTTP tests -- it's
arguable whether it's necessary to test that works, here.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-02-11 13:44:20 +00:00
Michael Bridgen 5d9f0f9958 Replace hard-wired GitImpl'n to that from spec
The "auth strategy", which depends on the GitImplementation, was
hard-wired to the "gogit" constant, but it should come from the
GitRepository spec. When the implementation is "libgit2" and the git
URL entails SSH, the result would normally include a callback for
checking the host key against known_hosts; but since it was
hard-wired, it was missing that callback.

This explains at least some instances of the error `user cancelled
hostkey check` from #106. The error, or a close relative, might also
arise if the callback rejects the host key because the host as it
appears in the known_hosts doesn't match that host as passed to the
callback -- see
https://github.com/fluxcd/source-controller/issues/287.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-02-11 13:44:20 +00:00
Stefan Prodan c1e0def8db
Merge pull request #108 from fluxcd/kyaml-v0.10.9
Update kyaml to v0.10.9
2021-02-11 12:46:23 +02:00
Stefan Prodan 4214372c68
Update kyaml to v0.10.9
Contains a fix for container ports merging issue

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-11 11:56:39 +02:00
Hidde Beydals 2576ec7426
Merge pull request #107 from fluxcd/alpine-3-13-pkgs 2021-02-11 09:52:22 +01:00
Hidde Beydals 0e7379d6c5 Use musl and libgit2 packages from v3.13 branch
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-02-10 22:34:38 +01:00
Stefan Prodan bbec5db754
Merge pull request #105 from fluxcd/alpine-3.13
Update Alpine to v3.13
2021-02-08 11:51:37 +02:00
Stefan Prodan 1e48cd3665
Update Alpine to v3.13
- set fsGroup to allow AWS IAM Role bindings
- fix the group assignment in Alpine
- bump Alpine to 3.13

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-08 11:36:57 +02:00
Hidde Beydals fa6e4ba7ac
Merge pull request #104 from fluxcd/pprof
Enable pprof endpoints on metrics server
2021-02-07 13:08:49 +01:00
Hidde Beydals 3ee2f904e1 Enable pprof endpoints on metrics server
Using the helper from `pkg/runtime/pprof`, which follows the suggestion
from controller-runtime to use `AddMetricsExtraHandler`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-02-07 12:52:14 +01:00
Hidde Beydals caa4edc510
Merge pull request #99 from fluxcd/release-v0.4.0
Release v0.4.0
2021-01-22 11:54:49 +00:00
Hidde Beydals 7ffd8f1577 Release v0.4.0
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-22 12:40:22 +01:00
Stefan Prodan 7d44d6f169
Merge pull request #98 from fluxcd/fluxcd/pkg/runtime-v0.8.0
Update fluxcd/pkg/runtime to v0.8.0
2021-01-22 09:29:32 +02: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 587d2410fe
Merge pull request #95 from fluxcd/update-spec-reform
Reform update strategy types
2021-01-20 17:49:44 +00: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 78dec3ce89 Update API refs
This commit updates the generated and written API refs to account for
the new update strategy types.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-20 13:59:15 +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 a804fcdfc8
Merge pull request #94 from fluxcd/api-ref
Add API reference for ImageUpdateAutomation
2021-01-18 16:59:51 +00:00
Michael Bridgen c33541dd08 Add API reference for ImageUpdateAutomation
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-18 14:40:08 +00:00
Stefan Prodan ec715bf173
Merge pull request #93 from fluxcd/release-0.3.1
Release v0.3.1
2021-01-18 15:32:16 +02:00
Stefan Prodan 06e785d7f1
Release v0.3.1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-01-18 15:20:19 +02:00
Stefan Prodan c1c2039b08
Merge pull request #91 from fluxcd/k8s.io/api-v0.20.2
Update Kubernetes packages
2021-01-18 15:15:44 +02:00
Stefan Prodan db94176374
Update Kubernetes packages
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-01-18 14:54:42 +02:00
Hidde Beydals f64ef67278
Merge pull request #88 from fluxcd/release-v0.3.0
Release v0.3.0
2021-01-15 10:21:05 +01:00
Hidde Beydals cd7c843a6d Release v0.3.0
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-15 10:16:58 +01:00
Michael Bridgen 30d3ef7892
Merge pull request #82 from fluxcd/libgit2-support
Libgit2 support
2021-01-14 16:34:59 +00:00
Michael Bridgen c5322814d9 Document libgit2 requirement in README
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-14 14:19:22 +01:00
Michael Bridgen 42241f2dd1 Use container with libgit2 for CI tests
The build now incorporates libgit2; however, most Linux distributions,
notably Ubuntu and Debian, have a version of libgit2 that's over a
year old. This copies the approach used in source-controller, which is
to use a container image that can be preloaded with an up to date
release of libgit2.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-14 14:19:22 +01:00
Michael Bridgen 4fde199362 Make both clone and push depend on the git impl
This follows up the stage-setting in prior commits, by respecting the
GitImplementation field given in the GitRepository object. NB it only
matters for cloning and pushing, so gogit is used in the "middle" to
record the commit in the local checkout.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-14 14:19:22 +01:00
Michael Bridgen 6866f98306 Separate commit and push
This separates the commit and push steps, since the commit step just
uses gogit, while the push step will dispatch based on the git
implementation.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-14 14:19:22 +01:00
Michael Bridgen 1c37d80f85 Add libgit2 to docker image build
This copies the approach used in source-controller: add the
libgit2-dev package (i.e., headers) to the build container, then add
the shared lib to the _image_ image.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-14 14:17:02 +01:00
Michael Bridgen 5e0ee72e68 Make sure clone and push work with libgit2
This commit changes the clone and push code to use libgit2. In the
case of clone, this means simply passing the const representing the
libgit2 implementation to the source-controller/pkg/git function. In
the case of push, this means adding a small helper to do the required
invocation.

NB:

 - there's no need to use libgit2 for operations other than clone and
   push; in particular, commits can have a single, go-git
   implementation.

 - libgit2's push is quite sensitive to the refspec it's given;
   `<branch>:refs/heads/<branch>` didn't work, and supplying no
   refspecs makes it time out.

 - libgit2 push will only work with a repository on disk that was
   cloned by libgit2 -- it's initialising the repo differently to
   go-git. This is surprising (a git repo is a git repo, isn't it?),
   but fine -- any given automation will use _either_ go-git or
   libgit2 for both of clone and push.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-14 14:17:02 +01:00
Michael Bridgen 861320075a Update to source-controller 0.5.2
This updates the source controller module to v0.5.2, and adjusts the
use of the git package therein. The main change there is that it now
accounts for two different git implementations -- go-git and libgit2
-- but I have not exposed that difference, just made it work as it did
before.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-14 14:15:55 +01:00
Hidde Beydals 0fc8d60e40
Merge pull request #84 from fluxcd/controller-runtime-v0.7.0
Upgrade controller-runtime to v0.7.0
2021-01-14 13:58:51 +01:00
Hidde Beydals 0531deaaed Upgrade controller-runtime to v0.7.0
This commit upgrades the `controller-runtime` dependency to `v0.7.0`,
including all changes required to make all wiring work again.

- Upgrade `runtime` to v0.6.2 to include `controller-runtime` changes.
- Logger has been removed from the reconciler, and is now retrieved
  from the `context.Context` passed to the `Reconcile` method and
  downwards functions.
- Logger configuration flags are now bound to the flag set using
  `BindFlags` from `runtime/logger`, ensuring the same contract across
  GitOps Toolkit controllers, and the `--log-json` flag has been
  deprecated in favour of the `--log-encoding=json` default.
- The `ChangePredicate` from `runtime` has changed to a
  `ReconcileRequestedPredicate`, and is now chained with the
  `GenerationChangedPredicate` from `controller-runtime` using
  `predicate.Or`.
- Signatures that made use of `runtime.Object` have changed to
  `client.Object`, removing the requirement to e.g. call
  `runtime.Object#Object`.
- The `leader-election-role` was changed, as leader election now works
  via the `coordination/v1` API.

Other notable changes:

- Upgrade of `image-reflector-controller` API package to include
  controller-runtime changes.
- Upgrade of `source-controller` API package to v0.6.1.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-14 13:48:37 +01:00
Michael Bridgen f0963d1884
Merge pull request #87 from fluxcd/bump-kyaml-with-consequences
Update to kyaml 0.10.5
2021-01-13 17:10:12 +00:00
Michael Bridgen a6e151d63a Update to kyaml 0.10.5
This contains a number of fixes, in particular for an indentation bug
that seems to have been introduced not long ago, and which would
otherwise cause problems after updating controller-runtime (which
brings a slightly less recent kyaml with it).

This also comes with a nice enhancement: it's no longer necessary to
use the global schema for kio setters, you can just build a schema and
use that. No need to serialise access to the global schema. Yay!

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-01-13 16:46:14 +00:00