Commit Graph

58 Commits

Author SHA1 Message Date
Jared Watts 079cc1d02b
feat: change logs: support for tracking all changes made to managed resources
Signed-off-by: Jared Watts <jbw976@gmail.com>
2024-08-11 20:34:26 -07:00
Nic Cope 0c7b1eb549 Bump golangci-lint, copy config from c/c
This copies the latest config from c/c and addresses all the linter
errors that config produces.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-02-20 03:45:27 -08:00
Dr. Stefan Schimanski e63d00a63c
resource: add FirstNAndSomeMore helper
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@upbound.io>
2023-09-08 08:28:09 +02:00
Dr. Stefan Schimanski b069d9debb
pkg/resource: add StoreCurrentRV
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@upbound.io>
2023-09-05 22:14:06 +02:00
Christopher Haar fd85873073 feat(remove): remove deprecated providerRef
Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
2023-08-23 15:46:55 +02:00
Hasan Turken 11e9468944
Cleanup deprecated stuff that are no longer used
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-08-11 13:02:54 +03:00
Nic Cope f0fcbc0af5 Update linter config to match c/c
This repo is a little out of date relative to our latest linting
practices.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-01-25 10:32:46 -08:00
Aditya Sharma cd68866501 Fix lints
Signed-off-by: Aditya Sharma <git@adi.run>
2022-07-21 22:01:32 -07:00
Hasan Turken 86fb15da2c
Extend Secret Store interface with more power
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-10 18:10:52 +03:00
Hasan Turken c8cc06c5fb
Implement ConnectionPropagator in connection.DetailsManager
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 12:43:53 +03:00
Hasan Turken 3ce0d92570
Refactor packages for connection details types and interfaces
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 12:43:52 +03:00
Hasan Turken e0edbc592f
Define types for using ESS with composition
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 12:43:52 +03:00
Nic Cope af4e148a11 Replace github.com/pkg/errors with our own pkg/errors.
Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-09 07:50:57 +00:00
Alper Rifat Ulucinar 406fe0b15f
Add Retry Logic for APISecretPublisher
- Fixes #263

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2021-05-04 19:24:53 +03:00
Sascha Grunert 423918f457
Update controller runtime to v0.8.0
This updates the controller-runtime and all of its dependencies to the
latest release.

This includes a bunch of changes which break backwards compatibility
introduced by controller-runtime 0.7.0 and 0.8.0, for example:

> A number of methods that previously took runtime.Object & internally
> type-asserted them to metav1.Object now take client.Object (for non-list
> objects) or client.ObjectList (for lists). The practical upshot of this
> is more type-safety and clarity around what's required for particular
> methods.
> All concrete API types (anything that implements runtime.Object & has
> a metadata field) already implement client.Object or client.ObjectList,
> so practical impact should be limited to folks who pass around
> runtime.Object values instead of concrete types.

Signed-off-by: Sascha Grunert <mail@saschagrunert.de>
2021-01-21 13:29:16 +01:00
Muvaffak Onus 10aa02f251
introduce IgnoreAll to be able to ignore more than one type of error
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2021-01-12 18:24:58 +03:00
hasheddan 0b27607592
Update core/v1alpha1 imports to common/v1
Updates all core/v1alpha1 imports to the common/v1, which is the new
home of these embedded API types.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-11-19 20:03:48 -06:00
Muvaffak Onus 6b88ef0288
managed reconciler: add retry attempt for updating the resource whose external name is assigned during the Create call
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-11-17 00:56:09 +03:00
Nic Cope 3058c2f2c8 Mark connection secret propagation machinery deprecated
The claim controller in Crossplane core is the only place this machinery is
still used, so it will be migrated into that controller.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-11-05 04:48:25 +00:00
Nic Cope 7cd38befc2 Remove the deprecated ControllersMustMatch utility
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-10-16 20:03:17 -07:00
Nic Cope defa322852 Remove reconcilers and utilities pertaining to workloads
https://github.com/crossplane/crossplane/issues/1755

This removes support for the secret propagation and target controllers that each
Kubernetes Cluster managed resource implemented before workloads were deprecated.
See the above issue for context.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-10-16 19:54:18 -07:00
Nic Cope be1324de71 Add a utility to track ProviderConfig usages
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-10-01 02:33:12 -07:00
Nic Cope 529fb076ce Add machinery for tracking ProviderConfig usage
This commit adds a reconciler and some utiltiies that allow Crossplane providers
to track the usage of their ProviderConfig resources. To do so, a provider must:

* Apply a ProviderConfigUsage each time a managed resource successfully connects
  to its external API using a ProviderConfig (or is reasonably expected to be
  about to do so). The Apply should be a no-op if there is an existing
  ProviderConfigUsage for the managed resource - the IsNotAllowed ApplyOption
  may be used to establish this.
* Start a controller that watches for ProviderConfigs and ProviderConfigUsages
  using the supplied providerconfig.Reconciler.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-10-01 02:03:41 -07:00
Nic Cope 95d71dbd91 Remove support for resource claims and classes
See https://github.com/crossplane/crossplane/issues/1670 for context.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-09-20 17:46:06 -07:00
Nic Cope b3fa859660 Indicate whether Apply errors are due to a resource being uncontrollable
This allows users of the MustBeControllableBy ApplyOptions to determine how to
handle the case in which a resource cannot be applied because it is not
controllable - e.g. to abort the apply operation without returning an error.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-09-17 18:27:27 -07:00
hasheddan 1d97e32d05
Accept TypedReference in AsOwner and AsController
This updates the AsOwner and AsController to use TypedReference, which
is a more scoped version of ObjectReference that still contains all
necessary fields to create a controller or owner reference for an
object.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-08 10:13:15 -05:00
Muvaffak Onus 367fa803d9
Add reference for ProviderConfig objects and deprecate Provider references
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-08-27 14:59:31 +03:00
Nic Cope dbf0f9af21 Rename 'requirement' to 'claim'
Crossplane composite resources are cluster scoped, but they can be 'published'
to create a namespaced proxy resource. We called this resource a 'requirement',
despite it being conceptually quite similar to our existing (and deprecated)
'resource claim' concept. We've found that the 'publish a requirement' concept
has not resonated with the community and have decided to switch our terminology.

Under this new approach platform builders may choose to enable platform operators
to 'offer' (not publish) a composite resource to their platform consumers. The
namespaced interface to these composite resources will be known as a 'claim' or
'composite resource claim'. Note that we think platform builders and operators
are the key audience for these concepts; platform consumers will simply think of
themselves as using the resource as its kind indicates - e.g. 'a Kubernetes
cluster' or 'an SQL instance', not 'an SQL instance claim'.

In some cases our existing but deprecated resource claim concept has name
conflicts with this new take on the claim concept - i.e. the resource.Claim
interface. In those cases I've named the new type CompositeClaim to distinguish
it.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-18 19:33:28 -07:00
hasheddan e130a99a00
Do not use pointer for Provider references
Provider reference is a required field for types that embed it. In
practice, accessing the Name field of a Provider reference should never
result in a nil pointer dereference, but it is still an unsafe
operation. Changing the Provider reference to a non-pointer absolves the
user from checking for a nil reference each time it is used.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-06-26 10:19:28 -05:00
hasheddan a964b65a29
Add UpdateFn for mutating ApplyOptions
Add an UpdateFn wrapper around ApplyOption that simplifies
the interface for passing a mutating function to
APIUpdatingApplicator.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-05-12 15:35:54 -05:00
Nic Cope 70b21471b6 Add a generic ConnectionPropagator
This is effectively identical to the existing ManagedConnectionPropagator, but
propagates from any ConnectionSecretOwner, rather than requiring the much larger
and more specific Managed interface. This allows this propagator to be used to
propagate from managed resources to claims and also from composite resources to
requirements.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 13:04:38 -07:00
Nic Cope ca1fe097be Expand and refactor unstructured types
This switches names around from unstructured.Composite (for example) to
composite.Unstructured, mostly to allow several unstructured types to use
identically named options like WithGroupVersionKind. It also adds a few
getters and setters required for resource publications, and introduces the
resource.Requirement type that represents an application's requirement for a
published composite resource.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 12:48:22 -07:00
Nic Cope 44099db82c Remove OAM code, which has moved to crossplane/oam-runtime
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-20 20:55:51 -07:00
Nic Cope cf8d3a6a26 Make connection secret propagation UID-agnostic
This allows propagation to function even when the propagating and/or propagated
secrets have been deleted and recreated, and thus allocated new UIDs.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-05 15:16:25 -07:00
Nic Cope b8b606426d Introduce an updating Applicator
This is roughly the same functionality as controllerutil.CreateOrUpdate, albeit
a little simpler. This variant is useful to us because it satisfies our
Applicator interface.

The key difference between the patching and updating applicators is that the
patching applicator will leave any existing, unset fields untouched (to the
extent that a JSON merge patch allows), while the updating applicator will
always update any existing object to exactly match the desired object.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-02 14:28:38 -07:00
Nic Cope ee9b68e00c Introduce a distinct secret type for connection secrets
This allows resource claims and managed resources to adopt existing orphaned
connection secrets without needing to be concerned with the fact that they
might be adopting an existing secret that is unrelated to Crossplane.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-02 14:28:38 -07:00
Nic Cope ff8a47bab6 Add a MustBeControllableBy ApplyOption
This option replaces ControllersMustMatch. It works slightly differently in that
it takes the expected controller UID explicitly instead of inferring it from the
desired object, and considers current objects with no controller reference to be
controllable. Presumable objects with no controller reference will be adopted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-01 22:20:18 -07:00
Nic Cope 51d293df2f Don't require callers to pass a client.Client to Applicator implementations
The Apply method of the resource.Applicator interface took a client.Client
largely because it was extracted from the pre-existing resource.Apply function
to allow pluggable Apply implementations. Now that we have types that satisfy
resource.Applicator it makes more sense for those types to include a client,
rather than being passed one for every Apply call.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-01 18:23:17 -07:00
hasheddan bb562fce25
Clean up OAM reconcilers
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-03-20 09:48:15 -05:00
hasheddan 8a48d21abb Pass apply checks as functions to Applicators
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-03-16 16:53:41 -05:00
Muvaffak Onus 34f8959f86
Implement GetExternalTags to return Crossplane tags for managed resource controllers to tag their external resources
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-03-04 11:18:24 +03:00
hasheddan 73c6076ff3 Add Applicator interface
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-03-03 19:20:02 -06:00
Nic Cope 625ec3bf23 Fix controller mismatch detection in resource.Apply
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-03-02 22:37:14 -08:00
Nic Cope 1eec52890b Stash desired, not existing object when applying changes
Getting, creating, or patching an object using the controller-runtime client
updates said object with the latest state from the API server. This commit
alters our resource.Apply logic to patch 'into' the supplied object, not a
deepcopy of that object. This ensures the object passed to apply is updated
with the latest view from the API server, whether it is created or patched.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-03-02 22:00:40 -08:00
Nic Cope 6ef3f96332 Add an Apply object function
This function either creates a new object or patches an existing one. I think
it belongs in crossplane-runtime because we have at least two implementations in
the wild, and I need another one for a new controller.

https://github.com/crossplane/templating-controller/blob/a035e2/pkg/controllers/templating_reconciler.go#L168
https://github.com/crossplane/crossplane/blob/c1933feab/pkg/controller/workload/kubernetes/resource/resource.go#L260

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-02-27 16:42:02 -08:00
hasheddan 16aa98bd07 Update go mod and refs with crossplane org name
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-02-18 18:17:32 -06:00
Nic Cope 034c58db2c Break reconcilers out into distinct packages
I'm hoping this will help us pass in loggers and eventers using variadic options
without awkward names like WithClaimBindingReconcilerLogger. This is a huge diff
but there's no functional changes - only moving things around and renaming them.

I was hoping we'd be able to do with without a breaking API change by using type
aliases, but doing so would create cyclic imports, because the new reconciler
packages depend on the resource package, which is where we'd need to create the
type alias to the reconciler packages.

I've broken up api.go (which contained most of the 'Kubernetes API' - i.e.
default - implementations of most of the pluggable interfaces used by our
reconcilers) into several files. My heuristic here was:

* If the implementation is used by a single reconciler, put it in that
  reconciler's package.
* If the implementation is used by more than one reconciler, put it in the
  resource package.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-01-14 19:52:53 -08:00
Nic Cope ca4b6b46c9 Mirror PersistentVolume ReclaimPolicy semantics
This commit changes the meaning of the resource claim resource policy to match
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#reclaiming as
closely as possible, minus the deprecated 'Recycle' policy. Previously the
reclaim policy dictated only what happened to the external resource when its
managed resource was deleted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-11-19 14:43:25 -08:00
Nic Cope a2e24876e0 Use custom types for secret references
This allows us to require that name (and namespace where appropriate) are set at
the CRD level. In the case of cluster scoped resources that reference secrets
this is less surprising than defaulting to the `default` namespace when the
namespace is omitted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-22 17:13:21 -07:00
Nic Cope 9f5188e0cb Assume resources, classes, and providers are cluster scoped
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-22 17:13:21 -07:00