use of org.eclipse.jkube.kit.common.Maintainer in project jkube by eclipse.
the class HelmConfigTest method createHelmConfig.
@Test
public void createHelmConfig() throws IOException {
// Given
File file = File.createTempFile("test", ".tmp");
file.deleteOnExit();
HelmConfig helmConfig = new HelmConfig();
helmConfig.setVersion("version");
helmConfig.setSecurity("security");
helmConfig.setChart("chart");
helmConfig.setTypes(Collections.singletonList(HelmType.KUBERNETES));
helmConfig.setType(HelmType.KUBERNETES.name());
helmConfig.setAdditionalFiles(Collections.singletonList(file));
helmConfig.setChartExtension("chartExtension");
helmConfig.setOutputDir("outputDir");
helmConfig.setSourceDir("sourceDir");
helmConfig.setSnapshotRepository(new HelmRepository());
helmConfig.setStableRepository(new HelmRepository());
helmConfig.setTarballOutputDir("tarballOutputDir");
helmConfig.setParameterTemplates(Collections.singletonList(new Template()));
helmConfig.setDescription("description");
helmConfig.setHome("home");
helmConfig.setIcon("icon");
helmConfig.setMaintainers(Collections.singletonList(new Maintainer()));
helmConfig.setSources(Collections.singletonList("source"));
helmConfig.setEngine("engine");
helmConfig.setKeywords(Collections.singletonList("keyword"));
helmConfig.setGeneratedChartListeners(Arrays.asList((helmConfig1, type, chartFile) -> {
}));
// Then
assertThat(helmConfig.getVersion()).isEqualTo("version");
assertThat(helmConfig.getSecurity()).isEqualTo("security");
assertThat(helmConfig.getChart()).isEqualTo("chart");
assertThat(helmConfig.getTypes().get(0)).isEqualTo(HelmType.KUBERNETES);
assertThat(helmConfig.getAdditionalFiles().get(0)).exists();
assertThat(helmConfig.getChartExtension()).isEqualTo("chartExtension");
assertThat(helmConfig.getOutputDir()).isEqualTo("outputDir");
assertThat(helmConfig.getSourceDir()).isEqualTo("sourceDir");
assertThat(helmConfig.getSnapshotRepository()).isNotNull();
assertThat(helmConfig.getStableRepository()).isNotNull();
assertThat(helmConfig.getTarballOutputDir()).isEqualTo("tarballOutputDir");
assertThat(helmConfig.getParameterTemplates()).isNotEmpty();
assertThat(helmConfig.getDescription()).isEqualTo("description");
assertThat(helmConfig.getHome()).isEqualTo("home");
assertThat(helmConfig.getIcon()).isEqualTo("icon");
assertThat(helmConfig.getMaintainers()).isNotEmpty();
assertThat(helmConfig.getSources().get(0)).isEqualTo("source");
assertThat(helmConfig.getEngine()).isEqualTo("engine");
assertThat(helmConfig.getKeywords().get(0)).isEqualTo("keyword");
}
use of org.eclipse.jkube.kit.common.Maintainer 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();
}
use of org.eclipse.jkube.kit.common.Maintainer in project jkube by eclipse.
the class HelmConfigTest method deserialize.
@Test
public void deserialize() throws Exception {
// Given
final String serializedChart = "{" + "\"version\":\"1337\"," + "\"security\":\"NYPD\"," + "\"chart\":\"pie\"," + "\"type\":\"kUberNetes\"," + "\"chartExtension\":\"tar\"," + "\"outputDir\":\"./output\"," + "\"sourceDir\":\"./src\"," + "\"snapshotRepository\":{}," + "\"stableRepository\":{}," + "\"tarballOutputDir\":\"./tar-output\"," + "\"parameterTemplates\":[{}]," + "\"parameters\": [{\"name\":\"key\"}]," + "\"description\":\"The description\"," + "\"home\":\"e.t.\"," + "\"icon\":\"Warhol\"," + "\"maintainers\":[{}]," + "\"sources\":[\"source\"]," + "\"engine\":\"V8\"," + "\"keywords\":[\"SEO\"]," + "\"dependencies\":[{" + "\"name\": \"ngnix\"," + "\"version\": \"1.2.3\"," + "\"repository\": \"https://example.com/charts\"" + "}]" + "}";
// When
final HelmConfig result = objectMapper.readValue(serializedChart, HelmConfig.class);
// Then
assertThat(result).hasFieldOrPropertyWithValue("version", "1337").hasFieldOrPropertyWithValue("security", "NYPD").hasFieldOrPropertyWithValue("chart", "pie").hasFieldOrPropertyWithValue("types", Collections.singletonList(HelmType.KUBERNETES)).hasFieldOrPropertyWithValue("chartExtension", "tar").hasFieldOrPropertyWithValue("outputDir", "./output").hasFieldOrPropertyWithValue("sourceDir", "./src").hasFieldOrPropertyWithValue("snapshotRepository", new HelmRepository()).hasFieldOrPropertyWithValue("stableRepository", new HelmRepository()).hasFieldOrPropertyWithValue("tarballOutputDir", "./tar-output").hasFieldOrPropertyWithValue("parameterTemplates", Collections.singletonList(new Template())).hasFieldOrPropertyWithValue("parameters", Collections.singletonList(new ParameterBuilder().withName("key").build())).hasFieldOrPropertyWithValue("description", "The description").hasFieldOrPropertyWithValue("home", "e.t.").hasFieldOrPropertyWithValue("icon", "Warhol").hasFieldOrPropertyWithValue("maintainers", Collections.singletonList(new Maintainer())).hasFieldOrPropertyWithValue("sources", Collections.singletonList("source")).hasFieldOrPropertyWithValue("engine", "V8").hasFieldOrPropertyWithValue("keywords", Collections.singletonList("SEO")).hasFieldOrPropertyWithValue("dependencies", Collections.singletonList(new HelmDependency().toBuilder().name("ngnix").version("1.2.3").repository("https://example.com/charts").build()));
}
use of org.eclipse.jkube.kit.common.Maintainer in project jkube by eclipse.
the class MavenUtil method convertMavenProjectToJKubeProject.
public static JavaProject convertMavenProjectToJKubeProject(MavenProject mavenProject, MavenSession mavenSession) throws DependencyResolutionRequiredException {
JavaProject.JavaProjectBuilder builder = JavaProject.builder();
Properties properties = new Properties();
if (mavenProject.getProperties() != null) {
properties.putAll(mavenProject.getProperties());
}
if (mavenSession != null) {
if (mavenSession.getUserProperties() != null) {
properties.putAll(mavenSession.getUserProperties());
}
if (mavenSession.getSystemProperties() != null) {
properties.putAll(mavenSession.getSystemProperties());
}
if (mavenSession.getExecutionProperties() != null) {
properties.putAll(mavenSession.getExecutionProperties());
}
}
builder.name(mavenProject.getName()).description(mavenProject.getDescription()).groupId(mavenProject.getGroupId()).artifactId(mavenProject.getArtifactId()).version(mavenProject.getVersion()).baseDirectory(mavenProject.getBasedir()).documentationUrl(getDocumentationUrl(mavenProject)).compileClassPathElements(mavenProject.getCompileClasspathElements()).properties(properties).packaging(mavenProject.getPackaging()).dependencies(getDependencies(mavenProject)).dependenciesWithTransitive(getTransitiveDependencies(mavenProject)).plugins(getPlugins(mavenProject));
if (mavenProject.getOrganization() != null) {
builder.site(mavenProject.getOrganization().getUrl()).organizationName(mavenProject.getOrganization().getName());
}
Optional.ofNullable(mavenProject.getBuild()).ifPresent(mavenBuild -> builder.outputDirectory(new File(mavenBuild.getOutputDirectory())).buildFinalName(mavenBuild.getFinalName()).buildDirectory(new File(mavenBuild.getDirectory())).buildPackageDirectory(new File(mavenBuild.getDirectory())));
if (mavenProject.getIssueManagement() != null) {
builder.issueManagementSystem(mavenProject.getIssueManagement().getSystem());
builder.issueManagementUrl(mavenProject.getIssueManagement().getUrl());
}
if (mavenProject.getScm() != null) {
builder.scmTag(mavenProject.getScm().getTag());
builder.scmUrl(mavenProject.getScm().getUrl());
}
if (mavenProject.getArtifact() != null) {
builder.artifact(mavenProject.getArtifact().getFile());
}
if (mavenProject.getUrl() != null) {
builder.url(mavenProject.getUrl());
}
if (mavenProject.getDevelopers() != null) {
builder.maintainers(Optional.of(mavenProject).map(MavenProject::getDevelopers).orElse(Collections.emptyList()).stream().filter(developer -> StringUtils.isNotBlank(developer.getName()) || StringUtils.isNotBlank(developer.getEmail())).map(developer -> new Maintainer(developer.getName(), developer.getEmail())).collect(Collectors.toList()));
}
return builder.build();
}
Aggregations