-
Notifications
You must be signed in to change notification settings - Fork 62
POC: Implement Boxcutter #1946
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
base: main
Are you sure you want to change the base?
POC: Implement Boxcutter #1946
Conversation
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
type ClusterExtensionRevisionObject struct { | ||
// +kubebuilder:validation:EmbeddedResource | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
Object unstructured.Unstructured `json:"object"` | ||
} |
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.
I suspect embedding fully objects in the ClusterExtensionRevision
will immediately fall over for the larger registry+v1 bundles, particularly those that ship many CRDs, which tend to be large due to descriptions and schemas.
Thoughts on sharding objects out to secrets or some other resource?
labels := obj.GetLabels() | ||
if labels == nil { | ||
labels = map[string]string{} | ||
} | ||
for k, v := range objectLabels { | ||
labels[k] = v | ||
} |
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.
nit: This could be simplified using the new-ish maps
package in the standard library.
labels := obj.GetLabels() | |
if labels == nil { | |
labels = map[string]string{} | |
} | |
for k, v := range objectLabels { | |
labels[k] = v | |
} | |
labels := maps.Clone(obj.GetLabels()) | |
maps.Copy(labels, objectLabels) |
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.
TIL
hasher.Reset() | ||
|
||
printer := spew.ConfigState{ | ||
Indent: " ", | ||
SortKeys: true, | ||
DisableMethods: true, | ||
SpewKeys: true, | ||
} | ||
if _, err := printer.Fprintf(hasher, "%#v", objectToWrite); err != nil { | ||
panic(err) | ||
} |
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.
Is this an OLM-ism or a boxcutter-ism? I wonder if json.NewEncoder(hasher).Encode(objectToWrite)
would be better?
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.
This is a kubernetes apimachinery thing:
https://github.com/kubernetes/kubernetes/blob/627ce4946ccd6b67bc18f5a4dda92cf6c583e9b7/pkg/util/hash/hash.go#L26-L32
https://github.com/kubernetes/apimachinery/blob/master/pkg/util/dump/dump.go
I'll import from apimachinery next.
type revisionAscending []ocv1.ClusterExtensionRevision | ||
|
||
func (a revisionAscending) Len() int { return len(a) } | ||
func (a revisionAscending) Swap(i, j int) { a[i], a[j] = a[j], a[i] } | ||
func (a revisionAscending) Less(i, j int) bool { | ||
iObj := a[i] | ||
jObj := a[j] | ||
|
||
return iObj.Spec.Revision < jObj.Spec.Revision | ||
} |
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.
Nit: might be able to avoid the type definition and associated boilerplate with slices.SortFunc
?
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Reviewer Checklist