-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add factory methods to help with SSA #6013
Conversation
...nerator/kubernetes-model-core/src/main/java/io/fabric8/kubernetes/api/model/HasMetadata.java
Outdated
Show resolved
Hide resolved
...nerator/kubernetes-model-core/src/main/java/io/fabric8/kubernetes/api/model/HasMetadata.java
Outdated
Show resolved
Hide resolved
02f3589
to
47a508b
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.
Looks good, just two more thoughts.
* @return a new ObjectMetaBuilder instance initialized with the name and namespace (if the resource it is called on is a | ||
* namespaced one) of the specified ObjectMeta | ||
*/ | ||
default ObjectMetaBuilder initMetadataBuilderNameAndNamespaceFrom(ObjectMeta original) { |
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.
Let's make this one static - it does not need access to the current instance.
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.
Makes sense. I originally hoped that I could set the metadata on the current instance as well.
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.
static ObjectMetaBuilder initMetadataBuilderNameAndNamespaceFrom(ObjectMeta original)
gives you the usage:
new SomethingBuilder().withMetadata(HasMetadata.initMetadataBuilderNameAndNamespaceFrom(original)....build())...
An alternative which doesn't quite set the metadata, but allows you to do so more fluently:
static <A extends ObjectMetaFluent<A>> A withNameAndNamespace(A value, HasMetadata original) {
gives you the usage:
HasMetadata.withNameAndNamespace(new SomethingBuilder().withNewMetadata(), original)...endMetadata()...
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.
Actually, it does access the current instance to check if it is Namespaced
or not to decide whether to use and set the namespace…
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.
@metacosm I think I was assuming based upon your other comment though it could instead be:
static ObjectMetaBuilder initMetadataBuilderNameAndNamespaceFrom(HasMetadata original)
But didn't make that change in the signature shown above.
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.
Gotcha. Sorry for being slow, it's been a long day. 😓
...nerator/kubernetes-model-core/src/main/java/io/fabric8/kubernetes/api/model/HasMetadata.java
Show resolved
Hide resolved
c4607e7
to
baac39f
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
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, thx!
Signed-off-by: Marc Nuri <[email protected]>
Quality Gate passedIssues Measures |
Description
Fixes #6012
Type of change
test, version modification, documentation, etc.)
Checklist