Skip to content

Commit 76ff080

Browse files
authored
Merge pull request #516 from oracle/remove_workaround_282
remove workaround
2 parents 44260a2 + 297c4ff commit 76ff080

File tree

3 files changed

+3
-44
lines changed

3 files changed

+3
-44
lines changed

operator/src/main/java/oracle/kubernetes/operator/Workarounds.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ public class Workarounds {
1515
// This breaks some K8s model comparisons.
1616

1717
// Reported to https://github.com/kubernetes-client/java as issue #282
18-
public static final boolean INTORSTRING_BAD_EQUALS = true;
18+
public static final boolean INTORSTRING_BAD_EQUALS = false;
1919
}

operator/src/main/java/oracle/kubernetes/operator/helpers/IngressHelper.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import static oracle.kubernetes.operator.LabelConstants.DOMAINUID_LABEL;
1313
import static oracle.kubernetes.operator.LabelConstants.RESOURCE_VERSION_LABEL;
1414
import static oracle.kubernetes.operator.VersionConstants.DEFAULT_DOMAIN_VERSION;
15-
import static oracle.kubernetes.operator.Workarounds.INTORSTRING_BAD_EQUALS;
1615

1716
import io.kubernetes.client.custom.IntOrString;
1817
import io.kubernetes.client.models.V1ObjectMeta;
@@ -31,7 +30,6 @@
3130
import oracle.kubernetes.operator.work.NextAction;
3231
import oracle.kubernetes.operator.work.Packet;
3332
import oracle.kubernetes.operator.work.Step;
34-
import org.yaml.snakeyaml.Yaml;
3533

3634
/** Helper class to add/remove server from Ingress. */
3735
public class IngressHelper {
@@ -123,21 +121,7 @@ Step replaceIngressStep(Step next) {
123121

124122
private boolean isCompatible(V1beta1Ingress result) {
125123
return VersionHelper.matchesResourceVersion(result.getMetadata(), DEFAULT_DOMAIN_VERSION)
126-
&& equalObjects(result.getSpec(), createIngressSpec());
127-
}
128-
129-
private boolean equalObjects(V1beta1IngressSpec object1, V1beta1IngressSpec object2) {
130-
return INTORSTRING_BAD_EQUALS
131-
? yamlEquals(object1, object2)
132-
: Objects.equals(object1, object2);
133-
}
134-
135-
private boolean yamlEquals(Object actual, Object expected) {
136-
return Objects.equals(objectToYaml(actual), objectToYaml(expected));
137-
}
138-
139-
private String objectToYaml(Object object) {
140-
return new Yaml().dump(object);
124+
&& Objects.equals(result.getSpec(), createIngressSpec());
141125
}
142126
}
143127

operator/src/test/java/oracle/kubernetes/operator/helpers/CallTestSupport.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44

55
package oracle.kubernetes.operator.helpers;
66

7-
import static oracle.kubernetes.operator.Workarounds.INTORSTRING_BAD_EQUALS;
8-
97
import com.meterware.simplestub.Memento;
108
import com.meterware.simplestub.StaticStubSupport;
119
import io.kubernetes.client.ApiClient;
1210
import io.kubernetes.client.ApiException;
13-
import io.kubernetes.client.models.V1beta1Ingress;
1411
import java.net.HttpURLConnection;
1512
import java.util.ArrayList;
1613
import java.util.Collections;
@@ -24,7 +21,6 @@
2421
import oracle.kubernetes.operator.calls.RequestParams;
2522
import oracle.kubernetes.operator.calls.SynchronousCallDispatcher;
2623
import oracle.kubernetes.operator.calls.SynchronousCallFactory;
27-
import oracle.kubernetes.operator.utils.YamlUtils;
2824

2925
/**
3026
* Support for writing unit tests that use CallBuilder to send requests that expect responses.
@@ -163,31 +159,10 @@ private boolean matches(RequestParams requestParams) {
163159

164160
private boolean matchesBody(Object actualBody, Object expectedBody) {
165161
return expectedBody instanceof BodyMatcher && ((BodyMatcher) expectedBody).matches(actualBody)
166-
|| equalBodies(actualBody, expectedBody)
162+
|| Objects.equals(actualBody, expectedBody)
167163
|| function != null;
168164
}
169165

170-
private static boolean equalBodies(Object actual, Object expected) {
171-
return useYamlComparison(actual)
172-
? yamlEquals(actual, expected)
173-
: Objects.equals(actual, expected);
174-
}
175-
176-
// This is a hack to get around a bug in the 1.0 K8s client code:
177-
// the IntOrString class does not define equals(), meaning that any classes which depend on
178-
// it require special handling.
179-
private static boolean useYamlComparison(Object actual) {
180-
return INTORSTRING_BAD_EQUALS && actual instanceof V1beta1Ingress;
181-
}
182-
183-
private static boolean yamlEquals(Object actual, Object expected) {
184-
return Objects.equals(objectToYaml(actual), objectToYaml(expected));
185-
}
186-
187-
private static String objectToYaml(Object object) {
188-
return YamlUtils.newYaml().dump(object);
189-
}
190-
191166
private boolean matches(AdditionalParams params) {
192167
return Objects.equals(params.fieldSelector, requestParamExpectations.get(FIELD_SELECTOR))
193168
&& Objects.equals(params.labelSelector, requestParamExpectations.get(LABEL_SELECTOR));

0 commit comments

Comments
 (0)