Commit Graph

481 Commits

Author SHA1 Message Date
hasheddan adb65bc635
Mark ReferenceTo as deprecated
ReferenceTo returns a pointer to an ObjectReference, which should be
avoided in favor of a more scoped reference type.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-07 16:27:42 -05:00
hasheddan c9515a5a0e
Add TypedReferenceTo meta utility
Adds a TypedReferenceTo utility function that matches the ReferenceTo
implementation for ObjectReference, but returns a TypedReference
instead.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-07 12:34:48 -05:00
hasheddan 0920efd331
Accept ObjectCreaterTyper interface instead of runtime.Scheme directly
Because the parser eventually passes a runtime.Creater and runtime.Typer
to the underlying serializer, we only require that the passed schemes
implement those interfaces, rather than require that they be
*runtime.Scheme explicitly.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-06 17:08:31 -05:00
hasheddan 49da505413
Add package parser
Adds a package parser and a variety of backends that reads from a YAML
stream, accepting objects that are either part of the meta or object
runtime.Scheme and returning them as a Package.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-04 19:59:50 -05:00
hasheddan 76c547909e
Add FsReadCloser to implement io.ReadCloser for a filesystem
Implements io.ReadCloser for afero.Fs to allow passing it to a parser
that accepts an io.ReadCloser and reads from it.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-04 19:59:49 -05:00
hasheddan a23862526f
Assert to resource.Object once in APIUpdatingApplicator
This eliminates an extraneous assertion to metav1.Object in the Apply
method of the APIUpdatingApplicator by asserting to resource.Object at
the beginning of the function.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-04 09:33:44 -05:00
hasheddan 2274effb45
Update with desired object in APIUpdatingApplicator
This modifies the behavior of the APIUpdatingApplicator to update with
the desired object by setting its resource version to that of the
current. This ensures that a successful update will result in the object
being modified to match the desired by default. Consumers of this
Applicator no longer are required to pass in an UpdateFn to avoid no-op
updates.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-03 22:37:14 -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 76a692ce94 Don't require composite resources to be reclaimable
https://github.com/crossplane/crossplane-runtime/pull/186

This change should have been included in the above PR; composite resources
no longer have a reclaim policy and instead are immediately deleted when
their claim (nee requirement) is deleted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-18 19:33:28 -07: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
Nic Cope f70051c0e6
Merge pull request #186 from negz/reclamation
Remove reclaim policy from composite resources
2020-08-13 18:23:25 -07:00
Nic Cope c7b7ea8043 Remove reclaim policy from composite resources
See https://github.com/crossplane/crossplane-runtime/issues/179 for context.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-12 17:09:59 -07:00
Nic Cope 8e173f4a75 Default to deleting, not retaining, external resources.
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-12 16:32:55 -07:00
Nic Cope 72cd5521e6 Rename the Deletable interface to Orphanable
This interface represents a resource with a deletion policy; i.e. a resource
whose underlying external resource may either be deleted or orphaned when the
it is deleted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-12 13:03:51 -07:00
Nic Cope 5c5d8932d3 Introduce a deletion policy, and deprecate the reclaim policy.
The deletion policy is a more narrowly scoped variant of the reclaim policy. It
affects only whether exeternal resources are deleted or orphaned when their
corresponding managed resource is deleted, as opposed to the reclaim policy
which also affects whether the managed resource is deleted when its bound claim
is deleted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-08-11 18:24:16 -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 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
Nic Cope 290de73499
Merge pull request #176 from hasheddan/resverauto
Update with object that is gotten in APIUpdatingApplicator
2020-05-12 13:45:08 -07: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
hasheddan 3420b651d6
Update with object that is gotten in APIUpdatingApplicator
This changes APIUpdatingApplicator to make its Update call
with the object it gets rather than the one passed so that
the default behavior is a no-op rather than a guaranteed
error on mismatched resource versions.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-05-12 15:15:27 -05:00
Nic Cope 72789b40db Refuse to bind claims to controlled managed resources
This will ensure resource claims don't bind to managed resources that are part
of a composite resource while these two features live side by side. I suspect it
will also nesure resource claims don't bind to a managed resource produced by a
stack. As far as I know we don't have any use cases in which a stack creates a
managed resource that is expected to be claimable.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-05-08 15:42:08 -07:00
Nic Cope 8f8929a0a8 Ensure resources reference the claim that is trying to bind or unbind them
This gates against two possible issues:

1. Claim A dynamically provisions managed resource M. Claim B runs and wins a
   race against Claim A to bind to the newly provisioned and bindable M.
2. Claim A dynamically provisions managed resource M. Claim B explicitly sets
   its resource reference to M, and is then deleted, thereby deleting M which it
   was never bound to and did not dynamically provision.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-05-07 16:02:24 -07:00
Kasey Kirkham dccc18c2df AddFinalizer before we attempt to provision or bind to a managed resource.
Signed-off-by: Kasey Kirkham <kasey@upbound.io>
2020-05-07 14:20:15 -07:00
Nic Cope 21d9cb6ea9
Merge pull request #171 from hasheddan/4ground
Delete CRDs in foreground at end of test run
2020-04-29 12:51:44 -07:00
hasheddan efd76064c9
Delete CRDs in foreground at end of test run
This guards against subsequent tests failing because
they are installing the same CRDs that we being deleted.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-04-29 13:18:33 -05:00
Muvaffak Onus 1ddc2c5d8d
Add missing field to fake.Composite to satisfy resource.Composite interface
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-29 17:11:34 +03:00
Nic Cope bd09d0c8f4 Make it possible to distinguish fieldpath.IsNotFound errors
https://github.com/crossplane/crossplane/issues/1455

See the above issue for a use case; this will allow the composition patching
functionality to ignore this error.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-28 21:36:06 -07: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 51ebec91a3 Add tests for unstructured wrappers.
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-25 21:32:29 -07:00
Nic Cope 6382f8b98c Add tests for unstructured.WrapperClient
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-25 20:03:59 -07:00
Nic Cope 100af7315c unstructured.WrapperClient nitpicks
Add a package docstring, and returns a concrete type rather than an interface
where possible.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-25 18:40:05 -07:00
Nic Cope da8cc179e7 Remove unused fake.Workload
This was for an OAM workload, that moved out to oam-kubernetes-runtime.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-24 12:06:27 -07:00
Nic Cope 477b9e592e Add fake composed, composite, and requirement resources.
We could also use pkg/resource/unstructured in tests, but I think this will
require a little less boilerplate to setup tests.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 21:34:33 -07:00
Nic Cope 3060371afd Remove unstructured.ObjectTyper
runtime.Scheme already does this.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 14:28:17 -07: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 dfff858421
Merge pull request #160 from negz/outofcontrol
Add a "controller engine" that manages the lifecycles of controllers
2020-04-23 12:42:53 -07:00
Nic Cope 1cd8a32c4f
Merge pull request #159 from muvaf/setowner
AddOwnerRef should update
2020-04-23 12:31:57 -07:00
Nic Cope 357942c02d Add a "controller engine" that manages the lifecycles of controllers
A controller engine is somewhat like a controller "sub-manager", in that it's
effectively a group of controllers. Unlike a typical controller manager, the
lifecycle of the controllers an engine manages are not coupled to the lifecycle
of the engine itself. An engine may be used by a parent controller to start and
stop child controllers in accordance with configuration provided by the custom
resource that the parent controller watches.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 01:51:27 -07:00
Nic Cope 8fe8833cc3 Pin controller-runtime to master
https://github.com/kubernetes-sigs/controller-runtime/pull/863

We'd like to use the above PR, which is not yet included in a controller-runtime
release. Updating controller-runtime requires updating a few other dependencies,
which changed the signature of client-go clientset methods. This commit removes
the only two uses of clientset from crossplane-runtime. pkg/test/integration now
uses a controller-runtime client.Client. pkg/test.Env has been removed, as it no
longer has any known users.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-22 19:14:42 -07:00
Muvaffak Onus 48c7c448d3
AddOwnerReference should always set the owner ref array to be able to modify the existing reference
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-22 23:31:04 +03:00
Nic Cope ae9aa170fc Add a fieldpath.PaveObject convenience method
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-21 23:15:04 -07:00
Nic Cope be37c50cc2
Merge pull request #157 from muvaf/unclient
Client for unstructured Crossplane types
2020-04-21 14:10:18 -07:00
Nic Cope 903cf3eff8
Merge pull request #155 from negz/noam
Remove OAM code, which has moved to crossplane/oam-runtime
2020-04-21 13:10:34 -07:00
Muvaffak Onus 9357d0ab18
Controller-runtime client wrapper for objects that are wrappers of unstructured.Unstructured
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-21 17:42:04 +03:00
Nic Cope 8ada1fa72b Compose the Composite interface of smaller interfaces
This also removes Bindable from the Composite interface, which I believe we will
not need.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-20 22:00:04 -07:00
Nic Cope 90d2786f90 Add a test for GetValueInto
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-20 21:29:10 -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
Muvaffak Onus 4a7ece2ff5
Add composition interfaces and unstructured composition structs.
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-21 03:11:24 +03:00
Nic Cope 3face651ef Support selecting and resolving arrays of references
Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-16 19:51:16 -07:00