Skip to content

Commit f859d79

Browse files
authored
Merge pull request #253 from oracle/fix-configmap-scripts-reading
Fix configmap scripts reading
2 parents 094c31b + 8c9c322 commit f859d79

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,35 +151,34 @@ protected V1ConfigMap computeDomainConfigMap() {
151151
metadata.setLabels(labels);
152152

153153
cm.setMetadata(metadata);
154-
cm.setData(loadScripts());
154+
cm.setData(loadScripts(domainNamespace));
155155

156156
return cm;
157157
}
158158

159-
private synchronized Map<String, String> loadScripts() {
159+
private static synchronized Map<String, String> loadScripts(String domainNamespace) {
160160
URI uri = null;
161161
try {
162-
uri = getClass().getResource(SCRIPT_LOCATION).toURI();
162+
uri = ScriptConfigMapStep.class.getResource(SCRIPT_LOCATION).toURI();
163163
} catch (URISyntaxException e) {
164164
LOGGER.warning(MessageKeys.EXCEPTION, e);
165165
throw new RuntimeException(e);
166166
}
167-
168167
try {
169168
if ("jar".equals(uri.getScheme())) {
170169
try (FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.<String, Object>emptyMap())) {
171-
return walkScriptsPath(fileSystem.getPath(SCRIPTS));
170+
return walkScriptsPath(fileSystem.getPath(SCRIPTS), domainNamespace);
172171
}
173172
} else {
174-
return walkScriptsPath(Paths.get(uri));
173+
return walkScriptsPath(Paths.get(uri), domainNamespace);
175174
}
176175
} catch (IOException e) {
177176
LOGGER.warning(MessageKeys.EXCEPTION, e);
178177
throw new RuntimeException(e);
179178
}
180179
}
181180

182-
private Map<String, String> walkScriptsPath(Path scriptsDir) throws IOException {
181+
private static Map<String, String> walkScriptsPath(Path scriptsDir, String domainNamespace) throws IOException {
183182
try (Stream<Path> walk = Files.walk(scriptsDir, 1)) {
184183
Map<String, String> data = walk.filter(i -> !Files.isDirectory(i)).collect(Collectors.toMap(
185184
i -> i.getFileName().toString(),
@@ -189,7 +188,7 @@ private Map<String, String> walkScriptsPath(Path scriptsDir) throws IOException
189188
}
190189
}
191190

192-
private byte[] read(Path path) {
191+
private static byte[] read(Path path) {
193192
try {
194193
return Files.readAllBytes(path);
195194
} catch (IOException io) {

0 commit comments

Comments
 (0)