You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2018/11/09 06:52:59 UTC
[camel-k] 03/03: Add automatic configuration to Knative endpoints
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 28fa60085981963b0c8d5a0624fad307b2aab30b
Author: nferraro <ni...@gmail.com>
AuthorDate: Thu Nov 8 23:41:50 2018 +0100
Add automatic configuration to Knative endpoints
---
pkg/metadata/dependencies.go | 2 +-
pkg/trait/service.go | 13 +++++----
pkg/util/camel/catalog.go | 5 ++++
pkg/util/camel/embedded.go | 32 ++++++++++++++++++++++
.../component/knative/KnativeConfiguration.java | 14 ++++++++++
5 files changed, 60 insertions(+), 6 deletions(-)
diff --git a/pkg/metadata/dependencies.go b/pkg/metadata/dependencies.go
index d207228..5dce778 100644
--- a/pkg/metadata/dependencies.go
+++ b/pkg/metadata/dependencies.go
@@ -54,7 +54,7 @@ func decodeComponent(uri string) string {
uriStart := uriSplit[0]
if component := camel.Runtime.GetArtifactByScheme(uriStart); component != nil {
artifactID := component.ArtifactID
- if strings.HasPrefix(artifactID, "camel-") {
+ if component.GroupID == "org.apache.camel" && strings.HasPrefix(artifactID, "camel-") {
return "camel:" + artifactID[6:]
}
return "mvn:" + component.GroupID + ":" + artifactID + ":" + component.Version
diff --git a/pkg/trait/service.go b/pkg/trait/service.go
index dcb77df..fdd2fa6 100644
--- a/pkg/trait/service.go
+++ b/pkg/trait/service.go
@@ -19,17 +19,20 @@ package trait
import (
"github.com/apache/camel-k/pkg/util/kubernetes"
+ "github.com/apache/camel-k/version"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
var webComponents = map[string]bool{
- "camel:servlet": true,
- "camel:undertow": true,
- "camel:jetty": true,
- "camel:netty-http": true,
- "camel:netty4-http": true,
+ "camel:servlet": true,
+ "camel:undertow": true,
+ "camel:jetty": true,
+ "camel:jetty9": true,
+ "camel:netty-http": true,
+ "camel:netty4-http": true,
+ "mvn:org.apache.camel.k:camel-knative:" + version.Version: true,
// TODO find a better way to discover need for exposure
// maybe using the resolved classpath of the context instead of the requested dependencies
}
diff --git a/pkg/util/camel/catalog.go b/pkg/util/camel/catalog.go
index fd148a1..5c0c8ab 100644
--- a/pkg/util/camel/catalog.go
+++ b/pkg/util/camel/catalog.go
@@ -44,6 +44,11 @@ func init() {
if err := yaml.Unmarshal([]byte(data), &Runtime); err != nil {
panic(err)
}
+ // Adding embedded artifacts
+ for k, v := range EmbeddedArtifacts() {
+ Runtime.Artifacts[k] = v
+ }
+
Runtime.artifactByScheme = make(map[string]string)
for id, artifact := range Runtime.Artifacts {
for _, scheme := range artifact.Schemes {
diff --git a/pkg/util/camel/embedded.go b/pkg/util/camel/embedded.go
new file mode 100644
index 0000000..392a864
--- /dev/null
+++ b/pkg/util/camel/embedded.go
@@ -0,0 +1,32 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package camel
+
+import "github.com/apache/camel-k/version"
+
+// EmbeddedArtifacts returns a list of artifacts that are shipped directly with Camel K
+func EmbeddedArtifacts() map[string]Artifact {
+ return map[string]Artifact{
+ "camel-knative": {
+ GroupID: "org.apache.camel.k",
+ ArtifactID: "camel-knative",
+ Version: version.Version,
+ Schemes: []string{"knative"},
+ },
+ }
+}
diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java
index cc3fa65..7b29444 100644
--- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java
+++ b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java
@@ -17,15 +17,29 @@
package org.apache.camel.component.knative;
import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.cloud.ServiceDefinition;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriParam;
+import java.util.Arrays;
+
+import static org.apache.camel.util.CollectionHelper.mapOf;
+
public class KnativeConfiguration implements Cloneable {
@UriParam
@Metadata(required = "true")
private KnativeEnvironment environment;
public KnativeConfiguration() {
+ this.environment = new KnativeEnvironment(Arrays.asList(
+ new KnativeEnvironment.KnativeServiceDefinition(
+ Knative.Type.endpoint,
+ Knative.Protocol.http,
+ "default",
+ "0.0.0.0",
+ 8080,
+ mapOf(ServiceDefinition.SERVICE_META_PATH, "/"))
+ ));
}
// ************************