protected Configuration getConfiguration() { return enricherContext.getConfiguration(); }
public BaseEnricher(EnricherContext enricherContext, String name) { this.enricherContext = enricherContext; // Pick the configuration which is for us this.config = new EnricherConfig(name, enricherContext.getConfiguration()); this.log = new PrefixedLogger(name, enricherContext.getLog()); this.name = name; }
public BaseEnricher(EnricherContext buildContext, String name) { this.buildContext = buildContext; // Pick the configuration which is for us this.config = new EnricherConfig(buildContext.getProject().getProperties(), name, buildContext.getConfig()); this.log = new PrefixedLogger(name, buildContext.getLog()); this.name = name; }
private boolean isApplicable() { return getContext().hasPlugin(VERTX_MAVEN_PLUGIN_GROUP, VERTX_MAVEN_PLUGIN_ARTIFACT) || getContext().hasDependency(VERTX_GROUPID, null); }
protected MavenProject getProject() { if (buildContext != null) { return buildContext.getProject(); } return null; }
public ControllerViaPluginConfigurationEnricher(MavenEnricherContext context) { super(context, "fmp-controller-from-configuration"); HandlerHub handlers = new HandlerHub( getContext().getGav(), getContext().getConfiguration().getProperties()); deployHandler = handlers.getDeploymentHandler(); statefulSetHandler = handlers.getStatefulSetHandler(); }
private ImageConfiguration getImageWithContainerName(String containerName) { if (containerName == null) { return null; } List<ImageConfiguration> images = getImages().orElse(Collections.emptyList()); for (ImageConfiguration image : images) { String imageContainerName = KubernetesResourceUtil.extractContainerName(getContext().getGav(), image); if (Objects.equal(containerName, imageContainerName)) { return image; } } return null; }
@Override public Map<String, String> getAnnotations(Kind kind) { final Map<String, String> annotations = new HashMap<>(); if (GitUtil.findGitFolder(getContext().getProjectDirectory()) != null) { Repository repository = null; try { if (kind.isController() || kind == Kind.SERVICE) { repository = GitUtil.getGitRepository(getContext().getProjectDirectory()); if (repository != null) { String branch = repository.getBranch(); String gitRemote = getContext().getConfiguration().getProperties().getProperty(GIT_REMOTE); gitRemote = gitRemote == null? "origin" : gitRemote; String gitRemoteUrl = repository.getConfig().getString("remote", gitRemote, "url");
ProjectClassLoaders cls = getContext().getProjectClassLoaders(); if (cls.isClassInCompileClasspath(false, "io.fabric8.funktion.runtime.Main") || getContext().hasDependency( "io.fabric8.funktion", null)) { return "funktion"; return "camel"; if (getContext().hasPlugin(null, SpringBootConfigurationHelper.SPRING_BOOT_MAVEN_PLUGIN_ARTIFACT_ID) || cls.isClassInCompileClasspath(false, "org.springframework.boot.SpringApplication")) { return "spring-boot"; if (getContext().hasPlugin("org.wildfly.swarm", "wildfly-swarm-plugin") || getContext().hasDependency( "org.wildfly.swarm", null)) { return "wildfly-swarm"; if (getContext().hasPlugin( "io.thorntail", "thorntail-maven-plugin") || getContext().hasDependency( "io.thorntail", null)) {
public VolumePermissionEnricher(EnricherContext buildContext) { super(buildContext, ENRICHER_NAME); initContainerHandler = new InitContainerHandler(buildContext.getLog()); }
@Override public Map<String, String> getAnnotations(Kind kind) { if (isOnline() && (kind.isController() || kind == Kind.SERVICE)) { Map<String, String> annotations = new HashMap<>(); String repoName = getContext().getGav().getArtifactId(); try (Repository repository = GitUtil.getGitRepository(getContext().getProjectDirectory())) { // Git annotations (if git is used as SCM) if (repository != null) { String gitCommitId = GitUtil.getGitCommitId(repository); if (gitCommitId != null) { addGitServiceUrl(annotations, repoName, gitCommitId); } else { log.debug("No Git commit id found"); } } else { log.debug("No local Git repository found"); } } catch (IOException | GitAPIException e) { log.error("Cannot extract Git information for adding to annotations: " + e, e); } // Jenkins annotations addJenkinsServiceUrl(annotations, repoName); return annotations; } return null; }
private InputStream loadPluginResource(String iconRef) { InputStream answer = Thread.currentThread().getContextClassLoader().getResourceAsStream(iconRef); if (answer == null) { answer = getContext().getProjectClassLoaders().getCompileClassLoader().getResourceAsStream(iconRef); } if (answer == null) { answer = this.getClass().getResourceAsStream(iconRef); } return answer; }
/** * Checks if given dependency is defined. * @param groupId of dependency. * @param artifactId of dependency. If null, check if there is any dependency with the given group * @return True if present, false otherwise. */ default boolean hasDependency(String groupId, String artifactId) { return getDependencyVersion(groupId, artifactId).isPresent(); }
public IconEnricher(MavenEnricherContext buildContext) { super(buildContext, "f8-deprecated-icon"); String baseDir = getContext().getProjectDirectory().getAbsolutePath(); templateTempDir = new File(getConfig(Config.templateTempDir, baseDir + "/target/fabric8/template-workdir")); appConfigDir = new File(getConfig(Config.sourceDir, baseDir + "/src/main/fabric8")); }
private Probe discoverThorntailHealthCheck(int initialDelay) { if (getContext().hasDependency(IO_THORNTAIL, "thorntail-kernel")) { // if there's thorntail-kernel, it's Thorntail v4 return null; } if (getContext().hasDependency(IO_THORNTAIL, "monitor") || getContext().hasDependency(IO_THORNTAIL, "microprofile-health")) { Integer port = getPort(); // scheme must be in upper case in k8s String scheme = getScheme().toUpperCase(); String path = getPath(); return new ProbeBuilder() .withNewHttpGet().withNewPort(port).withPath(path).withScheme(scheme).endHttpGet() .withFailureThreshold(getFailureThreshold()) .withSuccessThreshold(getSuccessThreshold()) .withInitialDelaySeconds(initialDelay).build(); } return null; }
/** * Gets version of given dependency. * @param groupId of the dependency. * @param artifactId of the dependency. * @return Version number. */ default Optional<String> getDependencyVersion(String groupId, String artifactId) { List<Dependency> dependencies = getDependencies(true); for (Dependency dep : dependencies) { String scope = dep.getScope(); if ("test".equals(scope) || (artifactId != null && !artifactId.equals(dep.getGav().getArtifactId()))) { continue; } if (dep.getGav().getGroupId().equals(groupId)) { return Optional.of(dep.getGav().getVersion()); } } return Optional.empty(); }
private boolean isApplicable() { return getContext() .hasPlugin("org.apache.maven.plugins", "maven-war-plugin") && StringUtils.isNotEmpty(Configs.asString(getConfig(Config.path))); }
private boolean debugEnabled() { MavenProject project = getContext().getProject(); if (project != null) { String value = project.getProperties().getProperty(ENABLE_DEBUG_MAVEN_PROPERTY); if (isTrueFlag(value)) { return true; }; } return isTrueFlag(System.getProperty(ENABLE_DEBUG_MAVEN_PROPERTY)); }
public DefaultControllerEnricher(MavenEnricherContext buildContext) { super(buildContext, "fmp-controller"); HandlerHub handlers = new HandlerHub( getContext().getGav(), getContext().getConfiguration().getProperties()); rcHandler = handlers.getReplicationControllerHandler(); rsHandler = handlers.getReplicaSetHandler(); deployHandler = handlers.getDeploymentHandler(); statefulSetHandler = handlers.getStatefulSetHandler(); daemonSetHandler = handlers.getDaemonSetHandler(); jobHandler = handlers.getJobHandler(); }
private String findGrafanaLink() { String defaultDashboard = detectDefaultDashboard(); String query = ""; String projectName = null; String version = null; // TODO - use the docker names which may differ from project metadata! if (StringUtils.isBlank(projectName)) { projectName = getContext().getGav().getArtifactId(); } if (StringUtils.isBlank(version)) { version = getContext().getGav().getVersion(); } if (StringUtils.isNotBlank(projectName)) { query += "&var-project=" + projectName; } if (StringUtils.isNotBlank(version)) { query += "&var-version=" + version; } if (query.startsWith("&")) { query = "?" + query.substring(1); } return String.format("dashboard/file/%s%s", defaultDashboard, query); }