Skip to content
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

pkg/manifests.list.AddInstance(): don't set Platform to an empty struct #1819

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

nalind
Copy link
Member

@nalind nalind commented Jan 23, 2024

If the Platform struct for an OCI instance being added to an image index is empty, set the Platform pointer field in the Descriptor struct to nil instead of setting it to point to a Platform struct filled with empty values. I expect this to be the case for at least some OCI artifacts being added to indexes.

Likewise, if we're updating the Platform for an OCI instance and its value goes to zero, set its pointer to nil to avoid the same case.

When reading information back from a descriptor, or setting a field in the Platform struct, don't assume that Platform is (already) set to a non-nil value.

If the Platform struct for an OCI instance being added to an image index
is empty, set the Platform pointer field in the Descriptor struct to
`nil` instead of setting it to point to a Platform struct filled with
empty values.  I expect this to be the case for at least some OCI
artifacts being added to indexes.

Likewise, if we're updating the Platform for an OCI instance and its
value goes to zero, set its pointer to `nil` to avoid the same case.

When reading information back from a descriptor, or setting a field in
the Platform struct, don't assume that Platform is (already) set to a
non-nil value.

Signed-off-by: Nalin Dahyabhai <[email protected]>
@mheon
Copy link
Member

mheon commented Jan 25, 2024

LGTM

Comment on lines 209 to 210
sort.Strings(expectedLibpodFilters)
sort.Strings(got)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use assert.ElementsMatch() instead of sorting explicitly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, that's a good one. I missed that somehow when doing a search of the functions in the package. Changing it.

Compare the two string slices in this test using ElementsMatch(), which
ignores the order.  One of them is built using a map traversal, the
order of which is not guaranteed, so the regular equality check can fail.

Signed-off-by: Nalin Dahyabhai <[email protected]>
@nalind
Copy link
Member Author

nalind commented Jan 30, 2024

Any other review comments, anyone?

@rhatdan
Copy link
Member

rhatdan commented Jan 30, 2024

/lgtm

@rhatdan
Copy link
Member

rhatdan commented Jan 30, 2024

/approve

Copy link
Contributor

openshift-ci bot commented Jan 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nalind, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit b260992 into containers:main Jan 30, 2024
7 checks passed
@nalind nalind deleted the platform-optional branch January 30, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants