Commit Graph

1121 Commits

Author SHA1 Message Date
Hidde Beydals d23bcbb5db controllers: wire ChartRepository in reconciler
This wires the `ChartRepository` changes into the reconciler to ensure
it works.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-19 17:04:00 +01:00
Hidde Beydals f5f212ff43 internal/helm: introduce ChartBuilder
This commit starts with the creation of a `ChartBuilder` to facilitate
the (conditional) build of a chart outside of the reconciler logic.

The builder can be configured with a set of (modifying) options, which
define together with the type of chart source what steps are taken
during the build.

To better facilitate the builder's needs and attempt to be more
efficient, changes have been made to the `DependencyBuilder` and
`ChartRepository` around (order of) operations and/or lazy-load
capabilities.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-19 17:04:00 +01:00
Hidde Beydals d60131d16b internal/helm: optimize dependency manager
This commit starts with the optimization of the `DepenendencyManager`,
ensuring the chart indexes are lazy loaded, and replacing the
(limitless) concurrency with a configurable number of workers with a
default of 1.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-19 17:04:00 +01:00
Hidde Beydals 44c1863334 internal/helm: add repository cache helpers
This commits adds simple caching capabilities to the
`ChartRepository`, which makes it possible to load the `Index` from a
defined `CachePath` using `LoadFromCache()`, and to download the index
to a new `CachePath` using `CacheIndex()`.

In addition, the repository tests have been updated to make use of
Gomega, and some missing ones have been added.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-19 17:04:00 +01:00
Hidde Beydals 8537a0f8fa internal/helm: add helpers to load chart metadata
This commits adds `LoadChartMetadataFromArchive` and
`LoadChartMetadataFromDir` helpers to the internal `helm` package
to be able to make observations to the Helm metadata file without
loading the chart in full.

The helpers are compatible with charts of the v1 format (with a
separate `requirements.yaml` file), and an additional
`LoadChartMetadata` helper is available to automatically call the
right `LoadChartMetadataFrom*` version by looking at the file
description of the given path.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-19 17:04:00 +01:00
Hidde Beydals cc2bc5691a
Merge pull request #493 from fluxcd/update-deps 2021-11-19 14:31:52 +01:00
Hidde Beydals 4ce894a62c Update opencontainers/image-spec to v1.0.2
Another patch for CVE-2021-41190.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-19 13:58:30 +01:00
Hidde Beydals f933cb5923 Update docker/cli to v20.10.9
To mitigate warnings for CVE-2021-41092. Because even if there is no
impact whatsoever, we are nice people.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-19 13:58:30 +01:00
Hidde Beydals 19eb3d5ce7 Update docker/distribution to v2.7.0-rc.0
This mitigates another warning for CVE-2017-11468, which is mostly
triggered because a part of Helm depends on it that our code paths
never reach.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-19 13:58:30 +01:00
Hidde Beydals d10c51547a Update containerd and runc dependencies
To mitigate warnings for CVE-2021-41190 which effects both.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-19 13:58:30 +01:00
Hidde Beydals 4677bfdca1
Merge pull request #489 from fluxcd/test-gc-fixes 2021-11-16 11:01:20 +01:00
Hidde Beydals cc71517ed3 tests: ensure proper garbage collection
- Ensure the proper path is garbage collected for libgit2 repositories,
  as the `Path` method on the repository object returns the `.git`
  directory, and not the root path.
- Ensure the Helm test server does not get swapped during tests,
  with as side-effect that no obsolete temporary directories remain.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-16 10:39:58 +01:00
Stefan Prodan 448d5e7afa
Merge pull request #488 from fluxcd/release-v0.18.0
Release v0.18.0
2021-11-12 15:12:00 +02:00
Stefan Prodan f26ce87c0d
Release v0.18.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-12 14:51:44 +02:00
Stefan Prodan e8109694bb
Merge pull request #487 from fluxcd/sha256-backport
storage: change Artifact checksum to SHA256
2021-11-12 09:12:54 +02:00
Hidde Beydals fb688ffe8a
storage: change Artifact checksum to SHA256
This changes the format of the Artifact checksum from SHA1 to SHA256 to
mitigate chosen-prefix and length extension attacks, and ensures it can
be used to secure content against malicious modifications.

Source consumers (including our own {kustomize,helm}-controllers)
should ensure the SHA256 of a downloaded artifact matches the
advertised checksum before making use of it.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-11 22:47:49 +01:00
Sunny f3f7193a53
Merge pull request #483 from fluxcd/release-v0.17.2
Release v0.17.2
2021-11-04 17:42:25 +05:30
Sunny ede3295bd6 Release v0.17.2
Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-11-04 17:19:23 +05:30
Sunny 68a3ea2e4d Add tests for libgit2 remote callbacks
- Adds tests for the libgit2 remote callbacks
- Adds tests for CheckoutStrategyForImplementation with context timeout
  and verify timeout is respected by both the git implementations.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-11-04 16:17:23 +05:30
Sunny 65e5c6a686 libgit2: Add more RemoteCallbacks
Add SidebandProgressCallback to be able to cancel the network operation
before any transfer operation.
Add PushTransferProgressCallback to be able to cancel the push transfer
operation.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-11-04 16:17:23 +05:30
Sunny d407c824d6 libgit2: Add early return to transferProgressCallback
In transferProgressCallback(), if the received objects is equal to the
total objects, return early with OK.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-11-04 16:17:23 +05:30
Hidde Beydals afa82bbc7a libgit2: ensure context timeout cancels transfer
With the information from the refactor still fresh in mind, I continue
to find new paths now I mentally tamed the git2go beast.

`libgit2` seems to assume that a transport will eventually tell by
itself that it has timed out. This also means that at present any
timeout configuration does not seem have an effect. It will continue
to transfer until the remote (or _something_ else) tells it is no
longer transfering.

This commit introduces a simple check (without tests) which was used
to confirm the theory in combination with the tests in
`pkg/git/strategy` (by setting it to a very low timeout and observing
it fail).

A future iteration should probably take the data given to the callback
into account to ensure it doesn't error out if the given data[1]
reports it has successfully received all objects. Another candidate
for this check may be `CompletionCallback`, but one should study the
C code (and likely some Go code as well) before this.

In addition, to ensure the same timeout is taken into account for push
operations, `PushTransferProgressCallback` may require a likewise
helper.

[1]: https://github.com/libgit2/git2go/blob/main/remote.go#L50-L58

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-04 16:17:23 +05:30
Hidde Beydals f0d0f2a0e8
Merge pull request #480 from fluxcd/release-v0.17.1 2021-10-30 14:54:12 +02:00
Hidde Beydals d98cfaa815 Release v0.17.1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-30 11:36:28 +02:00
Hidde Beydals 14cb2a7b29
Merge pull request #479 from kingdonb/fix-commit-verification 2021-10-29 17:31:10 +02:00
Kingdon Barrett d400c8e9e8 Fix error during public key import
For signed commit verification, this code errors out on line 303:

✗ GitRepository reconciliation failed: ''PGP public keys secret error: expected pointer, but got nil

Pointer was not initialized with a concrete instance of the Secret struct

Signed-off-by: Kingdon Barrett <yebyen@gmail.com>
2021-10-29 10:54:16 -04:00
Hidde Beydals d3ea648454
Merge pull request #476 from fluxcd/release-v0.17.0 2021-10-28 15:29:49 +02:00
Hidde Beydals 4d7812ea64 Release v0.17.0
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-28 15:11:58 +02:00
Hidde Beydals cd245069d1
Merge pull request #475 from darkowlzz/libgit2-parseKnownHosts-fix 2021-10-28 14:44:52 +02:00
Sunny 10d262032c libgit2: handle EOF in parseKnownHosts()
parseKnownHosts() uses golang.org/x/crypto/ssh's ParseKnownHosts() for
parsing known hosts. It returns EOF error when the input is not a host
public key, but a valid known_hosts content, like a comment line.

With this fix, lines causing EOF error are skipped and the parsing of
the known_hosts file continues. But invalid lines still cause parsing
failure.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-28 17:35:46 +05:30
Hidde Beydals 5ccb914620
Merge pull request #462 from fluxcd/git-auth-opts 2021-10-28 10:35:45 +02:00
Hidde Beydals d0ca107e55 docs: GitRepository commit without branch example
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 17:00:11 +05:30
Sunny a7f2e870bf transportAuth(): Add checks for invalid transports
Update GitRepositoryReconciler to use a nil authOpts unless it's
configured.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-27 16:59:26 +05:30
Sunny f9a34045e1 Update gittestserver
New gittestserver fixes the issue with custom branch in an
initialized repo.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-27 00:43:31 +05:30
Sunny 5bd08a6960 Add Host field check in AuthOptions.Validate()
For ssh, Host field is required in AuthOptions.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-27 00:43:31 +05:30
Sunny 562af6d658 Add git.CheckoutStrategy SemVer checkout tests
Adds tests for git.CheckoutStrategy to check if both the git
implementations follow the same SemVer tag selection rules.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-27 00:43:31 +05:30
Hidde Beydals 99428f593e libgit2: change credentialsCallback logic
This changes the logic of `credentialsCallback` so that it takes the
`allowedTypes` passed on by `git2go` into account. Reason for this
change is because this prepares it to work with `v33`, but also
because it can provide better guidance when `libgit2` has been
compiled with a different configuration, which e.g. doesn't
allow for "in-memory SSH keys".

Because `AuthOptions#Identity` now gets validated by the callback
and go-git does its own validaiton, the check has been removed
from `Validate` (and now does a simple check if the fields are set).

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Hidde Beydals 7a5d8b116d git: styling nitpicks
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Hidde Beydals c814e0fa26 git: remove ', error:' from returned error
As we properly nest errors.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Sunny 8c581ddfbc Add git.CheckoutStrategy auth tests
Adds tests for git.CheckoutStrategy to check if both the git
implementations work with all the authentication methods.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-27 00:43:31 +05:30
Sunny 942c310195 pkg/git: AuthOptions.Validate() test improvements
Adds more test cases for Validate() and an error for unknown transport.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-27 00:43:31 +05:30
Hidde Beydals 4a23126c6a libgit2: make RemoteCallbacks helper public
Main requirement for this is the image-automation-controller
depending on being able to get a working auth configuration.

Once the package is moved, we should add push logic to it,
so that the controller is able to use that instead.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Hidde Beydals b7376ce94c gogit: allow checkout of commit without branch
This commit changes the `gogit` behavior for commit checkouts,
now allowing one to reference to just a commit while omitting any
branch reference. Doing this creates an Artifact with a
`HEAD/<commit>` revision.

If both a `branch` and `commit` are defined, the commit is expected
to exist within the branch. This results in a more efficient clone
of just the target branch, and also makes this change backwards
compatible.

Fixes #407
Fixes #315

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Hidde Beydals 5a1fcc213b git: standardise commit and (PGP) verification
This commit refactors the previous `Commit` interface into a
standardised `Commit` struct. This object contains sufficient
information for referencing, observating and (PGP) verification.

- `libgit2` commit checkout does now return `HEAD/<SHA1>` as
  the branch is not taken into account.
- `git2go` objects are now properly `Free`d everywhere
- `Verify` logic is tested.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Hidde Beydals 80b9807550 gogit: add CheckoutStrategy tests
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Hidde Beydals 0cf0d4e756 git: refactor AuthStrategy into AuthOptions
This commit moves the previous `AuthStrategy` wiring to a more generic
`AuthOptions`, breaking free from implementation specific details in
the `git` package.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Hidde Beydals 46a5b9c27d
Merge pull request #466 from dholbach/move-contributor-doc 2021-10-26 16:03:39 +02:00
Daniel Holbach 4411a6ec80 Centralise Contributor docs, add Dev doc
As part of fluxcd/.github#4, create DEVELOPMENT.md
	Will link to this doc from fluxcd.io/contributing
	so new folks can find this easily.

Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-10-26 11:24:41 +02:00
Hidde Beydals db14c22923
Merge pull request #460 from fluxcd/release-v0.16.1 2021-10-22 14:40:45 +02:00
Hidde Beydals bef17ae851 Release v0.16.1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-22 14:24:22 +02:00