Merged
Conversation
- That can be used by other similar inventory endpoints
- Expose useInventory hook too
instead of per-item
bigkevmcd
requested changes
Oct 23, 2023
| return nil, fmt.Errorf("failed converting inventory entry to map[string]interface{}: %+v", entry) | ||
| } | ||
| ref := &kustomizev1.ResourceRef{} | ||
| err := runtime.DefaultUnstructuredConverter.FromUnstructured(entry, ref) |
Contributor
There was a problem hiding this comment.
Not quite sure why you're converting the ref from Unstructured?
Contributor
Author
There was a problem hiding this comment.
Changed the code here a bit to convert the entire block into a ResourceInventory and then iterate through it.
The conversion uses the kustomizations json tags etc { v, id } so you don't have to dig them out ourselves here etc was the thinking.
- Which is the case that breaks sometimes w/ reflection if not handled carefully w/ the adpator
- Move some tests around and revert Exposed fns to be internal - Cleanup the ToReconcileable fn interface, doesn't error anymore, we don't use the list value it returns - More explicit error handling for looking up inventory
Don't need 3rd party libs
bigkevmcd
approved these changes
Oct 24, 2023
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposal to re-use some of the endpoints here for other similar resources.
This would allow "kustomization-like" resources to also be sync'd, suspended and queried for an inventory.
The "contracts":
suspendon any registered kind that has aspec.suspendfieldsyncany registered kind that follows the "set-annotation -> spec.conditions is updated" flow.inventoryon any registered kind that has astatus.inventoryin the format of a kustomization's.API behaviour changes
If another kind is registered during startup with w/ the existing Kind registration system:
Then as well as the GetObject/ListObjects working, the following endpoints will now additionally work with a
FooKindobjects:Possible issues
The error handling on these endpoints will change, they will no longer respond with
syncing a FooKind is not supported, but will try and "sync" theFooKind. If you provide a kind that is not supported, like aConfigMap, it will try and sync it..Alternatives
Expose more helper codes and use that to create very similar endpoints instead: