forked from eclipse-jkube/jkube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (jkube-kit/jkube-kit-spring-boot) : Support for Spring Native (e…
…clipse-jkube#2138) Signed-off-by: Rohan Kumar <rohaan@redhat.com>
- Loading branch information
1 parent
1d10117
commit 21555cc
Showing
7 changed files
with
169 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/NativeGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.springboot.generator; | ||
|
||
import org.eclipse.jkube.generator.api.FromSelector; | ||
import org.eclipse.jkube.generator.api.GeneratorConfig; | ||
import org.eclipse.jkube.generator.api.GeneratorContext; | ||
import org.eclipse.jkube.kit.common.Arguments; | ||
import org.eclipse.jkube.kit.common.Assembly; | ||
import org.eclipse.jkube.kit.common.AssemblyConfiguration; | ||
import org.eclipse.jkube.kit.common.AssemblyFileSet; | ||
import org.eclipse.jkube.kit.common.JavaProject; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import static org.eclipse.jkube.kit.common.util.FileUtil.getRelativePath; | ||
|
||
public class NativeGenerator extends AbstractSpringBootNestedGenerator { | ||
private final File nativeBinary; | ||
private final FromSelector fromSelector; | ||
|
||
public NativeGenerator(GeneratorContext generatorContext, GeneratorConfig generatorConfig, File nativeBinary) { | ||
super(generatorContext, generatorConfig); | ||
this.nativeBinary = nativeBinary; | ||
fromSelector = new FromSelector.Default(generatorContext, "springboot-native"); | ||
} | ||
|
||
|
||
@Override | ||
public String getFrom() { | ||
return fromSelector.getFrom(); | ||
} | ||
|
||
@Override | ||
public String getDefaultJolokiaPort() { | ||
return "0"; | ||
} | ||
|
||
@Override | ||
public String getDefaultPrometheusPort() { | ||
return "0"; | ||
} | ||
|
||
@Override | ||
public Arguments getBuildEntryPoint() { | ||
return Arguments.builder() | ||
.execArgument("./" + getProject().getArtifactId()) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public String getBuildWorkdir() { | ||
return "/"; | ||
} | ||
|
||
@Override | ||
public String getTargetDir() { | ||
return "/"; | ||
} | ||
|
||
@Override | ||
public AssemblyConfiguration createAssemblyConfiguration(List<AssemblyFileSet> defaultFileSets) { | ||
Assembly.AssemblyBuilder assemblyBuilder = Assembly.builder(); | ||
final JavaProject project = getProject(); | ||
final AssemblyFileSet.AssemblyFileSetBuilder artifactFileSetBuilder = AssemblyFileSet.builder() | ||
.outputDirectory(new File(".")) | ||
.directory(getRelativePath(project.getBaseDirectory(), nativeBinary.getParentFile())) | ||
.fileMode("0755"); | ||
artifactFileSetBuilder.include(nativeBinary.getName()); | ||
|
||
assemblyBuilder.fileSets(defaultFileSets); | ||
assemblyBuilder.fileSet(artifactFileSetBuilder.build()); | ||
|
||
return AssemblyConfiguration.builder() | ||
.targetDir(getTargetDir()) | ||
.excludeFinalOutputArtifact(true) | ||
.layer(assemblyBuilder.build()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...kube-kit-spring-boot/src/main/resources-filtered/META-INF/jkube/default-images.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at: | ||
# | ||
# https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
# Properties for specifying the default images version to use | ||
# The replacement values are defined in the parent pom.xml as properties | ||
|
||
# Upstream images | ||
springboot-native.upstream.s2i=${image.springboot-native.upstream.s2i} | ||
springboot-native.upstream.docker=${image.springboot-native.upstream.docker} | ||
springboot-native.upstream.istag=${image.springboot-native.upstream.istag} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters