Commit Graph

104 Commits

Author SHA1 Message Date
Matheus Pimenta e128d3b795
[RFC-0010] Introduce object-level workload identity for container registry APIs
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-07 18:33:59 +01:00
Matheus Pimenta 2dde6bf536
Upgrade fluxcd/pkg cache, auth, git and gogit
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-03 15:47:39 +01:00
Stefan Prodan 3c7812d387
Update to Kubernetes 1.33.0 and Go 1.24.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-04-28 14:10:47 +03:00
Dipti Pai 61f9eb28fc Sparse Checkout Directories in GitRepositories.
- Add `.spec.sparseCheckout` and `.status.observedSparseCheckout` fields to `GitRepository`.
    - Add controller support to send the sparse checkout directories to go-git via pkg methods.
    - Use `.status/observedSparseCheckout` to detect drift in configuration.
    - Trim leading "./" in directory paths.
    - Validate spec configuration by checking directories specified in spec exist in the cloned repository after successful checkout
    - Add tests for testing the observed sparse checkout behavior.
    - Add docs describing the new fields.

Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2025-04-23 09:30:10 -07:00
Stefan Prodan b549fec2e7
Add tests for Git mutual TLS
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-04-22 10:28:00 +03:00
Stefan Prodan 2a839f8769
Renew testdata TLS certs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-04-22 10:12:10 +03:00
Dipti Pai 560dc5bc5f Rename references to pkg/auth/github to pkg/git/github
Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2025-03-13 13:53:18 -07:00
Matheus Pimenta 9593041b53
Introduce token cache and use it for GitHub App tokens
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-03-12 14:45:48 +00:00
Sunny 1ed845928b gitrepo: Use new reason for provider misconfig
Introduce InvalidProviderConfigurationReason for Git provider github
related misconfiguration.

Add github provider related tests to check the status conditions reason.

Rearrange and modify a test case for getAuthOpts() for provider test
where a referred secret doesn't exist. This scenario is not specific to
any provider.

Signed-off-by: Sunny <github@darkowlzz.space>
2024-12-19 21:01:44 +00:00
Dipti Pai 9556a639c6 [RFC-007] Implement GitHub app authentication for git repositories.
- API change to add new `github` provider field in `GitRepository` spec.
- Controller change to use the GitHub authentication information specified in `.spec.secretRef` to create the auth options to authenticate to git repositories when the `provider` field is set to `github`,
- Tests for new `github` provider field
- Updated docs to use GitHub Apps for authentication in source-controller.

Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2024-12-19 23:28:10 +05:30
hasithsen 2b320409de feat: Remove deprecated object metrics from controllers fluxcd/flux2#5083
Signed-off-by: hasithsen <sen.hasith@gmail.com>
2024-12-12 00:02:25 +05:30
Sunny db42b07914 GitRepo: Remove provider default value from API
For backwards compatibility, remove the default value for GitRepository
provider. An empty provider value will still be considered as the
default provider.

Signed-off-by: Sunny <github@darkowlzz.space>
2024-09-26 15:13:29 +00:00
Dipti Pai 48417bdc8b Enable Azure OIDC for Azure DevOps Respository
- Add a new provider field to GitRepository API spec which can be set to azure to enable passwordless authentication to Azure DevOps repositories.

- API docs for new provider field and guidance to setup Azure environment with workload identity.

- Controller changes to set the provider options in git authoptions to fetch credential while cloning the repository.

- Add unit tests for testing provider

Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2024-09-13 13:41:18 -07:00
Stefan Prodan e3992568f5
OCIRepository: Configure proxy for OIDC auth
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-09-10 18:54:32 +03:00
Stefan Prodan 225a452092
Update tests for notation 1.2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-09-04 09:42:41 +03:00
Stefan Prodan 36a4889ea2
Alias Bucket providers from v1beta2 to v1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-08-27 17:16:14 +03:00
Stefan Prodan 5be0c53729
Promote Bucket API to v1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-08-23 13:25:57 +03:00
Matheus Pimenta 02d492bc43 Introduce Bucket provider constants with the common part as a prefix
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-08-22 14:48:53 -03:00
Matheus Pimenta 10ac11314d Add LDAP provider for Bucket STS API
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-08-22 08:41:23 -03:00
Matheus Pimenta 03a118a94c Add proxy support for OCIRepository API
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-08-15 10:29:57 -03:00
Stefan Prodan 93ad04b6c8
Update dependencies to Kubernetes v1.31.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-08-14 21:40:29 +03:00
Matheus Pimenta b6bd2abe2d Add proxy support for Azure buckets
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-08-09 22:17:06 +01:00
Matheus Pimenta 31ed900a90 Add proxy support for GCS buckets
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-08-09 19:05:10 +01:00
Matheus Pimenta 7536ab4b02 Add support for AWS STS endpoint in the Bucket API
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-08-08 16:35:01 +01:00
Matheus Pimenta 8d19782683 Improve invalid proxy error message for Bucket API
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-07-16 09:57:31 +01:00
Florian Forster 277e5c1d55
Prefer `%s` over `%v` when formatting errors.
Signed-off-by: Florian Forster <fforster@gitlab.com>
2024-07-05 15:55:33 +02:00
Florian Forster fa3022443c
fix: Print `strings.Builder` by calling `String()` explicitly.
The `String()` method is only defined for the pointer receiver.

Signed-off-by: Florian Forster <fforster@gitlab.com>
2024-07-05 15:55:32 +02:00
Florian Forster 8be37ef1d2
Fix incorrect use of format strings with the `conditions` package.
Many of the functions in the `conditions` package accept a format string and
(optional) arguments, just like `fmt.Printf` and friends.

In many places, the code passed an error message as the format string, causing
it to be interpreted by the `fmt` package. This leads to issues when the
message contains percent signs, e.g. URL-encoded values.

Consider the following code:

```go
// internal/controller/ocirepository_controller.go
revision, err := r.getRevision(ref, opts)
if err != nil {
	e := serror.NewGeneric(
		fmt.Errorf("failed to determine artifact digest: %w", err),
		ociv1.OCIPullFailedReason,
	)
	conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error())
	return sreconcile.ResultEmpty, e
}
```

Since `getRevision()` includes the URL in the error message and the error
message is used as a format string, the resulting condition reads:

```
failed to determine artifact digest: GET https://gitlab.com/jwt/auth?scope=repository%!A(MISSING)fforster%!F(MISSING)<REDACTED>%!F(MISSING)k8s-resource-manifests%!A(MISSING)pull&service=container_registry: DENIED: access forbidden
```

This adds an explicit format string and shortens `e.Error()` and
`e.Err.Error()` to `e`, which yields the same output.

To the best of my knowledge, Go is safe from format string attacks. I **don't**
think this is a security vulnerability, but I'm also not a security expert.

Signed-off-by: Florian Forster <fforster@gitlab.com>
2024-07-05 15:55:31 +02:00
Matheus Pimenta 4d9c87cf3f Add support for .spec.proxySecretRef for generic provider of Bucket API
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-07-03 15:10:47 +01:00
Matheus Pimenta bc16734391 Add .certSecretRef for Bucket API
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-05-15 19:44:05 +01:00
Stefan Prodan 31c4df4a8d
Deprecate v1beta1 APIs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-05-02 19:40:15 +03:00
Stefan Prodan 0a7f66b0e3
docs: Add API spec for Helm v1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-05-02 16:19:48 +03:00
Stefan Prodan f85bc174e6
Promote Helm APIs to v1 (GA)
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-05-02 16:04:27 +03:00
Robin Breathe 1e82cec48d
chore: address feedback
Signed-off-by: Robin Breathe <robin@isometry.net>
2024-05-02 12:10:05 +02:00
Robin Breathe 9b57d3bc52
chore: update tests
Signed-off-by: Robin Breathe <robin@isometry.net>
2024-05-02 08:21:23 +02:00
Paulo Canilho bf97748339
feat: resolved values files are persisted to and retrieved from the [HelmChart.Status.ObservedValuesFiles] field
Signed-off-by: Paulo Canilho <paulo.canilho@nexthink.com>
2024-05-01 08:01:42 +02:00
Robin Breathe b84ab9e698
feat(HelmChartSpec): optionally ignore missing valuesFiles
Signed-off-by: Robin Breathe <robin@isometry.net>
2024-05-01 08:01:41 +02:00
Austin Abro ab6d560002
allow insecure registry login
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>

only add loginoptinsecure when already logging in

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>

fix tests, move registry login options

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>

cleaner code

Signed-off-by: Austin Abro <austinabro321@gmail.com>

change localhost to 127.0.0.1 in insecure suite test path

Signed-off-by: Austin Abro <austinabro321@gmail.com>

let myself run tests

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>

allow myself to run tests

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>

clearer error message in test

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>

update test to reflect new behavior

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>

undo test config changes

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>

remove extra whitespace

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
2024-04-18 13:12:18 +00:00
Stefan Prodan 4d29266821
Update dependencies to cosign v2.2.4
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-04-11 08:08:02 +03:00
Jagpreet Singh Tamber 5854dbee73
Sanitize URLs for bucket fetch error messages.
Co-authored-by: Jagpreet Singh Tamber <jagpreetstamber@gmail.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-04-04 15:22:21 +03:00
Stefan Prodan 76b38f4a8e
Generate unique names for notation secrets
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-04-03 10:14:19 +03:00
Soule BA 97bc896488
Fix the race condition happening in main
There is a race condition happening in main due to the mockdns resolver.
This is an attempt to fix it (cannot repoduce locally).

Signed-off-by: Soule BA <bah.soule@gmail.com>
2024-03-29 17:19:39 +01:00
Soule BA 10434e7e1f
Introduce a semver filter in OCIRepository
If implemented a semver filter regex can be declared in conjuction with
a semver range in the OCIRepository `spec.Reference`

Signed-off-by: Soule BA <bah.soule@gmail.com>
2024-03-28 00:09:51 +01:00
Soule BA 7f3df76ccc
Use the verify defined interface in OCIRepository
Signed-off-by: Soule BA <bah.soule@gmail.com>
2024-03-26 15:35:13 +01:00
JasonTheDeveloper 553945ab8e Add verification support for notation signed artifacts
Introduces a new verification provider `notation` to verify notation signed artifacts. Currently only cosign is supported and that is a problem if the end user utilises notation.

---------

Signed-off-by: Jason <jagoodse@microsoft.com>
Signed-off-by: JasonTheDeveloper <jagoodse@microsoft.com>
Signed-off-by: Jagpreet Singh Tamber <jagpreetstamber@gmail.com>
Co-authored-by: souleb <bah.soule@gmail.com>
Co-authored-by: Jagpreet Singh Tamber <jagpreetstamber@gmail.com>
Co-authored-by: Sunny <github@darkowlzz.space>
2024-03-26 21:32:23 +11:00
Stefan Prodan acccf95b31
Update OCI distribution to v3.0.0-alpha.1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-01-26 14:51:03 +02:00
Sunny a242bdabed helmrepo: Remove migration log event
This will be logged/event emitted forever once in the lifecycle of
HelmRepository OCI object because all new objects have to remove the
.status.observedGeneration which is set to -1 by the API defaulting.
Better to perform the object conversion internally without any log or
event.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-12-14 15:31:02 +05:30
Sanskar Jaiswal 4086c25acb
helmrepo: allow OCI helmrepos to connect to insecure registries
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-11-23 12:32:14 +05:30
Sunny 1a7adeb801 Fix helmrepo reconciler unfinished worker bug
Although all the APIs had interval as a required field, when tests
objects were created, they had the zero value of interval, which the API
server accepts. A zero interval value results in the test objects to
reconcile only once when they are created and never reconcile again
unless there's an update to the object. Most of the tests worked with
this behavior.

With HelmRepository removing the interval requirement and adding an
internal default, all the HelmRepository objects created in the tests
without any interval have a default interval value which results in
objects to reconcile automatically if they are not cleaned up after
running tests. TestHelmRepositoryReconciler_InMemoryCaching and
TestHelmChartReconciler_Reconcile create HelmRepository but doesn't
delete it at the end. This leads to a reconciliation of HelmRepository
outside of the test in the envtest environment. It just happened to be
that the reconciliation time matches with the end of test time. At the
end of the test run, the reconcilers receive shutdown signal and any
test server, like helmrepository server, are stopped. A HelmRepository
reconciliation triggered just before the shutdown signal gets stuck in
the reconciliation. HelmRepository can't download the index as the test
index server has stopped and hangs for some time. The HelmRepository
reconciler worker remains in active state, unlike other reconciler
workers that shut down, resulting in the test to timeout at the end.

The is fixed by deleting the HelmRepository object created in
TestHelmRepositoryReconciler_InMemoryCaching and
TestHelmChartReconciler_Reconcile at the end of the test similar to
other tests.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-22 21:05:57 +05:30
Sunny 3dacb3140e optional interval and default timeout for helmrepo
With static HelmRepository OCI, the interval become optional. Make
interval optional in the API. Introduce getters for interval, in the
form of GetRequeueAfter(), and timeout with internal default values.

HelmRepository will not have interval and timeout fields unless it's
explicitly set.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-22 21:05:57 +05:30