Skip to content

Commit

Permalink
squashing 2 commits
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarranzan committed Dec 20, 2023
1 parent 3b700ed commit ba28293
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/badges/branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .github/badges/jacoco.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .github/workflows/daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ jobs:
- name: Archive Coverage Report
uses: actions/upload-artifact@v4
with:
name: ci-coverage
name: ci-coverage${{ matrix.java }}
path: coverage-report/target/site/jacoco
retention-days: 1
linux-build-native:
Expand Down
2 changes: 1 addition & 1 deletion examples/amq-tcp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<dependency>
<groupId>io.quarkiverse.artemis</groupId>
<artifactId>quarkus-artemis-jms</artifactId>
<version>3.1.2</version>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</scm>
<url>https://github.com/quarkus-qe/quarkus-test-framework/</url>
<properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<compiler-plugin.version>3.12.0</compiler-plugin.version>
<source-plugin.version>3.3.0</source-plugin.version>
<javadoc-plugin.version>3.6.3</javadoc-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

public final class PropertiesUtils {

public static final String DESTINATION_TO_FILENAME_SEPARATOR = "|";
public static final String RESOURCE_PREFIX = "resource::/";
public static final String RESOURCE_WITH_DESTINATION_PREFIX = "resource_with_destination::";
public static final String SECRET_WITH_DESTINATION_PREFIX = "secret_with_destination::";
public static final String RESOURCE_WITH_DESTINATION_SPLIT_CHAR = "\\|";
public static final String RESOURCE_WITH_DESTINATION_PREFIX_MATCHER = ".*" + RESOURCE_WITH_DESTINATION_SPLIT_CHAR + ".*";
public static final String SECRET_PREFIX = "secret::/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import static io.quarkus.test.utils.AwaitilityUtils.AwaitilitySettings;
import static io.quarkus.test.utils.AwaitilityUtils.untilIsNotNull;
import static io.quarkus.test.utils.AwaitilityUtils.untilIsTrue;
import static io.quarkus.test.utils.PropertiesUtils.DESTINATION_TO_FILENAME_SEPARATOR;
import static io.quarkus.test.utils.PropertiesUtils.RESOURCE_PREFIX;
import static io.quarkus.test.utils.PropertiesUtils.RESOURCE_WITH_DESTINATION_PREFIX;
import static io.quarkus.test.utils.PropertiesUtils.RESOURCE_WITH_DESTINATION_PREFIX_MATCHER;
import static io.quarkus.test.utils.PropertiesUtils.RESOURCE_WITH_DESTINATION_SPLIT_CHAR;
import static io.quarkus.test.utils.PropertiesUtils.SECRET_PREFIX;
import static io.quarkus.test.utils.PropertiesUtils.SECRET_WITH_DESTINATION_PREFIX;
import static io.quarkus.test.utils.PropertiesUtils.SLASH;
import static io.quarkus.test.utils.PropertiesUtils.TARGET;
import static org.junit.jupiter.api.Assertions.fail;
Expand Down Expand Up @@ -845,7 +847,7 @@ private Map<String, String> enrichProperties(Map<String, String> properties, Dep
String path = entry.getValue().replace(RESOURCE_PREFIX, StringUtils.EMPTY);
String mountPath = getMountPath(path);
String filename = getFileName(path);
String configMapName = normalizeConfigMapName(mountPath);
String configMapName = normalizeConfigMapName(mountPath, filename);

// Update config map
createOrUpdateConfigMap(configMapName, filename, getFileContent(path));
Expand All @@ -855,7 +857,7 @@ private Map<String, String> enrichProperties(Map<String, String> properties, Dep
volumes.put(mountPath, new CustomVolume(configMapName, "", CONFIG_MAP));
}

propertyValue = mountPath + SLASH + filename;
propertyValue = joinMountPathAndFileName(mountPath, filename);
} else if (isResourceWithDestinationPath(propertyValue)) {
String path = propertyValue.replace(RESOURCE_WITH_DESTINATION_PREFIX, StringUtils.EMPTY);
if (!propertyValue.matches(RESOURCE_WITH_DESTINATION_PREFIX_MATCHER)) {
Expand All @@ -867,26 +869,37 @@ private Map<String, String> enrichProperties(Map<String, String> properties, Dep
String mountPath = path.split(RESOURCE_WITH_DESTINATION_SPLIT_CHAR)[0];
String fileName = path.split(RESOURCE_WITH_DESTINATION_SPLIT_CHAR)[1];
String fileNameNormalized = getFileName(fileName);
String configMapName = normalizeConfigMapName(mountPath);
String configMapName = normalizeConfigMapName(mountPath, fileNameNormalized);

// Update config map
createOrUpdateConfigMap(configMapName, fileNameNormalized, getFileContent(fileName));
propertyValue = mountPath + SLASH + fileNameNormalized;
propertyValue = joinMountPathAndFileName(mountPath, fileNameNormalized);
// Add the volume
if (!volumes.containsKey(mountPath)) {
if (!volumes.containsKey(propertyValue)) {
volumes.put(propertyValue, new CustomVolume(configMapName, fileNameNormalized, CONFIG_MAP));
}
} else if (propertyValue.startsWith(SECRET_WITH_DESTINATION_PREFIX)) {
String path = entry.getValue().replace(SECRET_WITH_DESTINATION_PREFIX, StringUtils.EMPTY);
int separatorIdx = path.indexOf(DESTINATION_TO_FILENAME_SEPARATOR);
final String mountPath = path.substring(0, separatorIdx);
final String filename = getFileName(path.substring(separatorIdx + 1));
final String secretName = normalizeConfigMapName(mountPath, filename);

// Push secret file
doCreateSecretFromFile(secretName, getFilePath(SLASH + filename));
propertyValue = joinMountPathAndFileName(mountPath, filename);
volumes.putIfAbsent(mountPath, new CustomVolume(secretName, "", SECRET));
} else if (isSecret(propertyValue)) {
String path = entry.getValue().replace(SECRET_PREFIX, StringUtils.EMPTY);
String mountPath = getMountPath(path);
String filename = getFileName(path);
String secretName = normalizeConfigMapName(path);
String secretName = normalizeConfigMapName(mountPath, filename);

// Push secret file
doCreateSecretFromFile(secretName, getFilePath(path));
volumes.put(mountPath, new CustomVolume(secretName, "", SECRET));

propertyValue = mountPath + SLASH + filename;
propertyValue = joinMountPathAndFileName(mountPath, filename);
}

output.put(entry.getKey(), propertyValue);
Expand Down Expand Up @@ -975,12 +988,21 @@ private String getFilePath(String path) {
return path;
}

private String normalizeConfigMapName(String name) {
return StringUtils.removeStart(name, SLASH)
private String normalizeConfigMapName(String mountPath, String fileName) {
// /some/mount/path/file-name => some-mount-path-file-name
return StringUtils.removeStart(joinMountPathAndFileName(mountPath, fileName), SLASH)
.replaceAll(Pattern.quote("."), "-")
.replaceAll(SLASH, "-");
}

private static String joinMountPathAndFileName(String mountPath, String fileName) {
if (!mountPath.endsWith(SLASH)) {
// /some/mount/path => /some/mount/path/
mountPath += SLASH;
}
return mountPath + fileName;
}

private boolean isResourceWithDestinationPath(String key) {
return key.startsWith(RESOURCE_WITH_DESTINATION_PREFIX);
}
Expand Down

0 comments on commit ba28293

Please sign in to comment.