This is an automated email from the ASF dual-hosted git repository. nferraro pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit bd8fc7b82787470343fb47b666cd6045b5643441 Author: Nicola Ferraro <ni.ferr...@gmail.com> AuthorDate: Wed May 20 14:03:02 2020 +0200 https://github.com/apache/camel-k-runtime/issues/224: enable cron capability in quarkus --- deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml | 2 +- deploy/resources.go | 2 +- pkg/trait/cron.go | 21 +++++++++------------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml b/deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml index 1c39eda..abd1b1b 100644 --- a/deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml +++ b/deploy/camel-catalog-1.3.0-SNAPSHOT-quarkus.yaml @@ -41,7 +41,7 @@ spec: cron: dependencies: - groupId: org.apache.camel.k - artifactId: camel-k-runtime-cron + artifactId: camel-k-quarkus-cron health: dependencies: - groupId: org.apache.camel.quarkus diff --git a/deploy/resources.go b/deploy/resources.go index e884007..45906b5 100644 --- a/deploy/resources.go +++ b/deploy/resources.go @@ -100,7 +100,7 @@ var assets = func() http.FileSystem { modTime: time.Time{}, uncompressedSize: 47185, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x7d\x5d\x73\xdc\x2a\xf2\xf7\xbd\x3f\x05\x15\xdf\xec\x56\x1d\x71\xce\x3a\xbb\xfb\x54\xe5\xb9\xb2\x9d\x38\xb1\x13\x3b\x4e\xc6\x7b\x92\x73\x6e\x52\x8c\xc4\xcc\xe0\x91\x40\x06\x34\x33\xf6\xa7\xff\x17\x08\xbd\x8d\xe5\xd6\x8b\xd1\xf8\xc2\xd2\x88\xe6\xd7\xd0\x20\x68\x75\x37\x70\x8c\x02\x7f\x7f\x47\xc7\xe8\x0b\x0b\x29\x57\x34\x42\x5a\x20\xbd\xa2\xe8\x34\x25\xe1\x8a\xa2\x99\x58\xe8\x2d\x91\x14\x5d\x88\x8c\x47\x44\x33\xc1\x [...] + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x7d\x5d\x73\xdc\x2a\xf2\xf7\xbd\x3f\x05\x15\xdf\xec\x56\x1d\x71\xce\x3a\xbb\xfb\x54\xe5\xb9\xb2\x9d\x38\xb1\x13\x3b\x4e\xc6\x7b\x92\x73\x6e\x52\x8c\xc4\xcc\xe0\x91\x40\x06\x34\x33\xf6\xa7\xff\x17\x08\xbd\x8d\xe5\xd6\x8b\xd1\xf8\xc2\xd2\x88\xe6\xd7\xd0\x20\x68\x75\x37\x70\x8c\x02\x7f\x7f\x47\xc7\xe8\x0b\x0b\x29\x57\x34\x42\x5a\x20\xbd\xa2\xe8\x34\x25\xe1\x8a\xa2\x99\x58\xe8\x2d\x91\x14\x5d\x88\x8c\x47\x44\x33\xc1\x [...] }, "/cr-example.yaml": &vfsgen۰CompressedFileInfo{ name: "cr-example.yaml", diff --git a/pkg/trait/cron.go b/pkg/trait/cron.go index b823df5..853e682 100644 --- a/pkg/trait/cron.go +++ b/pkg/trait/cron.go @@ -91,8 +91,8 @@ type cronInfo struct { type cronExtractor func(string) *cronInfo const ( - genericCronComponent = "cron" - genericCronComponentFallback = "camel:quartz" + genericCronComponent = "cron" + genericCronComponentFallbackScheme = "quartz" ) var ( @@ -165,14 +165,7 @@ func (t *cronTrait) Configure(e *Environment) (bool, error) { t.ConcurrencyPolicy = string(v1beta1.ForbidConcurrent) } - hasQuarkus := false - - qt := e.GetTrait("quarkus") - if qt != nil { - hasQuarkus = qt.(*quarkusTrait).Enabled != nil && *(qt.(*quarkusTrait).Enabled) - } - - if (hasQuarkus || (t.Schedule == "" && t.Components == "")) && t.Fallback == nil { + if (t.Schedule == "" && t.Components == "") && t.Fallback == nil { // If there's at least a `cron` endpoint, add a fallback implementation fromURIs, err := t.getSourcesFromURIs(e) if err != nil { @@ -235,11 +228,15 @@ func (t *cronTrait) Apply(e *Environment) error { util.StringSliceUniqueAdd(&e.Integration.Status.Capabilities, v1.CapabilityCron) if t.Fallback != nil && *t.Fallback { - util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, genericCronComponentFallback) + fallbackArtifact := e.CamelCatalog.GetArtifactByScheme(genericCronComponentFallbackScheme) + if fallbackArtifact == nil { + return fmt.Errorf("no fallback artifact for scheme %q has been found in camel catalog", genericCronComponentFallbackScheme) + } + util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, fallbackArtifact.GetDependencyID()) } } - if e.IntegrationInPhase(v1.IntegrationPhaseDeploying) { + if (t.Fallback == nil || !*t.Fallback) && e.IntegrationInPhase(v1.IntegrationPhaseDeploying) { if e.ApplicationProperties == nil { e.ApplicationProperties = make(map[string]string) }