Skip to content

Conversation

@marquiz
Copy link
Contributor

@marquiz marquiz commented Aug 21, 2025

No description provided.

@marquiz
Copy link
Contributor Author

marquiz commented Aug 21, 2025

@klihub @chrishenzie @mikebrow

Pre-work for some of my upcoming work on managing the linux.intelRdt object of the runtime-spec. I decided to submit this one as a separate PR with the hopes of easier and more focused review.

I'm not sure if we need all the pointer's-pointer (or nil's-nil) stuff or would it be sufficient to return []string (instead of *[]string) from Get()

@klihub
Copy link
Member

klihub commented Aug 21, 2025

@klihub @chrishenzie @mikebrow

Pre-work for some of my upcoming work on managing the linux.intelRdt object of the runtime-spec. I decided to submit this one as a separate PR with the hopes of easier and more focused review.

I'm not sure if we need all the pointer's-pointer (or nil's-nil) stuff or would it be sufficient to return []string (instead of *[]string) from Get()

@marquiz. This is I think the only part I was wondering about. But you will probably get a much better understanding about what makes sense for Get() and what alternatives make sense for the constructor once you have written some more code exercising this. Then there are two options. Either start with the minimal set your code needs, or with what you guesstimate to be potentially necessary. But this already LGTM as such.

@klihub klihub requested review from chrishenzie and klihub August 21, 2025 15:17
@chrishenzie
Copy link
Contributor

+1 to @klihub 's comment -- would it be possible to add your intended use case as a separate commit in this PR so we can take a look how it's being used? I'd prefer to review that vs. merge now and have to make subsequent changes later

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

agree with your and the other comments.. without the use case, outside the test bucket itself, sort of hard to see whether some of the optional elements are a + or -

@klihub klihub marked this pull request as draft September 22, 2025 18:29
@marquiz marquiz force-pushed the devel/api-optional-repeated-string branch from 335e5a8 to 9d843d5 Compare November 24, 2025 13:50
@marquiz marquiz marked this pull request as ready for review November 24, 2025 13:55
@marquiz
Copy link
Contributor Author

marquiz commented Nov 24, 2025

Rebased, marked ready-for-review.
@klihub @mikebrow @chrishenzie

@klihub klihub requested a review from mikebrow November 24, 2025 15:51
Copy link
Member

@klihub klihub left a comment

Choose a reason for hiding this comment

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

LGTM

@mikebrow
Copy link
Member

attempt at adding clarity around the ensure clone comment I made.. #212 (comment)

@chrishenzie
Copy link
Contributor

chrishenzie commented Nov 24, 2025

It looks like proto3 has a built-in optional keyword, but doesn't support optional repeated syntax.

Is the goal of this wrapper type to distinguish between a nil (unset) list and an empty list? If that distinction isn't critical for the intelRdt use case, could we simplify the API by using a standard repeated string field and treating an empty list as unset?

This probably is beyond the scope of this PR, but I'm just curious about this API choice that was made

@marquiz
Copy link
Contributor Author

marquiz commented Nov 25, 2025

Is the goal of this wrapper type to distinguish between a nil (unset) list and an empty list?

Exactly. There are similar "optional" wrappers for other types. This follows suite

If that distinction isn't critical for the intelRdt use case, could we simplify the API by using a standard repeated string field and treating an empty list as unset?

For now, it's not critical. But I want to be able to make the difference whether the list was specified or not. Make sure that we're not caught off guard if the empty list get's a special meaning in the runtime-spec in the future.

Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
@klihub klihub force-pushed the devel/api-optional-repeated-string branch from 9d843d5 to 687c1a6 Compare December 4, 2025 08:19
@klihub
Copy link
Member

klihub commented Dec 4, 2025

@mikebrow We could try to kick this one and #215 (which is stacked on top of this) forward...

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

LGTM
nit some doc explanation on the involved funcs explaining that the wrapper is a shallow clone..

The slices.Clone function in Go creates a shallow copy of a slice, meaning it copies the elements but retains references to the same underlying data. This allows you to modify the cloned slice without affecting the original slice, as long as the elements themselves are not mutable types.

@klihub
Copy link
Member

klihub commented Dec 4, 2025

LGTM nit some doc explanation on the involved funcs explaining that the wrapper is a shallow clone..

The slices.Clone function in Go creates a shallow copy of a slice, meaning it copies the elements but retains references to the same underlying data. This allows you to modify the cloned slice without affecting the original slice, as long as the elements themselves are not mutable types.

@mikebrow Hmm..., okay. I read the code again, and if you mean slices.Clone() in the RepeatedString(v interface{}) 'constructor', then I think we always end up shallow-cloning a []string in the end, so there is no data left shared there. And the other one in Get() *[]string does the same with a more straightforward control flow.

@mikebrow
Copy link
Member

mikebrow commented Dec 4, 2025

LGTM nit some doc explanation on the involved funcs explaining that the wrapper is a shallow clone..

The slices.Clone function in Go creates a shallow copy of a slice, meaning it copies the elements but retains references to the same underlying data. This allows you to modify the cloned slice without affecting the original slice, as long as the elements themselves are not mutable types.

@mikebrow Hmm..., okay. I read the code again, and if you mean slices.Clone() in the RepeatedString(v interface{}) 'constructor', then I think we always end up shallow-cloning a []string in the end, so there is no data left shared there. And the other one in Get() *[]string does the same with a more straightforward control flow.

nod and strings are immutable in golang.. so even if the caller wanted to change one of those strings it would not be allowed.. feels odd.. but ok, guess I'm just missing C :-)

@mikebrow mikebrow merged commit 8f3e69e into containerd:main Dec 4, 2025
16 checks passed
@marquiz marquiz deleted the devel/api-optional-repeated-string branch December 4, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants