-
Notifications
You must be signed in to change notification settings - Fork 220
feature: update observed generation on updateResource #731
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
Conversation
@@ -157,6 +157,9 @@ private R cloneResourceForErrorStatusHandlerIfNeeded(R resource, Context context | |||
updatedCustomResource = updateStatusGenerationAware(updateControl.getResource()); | |||
} else if (updateControl.isUpdateResource()) { |
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.
Can't that if/else
be simplified?
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.
Good question, could try magically transform this, but what I tried to achieve here is just break it down based on the return cases from the controller. So it's obvious what happens on those cases. If you have any suggestion pls let me know.
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.
If Enum
is used to express Status in UpdateControl, it seems that if/else can be refactored 🤔 .
public class UpdateControl<T extends HasMetadata> extends BaseControl<UpdateControl<T>> {
private final T resource;
private final boolean updateStatus;
private final boolean updateResource;
private final UpdateControlStatusEnum controlStatusEnum;
...
public enum UpdateControlStatusEnum {
UPDATE_RESOURCE_AND_STATUS {
@Override
public <R extends HasMetadata> R toUpdatedResource(....) {
return new UpdateResourceAndStatus(...);
}
},
UPDATE_RESOURCE {
@Override
public <R extends HasMetadata> R toUpdatedResource(....) {
return new UpdateResource(...);
}
},
UPDATE_STATUS {
@Override
public <R extends HasMetadata> R toUpdatedResource(....) {
return new UpdateStatus(...);
}
}
// abstract method for business logic per status..
// public abstract <R extends HasMetadata> R toUpdatedResource(...)
// private static class UpdateResourceAndStatus implements UpdateCustomResource { .. }
// private static class UpdateResource implements UpdateCustomResource { .. }
// private static class UpdateStatus implements UpdateCustomResource { .. }
// ...
Then in that class, you can use it like this:
class ReconciliationDispatcher<R extends HasMetadata> {
.
.
private PostExecutionControl<R> reconcileExecution(ExecutionScope<R> executionScope,
R resourceForExecution, R originalResource, Context context) {
// REMOVED IF/ELSE...
var updatedResource = updateControl.getControlStatusEnum.toUpdateResoruce(...);
return createPostExecutionControl(updateResource, updateControl);
}
If refactoring is needed for this part, I think it can be improved in other issues and PullRequest. :)
Sorry for the late comment review!
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.
I'd be interested in seeing how this would work in a more fleshed-out PR, yes. Is that something you could work on, @heesuk-ahn?
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 Yes, I will make an issue about this and work on it separately and upload the pr. :)
e8ad63b
to
e180777
Compare
No description provided.