File tree Expand file tree Collapse file tree
helm-wrapper/src/main/java/io/github/inseefrlab/helmwrapper/service
onyxia-api/src/main/java/fr/insee/onyxia/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ public class HelmInstallService {
2828 private static final Logger LOGGER = LoggerFactory .getLogger (HelmInstallService .class );
2929 private final Pattern helmNamePattern =
3030 Pattern .compile ("^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\ .[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$" );
31+ private final Pattern semverPattern =
32+ Pattern .compile (
33+ "^(0|[1-9]\\ d*)\\ .(0|[1-9]\\ d*)\\ .(0|[1-9]\\ d*)(?:-((?:0|[1-9]\\ d*|\\ d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\ .(?:0|[1-9]\\ d*|\\ d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\ +([0-9a-zA-Z-]+(?:\\ .[0-9a-zA-Z-]+)*))?$" );
3134
3235 private final HelmReleaseInfoParser helmReleaseInfoParser = new HelmReleaseInfoParser ();
3336 private static final String VALUES_INFO_TYPE = "values" ;
@@ -173,6 +176,10 @@ public HelmInstaller installChart(
173176 command .append ("-n " );
174177 safeConcat (command , namespace );
175178 if (StringUtils .isNotBlank (version )) {
179+ if (!semverPattern .matcher (version ).matches ()) {
180+ throw new IllegalArgumentException (
181+ "Invalid release version " + version + ", must be a SemVer 2 string" );
182+ }
176183 command .append (" --version " );
177184 safeConcat (command , version );
178185 }
Original file line number Diff line number Diff line change @@ -524,7 +524,8 @@ private Collection<Object> publishApps(
524524
525525 Pkg pkg =
526526 catalog .getCatalog ()
527- .getPackageByName (requestDTO .getPackageName ())
527+ .getPackageByNameAndVersion (
528+ requestDTO .getPackageName (), requestDTO .getPackageVersion ())
528529 .orElseThrow (NotFoundException ::new );
529530
530531 Map <String , Object > fusion = new HashMap <>();
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ public Collection<Object> installApp(
119119 catalogId + "/" + pkg .getName (),
120120 namespaceId ,
121121 requestDTO .getName (),
122- requestDTO . getPackageVersion (),
122+ pkg . getVersion (),
123123 requestDTO .isDryRun (),
124124 values ,
125125 null ,
You can’t perform that action at this time.
0 commit comments