You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/09/09 09:53:07 UTC
[camel-k] 28/37: chore(native): Polish native checks logic
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 50edc77a320759eff4ca2440b15e4bf1fad40d13
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Tue Aug 31 12:48:38 2021 +0200
chore(native): Polish native checks logic
---
pkg/trait/jvm.go | 3 ++-
pkg/trait/quarkus.go | 21 +++++++++++++--------
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index 8d17bcc..60e853b 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -77,7 +77,8 @@ func (t *jvmTrait) Configure(e *Environment) (bool, error) {
}
if trait := e.Catalog.GetTrait(quarkusTraitId); trait != nil {
- if quarkus := trait.(*quarkusTrait); IsNilOrTrue(quarkus.Enabled) && quarkus.hasNativePackageType(e) {
+ // The JVM trait must be disabled in case the current IntegrationKit corresponds to a native build
+ if quarkus := trait.(*quarkusTrait); IsNilOrTrue(quarkus.Enabled) && quarkus.isNativeIntegration(e) {
return false, nil
}
}
diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go
index 629ba82..49a180e 100644
--- a/pkg/trait/quarkus.go
+++ b/pkg/trait/quarkus.go
@@ -186,7 +186,9 @@ func (t *quarkusTrait) Apply(e *Environment) error {
steps = append(steps, builder.Quarkus.CommonSteps...)
- if t.hasNativePackageType(e) {
+ if native, err := t.isNativeKit(e); err != nil {
+ return err
+ } else if native {
build.Maven.Properties["quarkus.package.type"] = string(nativePackageType)
steps = append(steps, builder.Image.NativeImageContext)
// Spectrum does not rely on Dockerfile to assemble the image
@@ -210,7 +212,7 @@ func (t *quarkusTrait) Apply(e *Environment) error {
build.Steps = builder.StepIDsFor(steps...)
case v1.IntegrationKitPhaseReady:
- if e.IntegrationInPhase(v1.IntegrationPhaseDeploying, v1.IntegrationPhaseRunning) && t.hasNativePackageType(e) {
+ if e.IntegrationInPhase(v1.IntegrationPhaseDeploying, v1.IntegrationPhaseRunning) && t.isNativeIntegration(e) {
container := e.getIntegrationContainer()
if container == nil {
return fmt.Errorf("unable to find integration container: %s", e.Integration.Name)
@@ -263,19 +265,22 @@ func (t *quarkusTrait) getKitTraits(e *Environment) map[string]v1.TraitSpec {
return traits
}
-func (t *quarkusTrait) hasNativePackageType(e *Environment) bool {
+func (t *quarkusTrait) isNativeKit(e *Environment) (bool, error) {
switch types := t.PackageTypes; len(types) {
case 0:
- return false
+ return false, nil
case 1:
- return types[0] == nativePackageType
+ return types[0] == nativePackageType, nil
default:
- // The Integration has more than one package types.
- // Let's rely on the current IntegrationKit to resolve it.
- return e.IntegrationKit.Labels[v1.IntegrationKitLayoutLabel] == v1.IntegrationKitLayoutNative
+ return false, fmt.Errorf("kit %q has more than one package type", e.IntegrationKit.Name)
}
}
+func (t *quarkusTrait) isNativeIntegration(e *Environment) bool {
+ // The current IntegrationKit determines the Integration runtime type
+ return e.IntegrationKit.Labels[v1.IntegrationKitLayoutLabel] == v1.IntegrationKitLayoutNative
+}
+
func getBuilderTask(tasks []v1.Task) *v1.BuilderTask {
for i, task := range tasks {
if task.Builder != nil {