Skip to content

Commit 9208dfb

Browse files
authored
Split MII zips across Config Maps (#2095)
* Create plugin for running bash unit tests * Support splitting encoded zips across multiple config maps * Update implementation docs to mention additional config maps * simplify joining split archives * delete unusued functions * Remove unused functionality
1 parent 1d574eb commit 9208dfb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4060
-615
lines changed

docs-source/content/userguide/managing-domains/configoverrides/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ when `spec.logHome` is configured and `spec.logHomeEnabled` is true.
451451
* The operator runtime:
452452
* Reads the expanded configuration overrides files or errors from the introspector.
453453
* And, if the introspector reported no errors, it:
454-
* Puts configuration overrides files in a ConfigMap named `DOMAIN_UID-weblogic-domain-introspect-cm`.
455-
* Mounts this ConfigMap into the WebLogic Server instance Pods.
454+
* Puts configuration overrides files in one or more ConfigMaps whose names start with `DOMAIN_UID-weblogic-domain-introspect-cm`.
455+
* Mounts these ConfigMaps into the WebLogic Server instance Pods.
456456
* Otherwise, if the introspector reported errors, it:
457457
* Logs warning, error, or severe messages.
458458
* Will not start WebLogic Server instance Pods; however, any already running Pods are preserved.

docs-source/content/userguide/managing-domains/model-in-image/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ When you deploy a Model in Image Domain YAML file:
4747
- Packages the domain home and passes it to the operator.
4848

4949
- After the introspector job completes:
50-
- The operator creates a ConfigMap named `DOMAIN_UID-weblogic-domain-introspect-cm` and puts the packaged domain home in it.
50+
- The operator creates a ConfigMap named `DOMAIN_UID-weblogic-domain-introspect-cm` (possibly with some additional maps distinguished serial names) and puts the packaged domain home in it.
5151
- The operator subsequently boots your domain's WebLogic Server pods.
5252
- The pods will obtain their domain home from the ConfigMap.
5353

json-schema-maven-plugin/src/main/java/oracle/kubernetes/json/mojo/FileSystem.java

Lines changed: 0 additions & 90 deletions
This file was deleted.

json-schema-maven-plugin/pom.xml renamed to operator-build-maven-plugin/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
<version>3.2.0</version>
1111
</parent>
1212

13-
<artifactId>jsonschema-maven-plugin</artifactId>
13+
<artifactId>operator-build-maven-plugin</artifactId>
1414
<packaging>maven-plugin</packaging>
15-
<name>jsonschema-maven-plugin Maven Mojo</name>
15+
<name>Operator Build Maven Plugin</name>
1616

1717
<dependencies>
1818
<dependency>

json-schema-maven-plugin/src/main/java/oracle/kubernetes/json/mojo/JsonSchemaMojo.java renamed to operator-build-maven-plugin/src/main/java/oracle/kubernetes/json/mojo/JsonSchemaMojo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Map;
1313
import java.util.Optional;
1414

15+
import oracle.kubernetes.mojosupport.FileSystem;
1516
import org.apache.maven.plugin.AbstractMojo;
1617
import org.apache.maven.plugin.MojoExecutionException;
1718
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -26,12 +27,21 @@
2627
public class JsonSchemaMojo extends AbstractMojo {
2728

2829
private static final String DOT = "\\.";
30+
31+
@SuppressWarnings("FieldMayBeFinal") // must be non-final so unit tests can set it
2932
private static Main main = new MainImpl();
33+
34+
@SuppressWarnings("FieldMayBeFinal") // must be non-final so unit tests can set it
3035
private static FileSystem fileSystem = FileSystem.LIVE_FILE_SYSTEM;
36+
37+
@SuppressWarnings("unused") // set by Maven
3138
@Parameter(defaultValue = "${project.compileClasspathElements}", readonly = true, required = true)
3239
private List<String> compileClasspathElements;
40+
41+
@SuppressWarnings("unused") // set by Maven
3342
@Parameter(defaultValue = "${project.build.outputDirectory}/schema")
3443
private String targetDir;
44+
3545
@Parameter private String kubernetesVersion;
3646
@Parameter private final List<ExternalSchema> externalSchemas = Collections.emptyList();
3747
@Parameter(required = true)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package oracle.kubernetes.mojo.shunit2;
5+
6+
import java.util.Arrays;
7+
import java.util.regex.Matcher;
8+
import java.util.regex.Pattern;
9+
10+
/**
11+
* Utilities related to ANSI-formatting of strings sent to a terminal.
12+
*/
13+
class AnsiUtils {
14+
15+
private static final Pattern ANSI_ESCAPE_CHARS = Pattern.compile("(\\x9B|\\x1B\\[)[0-?]*[ -\\/]*[@-~]");
16+
17+
static String withoutAnsiEscapeChars(String input) {
18+
final Matcher matcher = ANSI_ESCAPE_CHARS.matcher(input);
19+
return matcher.replaceAll("");
20+
}
21+
22+
public static AnsiFormatter createFormatter(Format... formats) {
23+
return new AnsiFormatter(formats);
24+
}
25+
26+
static class AnsiFormatter {
27+
28+
private final Format[] formats;
29+
30+
AnsiFormatter(Format... formats) {
31+
this.formats = formats;
32+
}
33+
34+
String format(String string) {
35+
return startCodes() + string + endCodes();
36+
}
37+
38+
private String startCodes() {
39+
return formats.length == 0 ? "" : sequence(Arrays.stream(formats).map(Format::getFormat).toArray(String[]::new));
40+
}
41+
42+
private String endCodes() {
43+
return formats.length == 0 ? "" : sequence("0");
44+
}
45+
46+
String sequence(String... formatCodes) {
47+
return "\u001B[" + String.join(";", formatCodes) + "m";
48+
}
49+
}
50+
51+
static enum Format {
52+
BOLD(1), RED_FG(31), BLUE_FG(34), GREEN_FG(32);
53+
54+
private final String format;
55+
Format(int format) {
56+
this.format = Integer.toString(format);
57+
}
58+
59+
public String getFormat() {
60+
return format;
61+
}
62+
}
63+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package oracle.kubernetes.mojo.shunit2;
5+
6+
import java.io.IOException;
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
import java.util.function.BiFunction;
10+
import javax.annotation.Nonnull;
11+
12+
/**
13+
* A wrapper for ProcessBuilder, in order to allow unit testing.
14+
*/
15+
class BashProcessBuilder {
16+
17+
private final String commands;
18+
private final Map<String,String> environmentVariables = new HashMap<>();
19+
private final BiFunction<String,Map<String,String>,Process> processBiFunction;
20+
21+
/**
22+
* Constructs a builder.
23+
* @param commands the commands to be issued to a new bash process
24+
*/
25+
BashProcessBuilder(String commands) {
26+
this(BashProcessBuilder::createProcess, commands);
27+
}
28+
29+
BashProcessBuilder(BiFunction<String, Map<String, String>, Process> processBiFunction, String commands) {
30+
this.commands = commands;
31+
this.processBiFunction = processBiFunction;
32+
}
33+
34+
/**
35+
* Updates the builder by adding an environment variable to be set in the process.
36+
* @param name the environment variable name
37+
* @param value the environment variable value
38+
*/
39+
void addEnvironmentVariable(String name, String value) {
40+
environmentVariables.put(name, value);
41+
}
42+
43+
/**
44+
* Starts the specified process and returns a Process object to control it.
45+
*/
46+
public Process build() {
47+
return processBiFunction.apply(commands, environmentVariables);
48+
}
49+
50+
@Nonnull
51+
protected static Process createProcess(String command, Map<String, String> environmentVariables) {
52+
try {
53+
ProcessBuilder pb = new ProcessBuilder("bash", command);
54+
pb.environment().putAll(environmentVariables);
55+
return pb.start();
56+
} catch (IOException e) {
57+
throw new RuntimeException(e);
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)