Skip to content

Commit 4597a9f

Browse files
committed
Operator will retrieve internal Operator certificate from /operator/internal-identity/internalOperatorCert instead of weblogic-operator-cm
1 parent 1ff00a7 commit 4597a9f

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,8 @@ public boolean equals(Object o) {
259259
public WatchTuning getWatchTuning();
260260

261261
public PodTuning getPodTuning();
262+
263+
public String getFileContents(String path);
264+
265+
public boolean checkFileExists(String path);
262266
}

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
package oracle.kubernetes.operator;
66

7+
import java.io.File;
78
import java.io.IOException;
9+
import java.nio.file.Files;
10+
import java.nio.file.Paths;
811
import java.util.concurrent.ScheduledExecutorService;
912
import java.util.concurrent.locks.ReadWriteLock;
1013
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -134,4 +137,28 @@ public PodTuning getPodTuning() {
134137
lock.readLock().unlock();
135138
}
136139
}
140+
141+
// path - a file containing a base64 encoded string containing the operator's cert in pem format
142+
public String getFileContents(String path) {
143+
// in pem format
144+
String result = null;
145+
if (checkFileExists(path)) {
146+
try {
147+
result = new String(Files.readAllBytes(Paths.get(path)));
148+
} catch (Throwable t) {
149+
}
150+
}
151+
// do not include the certificate data in the log message
152+
return result;
153+
}
154+
155+
public boolean checkFileExists(String path) {
156+
File f = new File(path);
157+
boolean result = false;
158+
if (f.exists() && f.isFile()) {
159+
result = true;
160+
}
161+
162+
return result;
163+
}
137164
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ public class PodHelper {
3333
private PodHelper() {}
3434

3535
static class AdminPodStepContext extends PodStepContext {
36-
private static final String INTERNAL_OPERATOR_CERT_FILE = "internalOperatorCert";
36+
private static final String OPERATOR_DIR = "/operator/";
37+
private static final String INTERNAL_REST_IDENTITY_DIR = OPERATOR_DIR + "internal-identity/";
38+
private static final String INTERNAL_OPERATOR_CERTIFICATE =
39+
INTERNAL_REST_IDENTITY_DIR + "internalOperatorCert";
3740
static final String INTERNAL_OPERATOR_CERT_ENV = "INTERNAL_OPERATOR_CERT";
3841

3942
AdminPodStepContext(Step conflictStep, Packet packet) {
@@ -132,7 +135,7 @@ protected Map<String, String> getPodAnnotations() {
132135
}
133136

134137
private String getInternalOperatorCertFile(TuningParameters tuningParameters) {
135-
return tuningParameters.get(INTERNAL_OPERATOR_CERT_FILE);
138+
return tuningParameters.getFileContents(INTERNAL_OPERATOR_CERTIFICATE);
136139
}
137140
}
138141

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141

4242
@SuppressWarnings("SameParameterValue")
4343
public class AdminPodHelperTest extends PodHelperTestBase {
44-
private static final String INTERNAL_OPERATOR_CERT_FILE_PARAM = "internalOperatorCert";
44+
private static final String INTERNAL_OPERATOR_CERT_FILE_PARAM =
45+
"/operator/internal-identity/internalOperatorCert";
4546
private static final String INTERNAL_OPERATOR_CERT_ENV_NAME = "INTERNAL_OPERATOR_CERT";
4647
private static final String CERTFILE = "certfile";
4748

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,9 @@ public CallBuilderTuning getCallBuilderTuning() {
4848
public String get(Object key) {
4949
return namedParameters.get(key);
5050
}
51+
52+
@Override
53+
public String getFileContents(String path) {
54+
return get(path);
55+
}
5156
}

0 commit comments

Comments
 (0)