Commit Graph

787 Commits

Author SHA1 Message Date
Hasan Turken 112e9eda45
Add nolint directive for musttag on types used in unit tests
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-03-22 12:52:52 +03:00
Hasan Turken 3008beba94
Deprecate PredicateFn and helper predicate functions
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-03-17 17:27:56 +03:00
Hasan Turken c4ec21474a
Add DesiredStateChanged to filter out updates going to status
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-03-17 17:27:56 +03:00
Philippe Scorsolini d95d8e0cca tests: move FuzzParse to separate file
Co-authored-by: Lovro Sviben <46844730+lsviben@users.noreply.github.com>
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
2023-03-16 22:26:08 +01:00
Philippe Scorsolini 5a5939990b
tests(fuzz): add FuzzParse test case
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
2023-03-13 11:26:30 +01:00
Philippe Scorsolini 0aac4ba546
fix: properly validate max index
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
2023-03-08 16:10:26 +01:00
Hasan Turken 53508a9f43
Merge pull request from GHSA-vfvj-3m3g-m532
fix: enforce max index value for paths
2023-03-08 16:44:59 +03:00
Philippe Scorsolini 7560fbc041 fix: enforce max index value for paths
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
2023-03-08 14:41:11 +01:00
Hasan Turken af9e3effae
Merge pull request #367 from eljohnson92/support_float_pointers
add support for float pointer references
2023-02-28 15:21:31 +03:00
Hasan Turken b13075274f
Fix connection secret owner check for K8s Secret Store
Fixes https://github.com/crossplane/crossplane/issues/3520

Signed-off-by: Hasan Turken <turkenh@gmail.com>
2023-02-09 18:18:17 +03:00
Nic Cope 9e69576057 Add a test for the new subresource Create method
Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-01-25 10:34:38 -08:00
Nic Cope fd0a07f8eb Remove //nolint:interfacer directive
This linter has been deprecated and is disabled. I would have thought
nolintlint would catch this, but it did not.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-01-25 10:34:38 -08:00
Nic Cope b099031ba0 Pass GetOptions through to wrapped client
Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-01-25 10:34:38 -08:00
Nic Cope 71190c3e9a Remove fake.MockStatus* type aliases
I thought this would help with compatibility, but unfortunately this
package has breaking changes that will affect anyone who was using these
types regardless.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-01-25 10:34:38 -08:00
Nic Cope 8b832430e9 Bump Kubernetes dependencies
This required some updates to our implementations of client.Client,
which now has a generic SubResource sub-client.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-01-25 10:34:37 -08: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
Evan Johnson ce686bf20e add support for float pointer references
Signed-off-by: Evan Johnson <eljohn1014@gmail.com>
2022-12-08 12:29:11 -05:00
Nic Cope 65044f0439
Merge pull request #364 from ezgidemirel/comp-rev-selector
Add composition revision selectors
2022-11-14 11:51:50 -08:00
Maximilian Blatt 39428e10f6 fix(composite): SetEnvironmentConfigReferences to correct path
Signed-off-by: Maximilian Blatt <maximilian.blatt-extern@deutschebahn.com>
(external expert on behalf of DB Netz AG)
2022-11-09 00:27:13 +01:00
ezgidemirel efc8702e31
Add composition revision selectors
Signed-off-by: ezgidemirel <ezgidemirel91@gmail.com>
2022-11-03 14:41:45 +03:00
Alper Rifat Ulucinar 31279534ed
Add omitempty json tag to fake.ConnectionDetailsLastPublishedTimer.Time field
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2022-10-19 23:46:07 +03:00
Nic Cope bce61005a1
Merge pull request #355 from nokia/respect_finalizers
Support foreground cascading deletion
2022-10-11 18:39:34 -07:00
Bob Haddleton da77f4e104 Add blockOwnerDeletion: true and compositeDeletePolicy
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
2022-10-11 09:35:04 -05:00
Alper Rifat Ulucinar eaa6119f23
Add meta.IsPaused that checks whether reconciliations are paused for the managed resource
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2022-09-30 01:24:50 +03:00
Alper Rifat Ulucinar d5661c8fd6
Add support for a pause annotation which pauses reconciliations on managed resources
- If a managed resource has the "crossplane.io/paused" annotation with its value
  set to "true", then the managed reconciler emits an event indicating that
  further reconciliations on that resource are paused and returns early after
  setting a Synced status condition to false with the reason "ReconcilePaused".

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2022-09-29 04:27:29 +03:00
Maximilian Blatt dfd468741d feat(composite): Add support for EnvironmentConfigs
Signed-off-by: Maximilian Blatt <maximilian.blatt-extern@deutschebahn.com>
(external expert on behalf of DB Netz AG)
2022-09-05 22:27:26 +02:00
Muvaffak Onus ba9d8c29a7 fieldpath: DeleteField should be no-op if it cannot reach the node and it should be able to delete a top-level field
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2022-08-05 19:39:20 +03:00
Muvaffak Onus d950363569 fieldpath: add DeleteField function to delete elements from Paved
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2022-08-05 14:29:14 +03:00
Aditya Sharma cd68866501 Fix lints
Signed-off-by: Aditya Sharma <git@adi.run>
2022-07-21 22:01:32 -07:00
Aditya Sharma 1deb753676 s/interface{}/any/g
Signed-off-by: Aditya Sharma <git@adi.run>
2022-07-21 21:46:18 -07:00
Bulat Shakirzyanov fa6b2ef1e2 bump up the limits
Signed-off-by: Bulat Shakirzyanov <83289+avalanche123@users.noreply.github.com>
2022-07-13 11:58:52 -04:00
Bulat Shakirzyanov b781506537 increase burst to rps * 3
Signed-off-by: Bulat Shakirzyanov <83289+avalanche123@users.noreply.github.com>
2022-07-12 10:03:41 -04:00
muvaffak 75dda897e5
Merge pull request #328 from sergenyalcin/fix-circular-reference
Support for having circular dependencies while using referencers
2022-06-13 18:27:11 +03:00
Sergen Yalçın 5770f19db9
Add unit test cases
Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
2022-06-01 11:33:11 +03:00
Sergen Yalçın 38e79f4960
Preserve order of reference resolution
Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
2022-05-30 18:48:30 +03:00
Sergen Yalçın e2fb202fd5
Add policy api for Selector
Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
2022-05-12 16:11:37 +03:00
Sergen Yalçın 66e5e7ad0b
Re-design the Policy API
Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
2022-04-25 18:14:52 +03:00
Muvaffak Onus 85f12b9e2c
webhook.mutator: add unit tests
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2022-04-22 01:49:49 +03:00
Sergen Yalçın ec82fef853
Add a new policy about resolving references for every reconcile loop
Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
2022-04-16 16:03:18 +03:00
Sergen Yalçın ac7cf2045e
Support for having circular dependencies while using referencers
Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
2022-04-14 14:56:17 +03:00
Muvaffak Onus 43f716a1d4
webhook.validator: add unit tests
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2022-04-07 00:36:00 +03:00
Muvaffak Onus f655302042
webhook.validator: add options to the initializer
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2022-04-07 00:25:48 +03:00
Muvaffak Onus 0b23ec1338
webhook: add mutator struct for chained execution of mutating webhook functions
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2022-04-07 00:21:48 +03:00
Muvaffak Onus cdc7266d4b
webhook: add validator struct for chained execution of validation webhook functions
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2022-04-06 01:21:33 +03:00
Hasan Turken 79ea2fe449
Add comment for linter and use types.UID for uid parameter
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-15 10:29:23 +03:00
Hasan Turken 754abc4f83
Separate Vault KV client for v1 and v2
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-13 14:08:59 +03:00
Hasan Turken 6f9579f9bd
Use string instead if interface for KVSecret data
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-12 23:25:29 +03:00
Hasan Turken 80debfade8
Fix owner not being set for delete
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-11 22:34:48 +03:00
Hasan Turken d7cb4e66da
Fix metadata handling with Vault v1
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-11 12:00:52 +03:00
Hasan Turken ff57cdc7c4
Ensure secret owned by object before delete
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-11 10:29:34 +03:00
Hasan Turken ee3fb975d2
Fix writeOption conversion and add unit tests
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-11 01:16:06 +03:00
Hasan Turken 2d3b3def00
Add metadata support for Vault kv v1
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-10 23:45:40 +03: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 867c9bb8e8
Track connection secret owner with label
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-10 09:56:04 +03:00
Hasan Turken acaeae2f15
Add more unit tests for Connection Details Manager
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 17:25:15 +03:00
Hasan Turken bbbe8f8c66
Return proper error if Secret Store disabled but API used
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 16:29:42 +03:00
Hasan Turken 5273c0ff6d
Move features package to individual repos
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 14:56:39 +03:00
Hasan Turken 2f224692a9
Use store.KeyValue in connection.store package
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 14:46:59 +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 60059a2241
Add PublishConnectionDetailsTo to Composition types
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 12:43:53 +03:00
Hasan Turken b19ffddf2f
Move features package to runtime
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-09 12:43:52 +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
muvaffak onuş b35cdabfbe
Merge pull request #324 from muvaf/parser-or
package.parser: make Or linter work with arbitrary number of linters
2022-03-09 11:26:36 +03:00
Muvaffak Onus 90b7988df4
parser.linter: use strings.Join instead of strings.TrimSuffix to make the flow simpler
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2022-03-09 11:21:56 +03:00
Hasan Turken d591b5e442
Vault ESS - resolve comments and add support for custom CA bundle
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-07 23:47:37 +03:00
Muvaffak Onus 155dc9d659
package.parser: make Or linter work with arbitrary number of linters instead of only two
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2022-03-07 17:00:48 +03:00
Hasan Turken 71c2ae8a54
Add unit tests for Vault Secret Store
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-02 21:00:04 +03:00
Hasan Turken df72fd3089
Add unit tests for Vault KV client
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-02 21:00:04 +03:00
Hasan Turken 551b414fc8
Use metadata API with scheme
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-02 21:00:04 +03:00
Hasan Turken ba2ece4762
Extend KV client for v2 engine
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-02 21:00:04 +03:00
Hasan Turken 796c2ec38e
Implement client for KV Secrets API
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-02 21:00:04 +03:00
Hasan Turken ac03ae3946
Add initial implementation Vault as Secret Store
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-02 21:00:04 +03:00
Hasan Turken 31cce62ecf
Mark connection secret metadata fields as optional
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-02 09:20:08 +03:00
Hasan Turken 1d36dd39ba
More unit tests for kubernetes package
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-02 00:34:59 +03:00
Hasan Turken 06c155d60b
Define scheme for connection secret metadata
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-03-01 14:20:15 +03:00
Hasan Turken 15cf494997
Simplify kubernetes client by reusing clientcmd method
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-25 21:31:08 +03:00
Hasan Turken 21f1473d10
Fix optional fields in connection details API
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-25 17:55:36 +03:00
Hasan Turken 3215c89454
Add unit tests for Kubernetes secret store
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-18 21:55:32 +03:00
Hasan Turken cfcec11142
Do not use unstructured client for StoreConfig
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-17 23:29:03 +03:00
Hasan Turken 258add4288
Resolve first pass of comments in ESS foundation
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-17 16:28:52 +03:00
Hasan Turken 88c4d273a5
Remove publishConnectionDetailsTo from managed resource spec
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-16 11:32:34 +03:00
Hasan Turken a31600daa8
Do not unmarshal if no metadata provided
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-16 10:10:08 +03:00
Hasan Turken 9e13a889fe
Add unit tests for connection manager
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-16 00:00:51 +03:00
Hasan Turken 3c908b7855
Refactor naming and package structure
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-15 17:08:28 +03:00
Hasan Turken 48f7c046f5
Fix namespace calculation for secrets
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-10 19:19:52 +03:00
Hasan Turken bc23452656
Use seperate interfaces to keep existing MRs compiling
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-10 16:34:29 +03:00
Hasan Turken 936e12174d
Add fake store for unit tests
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-10 15:50:45 +03:00
Hasan Turken 19034f22d1
Fetch secret store config and complete connection manager
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-10 00:27:55 +03:00
Hasan Turken 8cc6436606
Add connection secret manager
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-08 18:25:32 +03:00
Hasan Turken cb4062f9c3
Add a placeholder Vault secret store
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-08 18:24:10 +03:00
Hasan Turken 05fff0ec25
Add kubernetes secret store
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-08 18:21:19 +03:00
Hasan Turken 300dc3127f
Define secret store interface
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-08 18:20:47 +03:00
Hasan Turken 4b082d3585
Extend managed resource with new API
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2022-02-08 18:19:57 +03:00
Nic Cope 295de4764e Tweak ExternalDisconnecter implementation
The primary functional change here is to avoid setting a status condition when a
deferred disconnect fails. We don't want to overwrite the original status
condition that may have been written if we're returning from Reconcile because
we hit an error. Emitting an event and a debug log should be sufficient.

This commit also tweaks a bit of grammar and updates the NopConnectDisconnecter
implementation to more closely match its docstring description.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-12-02 22:37:02 +00:00
Nic Cope 5cc9857410
Merge pull request #296 from vaspahomov/feature/disconnect-in-reconcile
Add Disconnect call in Reconcile
2021-12-02 14:16:43 -08:00
fahed dorgaa 7b45316e5b add NewNopFinalizer
Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
2021-11-08 12:49:03 +01:00
hasheddan f3ea898989
Use Wrapf for annotating parser errors
Updates error annotation formatting to use errors.Wrapf.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-10-29 17:00:55 -04:00
hasheddan cc6f044e79
Only attempt object scheme parsing if object is not registered in meta
Updates the package parsing logic to only attempt decoding with the
object scheme in the case that the error from decoding in the meta
scheme is due to the GVK not being registered. This does not change the
definition of a valid package, but does result in more informative
errors being returned when a package is invalid due to a malformed meta
type.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-10-29 15:51:06 -04:00
vaspahomov a5ff67d5a0
remove named returns; disconnect error should not requeue reconcile
Signed-off-by: vaspahomov <vas2142553@gmail.com>
2021-10-28 15:25:12 +05:00
vaspahomov bf53464ca5
Add Disconnect call in Reconcile
Signed-off-by: vaspahomov <vas2142553@gmail.com>
2021-10-28 15:20:56 +05:00
Nic Cope 67edf4ae83
Merge pull request #294 from negz/re-re-re-reconcile
Support true global reconcile rate limiting
2021-10-25 12:33:55 -07:00
Nic Cope ee4131e543 Plumb up reconciler contexts
I believe the Reconcile method started including a context in controller-runtime
v0.8.0, but it was never plumbed up. If I follow the contexts correctly the one
passed to Reconcile can be traced back to the one passed to mgr.Start, which is
typically a context that is cancelled on SIGTERM or SIGINT.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-10-14 00:36:16 +00:00
Hasan Turken 47bff13a91
Proper printing for wildcards
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2021-10-04 15:46:39 +03:00
Hasan Turken 77b66f3d77
Add unit tests for paved.ExpandWildcards
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2021-10-04 15:11:37 +03:00
Hasan Turken aefd94be9f
Add expand wildcards to Paved
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2021-10-03 23:07:28 +03:00
Muvaffak Onus d6c9f3e919
managed: make finalizer name string public so that it can be used in NewAPIFinalizer calls outside of package managed
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2021-09-30 00:27:45 +03:00
Nic Cope 70a386a588 Return, don't mutate, a rate limited *rest.Config
Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-25 03:07:12 +00:00
Nic Cope f7ed086985 Don't rate limit requests that are already delayed by rate limiting
Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-25 02:41:39 +00:00
Nic Cope 277dabb3df Support true global reconcile rate limiting
This PR tweaks how ratelimiters are applied to support _actual_ global reconcile
rate limiting - that is all reconcile triggers are rate limited, not just some.

See https://github.com/crossplane/crossplane/issues/2595 for details.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-24 21:29:00 +00:00
Nic Cope f2b0ca3026 Add DefaultOptions
I don't really expect these to be used in practice. They're mostly useful for
places like the XRD controllers where we need a default set of options to plumb
down to the XR and XRC controllers when none are passed to use (i.e. in tests).

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-21 03:47:25 +00:00
Nic Cope d89312be2f Make nil *feature.Flags somewhat usable
This will report that flags aren't enabled if *Flags is nil, rather than panicing.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-21 03:46:06 +00:00
Nic Cope efa7256648 Add a convenience function for deriving controller-runtime options
Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-21 03:12:43 +00:00
Nic Cope b7335472cd Add a controller.Options type
This type is intended to be passed as the argument to most Crossplane Setup
functions, for example:

```go
func Setup(mgr ctrl.Manager, o controller.Options) error
```

This allows us to add new options to be plumbed down to all or most controllers
without increasing the number of arguments provided to each Setup function. Sets
of controllers that require additional arguments (e.g. the pkg controllers from
crossplane/crossplane) can define their own Options struct that embeds this one.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-21 03:12:43 +00:00
Nic Cope 6ae31519f1 Switch ratelimiter package to more generic names
I'd like to reuse these existing ratelimiters for crossplane, where the names
'Provider' and 'Managed' don't make as much sense.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-21 03:12:43 +00:00
Nic Cope 4bd8016876 Add a feature flag package
https://github.com/crossplane/crossplane/tree/b7ce021e32/internal/feature
https://github.com/crossplane/crossplane/issues/2313.

This is a copy of the (almost) identical crossplane/crossplane package, which
will be removed in favor of this one. Moving to crossplane-runtime allows us to
use the same package in providers, e.g. to disable Alpha APIs per the above
issue.

The package is _almost_ identical because the Flag type has been changed from
int to string. This makes it easier to give flags string names, because the
stringer tool we previously used requires that types and instances be defined in
the same package.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-21 03:12:43 +00:00
Nic Cope f1ff9b11b7 Set Creating and Deleting conditions close to Status().Update() calls
https://github.com/crossplane/crossplane-runtime/issues/285

This approach causes us to repeat ourselves a bit, but prevents issues like the
above, where refactoring caused us to accidentally overwrite a pending status
update that we hadn't committed.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-17 23:35:29 +00:00
Nic Cope 3aa81c43b1 Remove TODO about cmpopts.EquateErrors
I tried to address this TODO today, but found that I kind of prefer how our
implementation works. I've found from time to time while writing tests that
I was accidentally wrapping my errors with the wrong context (i.e. message),
which is not something the cmpopts variant tests for.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-09 07:50:57 +00: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
Nic Cope 1a64750fcd Add an errors package with a similar API to github.com/pkg/errors
Go introduced a 'native' way to wrap errors back in v1.13. At that point we were
already using github.com/pkg/errors to 'wrap' errors with context, and we never
got around to migrating. In addition to pure inertia, I've personally avoided
making the switch because I prefer the github.com/pkg/errors API. Specifically I
like that errors.Wrap handles the "outer context: inner context" error format
that Go uses by convention, and that errors.Wrap will return nil when passed a
nil error.

Given that github.com/pkg/errors has long been in maintenance mode, and is (per
https://github.com/pkg/errors/issues/245) no longer used by its original author
now seems as good a time as any to migrate. This commit attempts to ease that
migration for the Crossplane project - and to retain the nice API - by adding a
package that acts as a small github.com/pkg/errors style shim layer around the
stdlib pkg/errors (and friends, like fmt.Errorf).

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-09 07:43:25 +00:00
Nic Cope 8e780ecd6d Don't rely on removal of the external-create-pending annotation
The retry logic we use to persist critical annotations makes it difficult to
delete an annotation without potentially also deleting annotations added by
another controller (e.g. the composition logic). This commit therefore changes
the way we detect whether we might have created an external resource but not
recorded the result. Previously we relied on the presence of the 'pending'
annotation to detect this state. Now we check whether the 'pending' annotation
is newer than any 'succeeded' or 'failed' annotation.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-03 04:41:00 +00:00
Nic Cope a3a59c95b6 Account for two different kinds of consistency issues
This commit is intended to address two issues that we diagnosed while
investigating https://github.com/crossplane/provider-aws/issues/802.

The first issue is that controller-runtime does not guarantee reads from cache
will return the freshest version of a resource. It's possible we could create an
external resource in one reconcile, then shortly after trigger another in which
it appears that the managed resource was never created because we didn't record
its external-name. This only affects the subset of managed resources with
non-deterministic external-names that are assigned during creation.

The second issue is that some external APIs are eventually consistent. A newly
created external resource may take some time before our ExternalClient's observe
call can confirm it exists. AWS EC2 is an example of one such API.

This commit attempts to address the first issue by making an Update to a managed
resource immediately before Create it called. This Update call will be rejected
by the API server if the managed resource we read from cache was not the latest
version.

It attempts to address the second issue by allowing managed resource controller
authors to configure an optional grace period that begins when an external
resource is successfully created. During this grace period we'll requeue and
keep waiting if Observe determines that the external resource doesn't exist,
rather than (re)creating it.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-09-01 06:04:31 +00:00
Nic Cope ba474e81c6
Merge pull request #273 from negz/revupyourengines
Add composition revision support to XRs and XRCs
2021-08-11 19:00:58 -07:00
Alper Rifat Ulucinar 0127cd0781
Improve comments on fieldpath.merge
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2021-08-05 18:22:32 +03:00
Alper Rifat Ulucinar 4d6ec580be
Do not append duplicate slice elements when MergeOptions.AppendSlice is set
- Move resource.WithMergeOptions to core Crossplane and unexport
- Move fieldpath.object functions to core Crossplane and unexport
- Move fieldpath.MergeValue & related functions to its own file
- Add tests for fieldpath.MergeValue

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2021-08-04 21:38:43 +03:00
Alper Rifat Ulucinar e7b4a22e42
Add Paved.MargeValue method
- Add "fieldpath/object" package that deals with runtime.Objects
- Move MergeOptions struct to package "apis/common/v1".

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2021-08-02 14:19:03 +03:00
Alper Rifat Ulucinar fcbfd04067
Add tests for merge.go
- Add MergeReplace in fieldpath package for
  ease of writing tests.

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2021-08-02 14:19:02 +03:00
Alper Rifat Ulucinar 6f106aac89
Support merging in addition to replacing objects in patches
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
2021-08-02 14:18:53 +03:00
Nic Cope 0b469fcc77
Merge pull request #272 from alecrajeev/Add-Verbose-Logging-Observe
Added verbose logging option when resource is updated
2021-07-21 17:59:35 -07:00
Nic Cope cb68ff958f Add composition revision support to XRs and XRCs
Signed-off-by: Nic Cope <negz@rk0n.org>
2021-07-22 00:51:16 +00:00
Alec Rajeev 5193d240d4 Improve name and log message
Signed-off-by: Alec Rajeev <alecinthecloud@gmail.com>
2021-07-13 20:16:39 -04:00
Nic Cope 85b19c28ea
Merge pull request #267 from saschagrunert/controller-runtime
Update controller-runtime to v0.9.2
2021-07-13 12:40:31 -07:00
Sascha Grunert 18438ce2cf
Update controller-runtime to v0.9.2
This patch updates the controller-runtime dependency to the latest
release.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2021-07-12 09:24:23 +02:00
Alec Rajeev 4eb03bf865 Added verbose logging option when resource is updated
Signed-off-by: Alec Rajeev <alecinthecloud@gmail.com>
2021-07-11 21:27:21 -04:00
hasheddan d76ee9b025
Ignore empty YAML documents in parser
If a document contains only whitespace and we are not able to decode it
into one of the supported schemas, we ignore it and continue. We want to
avoid skipping a type that does not have a registered schema so that we
do not silently ignore errors when package building, but we consider it
safe to assume that a YAML document with no content is safe to skip.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-06-09 10:56:24 -05:00
hasheddan a37f37a745
Write YAML document terminator on file end
YAML supports a document terminator (...) when reading files in a
stream. This allows for the reader to indicate that the current document
has ended without indicating that the stream is finished. Anything after
the document terminator is ignored by the consumer. Therefore, we write
the terminator at the end of a read file, then immediately follow with a
YAML document separator (---), which is mandatory according to the YAML
spec when using document terminators.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-06-09 10:49:36 -05:00
Muvaffak Onus 4a29bebf7c
resource: add SetChanged() to LateInitializer so that it can be extended by providers as needed
Signed-off-by: Muvaffak Onus <me@muvaf.com>
2021-05-31 14:21:24 +03:00
Muvaffak Onus 0503711c41
resource: implement LateInitializer struct to be used by providers
in order to track whether late initialization had any change on the CR.

Signed-off-by: Muvaffak Onus <me@muvaf.com>
2021-05-31 14:20:48 +03: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
Daniel Mangum 36fc69eff9
Merge pull request #259 from hasheddan/no-external-orphan
Unpublish connection details and remove finalizer without attempting to connect to external client when deletion policy is Orphan
2021-03-29 13:39:10 -05:00
hasheddan bc25c7110f
Update managed reconciler unit tests with early orphan handling
Updates managed reconciler unit tests to reflect that managed resources
with a deletion policy of Orphan will have connection details
unpublished and finalizer removed without attempting to connect to
external client.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-03-29 13:32:14 -05:00
hasheddan f2418dc9cd
Remove redundant managed resource deletion policy check
Now that the managed reconciler will handle deletion with policy Orphan
early, there is no need to check that deletion policy is not orphan when
handling a managed resource with deletion timestamp set and external
resource exists.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-03-29 13:32:13 -05:00
hasheddan cf89dda36b
Set status to deleting even when external resource does not exist
Updates the status of managed resource to be set to deleting in the case
where an external resource does not exist, but we fail to unpublish
connection or remove finalizer.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-03-29 13:32:13 -05:00
hasheddan 426347c178
Skip external connect when deletion policy orphan
Modifies managed reconciler to skip attempting to connect to external
client as well as initialize and resolve references when managed
resource has deletion timestamp and deletion policy is orphan.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-03-29 13:32:11 -05:00
Hasan Turken 6e1de520f8
Add IsNamed predicate
Signed-off-by: Hasan Turken <turkenh@gmail.com>
2021-03-29 16:58:28 +03:00
hasheddan 84dc59df2d
Fix misleading description on APIPatchingApplicator
Updates the APIPatchingApplicator with a description that more
accurately describes behavior when passing an object with a resource
version set.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-03-25 10:51:40 -05:00
Nic Cope 824eb6919d Use OpenAPI to set the default ProviderConfig
This allows us to avoid an extra update call to the API server when new managed
resources are created.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-03-11 08:02:04 +00:00
Daniel Mangum 3cd26cccdc
Merge pull request #244 from smcavallo/reference_ptrvalue_helpers
add pointer helper functions for slices for referencers
2021-03-01 16:00:09 -06:00
smcavallo f2440d956a reference pointer utility function comments
Signed-off-by: smcavallo <smcavallo@hotmail.com>
2021-03-01 16:29:20 -05:00
smcavallo 4347499aee add pointer helper functions for slices for referencers
Signed-off-by: smcavallo <smcavallo@hotmail.com>
2021-03-01 10:21:21 -05:00