Commit Graph

30 Commits

Author SHA1 Message Date
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
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
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 c5b903fedd
Use Refernce type for provider references
We are currently using corev1.ObjectReference for provider resources.
This includes more information than needed and encourages
using helper methods that may depend on other fields in the type that we
do not intend to be utilized. This updates provider references
fields to use the Reference type, which only has a name field.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-06-25 14:59:52 -05:00
Muvaffak Onus b5206ecd68
Export mock secret owner structs to be used in tests outside this repo
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-29 03:36:46 +03: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
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
Muvaffak Onus 5a3ce4f6c8
Removed Mock word from mocks in package fake.
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-12-12 15:02:06 +03:00
Muvaffak Onus 3cf4bd1275
Move MockManager into fake package
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-12-11 16:06:14 +03:00
Muvaffak Onus 81a7488824
Make mock of our interfaces available to be used out of this repository for testing purposes
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-12-11 16:03:16 +03: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 5468d81383 Use real conditioned and binding statuses in mock objects
The mock binding status was identical to the real one, while the mock
conditioned status set only the most recent condition, leading to a few
slightly broken managed resource reconciler tests.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-31 13:27:40 -07: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
soorena776 f063ec82d3 - Removing class level reference resolution if we can get away with it
- Removing the panic recovery logic
- Removing the superfluous IsConditionReady method
- Adding Nic's unit-tests for GetCondition and IsConditionTrue
- Minor other fixes

Signed-off-by: soorena776 <javad@upbound.io>
2019-10-21 17:05:15 -07:00
Nic Cope f1075e19e4 Add an IsManagedKind watch predicate.
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-09-18 15:13:38 -07:00
hasheddan 7d786e2dff runtime migration: strip apis and update dependencies
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-08-20 09:27:20 -05:00
hasheddan a72525edae kubebuilderv2: update core packages and tooling
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Co-authored-by: Muvaffak Onus <onus.muvaffak@gmail.com>
Co-authored-by: Jared Watts <jbw976@gmail.com>
Co-authored-by: hasheddan <georgedanielmangum@gmail.com>
2019-08-13 17:39:59 -05:00
Nic Cope 6e3d341349 Follow API conventions for object reference fields
I had previously attempted to standardise on fooReference for an ObjectReference
to a Foo, because we had a mix of fooRef and fooReference. Turns out the API
conventions document has a position on this and says we should use fooRef. I've
kept the actual Go fields named 'FooReference' for readability, but renamed the
struct tags to 'fooRef'. I've also renamed 'writeConnectionSecretTo' to
'writeConnectionSecretToRef' since it is also a reference.

https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#object-references

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-06-26 11:40:11 -07:00
Nic Cope e75c2b4f5c Set all managed resources to 'unbound' when they become available
The resource claim controller uses this binding phase to determine whether a
managed resource is available for binding to a resource claim.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-06-24 23:47:12 -07:00
Nic Cope 68a7580935 Add new resource claim reconciler.
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-06-24 23:47:11 -07:00