Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import (
  2. "k8s.io/apimachinery/pkg/runtime"
  3. "sigs.k8s.io/controller-runtime/pkg/reconcile"
  4. "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
  5.  
  6. "github.com/crossplaneio/crossplane/pkg/apis/cooltype/v1alpha1"
  7. )
  8.  
  9. // Result of a Sync or Delete call.
  10. type Result struct {
  11. reconcile.Result
  12. NeedsUpdate []NeedsUpdate
  13. }
  14.  
  15. // NeedsUpdate is an Object that needs to be updated as a side effect of
  16. // a Sync or Delete operation on a different Object. For example a
  17. // Secret that must be updated when a ResourceType is synced.
  18. type NeedsUpdate struct {
  19. Object runtime.Object
  20. MutateFn controllerutil.UpdateFn
  21. }
  22.  
  23. // Update (or create) the Object that needs an update.
  24. func (u NeedsUpdate) Update(ctx context.Context, c client.Client) (controllerutil.OperationResult, error) {
  25. return controllerutil.CreateOrUpdate(ctx, c, u.Object, u.MutateFn)
  26. }
  27.  
  28. // A Syncer can sync resources with an external store - e.g. the AWS API.
  29. type Syncer interface {
  30. // Sync the supplied resource with the external store.
  31. Sync(ctx context.Context, r *v1alpha1.ResourceType) Result
  32. }
  33.  
  34. // A Deleter can delete resources from an external store - e.g. the AWS API.
  35. type Deleter interface {
  36. // Delete the supplied resource from the external store.
  37. Delete(ctx context.Context, r *v1alpha1.ResourceType) Result
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement