io.fabric8.utils.Strings Java Examples

The following examples show how to use io.fabric8.utils.Strings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServicesList.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
private void printServices(ServiceList services, PrintStream out) {
    TablePrinter table = new TablePrinter();
    table.columns("id", "labels", "selector", "port");
    List<Service> items = services.getItems();
    if (items == null) {
        items = Collections.EMPTY_LIST;
    }
    Filter<Service> filter = KubernetesHelper.createServiceFilter(filterText.getValue());
    for (Service service : items) {
        if (filter.matches(service)) {
            String labels = KubernetesHelper.toLabelsString(service.getMetadata().getLabels());
            String selector = KubernetesHelper.toLabelsString(getSelector(service));
            Set<Integer> ports = getPorts(service);
            List<Integer> portList = new ArrayList<>(ports);
            String portText;
            if (portList.size() == 1) {
                portText = portList.get(0).toString();

            } else {
                portText = Strings.join(portList, ", ");
            }
            table.row(KubernetesHelper.getName(service), labels, selector, portText);
        }
    }
    table.print();
}
 
Example #2
Source File: PullRequestCommentReadWriteTest.java    From updatebot with Apache License 2.0 6 votes vote down vote up
@Test
public void testSingleUpdate() throws Exception {
    String dependency = "cheese";
    String version = "1.2.3";

    PushVersionChanges command = new PushVersionChanges(NPM, dependency, version);
    parentContext.updateVersion(NPM, dependency, version);
    assertContextCommandComment(command,
            COMMAND_COMMENT_INDENT + Strings.join(" ", PUSH_VERSION, "--kind", NPM, dependency, version));


    String comment = command.createPullRequestComment();
    CompositeCommand parsedCommands = parseCommandComment(comment, 1);
    PushVersionChanges parsedUpdateVersion = CommandAssertions.assertChildIsPushVersionChanges(parsedCommands, 0);
    CommandAssertions.assertPushVersionContext(parsedUpdateVersion, NPM, dependency, version);
}
 
Example #3
Source File: PullRequestCommentReadWriteTest.java    From updatebot with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoUpdates() throws Exception {
    String dependency1 = "beer";
    String version1 = "2.3.4";

    String dependency2 = "wine";
    String version2 = "4.5.6";

    PushVersionChanges command = new PushVersionChanges(NPM, dependency1, version1, dependency2, version2);

    assertContextCommandComment(command,
            COMMAND_COMMENT_INDENT + Strings.join(" ", PUSH_VERSION, "--kind", NPM, dependency1, version1, dependency2, version2));

    String comment = command.createPullRequestComment();
    CompositeCommand parsedCommands = parseCommandComment(comment, 1);
    PushVersionChanges parsedUpdateVersion1 = CommandAssertions.assertChildIsPushVersionChanges(parsedCommands, 0);
    CommandAssertions.assertPushVersionContext(parsedUpdateVersion1, NPM, dependency1, version1, dependency2, version2);
}
 
Example #4
Source File: CreateEventStepExecution.java    From kubernetes-pipeline-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public String run() throws Exception {

    String json = step.getJson();
    String index = step.getIndex();

    if (Strings.isNullOrBlank(json)) {
        throw new AbortException("No JSON payload found");
    }
    // validate JSON structure
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.readTree(json);

    String id = ElasticsearchClient.createEvent(json, index, listener);
    if (Strings.isNullOrBlank(id)){
        throw new AbortException("Error creating event in elasticsearch");
    }

    return id;

}
 
Example #5
Source File: PomHelperTest.java    From updatebot with Apache License 2.0 6 votes vote down vote up
protected static void assertPluginVersionChanged(File file, Document doc, DependencyVersionChange change) {
    boolean found = false;
    List<Element> elements = findElementsWithName(doc.getRootElement(), "plugin");
    for (Element element : elements) {
        String groupId = firstChildTextContent(element, "groupId");
        String artifactId = firstChildTextContent(element, "artifactId");
        String version = firstChildTextContent(element, "version");
        if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
            if (change.matches(groupId, artifactId)) {
                found = true;
                if (!version.startsWith("$")) {
                    LOG.info("File " + file + " has plugin " + change.getDependency() + " version: " + version);
                    assertThat(version).describedAs("File " + file + " plugin version for " + change.getDependency()).isEqualTo(change.getVersion());
                }
            }
        }
    }
    assertThat(found).describedAs("File " + file + " does not have plugin " +
            change.getDependency() + " version: " + change.getVersion()).isTrue();
}
 
Example #6
Source File: PomHelperTest.java    From updatebot with Apache License 2.0 6 votes vote down vote up
protected static void assertDependencyVersionChanged(File file, Document doc, DependencyVersionChange change) {
        boolean found = false;
        List<Element> elements = findElementsWithName(doc.getRootElement(), "dependency");
        for (Element element : elements) {
            String groupId = firstChildTextContent(element, "groupId");
            String artifactId = firstChildTextContent(element, "artifactId");
            String version = firstChildTextContent(element, "version");
            if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
                if (change.matches(groupId, artifactId)) {
                    found = true;
                    if (!version.startsWith("$")) {
                        LOG.info("File " + file + " has dependency " + change.getDependency() + " version: " + version);
                        assertThat(version).describedAs("File " + file + " dependency version for " + change.getDependency()).isEqualTo(change.getVersion());
                    }
                }
            }
        }
/*
        assertThat(found).describedAs("File " + file + " does not have dependency " +
                change.getDependency() + " version: " + change.getVersion()).isTrue();
*/
    }
 
Example #7
Source File: ApproveReceivedEventStepExecution.java    From kubernetes-pipeline-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public String run() throws Exception {

    if (step.getApproved() == null) {
        throw new AbortException("No Approved boolean set");
    }

    if (Strings.isNullOrBlank(step.getId())) {
        // if we dont have an id to update ignore the request as it's likely elasticsearch isn't running
        listener.getLogger().println("No approve event id found.  Skipping approval event update request");
        return OK;
    }
    ApprovalEventDTO approval = new ApprovalEventDTO();
    approval.setApproved(step.getApproved());
    approval.setReceivedTime(new Date());

    String json = mapper.writeValueAsString(approval);

    Boolean success = ElasticsearchClient.updateEvent(step.getId(), json, ElasticsearchClient.APPROVE, listener);
    if (!success){
        throw new AbortException("Error updating Approve event id ["+step.getId()+"]");
    }

    return OK;

}
 
Example #8
Source File: PopulateMavenRepositoryTest.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
protected List<String> getArchetypesFromJar(File archetypeJar) throws IOException {
    assertThat(archetypeJar).exists();
    JarFile jar = new JarFile(archetypeJar);
    String entryName = "archetype-catalog.xml";
    ZipEntry entry = jar.getEntry(entryName);
    assertThat(entry).describedAs("Missing entry " + entryName + " in jar " + archetypeJar).isNotNull();

    SortedSet<String> artifactIds = new TreeSet<>();
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(jar.getInputStream(entry));
        Document doc = builder.parse(is);
        NodeList artifactTags = doc.getElementsByTagName("artifactId");
        for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
            Node element = artifactTags.item(i);
            String artifactId = element.getTextContent();
            if (Strings.isNotBlank(artifactId)) {
                artifactIds.add(artifactId);
            }
        }
    } catch (Exception e) {
        fail("Failed to parse " + entryName + " in jar " + archetypeJar + ". Exception " + e, e);
    }
    return new ArrayList<>(artifactIds);
}
 
Example #9
Source File: ApproveRequestedEventStepExecution.java    From kubernetes-pipeline-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public String run() throws Exception {

    if (Strings.isNullOrBlank(step.getApp())) {
        throw new AbortException("No App name provided");
    }

    if (Strings.isNullOrBlank(step.getEnvironment())) {
        throw new AbortException("No environment name provided");
    }
    ApprovalEventDTO approval = new ApprovalEventDTO();
    approval.setApp(step.getApp());
    approval.setEnvironment(step.getEnvironment());
    approval.setRequestedTime(new Date());

    String json = mapper.writeValueAsString(approval);

    return ElasticsearchClient.createEvent(json, ElasticsearchClient.APPROVE, listener);

}
 
Example #10
Source File: CatalogBuilder.java    From ipaas-quickstarts with Apache License 2.0 6 votes vote down vote up
protected Set<String> loadArchetypesPomArtifactIds(File archetypesPomFile) throws IOException {
    Set<String> answer = new TreeSet<>();
    if (!archetypesPomFile.isFile() || !archetypesPomFile.exists()) {
        LOG.warn("archetypes pom.xml file does not exist!: " + archetypesPomFile);
        return null;

    }
    try {
        Document doc = archetypeUtils.parseXml(new InputSource(new FileReader(archetypesPomFile)));
        Element root = doc.getDocumentElement();

        // lets load all the properties defined in the <properties> element in the bom pom.
        NodeList moduleElements = root.getElementsByTagName("module");
        for (int i = 0, size = moduleElements.getLength(); i < size; i++) {
            Element moduleElement = (Element) moduleElements.item(i);
            String module = moduleElement.getTextContent();
            if (Strings.isNotBlank(module)) {
                answer.add(module);
            }
        }
        LOG.info("Loaded archetypes module names: "+ answer);
        return answer;
    } catch (FileNotFoundException e) {
        throw new IOException("Failed to parse " + archetypesPomFile + ". " + e, e);
    }
}
 
Example #11
Source File: CreateQuickstartProjectKT.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
protected List<String> getArchetypesFromJar() throws IOException {
    String entryName = "archetype-catalog.xml";
    URL url = getClass().getClassLoader().getResource(entryName);
    assertThat(url).describedAs("Could not find resource " + entryName + " on the classpath!").isNotNull();

    SortedSet<String> artifactIds = new TreeSet<>();
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(url.openStream());
        Document doc = builder.parse(is);
        NodeList artifactTags = doc.getElementsByTagName("artifactId");
        for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
            Node element = artifactTags.item(i);
            String artifactId = element.getTextContent();
            if (Strings.isNotBlank(artifactId)) {
                artifactIds.add(artifactId);
            }
        }
    } catch (Exception e) {
        fail("Failed to parse " + entryName + " in catalog " + url + ". Exception " + e, e);
    }
    return new ArrayList<>(artifactIds);
}
 
Example #12
Source File: UICommands.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
protected static String getResultMessage(Result result) {
    if (result instanceof CompositeResult) {
        CompositeResult compositeResult = (CompositeResult) result;
        List<Result> results = compositeResult.getResults();
        StringBuilder buffer = new StringBuilder();
        for (Result childResult : results) {
            String childResultMessage = getResultMessage(childResult);
            if (Strings.isNotBlank(childResultMessage)) {
                if (buffer.length() > 0) {
                    buffer.append("\n");
                }
                buffer.append(childResultMessage);
            }
        }
        return buffer.toString();
    } else if (result != null) {
        return result.getMessage();
    } else {
        return null;
    }
}
 
Example #13
Source File: CamelXmlHelper.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
private static String getIdOrIndex(Node node, Map<String, Integer> nodeCounts) {
    String answer = null;
    if (node instanceof Element) {
        Element element = (Element) node;
        String elementName = element.getTagName();
        if ("routes".equals(elementName)) {
            elementName = "camelContext";
        }
        Integer countObject = nodeCounts.get(elementName);
        int count = countObject != null ? countObject.intValue() : 0;
        nodeCounts.put(elementName, ++count);
        answer = element.getAttribute("id");
        if (Strings.isNullOrBlank(answer)) {
            answer = "_" + elementName + count;
        }
    }
    return answer;
}
 
Example #14
Source File: UICommands.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
/**
 * A name of the form "foo-bar-whatnot" is turned into "Foo: Bar Whatnot"
 */
public static String unshellifyName(String name) {
    if (Strings.isNotBlank(name)) {
        if (name.indexOf('-') >= 0 && name.toLowerCase().equals(name)) {
            String[] split = name.split("-");
            StringBuffer buffer = new StringBuffer();
            int idx = 0;
            for (String part : split) {
                if (idx == 1) {
                    buffer.append(": ");
                } else if (idx > 1) {
                    buffer.append(" ");
                }
                buffer.append(capitalize(part));
                idx++;
            }
            return buffer.toString();
        }
    }
    return name;
}
 
Example #15
Source File: CamelXmlHelper.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
protected static List<ContextDto> parseCamelContexts(CamelCatalog camelCatalog, File xmlFile) throws Exception {
    List<ContextDto> camelContexts = new ArrayList<>();

    RouteXml routeXml = new RouteXml();
    XmlModel xmlModel = routeXml.unmarshal(xmlFile);

    // TODO we don't handle multiple contexts inside an XML file!
    CamelContextFactoryBean contextElement = xmlModel.getContextElement();
    String name = contextElement.getId();
    List<RouteDefinition> routeDefs = contextElement.getRoutes();
    ContextDto context = new ContextDto(name);
    camelContexts.add(context);
    String key = name;
    if (Strings.isNullOrBlank(key)) {
        key = "_camelContext" + camelContexts.size();
    }
    context.setKey(key);
    List<NodeDto> routes = createRouteDtos(camelCatalog, routeDefs, context);
    context.setChildren(routes);
    return camelContexts;
}
 
Example #16
Source File: RepositoryResource.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
public CommitInfo createCommitInfo(RevCommit entry) {
    final Date date = GitUtils.getCommitDate(entry);
    PersonIdent authorIdent = entry.getAuthorIdent();
    String author = null;
    String name = null;
    String email = null;
    String avatarUrl = null;
    if (authorIdent != null) {
        author = authorIdent.getName();
        name = authorIdent.getName();
        email = authorIdent.getEmailAddress();

        // lets try default the avatar
        if (Strings.isNotBlank(email)) {
            avatarUrl = getAvatarUrl(email);
        }
    }
    boolean merge = entry.getParentCount() > 1;
    String shortMessage = entry.getShortMessage();
    String sha = entry.getName();
    return new CommitInfo(sha, author, name, email, avatarUrl, date, merge, shortMessage);
}
 
Example #17
Source File: RepositoryResource.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
protected void configureBranch(Git git, String branch) {
    // lets update the merge config
    if (Strings.isNotBlank(branch)) {
        StoredConfig config = git.getRepository().getConfig();
        if (Strings.isNullOrBlank(config.getString("branch", branch, "remote")) || Strings.isNullOrBlank(config.getString("branch", branch, "merge"))) {
            config.setString("branch", branch, "remote", getRemote());
            config.setString("branch", branch, "merge", "refs/heads/" + branch);
            try {
                config.save();
            } catch (IOException e) {
                LOG.error("Failed to save the git configuration to " + basedir
                        + " with branch " + branch + " on remote repo: " + remoteRepository + " due: " + e.getMessage() + ". This exception is ignored.", e);
            }
        }
    }
}
 
Example #18
Source File: ProjectFileSystem.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
public void asyncCloneOrPullJenkinsWorkflows(final UserDetails userDetails) {
    final File folder = getJenkinsfilesLibraryFolder();
    if (Strings.isNotBlank(jenkinsfileLibraryGitUrl)) {
        executorService.execute(new Runnable() {
            @Override
            public void run() {
                StopWatch watch = new StopWatch();
                try {
                    LOG.debug("Cloning or pulling jenkins workflow repo from " + jenkinsfileLibraryGitUrl + " to " + folder);
                    UserDetails anonymous = userDetails.createAnonymousDetails();
                    cloneOrPullRepo(anonymous, folder, jenkinsfileLibraryGitUrl, null, null);
                } catch (Exception e) {
                    LOG.error("Failed to clone jenkins workflow repo from : " + jenkinsfileLibraryGitUrl + ". " + e, e);
                } finally {
                    LOG.info("asyncCloneOrPullJenkinsWorkflows took " + watch.taken());
                }
            }
        });
    } else {
        LOG.warn("Cannot clone jenkins workflow repository as the environment variable JENKINSFILE_LIBRARY_GIT_REPOSITORY is not defined");
    }
}
 
Example #19
Source File: NodeDtoSupport.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
public void defaultKey(NodeDto owner, Map<String, Integer> nodeCounts) {
    String elementName = getPattern();
    Integer countObject = nodeCounts.get(elementName);
    int count = countObject != null ? countObject : 0;
    nodeCounts.put(elementName, ++count);
    if (Strings.isNullOrBlank(key)) {
        key = owner.getKey();
        if (Strings.isNullOrBlank(key)) {
            key = "";
        } else {
            key += "/";
        }
        if (Strings.isNotBlank(id)) {
            key += id;
        } else {
            key += "_" + elementName + count;
        }
    }
}
 
Example #20
Source File: BuildConfigs.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
public static BuildConfig createBuildConfig(String buildConfigName, Map<String, String> labels, String gitUrlText, String outputImageStreamName, String imageText, String webhookSecret) {
    BuildConfigBuilder buildConfigBuilder = buildConfigBuilder(buildConfigName, labels);
    BuildConfigSpecBuilder specBuilder = new BuildConfigSpecBuilder();

    addBuildParameterGitSource(specBuilder, gitUrlText);
    if (Strings.isNotBlank(outputImageStreamName)) {
        addBuildParameterOutput(specBuilder, outputImageStreamName);
    }
    if (Strings.isNotBlank(imageText)) {
        addBuildConfigSpectiStrategy(specBuilder, imageText);
    }
    if (Strings.isNotBlank(webhookSecret)) {
        addWebHookTriggers(specBuilder, webhookSecret);
    }
    return buildConfigBuilder.withSpec(specBuilder.build()).build();
}
 
Example #21
Source File: CommandHelpers.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
public static String getResultMessage(Result result) {
    if (result instanceof CompositeResult) {
        CompositeResult compositeResult = (CompositeResult) result;
        List<Result> results = compositeResult.getResults();
        StringBuilder buffer = new StringBuilder();
        for (Result childResult : results) {
            String childResultMessage = getResultMessage(childResult);
            if (Strings.isNotBlank(childResultMessage)) {
                if (buffer.length() > 0) {
                    buffer.append("\n");
                }
                buffer.append(childResultMessage);
            }
        }
        return buffer.toString();
    } else if (result != null) {
        return result.getMessage();
    } else {
        return null;
    }
}
 
Example #22
Source File: ArchetypeTest.java    From ipaas-quickstarts with Apache License 2.0 6 votes vote down vote up
protected List<String> getArchetypesFromJar() throws IOException {
    String entryName = "archetype-catalog.xml";
    URL url = getClass().getClassLoader().getResource(entryName);
    assertThat(url).describedAs("Could not find resource " + entryName + " on the classpath!").isNotNull();

    SortedSet<String> artifactIds = new TreeSet<>();
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(url.openStream());
        Document doc = builder.parse(is);
        NodeList artifactTags = doc.getElementsByTagName("artifactId");
        for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
            Node element = artifactTags.item(i);
            String artifactId = element.getTextContent();
            if (Strings.isNotBlank(artifactId)) {
                artifactIds.add(artifactId);
            }
        }
    } catch (Exception e) {
        fail("Failed to parse " + entryName + " in catalog " + url + ". Exception " + e, e);
    }
    return new ArrayList<>(artifactIds);
}
 
Example #23
Source File: OutputFormatHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static void addTableTextOutput(StringBuilder buffer, String title, TablePrinter table) {
    if (Strings.isNotBlank(title)) {
        buffer.append(title);
        buffer.append(":\n\n");
    }
    buffer.append(table.asText());
    buffer.append("\n");
}
 
Example #24
Source File: VersionHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the version to use for the fabric8 archetypes
 */
public static String fabric8ArchetypesVersion() {
    String version = System.getenv(ENV_FABRIC8_ARCHETYPES_VERSION);
    if (Strings.isNotBlank(version)) {
        return version;
    }
    return MavenHelpers.getVersion("io.fabric8.archetypes", "archetypes-catalog");
}
 
Example #25
Source File: MavenHelpers.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if the dependency was added or false if its already there
 */
public static boolean ensureMavenDependencyAdded(Project project, DependencyInstaller dependencyInstaller, String groupId, String artifactId, String scope) {
    List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
    for (Dependency d : dependencies) {
        if (groupId.equals(d.getCoordinate().getGroupId()) && artifactId.equals(d.getCoordinate().getArtifactId())) {
            getLOG().debug("Project already includes:  " + groupId + ":" + artifactId + " for version: " + d.getCoordinate().getVersion());
            return false;
        }
    }

    DependencyBuilder component = DependencyBuilder.create().
            setGroupId(groupId).
            setArtifactId(artifactId);

    if (scope != null) {
        component.setScopeType(scope);
    }

    String version = MavenHelpers.getVersion(groupId, artifactId);
    if (Strings.isNotBlank(version)) {
        component = component.setVersion(version);
        getLOG().debug("Adding pom.xml dependency:  " + groupId + ":" + artifactId + " version: " + version + " scope: " + scope);
    } else {
        getLOG().debug("No version could be found for:  " + groupId + ":" + artifactId);
    }
    dependencyInstaller.install(project, component);
    return true;
}
 
Example #26
Source File: NewBuildCommand.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
public Result execute(UIExecutionContext context) throws Exception {
    String buildConfigName = buildName.getValue();
    Objects.assertNotNull(buildConfigName, "buildName");
    Map<String, String> labels = BuildConfigs.createBuildLabels(buildConfigName);
    String ouputImageName = imageName.getValue();
    String gitUrlText = getOrFindGitUrl(context, gitUri.getValue());
    String imageText = outputImage.getValue();
    Model mavenModel = getMavenModel(context);
    if (Strings.isNullOrBlank(imageText) && mavenModel != null) {
        imageText = mavenModel.getProperties().getProperty("docker.image");
    }

    String webhookSecretText = webHookSecret.getValue();
    if (Strings.isNullOrBlank(webhookSecretText)) {
        // TODO generate a really good secret!
        webhookSecretText = "secret101";
    }
    BuildConfig buildConfig = BuildConfigs.createBuildConfig(buildConfigName, labels, gitUrlText, ouputImageName, imageText, webhookSecretText);

    System.out.println("Generated BuildConfig: " + toJson(buildConfig));

    ImageStream imageRepository = BuildConfigs.imageRepository(buildConfigName, labels);

    Controller controller = createController();
    controller.applyImageStream(imageRepository, "generated ImageStream: " + toJson(imageRepository));
    controller.applyBuildConfig(buildConfig, "generated BuildConfig: " + toJson(buildConfig));
    return Results.success("Added BuildConfig: " + Builds.getName(buildConfig) + " to OpenShift at master: " + getKubernetes().getMasterUrl());
}
 
Example #27
Source File: MavenHelpers.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the version from the list of pre-configured versions of common groupId/artifact pairs
 */
public static String getVersion(String groupId, String artifactId, String defaultVersion) {
    String answer = getVersion(groupId, artifactId);
    if (Strings.isNullOrBlank(answer)) {
        answer = defaultVersion;
    }
    return answer;
}
 
Example #28
Source File: Files.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static String joinPaths(String parentPath, String name) {
    String path = name;
    if (Strings.isNotBlank(parentPath)) {
        String separator = path.endsWith("/") || name.startsWith("/") ? "" : "/";
        path = parentPath + separator + name;
    }
    return path;
}
 
Example #29
Source File: NodeDtos.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static String getNodeText(NodeDtoSupport node) {
    String pattern = Strings2.getOrElse(node.getPattern());
    String label = Strings2.getOrElse(node.getLabel());

    // lets output the pattern for a few kinds of nodes....
    if (patternsToPrefix.contains(pattern)) {
        return Strings.join(" ", pattern, label);
    }
    return label;
}
 
Example #30
Source File: ArchetypeTest.java    From ipaas-quickstarts with Apache License 2.0 5 votes vote down vote up
@Test
public void testGenerateQuickstartArchetypes() {
    try {
        Files.recursiveDelete(projectsOutputFolder);

        List<String> archetypes = getArchetypesFromJar();
        assertThat(archetypes).describedAs("Archetypes to create").isNotEmpty();

        String testArchetype = System.getProperty(TEST_ARCHETYPE_SYSTEM_PROPERTY, "");
        if (Strings.isNotBlank(testArchetype)) {
            LOG.info("Due to system property: '" + TEST_ARCHETYPE_SYSTEM_PROPERTY + "' we will just run the test on archetype: " + testArchetype);
            assertArchetypeCreated(testArchetype);
        } else {
            LOG.info("Generating archetypes: " + archetypes);
            for (String archetype : archetypes) {
                if (ignoreArchetype(archetype)) {
                    LOG.warn("Ignoring archetype: " + archetype);
                } else {
                    assertArchetypeCreated(archetype);
                }
            }
        }

        removeSnapshotFabric8Artifacts();
    } catch (Exception e) {
        fail("Failed to create archetypes: " + e, e);
        failed = true;
    }
}