Skip to content

Commit 8b97a8d

Browse files
committed
fix DomainCRD
1 parent be4f239 commit 8b97a8d

File tree

2 files changed

+19
-36
lines changed

2 files changed

+19
-36
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ITPodsRestart.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,7 @@ public void testAdminServerRestartVersions() throws Exception {
324324
+ "/weblogic-domains/"
325325
+ domain.getDomainUid()
326326
+ "/domain.yaml";
327-
try {
328-
logger.info("Modifying the Domain CRD..");
329-
DomainCRD crd = new DomainCRD();
327+
try {
330328
logger.log(
331329
Level.INFO,
332330
"Running kubectl get Domain {0} -n {1} --output json",
@@ -340,6 +338,8 @@ public void testAdminServerRestartVersions() throws Exception {
340338
+ " --output json")
341339
.stdout();
342340
logger.info(jsonCrd);
341+
logger.info("Modifying the Domain CRD..");
342+
DomainCRD crd = new DomainCRD();
343343
String yaml = crd.addRestartVersionToAdminServer(jsonCrd, "v1.1");
344344
logger.info(yaml);
345345
Path path = Paths.get(restartTmpDir, "restart.admin.yaml");

integration-tests/src/test/java/oracle/kubernetes/operator/utils/DomainCRD.java

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,7 @@ public String addRestartVersionToMS(String domainCRD, String managedServerName,
108108
* @return - spec node entry from Domain CRD JSON tree
109109
*/
110110
private JsonNode getSpecNode(JsonNode root) {
111-
JsonNode items = root.get("items");
112-
JsonNode spec = null;
113-
for (JsonNode item : items) {
114-
spec = item.path("spec");
115-
}
116-
return spec;
111+
return root.path("spec");
117112
}
118113

119114
/**
@@ -123,12 +118,7 @@ private JsonNode getSpecNode(JsonNode root) {
123118
* @return - administration server node entry from Domain CRD JSON tree
124119
*/
125120
private JsonNode getAdminServerNode(JsonNode root) {
126-
JsonNode items = root.get("items");
127-
JsonNode adminServer = null;
128-
for (JsonNode item : items) {
129-
adminServer = item.path("spec").path("adminServer");
130-
}
131-
return adminServer;
121+
return root.path("spec").path("adminServer");
132122
}
133123

134124
/**
@@ -139,15 +129,11 @@ private JsonNode getAdminServerNode(JsonNode root) {
139129
* @return - cluster node entry from Domain CRD JSON tree
140130
*/
141131
private JsonNode getClusterNode(JsonNode root, String clusterName) {
142-
ArrayNode items = (ArrayNode) root.get("items");
143-
ArrayNode clusters;
132+
ArrayNode clusters = (ArrayNode) root.path("spec").path("clusters");
144133
JsonNode clusterNode = null;
145-
for (JsonNode item : items) {
146-
clusters = (ArrayNode) item.path("spec").path("clusters");
147-
for (JsonNode cluster : clusters) {
148-
if (cluster.get("clusterName").asText().equals(clusterName)) {
149-
clusterNode = cluster;
150-
}
134+
for (JsonNode cluster : clusters) {
135+
if (cluster.get("clusterName").asText().equals(clusterName)) {
136+
clusterNode = cluster;
151137
}
152138
}
153139
return clusterNode;
@@ -163,23 +149,20 @@ private JsonNode getClusterNode(JsonNode root, String clusterName) {
163149
*/
164150
private JsonNode getManagedServerNode(
165151
ObjectMapper objectMapper, JsonNode root, String managedServerName) {
166-
ArrayNode items = (ArrayNode) root.get("items");
167152
ArrayNode managedservers = null;
168153
JsonNode managedserverNode = null;
169-
for (JsonNode item : items) {
170-
managedservers = (ArrayNode) item.path("spec").path("managedServers");
171-
if (managedservers.size() != 0) {
172-
for (JsonNode managedserver : managedservers) {
173-
if (managedserver.get("serverName").equals(managedServerName)) {
174-
managedserverNode = managedserver;
175-
}
154+
managedservers = (ArrayNode) root.path("spec").path("managedServers");
155+
if (managedservers.size() != 0) {
156+
for (JsonNode managedserver : managedservers) {
157+
if (managedserver.get("serverName").equals(managedServerName)) {
158+
managedserverNode = managedserver;
176159
}
177-
} else {
178-
ObjectNode managedserver = objectMapper.createObjectNode();
179-
managedserver.put("serverName", managedServerName);
180-
managedservers.add(managedserver);
181-
managedserverNode = managedserver;
182160
}
161+
} else {
162+
ObjectNode managedserver = objectMapper.createObjectNode();
163+
managedserver.put("serverName", managedServerName);
164+
managedservers.add(managedserver);
165+
managedserverNode = managedserver;
183166
}
184167
return managedserverNode;
185168
}

0 commit comments

Comments
 (0)