Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/content/en/docs/documentation/reconciler.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public UpdateControl<StatusPatchCacheCustomResource> reconcile(
var freshCopy = createFreshCopy(primary);
freshCopy.getStatus().setValue(statusWithState());

var updatedResource = PrimaryUpdateAndCacheUtils.ssaPatchAndCacheStatus(resource, freshCopy, context);
var updatedResource = PrimaryUpdateAndCacheUtils.ssaPatchStatusAndCacheResource(resource, freshCopy, context);

return UpdateControl.noUpdate();
}
Expand Down Expand Up @@ -247,7 +247,7 @@ needs to be set to `false` you can use an explicit caching approach:
freshCopy.getStatus().setValue(statusWithState());

var updated =
PrimaryUpdateAndCacheUtils.ssaPatchAndCacheStatus(primary, freshCopy, context, cache);
PrimaryUpdateAndCacheUtils.ssaPatchStatusAndCacheResource(primary, freshCopy, context, cache);

return UpdateControl.noUpdate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,61 +25,64 @@ private PrimaryUpdateAndCacheUtils() {}
private static final Logger log = LoggerFactory.getLogger(PrimaryUpdateAndCacheUtils.class);

/**
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
* Using update (PUT) method.
* Updates status and makes sure that the up-to-date primary resource will be present during the
* next reconciliation. Using update (PUT) method.
*
* @param primary resource
* @param context of reconciliation
* @return updated resource
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P updateAndCacheStatus(P primary, Context<P> context) {
public static <P extends HasMetadata> P updateStatusAndCacheResource(
P primary, Context<P> context) {
logWarnIfResourceVersionPresent(primary);
return patchAndCacheStatus(
return patchStatusAndCacheResource(
primary, context, () -> context.getClient().resource(primary).updateStatus());
}

/**
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
* Using JSON Merge patch.
* Patches status with and makes sure that the up-to-date primary resource will be present during
* the next reconciliation. Using JSON Merge patch.
*
* @param primary resource
* @param context of reconciliation
* @return updated resource
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P patchAndCacheStatus(P primary, Context<P> context) {
public static <P extends HasMetadata> P patchStatusAndCacheResource(
P primary, Context<P> context) {
logWarnIfResourceVersionPresent(primary);
return patchAndCacheStatus(
return patchStatusAndCacheResource(
primary, context, () -> context.getClient().resource(primary).patchStatus());
}

/**
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
* Using JSON Patch.
* Patches status and makes sure that the up-to-date primary resource will be present during the
* next reconciliation. Using JSON Patch.
*
* @param primary resource
* @param context of reconciliation
* @return updated resource
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P editAndCacheStatus(
public static <P extends HasMetadata> P editStatusAndCacheResource(
P primary, Context<P> context, UnaryOperator<P> operation) {
logWarnIfResourceVersionPresent(primary);
return patchAndCacheStatus(
return patchStatusAndCacheResource(
primary, context, () -> context.getClient().resource(primary).editStatus(operation));
}

/**
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
* Patches the resource with supplied method and makes sure that the up-to-date primary resource
* will be present during the next reconciliation.
*
* @param primary resource
* @param context of reconciliation
* @param patch free implementation of cache
* @return the updated resource.
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P patchAndCacheStatus(
public static <P extends HasMetadata> P patchStatusAndCacheResource(
P primary, Context<P> context, Supplier<P> patch) {
var updatedResource = patch.get();
context
Expand All @@ -90,16 +93,16 @@ public static <P extends HasMetadata> P patchAndCacheStatus(
}

/**
* Makes sure that the up-to-date primary resource will be present during the next reconciliation.
* Using Server Side Apply.
* Patches status and makes sure that the up-to-date primary resource will be present during the
* next reconciliation. Using Server Side Apply.
*
* @param primary resource
* @param freshResourceWithStatus - fresh resource with target state
* @param context of reconciliation
* @return the updated resource.
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P ssaPatchAndCacheStatus(
public static <P extends HasMetadata> P ssaPatchStatusAndCacheResource(
P primary, P freshResourceWithStatus, Context<P> context) {
logWarnIfResourceVersionPresent(freshResourceWithStatus);
var res =
Expand All @@ -122,7 +125,8 @@ public static <P extends HasMetadata> P ssaPatchAndCacheStatus(
}

/**
* Patches the resource and adds it to the {@link PrimaryResourceCache}.
* Patches the resource status and caches the response in provided {@link PrimaryResourceCache}.
* Uses Server Side Apply.
*
* @param primary resource
* @param freshResourceWithStatus - fresh resource with target state
Expand All @@ -131,10 +135,10 @@ public static <P extends HasMetadata> P ssaPatchAndCacheStatus(
* @return the updated resource.
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P ssaPatchAndCacheStatus(
public static <P extends HasMetadata> P ssaPatchStatusAndCacheResource(
P primary, P freshResourceWithStatus, Context<P> context, PrimaryResourceCache<P> cache) {
logWarnIfResourceVersionPresent(freshResourceWithStatus);
return patchAndCacheStatus(
return patchStatusAndCacheResource(
primary,
cache,
() ->
Expand All @@ -151,64 +155,66 @@ public static <P extends HasMetadata> P ssaPatchAndCacheStatus(
}

/**
* Patches the resource with JSON Patch and adds it to the {@link PrimaryResourceCache}.
* Patches the resource with JSON Patch and caches the response in provided {@link
* PrimaryResourceCache}.
*
* @param primary resource
* @param context of reconciliation
* @param cache - resource cache managed by user
* @return the updated resource.
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P editAndCacheStatus(
public static <P extends HasMetadata> P editStatusAndCacheResource(
P primary, Context<P> context, PrimaryResourceCache<P> cache, UnaryOperator<P> operation) {
logWarnIfResourceVersionPresent(primary);
return patchAndCacheStatus(
return patchStatusAndCacheResource(
primary, cache, () -> context.getClient().resource(primary).editStatus(operation));
}

/**
* Patches the resource with JSON Merge patch and adds it to the {@link PrimaryResourceCache}
* provided.
* Patches the resource status with JSON Merge patch and caches the response in provided {@link
* PrimaryResourceCache}
*
* @param primary resource
* @param context of reconciliation
* @param cache - resource cache managed by user
* @return the updated resource.
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P patchAndCacheStatus(
public static <P extends HasMetadata> P patchStatusAndCacheResource(
P primary, Context<P> context, PrimaryResourceCache<P> cache) {
logWarnIfResourceVersionPresent(primary);
return patchAndCacheStatus(
return patchStatusAndCacheResource(
primary, cache, () -> context.getClient().resource(primary).patchStatus());
}

/**
* Updates the resource and adds it to the {@link PrimaryResourceCache}.
* Updates the resource status and caches the response in provided {@link PrimaryResourceCache}.
*
* @param primary resource
* @param context of reconciliation
* @param cache - resource cache managed by user
* @return the updated resource.
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P updateAndCacheStatus(
public static <P extends HasMetadata> P updateStatusAndCacheResource(
P primary, Context<P> context, PrimaryResourceCache<P> cache) {
logWarnIfResourceVersionPresent(primary);
return patchAndCacheStatus(
return patchStatusAndCacheResource(
primary, cache, () -> context.getClient().resource(primary).updateStatus());
}

/**
* Updates the resource using the user provided implementation anc caches the result.
* Updates the resource using the user provided implementation and caches the response in provided
* {@link PrimaryResourceCache}.
*
* @param primary resource
* @param cache resource cache managed by user
* @param patch implementation of resource update*
* @return the updated resource.
* @param <P> primary resource type
*/
public static <P extends HasMetadata> P patchAndCacheStatus(
public static <P extends HasMetadata> P patchStatusAndCacheResource(
P primary, PrimaryResourceCache<P> cache, Supplier<P> patch) {
var updatedResource = patch.get();
cache.cacheResource(primary, updatedResource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public UpdateControl<StatusPatchCacheCustomResource> reconcile(
.getStatus()
.setValue(resource.getStatus() == null ? 1 : resource.getStatus().getValue() + 1);

var updated = PrimaryUpdateAndCacheUtils.ssaPatchAndCacheStatus(resource, freshCopy, context);
var updated =
PrimaryUpdateAndCacheUtils.ssaPatchStatusAndCacheResource(resource, freshCopy, context);
latestValue = updated.getStatus().getValue();

return UpdateControl.noUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public UpdateControl<StatusPatchPrimaryCacheCustomResource> reconcile(
.setValue(primary.getStatus() == null ? 1 : primary.getStatus().getValue() + 1);

var updated =
PrimaryUpdateAndCacheUtils.ssaPatchAndCacheStatus(primary, freshCopy, context, cache);
PrimaryUpdateAndCacheUtils.ssaPatchStatusAndCacheResource(
primary, freshCopy, context, cache);
latestValue = updated.getStatus().getValue();

return UpdateControl.noUpdate();
Expand Down