-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[issue 123] - Implement WildFly/EAP 8 Helm Charts provisioning differ…
…entiation
- Loading branch information
Showing
17 changed files
with
14,464 additions
and
107 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
22 changes: 22 additions & 0 deletions
22
...c/test/resources/org/jboss/intersmash/testsuite/provision/openshift/eap8-helm-values.yaml
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,22 @@ | ||
build: | ||
enabled: true | ||
mode: "s2i" | ||
# uri and ref will be specified via Helm --set arguments | ||
contextDir: "deployments/openshift-jakarta-sample-standalone" | ||
env: | ||
- name: "MAVEN_ARGS_APPEND" | ||
value: "-Denforcer.skip=true -Pwildfly-deployments-build.eap" | ||
s2i: | ||
kind: "DockerImage" | ||
buildApplicationImage: true | ||
# builderImage and runtimeImage will be specified via Helm --set arguments | ||
deploy: | ||
enabled: true | ||
replicas: 1 | ||
env: [] | ||
envFrom: [] | ||
volumeMounts: [] | ||
volumes: [] | ||
initContainers: [] | ||
extraContainers: [] | ||
'imagePullSecrets:': [] |
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
86 changes: 86 additions & 0 deletions
86
...ners/src/main/java/org/jboss/intersmash/tools/provision/helm/HelmChartReleaseAdapter.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,86 @@ | ||
package org.jboss.intersmash.tools.provision.helm; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.jboss.intersmash.tools.application.openshift.helm.SerializableHelmChartRelease; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; | ||
|
||
import lombok.NonNull; | ||
|
||
/** | ||
* An adapter that implements a valid {@link org.jboss.intersmash.tools.application.openshift.helm.HelmChartRelease} by exposing an internal generic instance of a POJO | ||
* that represents the release data and that can be serialized to a values file, as an output for | ||
* {@link org.jboss.intersmash.tools.application.openshift.helm.HelmChartRelease#toValuesFile()} | ||
*/ | ||
public class HelmChartReleaseAdapter<A extends Object> implements SerializableHelmChartRelease { | ||
|
||
protected final A adaptee; | ||
protected final List<Path> additionalValuesFiles; | ||
|
||
public HelmChartReleaseAdapter(@NonNull A release) { | ||
this(release, new ArrayList<>()); | ||
} | ||
|
||
public HelmChartReleaseAdapter(@NonNull A release, List<Path> additionalValuesFiles) { | ||
this.adaptee = release; | ||
this.additionalValuesFiles = additionalValuesFiles; | ||
} | ||
|
||
public A getAdaptee() { | ||
return adaptee; | ||
} | ||
|
||
@Override | ||
public Path toValuesFile() { | ||
// Handle the values file creation | ||
Path temp; | ||
try { | ||
temp = Files.createTempFile("values", ".yaml"); | ||
} catch (IOException e) { | ||
throw new IllegalStateException("Temporary Helm Chart values file creation failed.", e); | ||
} | ||
ObjectMapper mapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)); | ||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
try { | ||
mapper.writeValue(temp.toFile(), adaptee); | ||
} catch (IOException e) { | ||
throw new IllegalStateException("Helm Chart values serialization failed.", e); | ||
} | ||
return temp; | ||
} | ||
|
||
/** | ||
* Implementors must generate the POJO by deserializing the data at each call and reflect the information held by | ||
* the concrete instance | ||
* @param valuesFileUrl Source values file URL | ||
* @param typeClazz Deserialized POJO type | ||
* @return A concrete instance of {@link A} generated from a source values file | ||
*/ | ||
public A fromValuesFile(final URL valuesFileUrl, Class<A> typeClazz) { | ||
if (valuesFileUrl == null) { | ||
throw new IllegalStateException("No values file provided!"); | ||
} | ||
try { | ||
Path valuePath = Path.of(valuesFileUrl.toURI()); | ||
ObjectMapper mapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)); | ||
return mapper.readValue(valuePath.toFile(), typeClazz); | ||
} catch (Error | RuntimeException e) { | ||
throw e; | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public List<Path> getAdditionalValuesFiles() { | ||
return additionalValuesFiles; | ||
} | ||
} |
Oops, something went wrong.