From 607f20833822d0960f224a87fed501f2a294f327 Mon Sep 17 00:00:00 2001 From: Jean Francois Denise Date: Tue, 14 May 2024 11:49:56 +0200 Subject: [PATCH] Fix for Issue #72, Provisioning to OpenShift fails when using Microprofile GraphQL layer --- .../openshift/api/OpenShiftSupport.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/openshift-deployment/api/src/main/java/org/wildfly/glow/deployment/openshift/api/OpenShiftSupport.java b/openshift-deployment/api/src/main/java/org/wildfly/glow/deployment/openshift/api/OpenShiftSupport.java index a8e5f2c7..2b4280e8 100644 --- a/openshift-deployment/api/src/main/java/org/wildfly/glow/deployment/openshift/api/OpenShiftSupport.java +++ b/openshift-deployment/api/src/main/java/org/wildfly/glow/deployment/openshift/api/OpenShiftSupport.java @@ -325,11 +325,14 @@ static final String generateValidName(String name) { } } } - String ret = validName.toString(); - if (ret.length() > 63) { - ret = ret.substring(0, 63); + return truncateValue(validName.toString()); + } + + private static String truncateValue(String val) { + if (val.length() > 63) { + val = val.substring(0, 63); } - return ret; + return val; } public static void deploy(List deployments, @@ -511,7 +514,7 @@ private static String bytesToHex(byte[] hash) { private static Map createCommonLabels(OpenShiftConfiguration osConfig) throws Exception { Map labels = new HashMap<>(); - labels.put(osConfig.getLabelRadical(), ""); + labels.put(truncateValue(osConfig.getLabelRadical()), ""); return labels; } @@ -526,10 +529,10 @@ private static Map createServerImageLabels(Path target, Path pro GalleonProvisioningConfig config = provider.newProvisioningBuilder(provisioning).setInstallationHome(dir).build().loadProvisioningConfig(provisioning); GalleonConfigurationWithLayers cl = config.getDefinedConfig(new ConfigId("standalone", "standalone.xml")); for (String s : cl.getIncludedLayers()) { - labels.put(osConfig.getLabelRadical() + ".layer." + s, ""); + labels.put(truncateValue(osConfig.getLabelRadical() + ".layer." + s), ""); } for (String s : cl.getExcludedLayers()) { - labels.put(osConfig.getLabelRadical() + ".excluded.layer." + s, ""); + labels.put(truncateValue(osConfig.getLabelRadical() + ".excluded.layer." + s), ""); } for (GalleonFeaturePackConfig gfpc : config.getFeaturePackDeps()) { if (fps.length() != 0) { @@ -542,12 +545,12 @@ private static Map createServerImageLabels(Path target, Path pro producerName = producerName.substring(i + 1); } producerName = producerName.replaceAll(":", "-"); - labels.put(osConfig.getLabelRadical() + ".feature-pack." + producerName, gfpc.getLocation().getBuild()); + labels.put(truncateValue(osConfig.getLabelRadical() + producerName), gfpc.getLocation().getBuild()); } } for (Entry entry : serverImageBuildLabels.entrySet()) { - labels.put(entry.getKey(), entry.getValue()); + labels.put(truncateValue(entry.getKey()), truncateValue(entry.getValue())); } labels.putAll(createCommonLabels(osConfig)); return labels;