-
Notifications
You must be signed in to change notification settings - Fork 202
cp pointers util from kubernetes/kubernetes #41
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
cp pointers util from kubernetes/kubernetes #41
Conversation
README.md
Outdated
@@ -1,5 +1,6 @@ | |||
# Utils | |||
|
|||
|
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: why this empty line?
// BoolPtr returns a pointer to a bool | ||
func BoolPtr(b bool) *bool { | ||
return &b | ||
} |
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.
StringPtr. Don't we have that 1000 times in kube?
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.
sure, add it now
3f07872
to
3289602
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
Thanks!
/cc @thockin |
README.md
Outdated
@@ -45,6 +45,7 @@ an existing package to this repository. | |||
|
|||
- [Clock](/clock) provides an interface for time-based operations. It allows | |||
mocking time for testing. | |||
- [Pointers](/pointers) provides some functions for pointer-based operations. |
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.
For some reason, we've kept an empty line between each module (don't ask me why), but maybe we should keep it consistent?
return true | ||
} | ||
|
||
// Int32Ptr returns a pointer to an int32 |
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.
AFAICR, Tim gave this as an example of what we shouldn't have in this repo (might remember it wrong, I'll look it up)
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.
seems Int32Ptr()
had been used, if do not put here, which file fo put it?
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.
The problem is not that it's not being used, the problem is that you're trying to share code with very little complexity.
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.
It's gonna be used by many packages, and is generally useful, although very simple.
On the other hand @apelisse kubernetes/kubernetes#66010 (review) :)
|
I guess I can't argue with that :-) |
New changes are detected. LGTM label has been removed. |
{(*struct{})(nil), true}, | ||
} | ||
for i, tc := range testCases { | ||
if AllPtrFieldsNil(tc.obj) != tc.expected { |
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 could use t.Run
Can you merge then to unblock us @apelisse :)? |
Thanks 🎉! |
Thanks all |
Finally we have a generic pointer package 🎉🚀 |
} | ||
|
||
// StringPtr returns a pointer to the passed string. | ||
func StringPtr(s string) *string { |
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.
float64 is missing 😱
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.
sorry, little knowledge about it, make be as follow-up
In generic, there are StringSlicePtr
StringMapPtr
Float32Ptr
Float64Ptr
, does we need some of them
or all
to make pointer
packages contained all pointer-oprater
?
This is in so I won't be a pain about it, but this is the sort of dependency that causes very interconnected dep graphs. Any tool that uses this now has to vendor this whole repo. Part of the go ethos is that it's better to copy a little code than to take a dependency. Let's please not let this accumulate tons of random crap. |
No agree we shouldn't put "random crap" in this repo, but this exact utilpointer code is referenced by most of our API packages that deal with defaulting, so this is kinda-needed unless we want to start doing stuff like this in our defaulting packages (that will now live in trueVar := true
obj.SomeBoolPointerField = &trueVar vs obj.SomeBoolPointerField = utilpointer.BoolVar(true) Well you know this already, but anyway I've made the argument for this now. For me this could have moved to
So I'm a bit confused.
hmm I had the idea one can vendor individual packages, not the whole repo? @sttts had also done some experimenting with this I think wrt the ComponentConfig KEP in general |
Lucas, you should know by now that I never claim to be 100% self-consistent
:)
You can vendor just one package, but you have to download and examine the
whole repo. Some tools used to not do subdir-vendoring, but I think we're
past that.
…On Fri, Jul 27, 2018 at 8:53 AM Lucas Käldström ***@***.***> wrote:
No agree we shouldn't put "random crap" in this repo, but this exact
utilpointer code is referenced by most of our API packages that deal with
defaulting, so this is kinda-needed unless we want to start doing stuff
like this in our defaulting packages (that will now live in n different
repos)
trueVar := true
obj.SomeBoolPointerField = &trueVar
vs
obj.SomeBoolPointerField = utilpointer.BoolVar(true)
Well you know this already, but anyway I've made the argument for this now.
For me this could have moved to k8s.io/apimachinery equally fine but you
said in kubernetes/kubernetes#66010 (review)
<kubernetes/kubernetes#66010 (review)>
This seems fine but why apimachinery and not
https://github.com/kubernetes/utils ? I might clean up some of the APIs,
if you want to put a little polish into it...
So I'm a bit confused.
In any case I'm of the opinion this needs to live somewhere to not be a
pain for the defaulting code for the ComponentConfigs.
Any tool that uses this now has to vendor this whole repo
hmm I had the idea one can vendor individual packages, not the whole repo?
@sttts <https://github.com/sttts> had also done some experimenting with
this I think wrt the ComponentConfig KEP in general
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#41 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFVgVOpeep3-yckjPFLBdljOdLM-8PvXks5uKzd8gaJpZM4VTzLK>
.
|
Hahah, yeah ;). Can't say I'm always super consistent with reviews either lol
I don't think this will be a problem as anything should be able to depend on @thockin If this sounds good to you, go ahead and approve kubernetes/kubernetes#66284 which follows this up in the k/k repo ;) |
We need move the
k8s.io/kubernetes/pkg/util/pointer
package tok8s.io/utils/
repo, more details please refer to PR inkubernetes
repo.Following the instruction, this PR is the first step