forked from eclipse-jkube/jkube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (jkube-kit) : Add support for specifying initContainers via reso…
…urce configuration (eclipse-jkube#1316) + Deprecate all controller specific configuration options in ResourceConfig. Move all controller specific options to nested controller configuration. + Add controller(s) configuration option in ResourceConfig + Add initContainres configuraiton option in Controller configuration Signed-off-by: Rohan Kumar <rohaan@redhat.com>
- Loading branch information
1 parent
b212dff
commit 0647535
Showing
69 changed files
with
2,366 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/ArgumentsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.common; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; | ||
|
||
class ArgumentsTest { | ||
|
||
@Test | ||
void testShellArgWithSpaceEscape() { | ||
String[] testSubject = { "java", "-jar", "$HOME/name with space.jar" }; | ||
Arguments arg = Arguments.builder().shell("java -jar $HOME/name\\ with\\ space.jar").build(); | ||
assertThat(arg.asStrings()).containsExactly(testSubject); | ||
} | ||
|
||
@Test | ||
void set_whenInvoked_shouldSetShell() { | ||
// Given | ||
Arguments arg = new Arguments(); | ||
|
||
// When | ||
arg.set("sleep 10"); | ||
|
||
// Then | ||
assertThat(arg.getShell()).isEqualTo("sleep 10"); | ||
assertThat(arg.asStrings()).containsExactly("sleep", "10"); | ||
} | ||
|
||
@Test | ||
void exec_withSpaceEscapeArg_shouldReturnCorrectCmd() { | ||
// Given | ||
Arguments arg = Arguments.builder().exec(Arrays.asList("wget", "-O", "/work-dir/index.html", "http://info.cern.ch")).build(); | ||
|
||
// When | ||
List<String> result = arg.asStrings(); | ||
|
||
// Then | ||
assertThat(result).containsExactly("wget", "-O", "/work-dir/index.html", "http://info.cern.ch"); | ||
} | ||
|
||
@Test | ||
void execInlined_withSpaceEscapeArg_shouldReturnCorrectCmd() { | ||
// Given | ||
List<String> execInline = Arrays.asList("wget", "-O", "/work-dir/index.html", "http://info.cern.ch"); | ||
Arguments arg = new Arguments(null, null, execInline); | ||
|
||
// When | ||
List<String> result = arg.asStrings(); | ||
|
||
// Then | ||
assertThat(arg.getExecInlined()).isEqualTo(execInline); | ||
assertThat(result).containsExactly("wget", "-O", "/work-dir/index.html", "http://info.cern.ch"); | ||
} | ||
|
||
@Test | ||
void getExec_whenInvoked_thenReturnsEitherExecOrExecInlined() { | ||
// Given | ||
Arguments arg = new Arguments(null, null, Arrays.asList("wget", "-O", "/work-dir/index.html", "http://info.cern.ch")); | ||
|
||
// When | ||
List<String> exec = arg.getExec(); | ||
|
||
// Then | ||
assertThat(exec).containsExactly("wget", "-O", "/work-dir/index.html", "http://info.cern.ch"); | ||
} | ||
|
||
@Test | ||
void validate_withValidObjects_thenNoExceptionThrown() { | ||
// Given | ||
Arguments shell = new Arguments("sleep 10", null, null); | ||
Arguments exec = new Arguments(null, Arrays.asList("sleep", "10"), null); | ||
Arguments execInlined = new Arguments(null, null, Arrays.asList("sleep", "10")); | ||
|
||
// When | ||
shell.validate(); | ||
exec.validate(); | ||
execInlined.validate(); | ||
|
||
// Then | ||
assertThat(shell).isNotNull(); | ||
assertThat(exec).isNotNull(); | ||
assertThat(execInlined).isNotNull(); | ||
} | ||
|
||
@Test | ||
void validate_whenWrongObjectProvided_thenThrowException() { | ||
// Given | ||
Arguments arg = new Arguments(); | ||
|
||
// When + Then | ||
assertThatIllegalArgumentException() | ||
.isThrownBy(arg::validate) | ||
.withMessage("Argument conflict: either shell or args should be specified and only in one form."); | ||
} | ||
|
||
@Test | ||
void equalsAndHashCodeShouldMatch() { | ||
// Given | ||
Arguments a1 = Arguments.builder().shell("sleep 10").build(); | ||
Arguments a2 = Arguments.builder().shell("sleep 10").build(); | ||
// When + Then | ||
assertThat(a1) | ||
.isEqualTo(a2) | ||
.hasSameHashCodeAs(a2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
...it/config/image/src/test/java/org/eclipse/jkube/kit/config/image/build/ArgumentsTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...esource/src/main/java/org/eclipse/jkube/kit/config/resource/ControllerResourceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.config.resource; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Singular; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Builder(toBuilder = true) | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
@EqualsAndHashCode | ||
public class ControllerResourceConfig { | ||
private Map<String, String> env; | ||
@Singular | ||
private List<VolumeConfig> volumes; | ||
@Singular | ||
private List<InitContainerConfig> initContainers; | ||
private String controllerName; | ||
private ProbeConfig liveness; | ||
private ProbeConfig readiness; | ||
private ProbeConfig startup; | ||
private boolean containerPrivileged; | ||
private String imagePullPolicy; | ||
private Integer replicas; | ||
private String restartPolicy; | ||
} |
38 changes: 38 additions & 0 deletions
38
...fig/resource/src/main/java/org/eclipse/jkube/kit/config/resource/InitContainerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.config.resource; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.eclipse.jkube.kit.common.Arguments; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Builder(toBuilder = true) | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
@EqualsAndHashCode | ||
public class InitContainerConfig { | ||
private Map<String, String> env; | ||
private String name; | ||
private String imageName; | ||
private String imagePullPolicy; | ||
private Arguments cmd; | ||
private List<VolumeConfig> volumes; | ||
} |
Oops, something went wrong.