Commit Graph

131 Commits

Author SHA1 Message Date
Stefan Prodan 87ca533b83
Refactor controller to use `fluxcd/pkg/artifact`
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-09-04 16:50:36 +03:00
Stefan Prodan c9a5e76d24
Refactor the API and controller to use the `meta.Artifact` type
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-09-03 20:57:45 +03:00
Dipti Pai 995f3538dc [RFC-0010] Add multi-tenant workload identity support for Azure Blob Storage
Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2025-09-02 09:58:31 -07:00
Stefan Prodan 3749be4d26
Migrate tests from gotest to gomega
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-08-31 10:29:36 +03:00
cappyzawa dc3eba62b0
[RFC-0010] Add default-service-account for lockdown
Add --default-service-account flag for multi-tenant workload identity
lockdown support. This flag sets the default service account name to
be used when .spec.serviceAccountName is not specified in resources.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-08-18 01:32:07 +09:00
Dipti Pai 4fe3434ee8 [RFC-0010] Add multi-tenant workload identity support for Azure GitRepository
Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2025-08-15 10:10:00 -07:00
cappyzawa 041aa6c993
[RFC-0010] Add multi-tenant workload identity support for AWS Bucket
Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-08-15 02:36:04 +09:00
cappyzawa 683719d33c
Remove ServerName pinning from TLS config
Remove ServerName pinning functionality that can cause TLS
verification failures in production environments with redirects,
proxies, and multi-host scenarios.

The Go standard library automatically handles SNI and hostname
verification based on the actual connection target, providing
better compatibility and security than fixed ServerName values.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-08-14 22:52:50 +09:00
abhijith-darshan 46522f9815
(chore): adds tls config for GitHub App auth
this commit ensures that if ca.crt or caFile is available in the github app secret, a tls config with user provided certs is appended to system cert pool and passed to the underlying http transport

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): update target URL for TLSConfigFromSecret

this commit ensures that the target URL for runtime/secrets.TLSConfigFromSecret has the scheme and host

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): adds test scenarios

this commit adds test scenarios for mTLS GitHub app in reconcile source auth strategy

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): use runtime/secrets authMethods

this commit ensures that GitHubApp secret resolution happens via pkg/runtime/secrets

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): update docs

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): adds github app data check

this commit ensures that when provider is github and no github app data is present in the secret, it will error out with invalid configuration

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): removes getProxyOpts helper func

this commit removes the helper method getProxyOpts and uses the standardized pkg/runtime/secrets APIs to get proxy options.

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): removes getProxyOpts test

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): improves test coverage

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): do not stall on missing github app data

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): adds a note on mTLS configuration in docs

This commit mentions in the docs that if tls.crt and tls.key is part of the secret then mutual TLS configuration will be automatically enabled and should be used optionally.

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>
2025-08-12 23:32:12 +02:00
Matheus Pimenta 1f4fc2fe87
Fix GitRepository controller stalling when it shouldn't
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-08-12 14:34:12 +01:00
Stefan Prodan 9e789f6d9a
Extract storage operations to a dedicated package
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-08-12 14:57:15 +03:00
Stefan Prodan ac8ec2e32a
Refactor bucket pkg structure
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-08-12 14:43:17 +03:00
cappyzawa 3733163358
[RFC-0010] Add multi-tenant workload identity support for GCP Bucket
Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-08-12 07:58:39 +09:00
cappyzawa 9463bcf0ee
Fix missing namespace in Helm Repository Controller secret error
Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-31 22:05:37 +09:00
cappyzawa 4b18040e22
Fix missing namespace in OCI Repository Controller secret error
Include namespace in secret error message for better debugging context.
The secret name was already present in the error, but namespace information
was missing, making it harder to identify which secret in which namespace
was not found.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-31 22:05:37 +09:00
cappyzawa 3caf8f1db9
Migrate Bucket controller to runtime/secrets
Replaces internal credential management with runtime/secrets package
to standardize authentication, proxy configuration, and TLS handling
across controllers. This migration eliminates code duplication by
leveraging shared utilities and improves maintainability through
consistent error handling patterns.

The refactoring splits the large reconcileSource method into focused
helper functions for better separation of concerns.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-31 22:05:37 +09:00
cappyzawa ba14962c1f
Add WithSystemCertPool for CA compatibility
Update pkg/runtime dependency from v0.76.0 to v0.78.0 and add
WithSystemCertPool() options to maintain backward compatibility
with the existing extend approach (system CAs + user CA).

This ensures source-controller continues to work with both system
and user-provided CA certificates, maintaining the same behavior
as before the pkg/runtime/secrets API changes.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-30 11:39:11 +09:00
cappyzawa 4b1ace618a
Enforce TLS certificate verification in Helm/OCI Repository controllers
Remove the insecure parameter from TLS configuration function calls to prevent
InsecureSkipVerify from being set when using certificate-based authentication.
This ensures TLS certificate verification is always performed when certificates
are provided, aligning with our security policy.

Updated pkg/runtime to v0.76.0 which no longer accepts the insecure parameter
in TLS configuration functions. For OCIRepository, maintain backward compatibility
by handling the specific case where no certificate is provided and insecure is
explicitly set to true. This is the only allowed exception in Flux controllers.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-29 02:42:22 +09:00
cappyzawa 74242e5d8a
Migrate OCIRepository controller to runtime/secrets
Migrates the OCIRepository controller's authentication handling from
internal implementations to the unified runtime/secrets API package.

The migration moves TLS configuration from internal/tls to
runtime/secrets.TLSConfigFromSecretRef and ServiceAccount processing
to secrets.PullSecretsFromServiceAccountRef, providing consistent
authentication handling across all source-controller components.

This change eliminates duplicate secret fetching logic and aligns
the OCIRepository controller with the standardized authentication
patterns used by other controllers in the GitOps Toolkit.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-22 00:39:59 +09:00
cappyzawa 9950f56d26
migrate HelmRepository to AuthMethodsFromSecret API
This commit upgrades pkg/runtime to v0.73.0 and adopts the unified
AuthMethodsFromSecret API for HelmRepository authentication handling.
The change replaces complex manual authentication detection with a
single API call and improves error handling consistency.

Breaking Changes:
- TLS certificate validation is now strictly enforced. Invalid CA
  certificates will cause authentication failures even for public
  repositories, where they were previously ignored.
- Empty TLS certificate secrets now trigger validation errors instead
  of being silently ignored. This affects certSecretRef with empty
  Data map - previously ignored, now causes proper error.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-18 21:29:37 +09:00
cappyzawa 274a6699cc
refactor: improve HelmRepository controller test structure for runtime/secrets migration
Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-18 03:37:02 +09:00
Matheus Pimenta e3abd39417
Upgrade Kubernetes to 1.33.2
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-07-14 18:33:46 +01:00
cappyzawa 738fb2b3a8
refactor: simplify OCI auth error handling
Update fluxcd/pkg/auth to v0.18.0 and remove unnecessary authenticator
nil check in Helm OCI repository authentication.

With fluxcd/pkg/auth v0.18.0, GetArtifactRegistryCredentials() returns
valid authenticator when error is nil, making the nil check redundant.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-06-21 22:21:51 +09:00
Matheus Pimenta 71aa99e934
Fix flaky test
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-27 09:24:01 +01:00
Stefan Prodan aadaf1c0aa
Remove deprecated status fields from OCIRepository v1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-05-27 08:29:44 +03:00
Stefan Prodan 34bb9862e6
Promote OCIRepository API to v1 (GA)
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-05-27 08:19:51 +03:00
Matheus Pimenta aff9ebde96
[RFC-0010] Introduce feature gate
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-19 13:39:36 +01:00
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