Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync main with the latest changes from camel-main #2426

Merged
merged 15 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build/maven/pom-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<artifactId>camel-k-catalog-generator</artifactId>
<version>1.0.0</version>

<properties>
<exclusion.list>qute</exclusion.list>
</properties>

<build>
<defaultGoal>generate-resources</defaultGoal>
<plugins>
Expand Down
22 changes: 0 additions & 22 deletions build/maven/pom-runtime.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,6 @@
<artifactId>camel-k-kamelet-reify-deployment</artifactId>
<version>${runtime.version}</version>
</dependency>

<!-- loaders -->
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-loader-groovy</artifactId>
<version>${runtime.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-loader-groovy-deployment</artifactId>
<version>${runtime.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-loader-yaml</artifactId>
<version>${runtime.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-loader-yaml-deployment</artifactId>
<version>${runtime.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-core-support</artifactId>
Expand Down
8 changes: 6 additions & 2 deletions config/crd/bases/camel.apache.org_kamelets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ spec:
type: string
type: array
flow:
description: Flow is an unstructured object representing a Camel Flow
in YAML/JSON DSL
description: 'Deprecated: use template'
type: object
x-kubernetes-preserve-unknown-fields: true
sources:
Expand Down Expand Up @@ -264,6 +263,11 @@ spec:
type: string
type: object
type: array
template:
description: Template is an unstructured object representing a Kamelet
template in YAML/JSON DSL
type: object
x-kubernetes-preserve-unknown-fields: true
types:
additionalProperties:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ spec:
type: string
type: array
flow:
description: Flow is an unstructured object representing a Camel Flow
in YAML/JSON DSL
description: 'Deprecated: use template'
type: object
x-kubernetes-preserve-unknown-fields: true
sources:
Expand Down Expand Up @@ -264,6 +263,11 @@ spec:
type: string
type: object
type: array
template:
description: Template is an unstructured object representing a Kamelet
template in YAML/JSON DSL
type: object
x-kubernetes-preserve-unknown-fields: true
types:
additionalProperties:
properties:
Expand Down
6 changes: 3 additions & 3 deletions e2e/knative/knative_platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

. "github.com/apache/camel-k/e2e/support"
"github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/util/flow"
"github.com/apache/camel-k/pkg/util/dsl"
"github.com/apache/camel-k/pkg/util/knative"
)

Expand All @@ -57,10 +57,10 @@ func TestKnativePlatform(t *testing.T) {
// Change something in the integration to produce a redeploy
Expect(UpdateIntegration(ns, "yaml", func(it *v1.Integration) {
it.Spec.Profile = ""
content, err := flow.ToYamlDSL(it.Spec.Flows)
content, err := dsl.ToYamlDSL(it.Spec.Flows)
assert.NoError(t, err)
newData := strings.ReplaceAll(string(content), "string!", "string!!!")
newFlows, err := flow.FromYamlDSLString(newData)
newFlows, err := dsl.FromYamlDSLString(newData)
assert.NoError(t, err)
it.Spec.Flows = newFlows
})).To(Succeed())
Expand Down
37 changes: 37 additions & 0 deletions e2e/yaks/common/kamelet-beans/beans-source.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------

apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: beans-source
labels:
camel.apache.org/kamelet.type: "source"
spec:
template:
beans:
- name: myBean
type: "#class:java.util.Date"
property:
- key: time
value: 0
from:
uri: timer:tick
steps:
- set-body:
simple: "Bean time is ${bean:{{myBean}}?method=getTime}!"
- to: "kamelet:sink"
15 changes: 15 additions & 0 deletions e2e/yaks/common/kamelet-beans/kamelet.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Feature: Kamelets can declare local beans

Background:
Given Disable auto removal of Kamelet resources
Given Disable auto removal of Kubernetes resources
Given Camel-K resource polling configuration
| maxAttempts | 40 |
| delayBetweenAttempts | 3000 |

Scenario: Kamelets templates can use beans
Given bind Kamelet beans-source to uri log:info
When create KameletBinding binding
Then KameletBinding binding should be available
Then Camel-K integration binding should be running
Then Camel-K integration binding should print Bean time is 0!
26 changes: 26 additions & 0 deletions e2e/yaks/common/kamelet-beans/yaks-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------

config:
namespace:
temporary: true
pre:
- name: installation
run: |
kamel install -n $YAKS_NAMESPACE

kubectl apply -f beans-source.kamelet.yaml -n $YAKS_NAMESPACE
8 changes: 6 additions & 2 deletions helm/camel-k/crds/crd-kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ spec:
type: string
type: array
flow:
description: Flow is an unstructured object representing a Camel Flow
in YAML/JSON DSL
description: 'Deprecated: use template'
type: object
x-kubernetes-preserve-unknown-fields: true
sources:
Expand Down Expand Up @@ -264,6 +263,11 @@ spec:
type: string
type: object
type: array
template:
description: Template is an unstructured object representing a Kamelet
template in YAML/JSON DSL
type: object
x-kubernetes-preserve-unknown-fields: true
types:
additionalProperties:
properties:
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/camel/v1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ type Flow struct {
RawMessage `json:",inline"`
}

// Template is an unstructured object representing a Kamelet template in YAML/JSON DSL
type Template struct {
RawMessage `json:",inline"`
}

// RuntimeProvider --
type RuntimeProvider string

Expand Down
8 changes: 6 additions & 2 deletions pkg/apis/camel/v1alpha1/kamelet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ var (

// KameletSpec defines the desired state of Kamelet
type KameletSpec struct {
Definition *JSONSchemaProps `json:"definition,omitempty"`
Sources []camelv1.SourceSpec `json:"sources,omitempty"`
Definition *JSONSchemaProps `json:"definition,omitempty"`
Sources []camelv1.SourceSpec `json:"sources,omitempty"`
Template *camelv1.Template `json:"template,omitempty"`
// Deprecated: use template
Flow *camelv1.Flow `json:"flow,omitempty"`
Authorization *AuthorizationSpec `json:"authorization,omitempty"`
Types map[EventSlot]EventTypeSpec `json:"types,omitempty"`
Expand Down Expand Up @@ -108,6 +110,8 @@ const (
KameletConditionReasonInvalidName string = "InvalidName"
// KameletConditionReasonInvalidProperty --
KameletConditionReasonInvalidProperty string = "InvalidProperty"
// KameletConditionReasonInvalidTemplate --
KameletConditionReasonInvalidTemplate string = "InvalidTemplate"
)

type KameletPhase string
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/camel/v1alpha1/kamelet_types_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ func ValidKameletProperties(kamelet *Kamelet) bool {
return true
}

func ValidKameletTemplate(kamelet *Kamelet) bool {
if kamelet == nil {
return true
}
if kamelet.Spec.Template != nil && kamelet.Spec.Flow != nil {
return false
}
return true
}

// NewKamelet creates a new kamelet
func NewKamelet(namespace string, name string) Kamelet {
return Kamelet{
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
"github.com/apache/camel-k/pkg/client"
"github.com/apache/camel-k/pkg/trait"
"github.com/apache/camel-k/pkg/util"
"github.com/apache/camel-k/pkg/util/flow"
"github.com/apache/camel-k/pkg/util/dsl"
"github.com/apache/camel-k/pkg/util/kubernetes"
k8slog "github.com/apache/camel-k/pkg/util/kubernetes/log"
"github.com/apache/camel-k/pkg/util/property"
Expand Down Expand Up @@ -531,7 +531,7 @@ func (o *runCmdOptions) createOrUpdateIntegration(c client.Client, sources []str

for _, source := range resolvedSources {
if o.UseFlows && !o.Compression && (strings.HasSuffix(source.Name, ".yaml") || strings.HasSuffix(source.Name, ".yml")) {
flows, err := flow.FromYamlDSLString(source.Content)
flows, err := dsl.FromYamlDSLString(source.Content)
if err != nil {
return nil, err
}
Expand Down
Loading