From cf94a008a7cf0abac880c46c5611e58026b9048a Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Fri, 10 Sep 2021 12:49:04 +0200 Subject: [PATCH] add script --- service.deps | 959 ++++++++++++++++++++++++++++++++++++++++++ validateplatform.java | 155 +++++++ 2 files changed, 1114 insertions(+) create mode 100644 service.deps create mode 100755 validateplatform.java diff --git a/service.deps b/service.deps new file mode 100644 index 0000000000..55e66b5eea --- /dev/null +++ b/service.deps @@ -0,0 +1,959 @@ +io.quarkus:quarkus-arc:2.1.0.Final-redhat-00004 +io.quarkus:quarkus-junit5-mockito:2.1.0.Final-redhat-00004 +io.quarkus:quarkus-junit5:2.1.0.Final-redhat-00004 +io.quarkus:quarkus-kubernetes-client:2.1.0.Final-redhat-00004 +io.quarkus:quarkus-maven-plugin:2.1.0.Final-redhat-00004 +io.quarkus:quarkus-picocli:2.1.0.Final-redhat-00004 +io.quarkus:quarkus-resteasy-jackson:2.1.0.Final-redhat-00004 +io.quarkus:quarkus-resteasy:2.1.0.Final-redhat-00004 +io.quarkus.platform:quarkus-bom:pom:2.1.0.Final-redhat-00004 +io.fabric8:openshift-model-operatorhub +io.quarkus:quarkus-universe-bom +io.quarkus:quarkus-kubernetes-client +io.quarkus:quarkus-junit5-mockito +io.quarkiverse.operatorsdk:quarkus-operator-sdk +io.quarkus:quarkus-kubernetes +io.quarkus:quarkus-kubernetes-client +io.quarkus:quarkus-arc +io.quarkus:quarkus-micrometer-registry-prometheus +io.quarkus:quarkus-scheduler:jar +io.quarkus:quarkus-kubernetes-config +io.quarkus:quarkus-junit5 +io.quarkus:quarkus-junit5-mockito +io.quarkus:quarkus-test-kubernetes-client +io.quarkus:quarkus-maven-plugin +io.quarkus:quarkus-container-image-jib +io.quarkus:quarkus-kubernetes:jar +io.quarkus:quarkus-kubernetes-client +io.quarkus:quarkus-arc:jar +io.quarkus:quarkus-rest-client +io.quarkus:quarkus-scheduler +io.quarkus:quarkus-smallrye-health +io.quarkus:quarkus-oidc-client-filter +io.quarkus:quarkus-kubernetes-config +io.quarkus:quarkus-micrometer-registry-prometheus +io.quarkus:quarkus-junit5 +io.quarkus:quarkus-junit5-mockito +io.quarkus:quarkus-test-kubernetes-client +io.quarkus:quarkus-maven-plugin +io.quarkus:quarkus-container-image-docker +io.quarkus:quarkus-resteasy +io.quarkus:quarkus-quartz +io.quarkus:quarkus-resteasy-jackson +io.quarkus:quarkus-arc +io.quarkus:quarkus-hibernate-orm-panache +io.quarkus:quarkus-jdbc-postgresql +io.quarkus:quarkus-jdbc-h2 +io.quarkus:quarkus-smallrye-health +io.quarkus:quarkus-micrometer-registry-prometheus +io.quarkus:quarkus-hibernate-validator +io.quarkus:quarkus-flyway +io.quarkus:quarkus-oidc +io.quarkus:quarkus-maven-plugin +io.quarkus:quarkus-junit5 +io.quarkus:quarkus-undertow +io.quarkus:quarkus-jackson +io.quarkus:quarkus-resteasy-jackson +io.quarkus:quarkus-smallrye-health +io.quarkus:quarkus-micrometer-registry-prometheus +io.quarkus:quarkus-vertx +io.quarkus:quarkus-oidc +io.quarkus:quarkus-scheduler +io.quarkus:quarkus-kotlin +io.quarkus:quarkus-smallrye-context-propagation +io.quarkus:quarkus-jdbc-h2 +io.quarkus:quarkus-junit5 +io.quarkus:quarkus-test-common +io.quarkus:quarkus-hibernate-orm +io.quarkus:quarkus-hibernate-validator +io.quarkus:quarkus-resteasy +io.quarkus:quarkus-hibernate-orm-panache +io.quarkus:quarkus-resteasy-jackson +io.quarkus:quarkus-smallrye-health +io.quarkus:quarkus-micrometer-registry-prometheus +io.quarkus:quarkus-jdbc-postgresql +io.quarkus:quarkus-jdbc-h2 +io.quarkus:quarkus-arc +io.quarkus:quarkus-oidc +io.quarkus:quarkus-flyway +io.quarkus:quarkus-junit5 +io.quarkus:quarkus-test-h2 +io.quarkiverse.operatorsdk:quarkus-operator-sdk +io.quarkus:quarkus-kubernetes +io.quarkus:quarkus-kubernetes-client +io.quarkus:quarkus-arc +io.quarkus:quarkus-kubernetes-config +io.quarkus:quarkus-junit5 +io.quarkus:quarkus-junit5-mockito +io.quarkus:quarkus-smallrye-jwt-build +io.quarkus:quarkus-smallrye-jwt +io.quarkus:quarkus-maven-plugin +io.fabric8:kubernetes-client +io.fabric8:kubernetes-server-mock +io.fabric8:mockwebserver +io.quarkus.arc:arc +io.quarkus:quarkus-apache-httpclient +io.quarkus:quarkus-arc +io.quarkus:quarkus-bootstrap-app-model +io.quarkus:quarkus-bootstrap-core +io.quarkus:quarkus-bootstrap-gradle-resolver +io.quarkus:quarkus-bootstrap-maven-resolver +io.quarkus:quarkus-bootstrap-runner +io.quarkus:quarkus-builder +io.quarkus:quarkus-class-change-agent +io.quarkus:quarkus-container-image +io.quarkus:quarkus-container-image-jib +io.quarkus:quarkus-core-deployment +io.quarkus:quarkus-core +io.quarkus:quarkus-credentials +io.quarkus:quarkus-development-mode-spi +io.quarkus:quarkus-devtools-utilities +io.quarkus:quarkus-ide-launcher +io.quarkus:quarkus-jackson +io.quarkus:quarkus-jsonp-deployment +io.quarkus:quarkus-jsonp +io.quarkus:quarkus-kubernetes-client-internal +io.quarkus:quarkus-kubernetes-client +io.quarkus:quarkus-kubernetes +io.quarkus:quarkus-micrometer +io.quarkus:quarkus-micrometer-registry-prometheus +io.quarkus:quarkus-mutiny +io.quarkus:quarkus-netty +io.quarkus:quarkus-oidc-client-filter +io.quarkus:quarkus-oidc-client +io.quarkus:quarkus-oidc-common +io.quarkus:quarkus-openshift-client +io.quarkus:quarkus-rest-client-jackson +io.quarkus:quarkus-rest-client +io.quarkus:quarkus-resteasy-common +io.quarkus:quarkus-resteasy-jackson +io.quarkus:quarkus-resteasy +io.quarkus:quarkus-resteasy-server-common +io.quarkus:quarkus-scheduler +io.quarkus:quarkus-security-runtime-spi +io.quarkus:quarkus-smallrye-context-propagation +io.quarkus:quarkus-smallrye-health +io.quarkus:quarkus-smallrye-jwt-build +io.quarkus:quarkus-vertx-core +io.quarkus:quarkus-vertx-http-dev-console-runtime-spi +io.quarkus:quarkus-vertx-http +io.quarkus.gizmo:gizmo +io.quarkus.security:quarkus-security +io.quarkiverse.operatorsdk:quarkus-operator-sdk:jar:2.0.0.Beta4 +io.quarkus:quarkus-test-common +io.quarkus:quarkus-test-kubernetes-client +io.quarkus:quarkus-junit5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/validateplatform.java b/validateplatform.java new file mode 100755 index 0000000000..3a8151c2ea --- /dev/null +++ b/validateplatform.java @@ -0,0 +1,155 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? +//DEPS info.picocli:picocli:4.5.0 +//DEPS io.quarkus:quarkus-devtools-registry-client:2.2.0.CR1 + +//DESCRIPTION quick hack to validate platform descriptors +//DESCRIPTION Make sure platform have been built then run: +//DESCRIPTION if you have a file with list of dependences to check if supported or not run: +//DESCRIPTION ./validateplatform.java --deps service.deps `find generated-platform-project -name "*descriptor*.json"` +//DESCRIPTION to get a report of extensions where product is supported but extension in community non-stable +//DESCRIPTION ./validateplatform.java kafka.deps `find generated-platform-project -name "*descriptor*.json"` +//DESCRIPTION output is tab separated; I use visidata to easily browse it. + +import io.quarkus.maven.ArtifactCoords; +import io.quarkus.registry.catalog.Extension; +import io.quarkus.registry.catalog.ExtensionCatalog; +import io.quarkus.registry.catalog.ExtensionOrigin; +import io.quarkus.registry.catalog.json.JsonCatalogMapperHelper; +import io.quarkus.registry.catalog.json.JsonCatalogMerger; +import io.quarkus.registry.catalog.json.JsonExtensionCatalog; +import picocli.CommandLine; +import picocli.CommandLine.Command; +import picocli.CommandLine.Parameters; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static java.util.stream.Collectors.toList; + +@Command(name = "validateplatform", mixinStandardHelpOptions = true, version = "validateplatform 0.1", + description = "validateplatform made with jbang") +class validateplatform implements Callable { + + @Parameters(arity = "1..N", description = "the descriptors to read", defaultValue = "") + private Set descriptors; + + @CommandLine.Option(names = "--deps", description = "file with List of GAV/dependencies to validate against the platform") + Path deps; + + public static void main(String... args) { + int exitCode = new CommandLine(new validateplatform()).execute(args); + System.exit(exitCode); + } + + static class Validation { + String kind; + Extension ext; + List origins; + + public String getKind() { + return kind; + } + + public Validation(String missing_status, Extension ext, List origins) { + this.kind = missing_status; + this.ext = ext; + this.origins = origins; + } + + @Override + public String toString() { + return kind + + "\t" + ext.getArtifact().getGroupId() + + "\t" + ext.getArtifact().getArtifactId() + + "\t" + ext.getArtifact().getVersion() + + "\t" + ext.getMetadata().get("status") + + "\t" + ext.getMetadata().get("redhat-support") + + "\t" + origins; + + } + } + + @Override + public Integer call() throws Exception { // your business logic goes here... + // URI u = new URI("https://repo1.maven.org/maven2/io/quarkus/quarkus-universe-bom-quarkus-platform-descriptor/2.2.0.CR1/quarkus-universe-bom-quarkus-platform-descriptor-2.2.0.CR1-2.2.0.CR1.json"); + + List catalogs = new ArrayList<>(); + + for (String path : descriptors) { + JsonExtensionCatalog catalog = null; + catalog = JsonCatalogMapperHelper.deserialize(Path.of(path), JsonExtensionCatalog.class); + catalogs.add(catalog); + } + + var mergedCatalog = JsonCatalogMerger.merge(catalogs); + + if(deps==null) { + var validations = validate(mergedCatalog); + validations.stream().forEach(System.out::println); + } else{ + var dependencies = Files.readAllLines(deps).stream().filter(s -> !s.isBlank()).collect(toList()); + + dependencies = dependencies.stream().distinct().collect(toList()); + + Pattern p = Pattern.compile("^(?[^:]*):(?[^:]*)(:(?[^:@]*))?(:(?[^@]*))?(@(?.*))?$"); + + System.out.println("dependency\tmatch in platform\tredhat-support\tstatus"); + for (String dep : + dependencies) { + + Matcher matcher = p.matcher(dep); + + var lists = List.of(); + if(matcher.find()) { + String g = matcher.group("groupid"); + String a = matcher.group("artifactid"); + + var matchingExtensions = mergedCatalog.getExtensions().stream().filter(ext -> a.equals(ext.getArtifact().getArtifactId()) && g.equals(ext.getArtifact().getGroupId())).collect(toList()); + if(matchingExtensions.isEmpty()) { + System.out.println(dep + "\tNO MATCH\tnot an extension ?"); + } else { + System.out.println(dep + "\t " + matchingExtensions + + "\t" + matchingExtensions.stream().findFirst().map(e -> + { + var redhat = Optional.ofNullable(e.getMetadata().get("redhat-support")); + var status = Optional.ofNullable(e.getMetadata().get("status")); + return redhat.orElse("") + "\t" + status.orElse("stable?"); + } + ).get()); + } + } else { + System.out.println("Could not recognize " + dep); + } + } + } + return 0; + } + + private List validate(ExtensionCatalog mergedCatalog) { + List validations = new ArrayList<>(); + var extensions = mergedCatalog.getExtensions(); + for (Extension ext : extensions) { + var redhat = ext.getMetadata().get("redhat-support"); + var status = ext.getMetadata().get("status"); + + if (redhat != null) { + // System.out.println(redhat + " <-> " + status); + if (redhat instanceof Collection) { + if (((Collection) redhat).contains("supported") && !(status == null || status.equals("stable"))) { + validations.add(new Validation("Product supported but not stable", ext, ext.getOrigins())); + } + } + } + } + return validations; + } +}