Search in sources :

Example 26 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class HelmServiceUtil method initHelmConfig.

public static HelmConfig.HelmConfigBuilder initHelmConfig(HelmConfig.HelmType defaultHelmType, JavaProject project, File manifest, File template, HelmConfig original) throws IOException {
    if (original == null) {
        original = new HelmConfig();
    }
    original.setChart(resolveFromPropertyOrDefault(PROPERTY_CHART, project, original::getChart, project.getArtifactId()));
    original.setChartExtension(resolveFromPropertyOrDefault(PROPERTY_CHART_EXTENSION, project, original::getChartExtension, DEFAULT_CHART_EXTENSION));
    original.setVersion(resolveFromPropertyOrDefault(PROPERTY_VERSION, project, original::getVersion, project.getVersion()));
    original.setDescription(resolveFromPropertyOrDefault(PROPERTY_DESCRIPTION, project, original::getDescription, project.getDescription()));
    original.setHome(resolveFromPropertyOrDefault(PROPERTY_HOME, project, original::getHome, project.getUrl()));
    if (original.getSources() == null) {
        original.setSources(project.getScmUrl() != null ? Collections.singletonList(project.getScmUrl()) : Collections.emptyList());
    }
    if (original.getMaintainers() == null && project.getMaintainers() != null) {
        original.setMaintainers(project.getMaintainers().stream().filter(m -> StringUtils.isNotBlank(m.getName()) || StringUtils.isNotBlank(m.getEmail())).map(m -> new Maintainer(m.getName(), m.getEmail())).collect(Collectors.toList()));
    }
    original.setIcon(resolveFromPropertyOrDefault(PROPERTY_ICON, project, original::getIcon, findIconURL(manifest)));
    original.setAdditionalFiles(getAdditionalFiles(original, project));
    if (original.getParameterTemplates() == null) {
        original.setParameterTemplates(findTemplates(template));
    }
    original.setTypes(resolveHelmTypes(defaultHelmType, project));
    original.setSourceDir(resolveFromPropertyOrDefault(PROPERTY_SOURCE_DIR, project, original::getSourceDir, String.format("%s/META-INF/jkube/", project.getOutputDirectory())));
    original.setOutputDir(resolveFromPropertyOrDefault(PROPERTY_OUTPUT_DIR, project, original::getOutputDir, String.format("%s/jkube/helm/%s", project.getBuildDirectory(), original.getChart())));
    original.setTarballOutputDir(resolveFromPropertyOrDefault(PROPERTY_TARBALL_OUTPUT_DIR, project, original::getTarballOutputDir, project.getBuildDirectory().getAbsolutePath()));
    return original.toBuilder();
}
Also used : ResourceUtil(org.eclipse.jkube.kit.common.util.ResourceUtil) FilenameFilter(java.io.FilenameFilter) JKubeProjectUtil.getProperty(org.eclipse.jkube.kit.common.util.JKubeProjectUtil.getProperty) UnaryOperator(java.util.function.UnaryOperator) StringUtils(org.apache.commons.lang3.StringUtils) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) RegistryServerConfiguration(org.eclipse.jkube.kit.common.RegistryServerConfiguration) Locale(java.util.Locale) JavaProject(org.eclipse.jkube.kit.common.JavaProject) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) KubernetesHelper(org.eclipse.jkube.kit.common.util.KubernetesHelper) IOException(java.io.IOException) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Collectors(java.util.stream.Collectors) File(java.io.File) Objects(java.util.Objects) KitLogger(org.eclipse.jkube.kit.common.KitLogger) Template(io.fabric8.openshift.api.model.Template) List(java.util.List) Stream(java.util.stream.Stream) KubernetesResource(io.fabric8.kubernetes.api.model.KubernetesResource) Optional(java.util.Optional) Collections(java.util.Collections) Maintainer(org.eclipse.jkube.kit.common.Maintainer) Maintainer(org.eclipse.jkube.kit.common.Maintainer)

Example 27 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class OpenShiftResourceMojoTest method setUp.

@Before
public void setUp() {
    mockedClusterAccess = mock(ClusterAccess.class, RETURNS_DEEP_STUBS);
    mockedImageConfigResolver = mock(ImageConfigResolver.class, RETURNS_DEEP_STUBS);
    MavenProject mockedMavenProject = mock(MavenProject.class, RETURNS_DEEP_STUBS);
    JavaProject mockedJavaProject = mock(JavaProject.class, RETURNS_DEEP_STUBS);
    JKubeServiceHub mockedJKubeServiceHub = mock(JKubeServiceHub.class, RETURNS_DEEP_STUBS);
    Properties properties = new Properties();
    this.openShiftResourceMojo = new OpenshiftResourceMojo();
    this.openShiftResourceMojo.project = mockedMavenProject;
    this.openShiftResourceMojo.settings = mock(Settings.class, RETURNS_DEEP_STUBS);
    this.openShiftResourceMojo.jkubeServiceHub = mockedJKubeServiceHub;
    this.openShiftResourceMojo.clusterAccess = mockedClusterAccess;
    this.openShiftResourceMojo.log = mock(KitLogger.class, RETURNS_DEEP_STUBS);
    this.openShiftResourceMojo.skipResourceValidation = true;
    this.openShiftResourceMojo.projectHelper = mock(MavenProjectHelper.class, RETURNS_DEEP_STUBS);
    this.openShiftResourceMojo.imageConfigResolver = mockedImageConfigResolver;
    this.openShiftResourceMojo.javaProject = mockedJavaProject;
    when(mockedMavenProject.getProperties()).thenReturn(properties);
    when(mockedJavaProject.getArtifactId()).thenReturn("test-project");
    when(mockedJavaProject.getGroupId()).thenReturn("org.eclipse.jkube");
    when(mockedJavaProject.getProperties()).thenReturn(properties);
    when(mockedJKubeServiceHub.getConfiguration().getProject()).thenReturn(mockedJavaProject);
    when(mockedJKubeServiceHub.getConfiguration().getBasedir()).thenReturn(temporaryFolder.getRoot());
}
Also used : KitLogger(org.eclipse.jkube.kit.common.KitLogger) MavenProjectHelper(org.apache.maven.project.MavenProjectHelper) JavaProject(org.eclipse.jkube.kit.common.JavaProject) MavenProject(org.apache.maven.project.MavenProject) ClusterAccess(org.eclipse.jkube.kit.config.access.ClusterAccess) ImageConfigResolver(org.eclipse.jkube.kit.build.service.docker.config.handler.ImageConfigResolver) Properties(java.util.Properties) Settings(org.apache.maven.settings.Settings) JKubeServiceHub(org.eclipse.jkube.kit.config.service.JKubeServiceHub) Before(org.junit.Before)

Example 28 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class SpringBootGenerator method isSpringBootRepackage.

private boolean isSpringBootRepackage() {
    JavaProject project = getProject();
    Plugin plugin = JKubeProjectUtil.getPlugin(project, SpringBootConfigurationHelper.SPRING_BOOT_MAVEN_PLUGIN_ARTIFACT_ID);
    if (Optional.ofNullable(plugin).map(Plugin::getExecutions).map(e -> e.contains("repackage")).orElse(false)) {
        log.verbose("Using fat jar packaging as the spring boot plugin is using `repackage` goal execution");
        return true;
    }
    return false;
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) JKubeProjectUtil(org.eclipse.jkube.kit.common.util.JKubeProjectUtil) ZipInputStream(java.util.zip.ZipInputStream) Getter(lombok.Getter) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) COLOR(org.eclipse.jkube.springboot.generator.SpringBootGenerator.Config.COLOR) SPRING_BOOT_DEVTOOLS_ARTIFACT_ID(org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper.SPRING_BOOT_DEVTOOLS_ARTIFACT_ID) SPRING_BOOT_GROUP_ID(org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper.SPRING_BOOT_GROUP_ID) SpringBootConfigurationHelper(org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper) StringUtils(org.apache.commons.lang3.StringUtils) GeneratorContext(org.eclipse.jkube.generator.api.GeneratorContext) Strings(com.google.common.base.Strings) DEV_TOOLS_REMOTE_SECRET(org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper.DEV_TOOLS_REMOTE_SECRET) Map(java.util.Map) FatJarDetector(org.eclipse.jkube.generator.javaexec.FatJarDetector) SpringBootUtil(org.eclipse.jkube.kit.common.util.SpringBootUtil) ZipEntry(java.util.zip.ZipEntry) JavaProject(org.eclipse.jkube.kit.common.JavaProject) GeneratorMode(org.eclipse.jkube.generator.api.GeneratorMode) Properties(java.util.Properties) FileWriter(java.io.FileWriter) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) FileInputStream(java.io.FileInputStream) UUID(java.util.UUID) File(java.io.File) Plugin(org.eclipse.jkube.kit.common.Plugin) JavaExecGenerator(org.eclipse.jkube.generator.javaexec.JavaExecGenerator) List(java.util.List) Configs(org.eclipse.jkube.kit.common.Configs) Optional(java.util.Optional) CRC32(java.util.zip.CRC32) AllArgsConstructor(lombok.AllArgsConstructor) Collections(java.util.Collections) InputStream(java.io.InputStream) JavaProject(org.eclipse.jkube.kit.common.JavaProject) Plugin(org.eclipse.jkube.kit.common.Plugin)

Example 29 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class VertxPortsExtractorTest method testNoVertxConfiguration.

@Test
public void testNoVertxConfiguration() {
    JavaProject project = JavaProject.builder().plugins(Collections.singletonList(Plugin.builder().groupId(Constants.VERTX_MAVEN_PLUGIN_GROUP).artifactId(Constants.VERTX_MAVEN_PLUGIN_ARTIFACT).version("testversion").configuration(Collections.emptyMap()).build())).build();
    Map<String, Integer> result = new VertxPortsExtractor(log).extract(project);
    assertEquals(0, result.size());
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) Test(org.junit.Test)

Example 30 with JavaProject

use of org.eclipse.jkube.kit.common.JavaProject in project jkube by eclipse.

the class VertxPortsExtractorTest method testVertxConfigPathFromProject.

@Test
public void testVertxConfigPathFromProject() {
    Map<String, Object> vertxConfig = new HashMap<>();
    vertxConfig.put("vertxConfig", getAbsolutePath(VertxPortsExtractorTest.class.getResource("/config.json")));
    Map<String, Object> configuration = new HashMap<>();
    configuration.put("config", vertxConfig);
    JavaProject project = JavaProject.builder().plugins(Collections.singletonList(Plugin.builder().groupId(Constants.VERTX_MAVEN_PLUGIN_GROUP).artifactId(Constants.VERTX_MAVEN_PLUGIN_ARTIFACT).version("testversion").executions(Collections.singletonList("testexec")).configuration(configuration).build())).build();
    Map<String, Integer> result = new VertxPortsExtractor(log).extract(project);
    assertEquals((Integer) 80, result.get("http.port"));
}
Also used : JavaProject(org.eclipse.jkube.kit.common.JavaProject) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

JavaProject (org.eclipse.jkube.kit.common.JavaProject)52 Test (org.junit.Test)43 File (java.io.File)16 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)9 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)9 Expectations (mockit.Expectations)9 HashMap (java.util.HashMap)7 Properties (java.util.Properties)6 Configuration (org.gradle.api.artifacts.Configuration)6 DeprecatableConfiguration (org.gradle.internal.deprecation.DeprecatableConfiguration)6 IOException (java.io.IOException)5 Collections (java.util.Collections)4 List (java.util.List)4 MavenProject (org.apache.maven.project.MavenProject)4 Plugin (org.eclipse.jkube.kit.common.Plugin)4 JKubeEnricherContext (org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext)4 ArrayList (java.util.ArrayList)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang3.StringUtils)3