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/02/03 12:12:27 UTC

[camel-k] branch master updated (65272e4 -> fb615c5)

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.


    from 65272e4  fix(OLM): Remove replaces field from Kustomize base CSV manifest
     new 8e97ba7  feat(trait): leverage ConfigMap binary data for resources
     new cfd2ffd  feat(test): binary data integration test
     new d643368  chore(examples): group resources examples
     new b482460  feat(cmd): compress-binary no longer needed
     new c573998  chore(crd): upgrade CRDs
     new fb615c5  chore(examples): remove duplicate examplese

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 config/crd/bases/camel.apache.org_builds.yaml      |  10 ++
 .../crd/bases/camel.apache.org_integrations.yaml   |  20 +++
 .../bases/camel.apache.org_kameletbindings.yaml    |  10 ++
 config/crd/bases/camel.apache.org_kamelets.yaml    |   5 +
 deploy/crd-build.yaml                              |  10 ++
 deploy/crd-integration.yaml                        |  20 +++
 deploy/crd-kamelet-binding.yaml                    |  10 ++
 deploy/crd-kamelet.yaml                            |   5 +
 .../builds.camel.apache.org.crd.yaml               |  10 ++
 .../integrations.camel.apache.org.crd.yaml         |  20 +++
 .../kameletbindings.camel.apache.org.crd.yaml      |  10 ++
 .../kamelets.camel.apache.org.crd.yaml             |   5 +
 .../resources/files/ResourcesBinary.java           |  23 ++-
 .../resources/files/ResourcesText.java             |  14 +-
 .../resources/files}/resources-data.txt            |   0
 e2e/resources/files/resources-data.zip             | Bin 0 -> 199 bytes
 .../java_test.go => resources/resources_test.go}   |  27 ++-
 helm/camel-k/crds/crd-build.yaml                   |  10 ++
 helm/camel-k/crds/crd-integration.yaml             |  20 +++
 helm/camel-k/crds/crd-kamelet-binding.yaml         |  10 ++
 helm/camel-k/crds/crd-kamelet.yaml                 |   5 +
 pkg/apis/camel/v1/common_types.go                  |   2 +
 pkg/cmd/run.go                                     |  48 ++++--
 pkg/cmd/run_test.go                                |  54 +++++-
 pkg/cmd/util_content.go                            |  37 +++--
 pkg/cmd/util_content_test.go                       |  99 +++++++++++
 pkg/cmd/util_dependencies.go                       |   2 +-
 pkg/trait/trait_test.go                            | 185 ++++++++++++++-------
 pkg/trait/trait_types.go                           |  15 +-
 script/Makefile                                    |   4 +
 30 files changed, 563 insertions(+), 127 deletions(-)
 copy examples/polyglot/JavaRoute.java => e2e/resources/files/ResourcesBinary.java (64%)
 copy examples/polyglot/JavaRoute.java => e2e/resources/files/ResourcesText.java (76%)
 copy {examples/basic => e2e/resources/files}/resources-data.txt (100%)
 create mode 100644 e2e/resources/files/resources-data.zip
 copy e2e/{common/languages/java_test.go => resources/resources_test.go} (56%)
 create mode 100644 pkg/cmd/util_content_test.go


[camel-k] 04/06: feat(cmd): compress-binary no longer needed

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit b48246037a75beaa0a1cd12d8bc591f284c70c41
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Jan 29 15:33:17 2021 +0100

    feat(cmd): compress-binary no longer needed
    
    With #1946 we are no longer needing a special `compress-binary` flag
---
 pkg/cmd/run.go      |  2 --
 pkg/cmd/run_test.go | 10 +---------
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 8ac482e..874c443 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -88,7 +88,6 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) (*cobra.Command, *runCmdOptions)
 	cmd.Flags().StringArray("logging-level", nil, "Configure the logging level. e.g. \"--logging-level org.apache.camel=DEBUG\"")
 	cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
 	cmd.Flags().Bool("compression", false, "Enable storage of sources and resources as a compressed binary blobs")
-	cmd.Flags().Bool("compress-binary", true, "Enable compression of sources and resources having a binary content type (to encode them)")
 	cmd.Flags().StringArray("resource", nil, "Add a resource")
 	cmd.Flags().StringArray("open-api", nil, "Add an OpenAPI v2 spec")
 	cmd.Flags().StringArrayP("volume", "v", nil, "Mount a volume into the integration container. E.g \"-v pvcname:/container/path\"")
@@ -108,7 +107,6 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) (*cobra.Command, *runCmdOptions)
 type runCmdOptions struct {
 	*RootCmdOptions `json:"-"`
 	Compression     bool     `mapstructure:"compression" yaml:",omitempty"`
-	CompressBinary  bool     `mapstructure:"compress-binary" yaml:",omitempty"`
 	Wait            bool     `mapstructure:"wait" yaml:",omitempty"`
 	Logs            bool     `mapstructure:"logs" yaml:",omitempty"`
 	Sync            bool     `mapstructure:"sync" yaml:",omitempty"`
diff --git a/pkg/cmd/run_test.go b/pkg/cmd/run_test.go
index 2dda764..eddb32f 100644
--- a/pkg/cmd/run_test.go
+++ b/pkg/cmd/run_test.go
@@ -65,7 +65,6 @@ func TestRunNoFlag(t *testing.T) {
 	assert.Equal(t, false, runCmdOptions.Dev)
 	assert.Equal(t, true, runCmdOptions.UseFlows)
 	assert.Equal(t, false, runCmdOptions.Compression)
-	assert.Equal(t, true, runCmdOptions.CompressBinary)
 	assert.Equal(t, false, runCmdOptions.Save)
 }
 
@@ -75,18 +74,11 @@ func TestRunNonExistingFlag(t *testing.T) {
 	assert.NotNil(t, err)
 }
 
-func TestRunCompressBinaryFlag(t *testing.T) {
-	runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t)
-	_, err := test.ExecuteCommand(rootCmd, cmdRun, "--compress-binary=false", integrationSource)
-	assert.Nil(t, err)
-	assert.Equal(t, false, runCmdOptions.CompressBinary)
-}
-
 func TestRunCompressionFlag(t *testing.T) {
 	runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t)
 	_, err := test.ExecuteCommand(rootCmd, cmdRun, "--compression", integrationSource)
 	assert.Nil(t, err)
-	assert.Equal(t, true, runCmdOptions.CompressBinary)
+	assert.Equal(t, true, runCmdOptions.Compression)
 }
 
 func TestRunConfigMapFlag(t *testing.T) {


[camel-k] 06/06: chore(examples): remove duplicate examplese

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit fb615c514f425bc47d31a755925ba1387b10aa87
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Mon Feb 1 15:19:55 2021 +0100

    chore(examples): remove duplicate examplese
---
 examples/resources/resources-data.txt     |  1 -
 examples/resources/resources-route.groovy | 29 -----------------------------
 2 files changed, 30 deletions(-)

diff --git a/examples/resources/resources-data.txt b/examples/resources/resources-data.txt
deleted file mode 100644
index dff7947..0000000
--- a/examples/resources/resources-data.txt
+++ /dev/null
@@ -1 +0,0 @@
-the file body
\ No newline at end of file
diff --git a/examples/resources/resources-route.groovy b/examples/resources/resources-route.groovy
deleted file mode 100644
index 6f8be44..0000000
--- a/examples/resources/resources-route.groovy
+++ /dev/null
@@ -1,29 +0,0 @@
-// camel-k: language=groovy
-/*
- * 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.
- */
-
-//
-// To run this integrations use:
-//
-//     kamel run --resource examples/resources-data.txt examples/resources-route.groovy
-//
-
-from('timer:resources')
-    .routeId('resources')
-    .setBody()
-        .simple("resource:classpath:resources-data.txt")
-    .log('file content is: ${body}')


[camel-k] 02/06: feat(test): binary data integration test

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit cfd2ffd536314a65821681b2874ad24574bb35e8
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Jan 29 15:26:47 2021 +0100

    feat(test): binary data integration test
    
    * Added integration test for #1946
---
 e2e/resources/files/ResourcesBinary.java |  40 ++++++++++++++++++++++
 e2e/resources/files/ResourcesText.java   |  29 ++++++++++++++++
 e2e/resources/files/resources-data.txt   |   1 +
 e2e/resources/files/resources-data.zip   | Bin 0 -> 199 bytes
 e2e/resources/resources_test.go          |  57 +++++++++++++++++++++++++++++++
 script/Makefile                          |   4 +++
 6 files changed, 131 insertions(+)

diff --git a/e2e/resources/files/ResourcesBinary.java b/e2e/resources/files/ResourcesBinary.java
new file mode 100644
index 0000000..e1dbb55
--- /dev/null
+++ b/e2e/resources/files/ResourcesBinary.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+ 
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class ResourcesBinary extends org.apache.camel.builder.RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        from("file:/etc/camel/resources/i-resource-000/?noop=true")
+                .unmarshal().zipFile()
+                .convertBodyTo(String.class)
+                .process(new ZipEntryProcessor());
+    }
+
+}
+
+class ZipEntryProcessor implements Processor {
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        System.out.println(exchange.getIn().getBody().toString());
+    }
+
+}
\ No newline at end of file
diff --git a/e2e/resources/files/ResourcesText.java b/e2e/resources/files/ResourcesText.java
new file mode 100644
index 0000000..8ae314f
--- /dev/null
+++ b/e2e/resources/files/ResourcesText.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+ 
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class ResourcesText extends org.apache.camel.builder.RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        from("file:/etc/camel/resources/i-resource-000/?noop=true")
+                .log("${body}");
+    }
+
+}
\ No newline at end of file
diff --git a/e2e/resources/files/resources-data.txt b/e2e/resources/files/resources-data.txt
new file mode 100644
index 0000000..dff7947
--- /dev/null
+++ b/e2e/resources/files/resources-data.txt
@@ -0,0 +1 @@
+the file body
\ No newline at end of file
diff --git a/e2e/resources/files/resources-data.zip b/e2e/resources/files/resources-data.zip
new file mode 100644
index 0000000..5c5b80b
Binary files /dev/null and b/e2e/resources/files/resources-data.zip differ
diff --git a/e2e/resources/resources_test.go b/e2e/resources/resources_test.go
new file mode 100644
index 0000000..7625e8e
--- /dev/null
+++ b/e2e/resources/resources_test.go
@@ -0,0 +1,57 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+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 resources
+
+import (
+	"testing"
+
+	. "github.com/apache/camel-k/e2e/support"
+	camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	. "github.com/onsi/gomega"
+	v1 "k8s.io/api/core/v1"
+)
+
+func TestRunResourceExamples(t *testing.T) {
+
+	WithNewTestNamespace(t, func(ns string) {
+		Expect(Kamel("install", "-n", ns).Execute()).Should(BeNil())
+
+		t.Run("run java", func(t *testing.T) {
+			RegisterTestingT(t)
+			Expect(Kamel("run", "-n", ns, "./files/ResourcesText.java", "--resource", "./files/resources-data.txt").Execute()).Should(BeNil())
+			Eventually(IntegrationPodPhase(ns, "resources-text"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "resources-text", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "resources-text"), TestTimeoutShort).Should(ContainSubstring("the file body"))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+		})
+
+		t.Run("run java", func(t *testing.T) {
+			RegisterTestingT(t)
+			Expect(Kamel("run", "-n", ns, "./files/ResourcesBinary.java",
+				"--resource", "./files/resources-data.zip", "-d", "camel-zipfile").Execute()).Should(BeNil())
+			Eventually(IntegrationPodPhase(ns, "resources-binary"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
+			Eventually(IntegrationCondition(ns, "resources-binary", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "resources-binary"), TestTimeoutShort).Should(ContainSubstring("the file body"))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+		})
+	})
+}
diff --git a/script/Makefile b/script/Makefile
index dd94dd9..16893a9 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -161,6 +161,10 @@ test-local: build
 	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" go test -timeout 60m -v ./e2e/local -tags=integration
 	#go test -timeout 60m -v ./e2e/local -tags=integration
 
+test-resources: build
+	STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)" go test -timeout 60m -v ./e2e/resources -tags=integration
+	#go test -timeout 60m -v ./e2e/resources -tags=integration
+
 build-kamel:
 	go build $(GOFLAGS) -o kamel ./cmd/kamel/*.go
 


[camel-k] 03/06: chore(examples): group resources examples

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit d6433681bc4cfd09a6b827778962baf732325c61
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Jan 29 15:27:44 2021 +0100

    chore(examples): group resources examples
---
 examples/resources/resources-data.txt     |  1 +
 examples/resources/resources-route.groovy | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/examples/resources/resources-data.txt b/examples/resources/resources-data.txt
new file mode 100644
index 0000000..dff7947
--- /dev/null
+++ b/examples/resources/resources-data.txt
@@ -0,0 +1 @@
+the file body
\ No newline at end of file
diff --git a/examples/resources/resources-route.groovy b/examples/resources/resources-route.groovy
new file mode 100644
index 0000000..6f8be44
--- /dev/null
+++ b/examples/resources/resources-route.groovy
@@ -0,0 +1,29 @@
+// camel-k: language=groovy
+/*
+ * 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.
+ */
+
+//
+// To run this integrations use:
+//
+//     kamel run --resource examples/resources-data.txt examples/resources-route.groovy
+//
+
+from('timer:resources')
+    .routeId('resources')
+    .setBody()
+        .simple("resource:classpath:resources-data.txt")
+    .log('file content is: ${body}')


[camel-k] 01/06: feat(trait): leverage ConfigMap binary data for resources

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 8e97ba7a2e7cdd2ec808198c52dc5b8a7e288121
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Jan 29 15:25:38 2021 +0100

    feat(trait): leverage ConfigMap binary data for resources
    
    * Any binary data will be using BinaryData ConfiMap instead of Data. We let the cluster to encode/decode the resource
    * Any text resource will be still using the Data (plain) ConfigMap
    * The `compression` feature can be run both on binary and text resources, providing a base64 encoded file.
    * Added unit test to check all the possible scenarios
    
    Close #1946, close #1881
---
 pkg/apis/camel/v1/common_types.go |   2 +
 pkg/cmd/run.go                    |  46 +++++++---
 pkg/cmd/run_test.go               |  44 +++++++++
 pkg/cmd/util_content.go           |  37 +++++---
 pkg/cmd/util_content_test.go      |  99 ++++++++++++++++++++
 pkg/cmd/util_dependencies.go      |   2 +-
 pkg/trait/trait_test.go           | 185 ++++++++++++++++++++++++++------------
 pkg/trait/trait_types.go          |  15 +++-
 8 files changed, 344 insertions(+), 86 deletions(-)

diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go
index b940b2f..2d50208 100644
--- a/pkg/apis/camel/v1/common_types.go
+++ b/pkg/apis/camel/v1/common_types.go
@@ -207,8 +207,10 @@ const (
 type DataSpec struct {
 	Name        string `json:"name,omitempty"`
 	Content     string `json:"content,omitempty"`
+	RawContent  []byte `json:"rawContent,omitempty"`
 	ContentRef  string `json:"contentRef,omitempty"`
 	ContentKey  string `json:"contentKey,omitempty"`
+	ContentType string `json:"contentType,omitempty"`
 	Compression bool   `json:"compression,omitempty"`
 }
 
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 695f01f..8ac482e 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -495,23 +495,20 @@ func (o *runCmdOptions) updateIntegrationCode(c client.Client, sources []string,
 	}
 
 	for _, resource := range o.Resources {
-		data, compressed, err := loadContent(resource, o.Compression, o.CompressBinary)
+		rawData, contentType, err := loadRawContent(resource)
 		if err != nil {
 			return nil, err
 		}
 
-		integration.Spec.AddResources(v1.ResourceSpec{
-			DataSpec: v1.DataSpec{
-				Name:        path.Base(resource),
-				Content:     data,
-				Compression: compressed,
-			},
-			Type: v1.ResourceTypeData,
-		})
+		resourceSpec, err := binaryOrTextResource(path.Base(resource), rawData, contentType, o.Compression)
+		if err != nil {
+			return nil, err
+		}
+		integration.Spec.AddResources(resourceSpec)
 	}
 
 	for _, resource := range o.OpenAPIs {
-		data, compressed, err := loadContent(resource, o.Compression, o.CompressBinary)
+		data, _, compressed, err := loadTextContent(resource, o.Compression)
 		if err != nil {
 			return nil, err
 		}
@@ -623,6 +620,35 @@ func (o *runCmdOptions) updateIntegrationCode(c client.Client, sources []string,
 	return &integration, nil
 }
 
+func binaryOrTextResource(fileName string, data []byte, contentType string, base64Compression bool) (v1.ResourceSpec, error) {
+	resourceSpec := v1.ResourceSpec{
+		DataSpec: v1.DataSpec{
+			Name:        fileName,
+			ContentKey:  fileName,
+			ContentType: contentType,
+			Compression: false,
+		},
+		Type: v1.ResourceTypeData,
+	}
+
+	if !base64Compression && isBinary(contentType) {
+		resourceSpec.RawContent = data
+		return resourceSpec, nil
+	}
+	// either is a text resource or base64 compression is enabled
+	if base64Compression {
+		content, err := compressToString(data)
+		if err != nil {
+			return resourceSpec, err
+		}
+		resourceSpec.Content = content
+		resourceSpec.Compression = true
+	} else {
+		resourceSpec.Content = string(data)
+	}
+	return resourceSpec, nil
+}
+
 func (o *runCmdOptions) GetIntegrationName(sources []string) string {
 	name := ""
 	if o.IntegrationName != "" {
diff --git a/pkg/cmd/run_test.go b/pkg/cmd/run_test.go
index ce9527f..2dda764 100644
--- a/pkg/cmd/run_test.go
+++ b/pkg/cmd/run_test.go
@@ -477,3 +477,47 @@ func TestRunWithSavedValues(t *testing.T) {
 	assert.Nil(t, err)
 	assert.Len(t, runCmdOptions.Sources, 2)
 }*/
+
+func TestRunBinaryResource(t *testing.T) {
+	binaryResourceSpec, err := binaryOrTextResource("file.ext", []byte{1, 2, 3, 4}, "application/octet-stream", false)
+	assert.Nil(t, err)
+	assert.Equal(t, "", binaryResourceSpec.Content)
+	assert.NotNil(t, binaryResourceSpec.RawContent)
+	assert.Equal(t, "file.ext", binaryResourceSpec.Name)
+	assert.Equal(t, "application/octet-stream", binaryResourceSpec.ContentType)
+	assert.False(t, binaryResourceSpec.Compression)
+}
+
+func TestRunBinaryCompressedResource(t *testing.T) {
+	data := []byte{1, 2, 3, 4}
+	base64Compressed, _ := compressToString(data)
+	binaryResourceSpec, err := binaryOrTextResource("file.ext", data, "application/octet-stream", true)
+	assert.Nil(t, err)
+	assert.Equal(t, base64Compressed, binaryResourceSpec.Content)
+	assert.Nil(t, binaryResourceSpec.RawContent)
+	assert.Equal(t, "file.ext", binaryResourceSpec.Name)
+	assert.Equal(t, "application/octet-stream", binaryResourceSpec.ContentType)
+	assert.True(t, binaryResourceSpec.Compression)
+}
+
+func TestRunTextResource(t *testing.T) {
+	textResourceSpec, err := binaryOrTextResource("file.ext", []byte("hello world"), "text/plain", false)
+	assert.Nil(t, err)
+	assert.Equal(t, "hello world", textResourceSpec.Content)
+	assert.Nil(t, textResourceSpec.RawContent)
+	assert.Equal(t, "file.ext", textResourceSpec.Name)
+	assert.Equal(t, "text/plain", textResourceSpec.ContentType)
+	assert.False(t, textResourceSpec.Compression)
+}
+
+func TestRunTextCompressedResource(t *testing.T) {
+	data := []byte("hello horld")
+	base64Compressed, _ := compressToString(data)
+	textResourceSpec, err := binaryOrTextResource("file.ext", []byte("hello horld"), "text/plain", true)
+	assert.Nil(t, err)
+	assert.Equal(t, base64Compressed, textResourceSpec.Content)
+	assert.Nil(t, textResourceSpec.RawContent)
+	assert.Equal(t, "file.ext", textResourceSpec.Name)
+	assert.Equal(t, "text/plain", textResourceSpec.ContentType)
+	assert.True(t, textResourceSpec.Compression)
+}
diff --git a/pkg/cmd/util_content.go b/pkg/cmd/util_content.go
index c210870..7950e44 100644
--- a/pkg/cmd/util_content.go
+++ b/pkg/cmd/util_content.go
@@ -26,7 +26,7 @@ import (
 	"strings"
 )
 
-func loadContent(source string, compress bool, compressBinary bool) (string, bool, error) {
+func loadRawContent(source string) ([]byte, string, error) {
 	var content []byte
 	var err error
 
@@ -35,7 +35,7 @@ func loadContent(source string, compress bool, compressBinary bool) (string, boo
 	} else {
 		u, err := url.Parse(source)
 		if err != nil {
-			return "", false, err
+			return nil, "", err
 		}
 
 		switch u.Scheme {
@@ -46,27 +46,36 @@ func loadContent(source string, compress bool, compressBinary bool) (string, boo
 		case "https":
 			content, err = loadContentHTTP(u)
 		default:
-			return "", false, fmt.Errorf("unsupported scheme %s", u.Scheme)
+			return nil, "", fmt.Errorf("unsupported scheme %s", u.Scheme)
 		}
 	}
 
 	if err != nil {
-		return "", false, err
+		return nil, "", err
 	}
-	doCompress := compress
-	if !doCompress && compressBinary {
-		contentType := http.DetectContentType(content)
-		if strings.HasPrefix(contentType, "application/octet-stream") {
-			doCompress = true
-		}
+
+	contentType := http.DetectContentType(content)
+	return content, contentType, nil
+}
+
+func isBinary(contentType string) bool {
+	// According the http.DetectContentType method
+	// also json and other "text" application mime types would be reported as text
+	return !strings.HasPrefix(contentType, "text")
+}
+
+func loadTextContent(source string, base64Compression bool) (string, string, bool, error) {
+	content, contentType, err := loadRawContent(source)
+	if err != nil {
+		return "", "", false, err
 	}
 
-	if doCompress {
-		answer, err := compressToString(content)
-		return answer, true, err
+	if base64Compression {
+		base64Compressed, err := compressToString(content)
+		return base64Compressed, contentType, true, err
 	}
 
-	return string(content), false, nil
+	return string(content), contentType, false, nil
 }
 
 func loadContentHTTP(u *url.URL) ([]byte, error) {
diff --git a/pkg/cmd/util_content_test.go b/pkg/cmd/util_content_test.go
new file mode 100644
index 0000000..10d6610
--- /dev/null
+++ b/pkg/cmd/util_content_test.go
@@ -0,0 +1,99 @@
+/*
+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 cmd
+
+import (
+	"io/ioutil"
+	"os"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestRawContentFileMissing(t *testing.T) {
+	_, _, err := loadRawContent("dsadas")
+	assert.NotNil(t, err)
+}
+
+func TestRawBinaryContentType(t *testing.T) {
+	var tmpFile *os.File
+	var err error
+	if tmpFile, err = ioutil.TempFile("", "camel-k-*.json"); err != nil {
+		t.Error(err)
+	}
+	assert.Nil(t, tmpFile.Close())
+	assert.Nil(t, ioutil.WriteFile(tmpFile.Name(), []byte{1, 2, 3, 4, 5, 6}, 0644))
+
+	data, contentType, err := loadRawContent(tmpFile.Name())
+	assert.Nil(t, err)
+	assert.Equal(t, []byte{1, 2, 3, 4, 5, 6}, data)
+	assert.True(t, isBinary(contentType))
+}
+
+func TestRawApplicationContentType(t *testing.T) {
+	var tmpFile *os.File
+	var err error
+	if tmpFile, err = ioutil.TempFile("", "camel-k-*.json"); err != nil {
+		t.Error(err)
+	}
+	assert.Nil(t, tmpFile.Close())
+	assert.Nil(t, ioutil.WriteFile(tmpFile.Name(), []byte(`{"hello":"world"}`), 0644))
+
+	data, contentType, err := loadRawContent(tmpFile.Name())
+	assert.Nil(t, err)
+	assert.Equal(t, `{"hello":"world"}`, string(data))
+	assert.False(t, isBinary(contentType))
+}
+
+func TestTextContentType(t *testing.T) {
+	var tmpFile *os.File
+	var err error
+	if tmpFile, err = ioutil.TempFile("", "camel-k-*.json"); err != nil {
+		t.Error(err)
+	}
+	assert.Nil(t, tmpFile.Close())
+	assert.Nil(t, ioutil.WriteFile(tmpFile.Name(), []byte(`{"hello":"world"}`), 0644))
+
+	data, contentType, compressed, err := loadTextContent(tmpFile.Name(), false)
+	assert.Nil(t, err)
+	assert.Equal(t, `{"hello":"world"}`, string(data))
+	assert.False(t, isBinary(contentType))
+	assert.False(t, compressed)
+}
+
+func TestTextCompressed(t *testing.T) {
+	var tmpFile *os.File
+	var err error
+	if tmpFile, err = ioutil.TempFile("", "camel-k-*.json"); err != nil {
+		t.Error(err)
+	}
+	assert.Nil(t, tmpFile.Close())
+	assert.Nil(t, ioutil.WriteFile(tmpFile.Name(), []byte(`{"hello":"world"}`), 0644))
+
+	data, contentType, compressed, err := loadTextContent(tmpFile.Name(), true)
+	assert.Nil(t, err)
+	assert.NotEqual(t, `{"hello":"world"}`, string(data))
+	assert.False(t, isBinary(contentType))
+	assert.True(t, compressed)
+}
+
+func TestIsBinary(t *testing.T) {
+	assert.True(t, isBinary("image/jpeg"))
+	assert.True(t, isBinary("application/zip"))
+	assert.False(t, isBinary("text/plain"))
+}
diff --git a/pkg/cmd/util_dependencies.go b/pkg/cmd/util_dependencies.go
index 94cc757..f987aa7 100644
--- a/pkg/cmd/util_dependencies.go
+++ b/pkg/cmd/util_dependencies.go
@@ -81,7 +81,7 @@ func getTopLevelDependencies(catalog *camel.RuntimeCatalog, args []string) ([]st
 
 	// Invoke the dependency inspector code for each source file
 	for _, source := range args {
-		data, _, err := loadContent(source, false, false)
+		data, _, _, err := loadTextContent(source, false)
 		if err != nil {
 			return []string{}, err
 		}
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index 6336fd7..2b4f2a0 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -207,65 +207,7 @@ func TestTraitHierarchyDecode(t *testing.T) {
 	assert.Equal(t, 15, *kns.Target)
 }
 
-func TestConfigureVolumesAndMountsSources(t *testing.T) {
-	env := Environment{
-		Resources: kubernetes.NewCollection(),
-		Integration: &v1.Integration{
-			ObjectMeta: metav1.ObjectMeta{
-				Name:      TestDeploymentName,
-				Namespace: "ns",
-			},
-			Spec: v1.IntegrationSpec{
-				Sources: []v1.SourceSpec{
-					{
-						DataSpec: v1.DataSpec{
-							Name:       "source1.java",
-							ContentRef: "my-cm1",
-							ContentKey: "source1.java",
-						},
-						Type: "data",
-					},
-					{
-						DataSpec: v1.DataSpec{
-							Name:       "source2.java",
-							ContentRef: "my-cm2",
-						},
-						Type: "data",
-					},
-				},
-			},
-		},
-	}
-
-	vols := make([]corev1.Volume, 0)
-	mnts := make([]corev1.VolumeMount, 0)
-
-	env.Resources.AddAll(env.ComputeConfigMaps())
-	env.ConfigureVolumesAndMounts(&vols, &mnts)
-
-	assert.Len(t, vols, 2)
-	assert.Len(t, mnts, 2)
-
-	v := findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "my-cm1" })
-	assert.NotNil(t, v)
-	assert.NotNil(t, v.VolumeSource.ConfigMap)
-	assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
-	assert.Equal(t, "source1.java", v.VolumeSource.ConfigMap.Items[0].Key)
-
-	m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == v.Name })
-	assert.NotNil(t, m)
-
-	v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "my-cm2" })
-	assert.NotNil(t, v)
-	assert.NotNil(t, v.VolumeSource.ConfigMap)
-	assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
-	assert.Equal(t, "content", v.VolumeSource.ConfigMap.Items[0].Key)
-
-	m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == v.Name })
-	assert.NotNil(t, m)
-}
-
-func TestConfigureVolumesAndMountsResourcesAndProperties(t *testing.T) {
+func TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) {
 	env := Environment{
 		Resources: kubernetes.NewCollection(),
 		Integration: &v1.Integration{
@@ -425,6 +367,131 @@ func TestConfigureVolumesAndMountsResourcesAndProperties(t *testing.T) {
 	assert.Equal(t, "/foo/bar", m.MountPath)
 }
 
+func TestConfigureVolumesAndMountsSources(t *testing.T) {
+	env := Environment{
+		Resources: kubernetes.NewCollection(),
+		Integration: &v1.Integration{
+			ObjectMeta: metav1.ObjectMeta{
+				Name:      TestDeploymentName,
+				Namespace: "ns",
+			},
+			Spec: v1.IntegrationSpec{
+				Sources: []v1.SourceSpec{
+					{
+						DataSpec: v1.DataSpec{
+							Name:       "source1.java",
+							ContentRef: "my-cm1",
+							ContentKey: "source1.java",
+						},
+						Type: "data",
+					},
+					{
+						DataSpec: v1.DataSpec{
+							Name:       "source2.java",
+							ContentRef: "my-cm2",
+						},
+						Type: "data",
+					},
+				},
+			},
+		},
+	}
+
+	vols := make([]corev1.Volume, 0)
+	mnts := make([]corev1.VolumeMount, 0)
+
+	env.Resources.AddAll(env.ComputeConfigMaps())
+	env.ConfigureVolumesAndMounts(&vols, &mnts)
+
+	assert.Len(t, vols, 2)
+	assert.Len(t, mnts, 2)
+
+	v := findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "my-cm1" })
+	assert.NotNil(t, v)
+	assert.NotNil(t, v.VolumeSource.ConfigMap)
+	assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
+	assert.Equal(t, "source1.java", v.VolumeSource.ConfigMap.Items[0].Key)
+
+	m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == v.Name })
+	assert.NotNil(t, m)
+
+	v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "my-cm2" })
+	assert.NotNil(t, v)
+	assert.NotNil(t, v.VolumeSource.ConfigMap)
+	assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
+	assert.Equal(t, "content", v.VolumeSource.ConfigMap.Items[0].Key)
+
+	m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == v.Name })
+	assert.NotNil(t, m)
+}
+
+func TestConfigureVolumesAndMountsBinaryAndTextResources(t *testing.T) {
+	env := Environment{
+		Resources: kubernetes.NewCollection(),
+		Integration: &v1.Integration{
+			ObjectMeta: metav1.ObjectMeta{
+				Name:      TestDeploymentName,
+				Namespace: "ns",
+			},
+			Spec: v1.IntegrationSpec{
+				Resources: []v1.ResourceSpec{
+					{
+						DataSpec: v1.DataSpec{
+							Name:        "res1.bin",
+							RawContent:  []byte{1, 2, 3, 4},
+							ContentRef:  "my-cm1",
+							ContentKey:  "my-binary",
+							ContentType: "application/octet-stream",
+						},
+						Type: "data",
+					},
+					{
+						DataSpec: v1.DataSpec{
+							Name:        "res2.txt",
+							ContentRef:  "my-cm2",
+							Content:     "hello",
+							ContentKey:  "my-text",
+							ContentType: "text/plain",
+						},
+						Type: "data",
+					},
+				},
+			},
+		},
+	}
+
+	vols := make([]corev1.Volume, 0)
+	mnts := make([]corev1.VolumeMount, 0)
+
+	env.Resources.AddAll(env.ComputeConfigMaps())
+	env.ConfigureVolumesAndMounts(&vols, &mnts)
+
+	assert.Len(t, vols, 2)
+	assert.Len(t, mnts, 2)
+
+	v := findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "my-cm1" })
+	assert.NotNil(t, v)
+	assert.NotNil(t, v.VolumeSource.ConfigMap)
+	assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
+	assert.Equal(t, "my-binary", v.VolumeSource.ConfigMap.Items[0].Key)
+	assert.Equal(t, "res1.bin", v.VolumeSource.ConfigMap.Items[0].Path)
+
+	m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == v.Name })
+	assert.NotNil(t, m)
+	assert.Equal(t, "/etc/camel/resources/i-resource-000", m.MountPath)
+
+	v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "my-cm2" })
+	assert.NotNil(t, v)
+	assert.NotNil(t, v.VolumeSource.ConfigMap)
+	assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
+	assert.Equal(t, "my-text", v.VolumeSource.ConfigMap.Items[0].Key)
+	assert.Equal(t, "res2.txt", v.VolumeSource.ConfigMap.Items[0].Path)
+
+	m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == v.Name })
+	assert.NotNil(t, m)
+	assert.Equal(t, "/etc/camel/resources/i-resource-001", m.MountPath)
+}
+
 func TestOnlySomeTraitsInfluenceBuild(t *testing.T) {
 	c := NewTraitTestCatalog()
 	buildTraits := []string{"builder", "quarkus"}
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index e896b3b..10a99c0 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -464,9 +464,20 @@ func (e *Environment) ComputeConfigMaps() []runtime.Object {
 					"camel.apache.org/resource.compression": strconv.FormatBool(r.Compression),
 				},
 			},
-			Data: map[string]string{
+		}
+
+		if r.ContentType != "" {
+			cm.Annotations["camel.apache.org/resource.content-type"] = r.ContentType
+		}
+
+		if r.RawContent != nil {
+			cm.BinaryData = map[string][]byte{
+				cmKey: []byte(r.RawContent),
+			}
+		} else {
+			cm.Data = map[string]string{
 				cmKey: r.Content,
-			},
+			}
 		}
 
 		maps = append(maps, &cm)


[camel-k] 05/06: chore(crd): upgrade CRDs

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit c573998984b539093ba668c0987a64c753fb5197
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Mon Feb 1 15:19:55 2021 +0100

    chore(crd): upgrade CRDs
    
    Include rawContent and contentType for resources
    
    Ref #1946
---
 config/crd/bases/camel.apache.org_builds.yaml        | 10 ++++++++++
 config/crd/bases/camel.apache.org_integrations.yaml  | 20 ++++++++++++++++++++
 .../crd/bases/camel.apache.org_kameletbindings.yaml  | 10 ++++++++++
 config/crd/bases/camel.apache.org_kamelets.yaml      |  5 +++++
 deploy/crd-build.yaml                                | 10 ++++++++++
 deploy/crd-integration.yaml                          | 20 ++++++++++++++++++++
 deploy/crd-kamelet-binding.yaml                      | 10 ++++++++++
 deploy/crd-kamelet.yaml                              |  5 +++++
 .../1.4.0-snapshot/builds.camel.apache.org.crd.yaml  | 10 ++++++++++
 .../integrations.camel.apache.org.crd.yaml           | 20 ++++++++++++++++++++
 .../kameletbindings.camel.apache.org.crd.yaml        | 10 ++++++++++
 .../kamelets.camel.apache.org.crd.yaml               |  5 +++++
 helm/camel-k/crds/crd-build.yaml                     | 10 ++++++++++
 helm/camel-k/crds/crd-integration.yaml               | 20 ++++++++++++++++++++
 helm/camel-k/crds/crd-kamelet-binding.yaml           | 10 ++++++++++
 helm/camel-k/crds/crd-kamelet.yaml                   |  5 +++++
 16 files changed, 180 insertions(+)

diff --git a/config/crd/bases/camel.apache.org_builds.yaml b/config/crd/bases/camel.apache.org_builds.yaml
index b657821..7d732ef 100644
--- a/config/crd/bases/camel.apache.org_builds.yaml
+++ b/config/crd/bases/camel.apache.org_builds.yaml
@@ -828,10 +828,15 @@ spec:
                                 type: string
                               contentRef:
                                 type: string
+                              contentType:
+                                type: string
                               mountPath:
                                 type: string
                               name:
                                 type: string
+                              rawContent:
+                                format: byte
+                                type: string
                               type:
                                 description: ResourceType --
                                 type: string
@@ -911,6 +916,8 @@ spec:
                                 type: string
                               contentRef:
                                 type: string
+                              contentType:
+                                type: string
                               interceptors:
                                 description: Interceptors are optional identifiers
                                   the org.apache.camel.k.RoutesLoader uses to pre/post
@@ -933,6 +940,9 @@ spec:
                                 items:
                                   type: string
                                 type: array
+                              rawContent:
+                                format: byte
+                                type: string
                               type:
                                 description: Type defines the kind of source described
                                   by this object
diff --git a/config/crd/bases/camel.apache.org_integrations.yaml b/config/crd/bases/camel.apache.org_integrations.yaml
index 0979d4a..16178af 100644
--- a/config/crd/bases/camel.apache.org_integrations.yaml
+++ b/config/crd/bases/camel.apache.org_integrations.yaml
@@ -120,10 +120,15 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     mountPath:
                       type: string
                     name:
                       type: string
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: ResourceType --
                       type: string
@@ -143,6 +148,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -164,6 +171,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
@@ -285,10 +295,15 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     mountPath:
                       type: string
                     name:
                       type: string
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: ResourceType --
                       type: string
@@ -306,6 +321,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -327,6 +344,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
diff --git a/config/crd/bases/camel.apache.org_kameletbindings.yaml b/config/crd/bases/camel.apache.org_kameletbindings.yaml
index 70b5acb..2c95ef4 100644
--- a/config/crd/bases/camel.apache.org_kameletbindings.yaml
+++ b/config/crd/bases/camel.apache.org_kameletbindings.yaml
@@ -116,10 +116,15 @@ spec:
                           type: string
                         contentRef:
                           type: string
+                        contentType:
+                          type: string
                         mountPath:
                           type: string
                         name:
                           type: string
+                        rawContent:
+                          format: byte
+                          type: string
                         type:
                           description: ResourceType --
                           type: string
@@ -139,6 +144,8 @@ spec:
                           type: string
                         contentRef:
                           type: string
+                        contentType:
+                          type: string
                         interceptors:
                           description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                             uses to pre/post process sources
@@ -160,6 +167,9 @@ spec:
                           items:
                             type: string
                           type: array
+                        rawContent:
+                          format: byte
+                          type: string
                         type:
                           description: Type defines the kind of source described by
                             this object
diff --git a/config/crd/bases/camel.apache.org_kamelets.yaml b/config/crd/bases/camel.apache.org_kamelets.yaml
index 377c2b1..b79e7dc 100644
--- a/config/crd/bases/camel.apache.org_kamelets.yaml
+++ b/config/crd/bases/camel.apache.org_kamelets.yaml
@@ -230,6 +230,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -251,6 +253,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
diff --git a/deploy/crd-build.yaml b/deploy/crd-build.yaml
index b657821..7d732ef 100644
--- a/deploy/crd-build.yaml
+++ b/deploy/crd-build.yaml
@@ -828,10 +828,15 @@ spec:
                                 type: string
                               contentRef:
                                 type: string
+                              contentType:
+                                type: string
                               mountPath:
                                 type: string
                               name:
                                 type: string
+                              rawContent:
+                                format: byte
+                                type: string
                               type:
                                 description: ResourceType --
                                 type: string
@@ -911,6 +916,8 @@ spec:
                                 type: string
                               contentRef:
                                 type: string
+                              contentType:
+                                type: string
                               interceptors:
                                 description: Interceptors are optional identifiers
                                   the org.apache.camel.k.RoutesLoader uses to pre/post
@@ -933,6 +940,9 @@ spec:
                                 items:
                                   type: string
                                 type: array
+                              rawContent:
+                                format: byte
+                                type: string
                               type:
                                 description: Type defines the kind of source described
                                   by this object
diff --git a/deploy/crd-integration.yaml b/deploy/crd-integration.yaml
index 0979d4a..16178af 100644
--- a/deploy/crd-integration.yaml
+++ b/deploy/crd-integration.yaml
@@ -120,10 +120,15 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     mountPath:
                       type: string
                     name:
                       type: string
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: ResourceType --
                       type: string
@@ -143,6 +148,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -164,6 +171,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
@@ -285,10 +295,15 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     mountPath:
                       type: string
                     name:
                       type: string
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: ResourceType --
                       type: string
@@ -306,6 +321,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -327,6 +344,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
diff --git a/deploy/crd-kamelet-binding.yaml b/deploy/crd-kamelet-binding.yaml
index 70b5acb..2c95ef4 100644
--- a/deploy/crd-kamelet-binding.yaml
+++ b/deploy/crd-kamelet-binding.yaml
@@ -116,10 +116,15 @@ spec:
                           type: string
                         contentRef:
                           type: string
+                        contentType:
+                          type: string
                         mountPath:
                           type: string
                         name:
                           type: string
+                        rawContent:
+                          format: byte
+                          type: string
                         type:
                           description: ResourceType --
                           type: string
@@ -139,6 +144,8 @@ spec:
                           type: string
                         contentRef:
                           type: string
+                        contentType:
+                          type: string
                         interceptors:
                           description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                             uses to pre/post process sources
@@ -160,6 +167,9 @@ spec:
                           items:
                             type: string
                           type: array
+                        rawContent:
+                          format: byte
+                          type: string
                         type:
                           description: Type defines the kind of source described by
                             this object
diff --git a/deploy/crd-kamelet.yaml b/deploy/crd-kamelet.yaml
index 377c2b1..b79e7dc 100644
--- a/deploy/crd-kamelet.yaml
+++ b/deploy/crd-kamelet.yaml
@@ -230,6 +230,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -251,6 +253,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
diff --git a/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/builds.camel.apache.org.crd.yaml b/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/builds.camel.apache.org.crd.yaml
index b657821..7d732ef 100644
--- a/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/builds.camel.apache.org.crd.yaml
+++ b/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/builds.camel.apache.org.crd.yaml
@@ -828,10 +828,15 @@ spec:
                                 type: string
                               contentRef:
                                 type: string
+                              contentType:
+                                type: string
                               mountPath:
                                 type: string
                               name:
                                 type: string
+                              rawContent:
+                                format: byte
+                                type: string
                               type:
                                 description: ResourceType --
                                 type: string
@@ -911,6 +916,8 @@ spec:
                                 type: string
                               contentRef:
                                 type: string
+                              contentType:
+                                type: string
                               interceptors:
                                 description: Interceptors are optional identifiers
                                   the org.apache.camel.k.RoutesLoader uses to pre/post
@@ -933,6 +940,9 @@ spec:
                                 items:
                                   type: string
                                 type: array
+                              rawContent:
+                                format: byte
+                                type: string
                               type:
                                 description: Type defines the kind of source described
                                   by this object
diff --git a/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/integrations.camel.apache.org.crd.yaml b/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/integrations.camel.apache.org.crd.yaml
index 0979d4a..16178af 100644
--- a/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/integrations.camel.apache.org.crd.yaml
+++ b/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/integrations.camel.apache.org.crd.yaml
@@ -120,10 +120,15 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     mountPath:
                       type: string
                     name:
                       type: string
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: ResourceType --
                       type: string
@@ -143,6 +148,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -164,6 +171,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
@@ -285,10 +295,15 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     mountPath:
                       type: string
                     name:
                       type: string
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: ResourceType --
                       type: string
@@ -306,6 +321,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -327,6 +344,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
diff --git a/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/kameletbindings.camel.apache.org.crd.yaml b/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/kameletbindings.camel.apache.org.crd.yaml
index 70b5acb..2c95ef4 100644
--- a/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/kameletbindings.camel.apache.org.crd.yaml
+++ b/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/kameletbindings.camel.apache.org.crd.yaml
@@ -116,10 +116,15 @@ spec:
                           type: string
                         contentRef:
                           type: string
+                        contentType:
+                          type: string
                         mountPath:
                           type: string
                         name:
                           type: string
+                        rawContent:
+                          format: byte
+                          type: string
                         type:
                           description: ResourceType --
                           type: string
@@ -139,6 +144,8 @@ spec:
                           type: string
                         contentRef:
                           type: string
+                        contentType:
+                          type: string
                         interceptors:
                           description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                             uses to pre/post process sources
@@ -160,6 +167,9 @@ spec:
                           items:
                             type: string
                           type: array
+                        rawContent:
+                          format: byte
+                          type: string
                         type:
                           description: Type defines the kind of source described by
                             this object
diff --git a/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/kamelets.camel.apache.org.crd.yaml b/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/kamelets.camel.apache.org.crd.yaml
index 377c2b1..b79e7dc 100644
--- a/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/kamelets.camel.apache.org.crd.yaml
+++ b/deploy/olm-catalog/camel-k-dev/1.4.0-snapshot/kamelets.camel.apache.org.crd.yaml
@@ -230,6 +230,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -251,6 +253,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
diff --git a/helm/camel-k/crds/crd-build.yaml b/helm/camel-k/crds/crd-build.yaml
index b657821..7d732ef 100644
--- a/helm/camel-k/crds/crd-build.yaml
+++ b/helm/camel-k/crds/crd-build.yaml
@@ -828,10 +828,15 @@ spec:
                                 type: string
                               contentRef:
                                 type: string
+                              contentType:
+                                type: string
                               mountPath:
                                 type: string
                               name:
                                 type: string
+                              rawContent:
+                                format: byte
+                                type: string
                               type:
                                 description: ResourceType --
                                 type: string
@@ -911,6 +916,8 @@ spec:
                                 type: string
                               contentRef:
                                 type: string
+                              contentType:
+                                type: string
                               interceptors:
                                 description: Interceptors are optional identifiers
                                   the org.apache.camel.k.RoutesLoader uses to pre/post
@@ -933,6 +940,9 @@ spec:
                                 items:
                                   type: string
                                 type: array
+                              rawContent:
+                                format: byte
+                                type: string
                               type:
                                 description: Type defines the kind of source described
                                   by this object
diff --git a/helm/camel-k/crds/crd-integration.yaml b/helm/camel-k/crds/crd-integration.yaml
index 0979d4a..16178af 100644
--- a/helm/camel-k/crds/crd-integration.yaml
+++ b/helm/camel-k/crds/crd-integration.yaml
@@ -120,10 +120,15 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     mountPath:
                       type: string
                     name:
                       type: string
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: ResourceType --
                       type: string
@@ -143,6 +148,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -164,6 +171,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
@@ -285,10 +295,15 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     mountPath:
                       type: string
                     name:
                       type: string
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: ResourceType --
                       type: string
@@ -306,6 +321,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -327,6 +344,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object
diff --git a/helm/camel-k/crds/crd-kamelet-binding.yaml b/helm/camel-k/crds/crd-kamelet-binding.yaml
index 70b5acb..2c95ef4 100644
--- a/helm/camel-k/crds/crd-kamelet-binding.yaml
+++ b/helm/camel-k/crds/crd-kamelet-binding.yaml
@@ -116,10 +116,15 @@ spec:
                           type: string
                         contentRef:
                           type: string
+                        contentType:
+                          type: string
                         mountPath:
                           type: string
                         name:
                           type: string
+                        rawContent:
+                          format: byte
+                          type: string
                         type:
                           description: ResourceType --
                           type: string
@@ -139,6 +144,8 @@ spec:
                           type: string
                         contentRef:
                           type: string
+                        contentType:
+                          type: string
                         interceptors:
                           description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                             uses to pre/post process sources
@@ -160,6 +167,9 @@ spec:
                           items:
                             type: string
                           type: array
+                        rawContent:
+                          format: byte
+                          type: string
                         type:
                           description: Type defines the kind of source described by
                             this object
diff --git a/helm/camel-k/crds/crd-kamelet.yaml b/helm/camel-k/crds/crd-kamelet.yaml
index 377c2b1..b79e7dc 100644
--- a/helm/camel-k/crds/crd-kamelet.yaml
+++ b/helm/camel-k/crds/crd-kamelet.yaml
@@ -230,6 +230,8 @@ spec:
                       type: string
                     contentRef:
                       type: string
+                    contentType:
+                      type: string
                     interceptors:
                       description: Interceptors are optional identifiers the org.apache.camel.k.RoutesLoader
                         uses to pre/post process sources
@@ -251,6 +253,9 @@ spec:
                       items:
                         type: string
                       type: array
+                    rawContent:
+                      format: byte
+                      type: string
                     type:
                       description: Type defines the kind of source described by this
                         object