Skip to content

Commit

Permalink
Consistently manage domain resources using name rather than domainUid (
Browse files Browse the repository at this point in the history
  • Loading branch information
rjeberhard authored Dec 10, 2022
1 parent ac94ef1 commit 9fa9d85
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class WaitForReadyStep<T> extends Step {

protected static Step createMakeDomainRightStep(WaitForReadyStep<?>.Callback callback,
DomainPresenceInfo info, Step next) {
return new CallBuilder().readDomainAsync(info.getDomainUid(),
return new CallBuilder().readDomainAsync(info.getDomainName(),
info.getNamespace(), new MakeRightDomainStep<>(callback, null));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public Object createClusterUntyped(String namespace, Map<String, Object> body) t
/**
* Patch cluster.
*
* @param name the domain uid (unique within the k8s cluster)
* @param name the domain name
* @param namespace the namespace containing the domain
* @param patchBody the patch to apply
* @return Updated cluster
Expand Down Expand Up @@ -921,41 +921,41 @@ public Step readDomainAsync(String name, String namespace, ResponseStep<DomainRe
/**
* Read domain synchronously.
*
* @param uid the domain uid (unique within the k8s cluster)
* @param name the domain name
* @param namespace Namespace
* @return Replaced domain
* @throws ApiException APIException
*/
public DomainResource readDomain(String uid, String namespace) throws ApiException {
RequestParams requestParams = new RequestParams("readDomain", namespace, uid, null, (String)null);
public DomainResource readDomain(String name, String namespace) throws ApiException {
RequestParams requestParams = new RequestParams("readDomain", namespace, name, null, (String)null);
return executeSynchronousCall(requestParams, readDomainCall);
}

/**
* Replace domain.
*
* @param uid the domain uid (unique within the k8s cluster)
* @param name the domain name
* @param namespace Namespace
* @param body Body
* @return Replaced domain
* @throws ApiException APIException
*/
public DomainResource replaceDomain(String uid, String namespace, DomainResource body) throws ApiException {
RequestParams requestParams = new RequestParams("replaceDomain", namespace, uid, body, uid);
public DomainResource replaceDomain(String name, String namespace, DomainResource body) throws ApiException {
RequestParams requestParams = new RequestParams("replaceDomain", namespace, name, body, name);
return executeSynchronousCall(requestParams, replaceDomainCall);
}

/**
* Replace domain status.
*
* @param uid the domain uid (unique within the k8s cluster)
* @param name the domain name
* @param namespace Namespace
* @param body Body
* @return Replaced domain
* @throws ApiException APIException
*/
public DomainResource replaceDomainStatus(String uid, String namespace, DomainResource body) throws ApiException {
RequestParams requestParams = new RequestParams("replaceDomainStatus", namespace, uid, body, uid);
public DomainResource replaceDomainStatus(String name, String namespace, DomainResource body) throws ApiException {
RequestParams requestParams = new RequestParams("replaceDomainStatus", namespace, name, body, name);
return executeSynchronousCall(requestParams, replaceDomainStatusCall);
}

Expand Down Expand Up @@ -984,15 +984,15 @@ public Step replaceDomainAsync(
/**
* Patch domain.
*
* @param uid the domain uid (unique within the k8s cluster)
* @param name the domain name
* @param namespace the namespace containing the domain
* @param patchBody the patch to apply
* @return Updated domain
* @throws ApiException APIException
*/
public DomainResource patchDomain(String uid, String namespace, V1Patch patchBody) throws ApiException {
public DomainResource patchDomain(String name, String namespace, V1Patch patchBody) throws ApiException {
RequestParams requestParams =
new RequestParams("patchDomain", namespace, uid, patchBody, uid);
new RequestParams("patchDomain", namespace, name, patchBody, name);
return executeSynchronousCall(requestParams, patchDomainCall);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,15 @@ public String getDomainUid() {
return domainUid;
}

/**
* Gets the Domain name.
*
* @return Domain name
*/
public String getDomainName() {
return getDomain().getMetadata().getName();
}

@Override
public String getResourceName() {
return getDomainUid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ private void patchDomain(DomainResource domain, JsonPatchBuilder patchBuilder) {
try {
callBuilder
.patchDomain(
domain.getDomainUid(), domain.getMetadata().getNamespace(),
domain.getMetadata().getName(), domain.getMetadata().getNamespace(),
new V1Patch(patchBuilder.build().toString()));
} catch (ApiException e) {
throw handleApiException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private class UpHeadStep extends Step {
@Override
public NextAction apply(Packet packet) {
DomainPresenceInfo info = packet.getSpi(DomainPresenceInfo.class);
return doNext(new CallBuilder().readDomainAsync(info.getDomainUid(), info.getNamespace(),
return doNext(new CallBuilder().readDomainAsync(info.getDomainName(), info.getNamespace(),
new ReadDomainResponseStep(getNext())), packet);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ public static boolean isAdminChannelPortForwardingEnabled(DomainSpec domainSpec)
* @return domain home
*/
public String getDomainHome() {
return emptyToNull(spec.getDomainHome());
return emptyToNull(Optional.ofNullable(spec.getDomainHome())
.orElse(getDomainHomeSourceType().getDefaultDomainHome(getDomainUid())));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ public DomainSpec withDomainUid(String domainUid) {
* @return domain home
*/
String getDomainHome() {
return Optional.ofNullable(domainHome).orElse(getDomainHomeSourceType().getDefaultDomainHome(getDomainUid()));
return domainHome;
}

public String getLivenessProbeCustomScript() {
Expand Down

0 comments on commit 9fa9d85

Please sign in to comment.