-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic sync/suspend/inventory listing #4096
Conversation
- That can be used by other similar inventory endpoints
- Expose useInventory hook too
instead of per-item
core/server/inventory.go
Outdated
return nil, fmt.Errorf("failed converting inventory entry to map[string]interface{}: %+v", entry) | ||
} | ||
ref := &kustomizev1.ResourceRef{} | ||
err := runtime.DefaultUnstructuredConverter.FromUnstructured(entry, ref) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure why you're converting the ref from Unstructured?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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":
suspend
on any registered kind that has aspec.suspend
fieldsync
any registered kind that follows the "set-annotation -> spec.conditions is updated" flow.inventory
on any registered kind that has astatus.inventory
in 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
FooKind
objects: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: