-
Notifications
You must be signed in to change notification settings - Fork 86
pkg/api: add OptionalRepeatedString type #212
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/api: add OptionalRepeatedString type #212
Conversation
|
@klihub @chrishenzie @mikebrow Pre-work for some of my upcoming work on managing the I'm not sure if we need all the pointer's-pointer (or nil's-nil) stuff or would it be sufficient to return |
@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. |
|
+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 |
mikebrow
left a comment
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.
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 -
335e5a8 to
9d843d5
Compare
|
Rebased, marked ready-for-review. |
klihub
left a comment
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.
LGTM
|
attempt at adding clarity around the ensure clone comment I made.. #212 (comment) |
|
It looks like proto3 has a built-in Is the goal of this wrapper type to distinguish between a This probably is beyond the scope of this PR, but I'm just curious about this API choice that was made |
Exactly. There are similar "optional" wrappers for other types. This follows suite
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>
9d843d5 to
687c1a6
Compare
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.
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 |
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 :-) |
No description provided.