You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2019/01/04 09:12:01 UTC

[camel-k] branch master updated (94305dd -> 692c4f1)

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

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


    from 94305dd  Adding JSON auto-conversion option
     new 920d3ae  Avoid changing the spec field if not necessary
     new fc708d5  Copy dependencies and context to status
     new 692c4f1  chore(lint): make golangci-lint happy

The 3 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:
 pkg/apis/camel/v1alpha1/types.go                   | 24 +++++++++---
 pkg/apis/camel/v1alpha1/types_support.go           | 15 +++++++-
 .../camel/v1alpha1/types_support_test.go}          | 19 ++++-----
 pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go   | 29 +++++++++++++-
 pkg/client/cmd/get.go                              |  2 +-
 pkg/metadata/http.go                               |  2 +-
 pkg/metadata/languages.go                          | 45 ----------------------
 pkg/metadata/metadata.go                           |  9 +----
 pkg/metadata/types.go                              |  4 --
 pkg/stub/action/context/build.go                   |  2 +-
 pkg/stub/action/integration/build_context.go       | 16 ++++----
 pkg/stub/action/integration/build_image.go         |  4 +-
 pkg/stub/action/integration/deploy.go              |  5 ++-
 pkg/stub/action/integration/initialize.go          | 18 +++------
 pkg/stub/action/integration/monitor.go             |  2 +-
 pkg/stub/action/integration/util.go                |  8 ++--
 pkg/trait/classpath.go                             |  6 +--
 pkg/trait/dependencies.go                          | 23 +++++++----
 pkg/trait/deployment.go                            |  6 +--
 pkg/trait/knative.go                               |  8 ++--
 pkg/trait/springboot.go                            |  4 +-
 pkg/trait/util.go                                  |  4 +-
 pkg/util/source/inspector_xml.go                   |  6 +--
 pkg/util/util.go                                   |  4 ++
 24 files changed, 132 insertions(+), 133 deletions(-)
 rename pkg/{metadata/metadata_languages_test.go => apis/camel/v1alpha1/types_support_test.go} (71%)
 delete mode 100644 pkg/metadata/languages.go


[camel-k] 01/03: Avoid changing the spec field if not necessary

Posted by nf...@apache.org.
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 920d3ae2cb0d6c93270fb0bd3eb9908d3824bb12
Author: nferraro <ni...@gmail.com>
AuthorDate: Mon Dec 24 15:05:37 2018 +0100

    Avoid changing the spec field if not necessary
---
 pkg/apis/camel/v1alpha1/types.go                   | 11 ++++++
 pkg/apis/camel/v1alpha1/types_support.go           | 13 +++++++
 .../camel/v1alpha1/types_support_test.go}          | 19 ++++-----
 pkg/metadata/http.go                               |  2 +-
 pkg/metadata/languages.go                          | 45 ----------------------
 pkg/metadata/metadata.go                           |  9 +----
 pkg/metadata/types.go                              |  4 --
 pkg/stub/action/integration/initialize.go          | 14 +------
 pkg/trait/dependencies.go                          |  2 +-
 pkg/trait/deployment.go                            |  6 +--
 pkg/trait/knative.go                               |  4 +-
 11 files changed, 41 insertions(+), 88 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/types.go b/pkg/apis/camel/v1alpha1/types.go
index 9951e3f..6df4c30 100644
--- a/pkg/apis/camel/v1alpha1/types.go
+++ b/pkg/apis/camel/v1alpha1/types.go
@@ -137,6 +137,17 @@ const (
 	LanguageYamlFlow Language = "flow"
 )
 
+// Languages is the list of all supported languages
+var Languages = []Language{
+	LanguageJavaSource,
+	LanguageJavaClass,
+	LanguageJavaScript,
+	LanguageGroovy,
+	LanguageJavaScript,
+	LanguageKotlin,
+	LanguageYamlFlow,
+}
+
 // A IntegrationTraitSpec contains the configuration of a trait
 type IntegrationTraitSpec struct {
 	Configuration map[string]string `json:"configuration,omitempty"`
diff --git a/pkg/apis/camel/v1alpha1/types_support.go b/pkg/apis/camel/v1alpha1/types_support.go
index 95a842f..861223b 100644
--- a/pkg/apis/camel/v1alpha1/types_support.go
+++ b/pkg/apis/camel/v1alpha1/types_support.go
@@ -138,3 +138,16 @@ func (flows Flows) Serialize() (string, error) {
 	}
 	return string(res), nil
 }
+
+// InferLanguage returns the language of the source or discovers it from file extension if not set
+func (s SourceSpec) InferLanguage() Language {
+	if s.Language != "" {
+		return s.Language
+	}
+	for _, l := range Languages {
+		if strings.HasSuffix(s.Name, "."+string(l)) {
+			return l
+		}
+	}
+	return ""
+}
diff --git a/pkg/metadata/metadata_languages_test.go b/pkg/apis/camel/v1alpha1/types_support_test.go
similarity index 71%
rename from pkg/metadata/metadata_languages_test.go
rename to pkg/apis/camel/v1alpha1/types_support_test.go
index 8a11a56..ebfbc7e 100644
--- a/pkg/metadata/metadata_languages_test.go
+++ b/pkg/apis/camel/v1alpha1/types_support_test.go
@@ -15,32 +15,29 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-package metadata
+package v1alpha1
 
 import (
 	"testing"
 
-	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/stretchr/testify/assert"
 )
 
 func TestLanguageJavaSource(t *testing.T) {
-	code := v1alpha1.SourceSpec{
-		DataSpec: v1alpha1.DataSpec{
+	code := SourceSpec{
+		DataSpec: DataSpec{
 			Name: "Request.java",
 		},
 	}
-	meta := Extract(code)
-	assert.Equal(t, v1alpha1.LanguageJavaSource, meta.Language)
+	assert.Equal(t, LanguageJavaSource, code.InferLanguage())
 }
 
 func TestLanguageAlreadySet(t *testing.T) {
-	code := v1alpha1.SourceSpec{
-		DataSpec: v1alpha1.DataSpec{
+	code := SourceSpec{
+		DataSpec: DataSpec{
 			Name: "Request.java",
 		},
-		Language: v1alpha1.LanguageJavaScript,
+		Language: LanguageJavaScript,
 	}
-	meta := Extract(code)
-	assert.Equal(t, v1alpha1.LanguageJavaScript, meta.Language)
+	assert.Equal(t, LanguageJavaScript, code.InferLanguage())
 }
diff --git a/pkg/metadata/http.go b/pkg/metadata/http.go
index 2feeecb..9ca6a30 100644
--- a/pkg/metadata/http.go
+++ b/pkg/metadata/http.go
@@ -87,7 +87,7 @@ func getURIPrefix(uri string) string {
 }
 
 func hasRestIndicator(source v1alpha1.SourceSpec) bool {
-	pat := getRestIndicatorRegexpsForLanguage(source.Language)
+	pat := getRestIndicatorRegexpsForLanguage(source.InferLanguage())
 	return pat.MatchString(source.Content)
 }
 
diff --git a/pkg/metadata/languages.go b/pkg/metadata/languages.go
deleted file mode 100644
index 55389dc..0000000
--- a/pkg/metadata/languages.go
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-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 metadata
-
-import (
-	"strings"
-
-	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
-)
-
-// discoverLanguage discovers the code language from file extension if not set
-func discoverLanguage(source v1alpha1.SourceSpec) v1alpha1.Language {
-	if source.Language != "" {
-		return source.Language
-	}
-	for _, l := range []v1alpha1.Language{
-		v1alpha1.LanguageJavaSource,
-		v1alpha1.LanguageJavaClass,
-		v1alpha1.LanguageJavaScript,
-		v1alpha1.LanguageGroovy,
-		v1alpha1.LanguageJavaScript,
-		v1alpha1.LanguageKotlin,
-		v1alpha1.LanguageYamlFlow} {
-
-		if strings.HasSuffix(source.Name, "."+string(l)) {
-			return l
-		}
-	}
-	return ""
-}
diff --git a/pkg/metadata/metadata.go b/pkg/metadata/metadata.go
index 4f7d980..bbdacfd 100644
--- a/pkg/metadata/metadata.go
+++ b/pkg/metadata/metadata.go
@@ -28,7 +28,6 @@ import (
 func ExtractAll(sources []v1alpha1.SourceSpec) IntegrationMetadata {
 	// neutral metadata
 	meta := IntegrationMetadata{
-		Language:            "",
 		Dependencies:        []string{},
 		FromURIs:            []string{},
 		ToURIs:              []string{},
@@ -42,10 +41,6 @@ func ExtractAll(sources []v1alpha1.SourceSpec) IntegrationMetadata {
 }
 
 func merge(m1 IntegrationMetadata, m2 IntegrationMetadata) IntegrationMetadata {
-	language := m2.Language
-	if m1.Language != "" && m1.Language != language {
-		language = ""
-	}
 	deps := make(map[string]bool)
 	for _, d := range m1.Dependencies {
 		deps[d] = true
@@ -59,7 +54,6 @@ func merge(m1 IntegrationMetadata, m2 IntegrationMetadata) IntegrationMetadata {
 	}
 	sort.Strings(allDependencies)
 	return IntegrationMetadata{
-		Language:            language,
 		FromURIs:            append(m1.FromURIs, m2.FromURIs...),
 		ToURIs:              append(m1.ToURIs, m2.ToURIs...),
 		Dependencies:        allDependencies,
@@ -70,7 +64,7 @@ func merge(m1 IntegrationMetadata, m2 IntegrationMetadata) IntegrationMetadata {
 
 // Extract returns metadata information from the source code
 func Extract(source v1alpha1.SourceSpec) IntegrationMetadata {
-	language := discoverLanguage(source)
+	language := source.InferLanguage()
 	// TODO: handle error
 	fromURIs, _ := src.InspectorForLanguage(language).FromURIs(source)
 	// TODO:: handle error
@@ -79,7 +73,6 @@ func Extract(source v1alpha1.SourceSpec) IntegrationMetadata {
 	requiresHTTPService := requiresHTTPService(source, fromURIs)
 	passiveEndpoints := hasOnlyPassiveEndpoints(source, fromURIs)
 	return IntegrationMetadata{
-		Language:            language,
 		FromURIs:            fromURIs,
 		ToURIs:              toURIs,
 		Dependencies:        dependencies,
diff --git a/pkg/metadata/types.go b/pkg/metadata/types.go
index 2874eaf..af81ef1 100644
--- a/pkg/metadata/types.go
+++ b/pkg/metadata/types.go
@@ -17,8 +17,6 @@ limitations under the License.
 
 package metadata
 
-import "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
-
 // IntegrationMetadata contains aggregate metadata about all Camel routes in a integrations
 type IntegrationMetadata struct {
 	// All starting URIs of defined routes
@@ -27,8 +25,6 @@ type IntegrationMetadata struct {
 	ToURIs []string
 	// All inferred dependencies required to run the integration
 	Dependencies []string
-	// The language in which the integration is written
-	Language v1alpha1.Language
 	// RequiresHTTPService indicates if the integration needs to be invoked through HTTP
 	RequiresHTTPService bool
 	// PassiveEndpoints indicates that the integration contains only passive endpoints that are activated from
diff --git a/pkg/stub/action/integration/initialize.go b/pkg/stub/action/integration/initialize.go
index eea1957..b9ca930 100644
--- a/pkg/stub/action/integration/initialize.go
+++ b/pkg/stub/action/integration/initialize.go
@@ -19,7 +19,6 @@ package integration
 
 import (
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
-	"github.com/apache/camel-k/pkg/metadata"
 	"github.com/apache/camel-k/pkg/platform"
 	"github.com/apache/camel-k/pkg/trait"
 	"github.com/apache/camel-k/pkg/util/digest"
@@ -54,18 +53,7 @@ func (action *initializeAction) Handle(integration *v1alpha1.Integration) error
 	}
 
 	target := integration.DeepCopy()
-	// set default values
-	if target.Spec.Replicas == nil {
-		var defaultReplicas int32 = 1
-		target.Spec.Replicas = &defaultReplicas
-	}
-	for i := range target.Spec.Sources {
-		// extract metadata
-		s := &target.Spec.Sources[i]
-
-		meta := metadata.Extract(*s)
-		s.Language = meta.Language
-	}
+	// better not changing the spec section of the target because it may be used for comparison by a higher level controller (e.g. Knative source controller)
 
 	// execute custom initialization
 	if _, err := trait.Apply(target, nil); err != nil {
diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go
index eddee8b..79862a6 100644
--- a/pkg/trait/dependencies.go
+++ b/pkg/trait/dependencies.go
@@ -49,7 +49,7 @@ func (t *dependenciesTrait) Apply(e *Environment) error {
 	for _, s := range e.Integration.Spec.Sources {
 		meta := metadata.Extract(s)
 
-		switch meta.Language {
+		switch s.InferLanguage() {
 		case v1alpha1.LanguageGroovy:
 			util.StringSliceUniqueAdd(&e.Integration.Spec.Dependencies, "runtime:groovy")
 		case v1alpha1.LanguageKotlin:
diff --git a/pkg/trait/deployment.go b/pkg/trait/deployment.go
index ec53ac3..63790c6 100644
--- a/pkg/trait/deployment.go
+++ b/pkg/trait/deployment.go
@@ -142,7 +142,7 @@ func (t *deploymentTrait) getConfigMapsFor(e *Environment) []runtime.Object {
 						"camel.apache.org/integration": e.Integration.Name,
 					},
 					Annotations: map[string]string{
-						"camel.apache.org/source.language":    string(s.Language),
+						"camel.apache.org/source.language":    string(s.InferLanguage()),
 						"camel.apache.org/source.name":        s.Name,
 						"camel.apache.org/source.compression": strconv.FormatBool(s.Compression),
 					},
@@ -207,8 +207,8 @@ func (t *deploymentTrait) getSources(e *Environment) []string {
 		src = "file:" + src
 
 		params := make([]string, 0)
-		if s.Language != "" {
-			params = append(params, "language="+string(s.Language))
+		if s.InferLanguage() != "" {
+			params = append(params, "language="+string(s.InferLanguage()))
 		}
 		if s.Compression {
 			params = append(params, "compression=true")
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 977d6ad..4157185 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -142,8 +142,8 @@ func (t *knativeTrait) getServiceFor(e *Environment) *serving.Service {
 		envvar.SetVal(&environment, envName, s.Content)
 
 		params := make([]string, 0)
-		if s.Language != "" {
-			params = append(params, "language="+string(s.Language))
+		if s.InferLanguage() != "" {
+			params = append(params, "language="+string(s.InferLanguage()))
 		}
 		if s.Compression {
 			params = append(params, "compression=true")


[camel-k] 03/03: chore(lint): make golangci-lint happy

Posted by nf...@apache.org.
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 692c4f11fc79b020c13a22206596bae80c2fb434
Author: nferraro <ni...@gmail.com>
AuthorDate: Fri Jan 4 09:39:43 2019 +0100

    chore(lint): make golangci-lint happy
---
 pkg/apis/camel/v1alpha1/types.go          | 1 +
 pkg/apis/camel/v1alpha1/types_support.go  | 2 +-
 pkg/stub/action/integration/initialize.go | 3 ++-
 pkg/trait/knative.go                      | 4 +++-
 pkg/trait/util.go                         | 2 +-
 pkg/util/source/inspector_xml.go          | 6 ++----
 6 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/types.go b/pkg/apis/camel/v1alpha1/types.go
index df2c251..09b46fa 100644
--- a/pkg/apis/camel/v1alpha1/types.go
+++ b/pkg/apis/camel/v1alpha1/types.go
@@ -21,6 +21,7 @@ import (
 	"github.com/apache/camel-k/pkg/util"
 	"github.com/mitchellh/mapstructure"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
 	"strings"
 )
 
diff --git a/pkg/apis/camel/v1alpha1/types_support.go b/pkg/apis/camel/v1alpha1/types_support.go
index 861223b..f73414c 100644
--- a/pkg/apis/camel/v1alpha1/types_support.go
+++ b/pkg/apis/camel/v1alpha1/types_support.go
@@ -19,9 +19,9 @@ package v1alpha1
 
 import (
 	"fmt"
-	"gopkg.in/yaml.v2"
 	"strings"
 
+	"gopkg.in/yaml.v2"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
diff --git a/pkg/stub/action/integration/initialize.go b/pkg/stub/action/integration/initialize.go
index c2e0289..aa4f5dc 100644
--- a/pkg/stub/action/integration/initialize.go
+++ b/pkg/stub/action/integration/initialize.go
@@ -53,7 +53,8 @@ func (action *initializeAction) Handle(integration *v1alpha1.Integration) error
 	}
 
 	target := integration.DeepCopy()
-	// better not changing the spec section of the target because it may be used for comparison by a higher level controller (e.g. Knative source controller)
+	// better not changing the spec section of the target because it may be used for comparison by a
+	// higher level controller (e.g. Knative source controller)
 
 	// execute custom initialization
 	if _, err := trait.Apply(target, nil); err != nil {
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 4157185..f5f02a3 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -295,7 +295,9 @@ func (t *knativeTrait) getConfigurationSerialized(e *Environment) (string, error
 func (t *knativeTrait) getConfiguration(e *Environment) (knativeapi.CamelEnvironment, error) {
 	env := knativeapi.NewCamelEnvironment()
 	if t.Configuration != "" {
-		env.Deserialize(t.Configuration)
+		if err := env.Deserialize(t.Configuration); err != nil {
+			return knativeapi.CamelEnvironment{}, err
+		}
 	}
 
 	// Sources
diff --git a/pkg/trait/util.go b/pkg/trait/util.go
index 3c73236..f9875a5 100644
--- a/pkg/trait/util.go
+++ b/pkg/trait/util.go
@@ -26,7 +26,7 @@ import (
 
 // GetIntegrationContext retrieves the context set on the integration
 func GetIntegrationContext(integration *v1alpha1.Integration) (*v1alpha1.IntegrationContext, error) {
-	if integration.Status.Context== "" {
+	if integration.Status.Context == "" {
 		return nil, nil
 	}
 
diff --git a/pkg/util/source/inspector_xml.go b/pkg/util/source/inspector_xml.go
index c13f1e6..b2bd2e8 100644
--- a/pkg/util/source/inspector_xml.go
+++ b/pkg/util/source/inspector_xml.go
@@ -42,8 +42,7 @@ func (i XMLInspector) FromURIs(source v1alpha1.SourceSpec) ([]string, error) {
 			break
 		}
 
-		switch se := t.(type) {
-		case xml.StartElement:
+		if se, ok := t.(xml.StartElement); ok {
 			switch se.Name.Local {
 			case "from", "fromF":
 				for _, a := range se.Attr {
@@ -72,8 +71,7 @@ func (i XMLInspector) ToURIs(source v1alpha1.SourceSpec) ([]string, error) {
 			break
 		}
 
-		switch se := t.(type) {
-		case xml.StartElement:
+		if se, ok := t.(xml.StartElement); ok {
 			switch se.Name.Local {
 			case "to", "toD", "toF":
 				for _, a := range se.Attr {


[camel-k] 02/03: Copy dependencies and context to status

Posted by nf...@apache.org.
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 fc708d5b5bab42d708e00e1ad2d937b1f9b129b0
Author: nferraro <ni...@gmail.com>
AuthorDate: Mon Dec 24 16:39:27 2018 +0100

    Copy dependencies and context to status
---
 pkg/apis/camel/v1alpha1/types.go                 | 12 +++++-----
 pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go | 29 +++++++++++++++++++++++-
 pkg/client/cmd/get.go                            |  2 +-
 pkg/stub/action/context/build.go                 |  2 +-
 pkg/stub/action/integration/build_context.go     | 16 ++++++-------
 pkg/stub/action/integration/build_image.go       |  4 ++--
 pkg/stub/action/integration/deploy.go            |  5 +++-
 pkg/stub/action/integration/initialize.go        |  3 +++
 pkg/stub/action/integration/monitor.go           |  2 +-
 pkg/stub/action/integration/util.go              |  8 +++----
 pkg/trait/classpath.go                           |  6 ++---
 pkg/trait/dependencies.go                        | 21 +++++++++++------
 pkg/trait/springboot.go                          |  4 ++--
 pkg/trait/util.go                                |  4 ++--
 pkg/util/util.go                                 |  4 ++++
 15 files changed, 83 insertions(+), 39 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/types.go b/pkg/apis/camel/v1alpha1/types.go
index 6df4c30..df2c251 100644
--- a/pkg/apis/camel/v1alpha1/types.go
+++ b/pkg/apis/camel/v1alpha1/types.go
@@ -18,12 +18,10 @@ limitations under the License.
 package v1alpha1
 
 import (
-	"strings"
-
 	"github.com/apache/camel-k/pkg/util"
-
 	"github.com/mitchellh/mapstructure"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"strings"
 )
 
 // ConfigurationSpec --
@@ -175,9 +173,11 @@ func (in *IntegrationTraitSpec) Decode(target interface{}) error {
 
 // IntegrationStatus --
 type IntegrationStatus struct {
-	Phase  IntegrationPhase `json:"phase,omitempty"`
-	Digest string           `json:"digest,omitempty"`
-	Image  string           `json:"image,omitempty"`
+	Phase        IntegrationPhase `json:"phase,omitempty"`
+	Digest       string           `json:"digest,omitempty"`
+	Image        string           `json:"image,omitempty"`
+	Dependencies []string         `json:"dependencies,omitempty"`
+	Context      string           `json:"context,omitempty"`
 }
 
 // IntegrationPhase --
diff --git a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
index 85e3be8..8df4769 100644
--- a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
@@ -95,12 +95,34 @@ func (in *Flow) DeepCopy() *Flow {
 }
 
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in Flows) DeepCopyInto(out *Flows) {
+	{
+		in := &in
+		*out = make(Flows, len(*in))
+		for i := range *in {
+			(*in)[i].DeepCopyInto(&(*out)[i])
+		}
+		return
+	}
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Flows.
+func (in Flows) DeepCopy() Flows {
+	if in == nil {
+		return nil
+	}
+	out := new(Flows)
+	in.DeepCopyInto(out)
+	return *out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *Integration) DeepCopyInto(out *Integration) {
 	*out = *in
 	out.TypeMeta = in.TypeMeta
 	in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
 	in.Spec.DeepCopyInto(&out.Spec)
-	out.Status = in.Status
+	in.Status.DeepCopyInto(&out.Status)
 	return
 }
 
@@ -453,6 +475,11 @@ func (in *IntegrationSpec) DeepCopy() *IntegrationSpec {
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *IntegrationStatus) DeepCopyInto(out *IntegrationStatus) {
 	*out = *in
+	if in.Dependencies != nil {
+		in, out := &in.Dependencies, &out.Dependencies
+		*out = make([]string, len(*in))
+		copy(*out, *in)
+	}
 	return
 }
 
diff --git a/pkg/client/cmd/get.go b/pkg/client/cmd/get.go
index 02d4726..d9e4851 100644
--- a/pkg/client/cmd/get.go
+++ b/pkg/client/cmd/get.go
@@ -64,7 +64,7 @@ func (o *getCmdOptions) run(cmd *cobra.Command, args []string) error {
 	w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
 	fmt.Fprintln(w, "NAME\tCONTEXT\tSTATUS")
 	for _, integration := range integrationList.Items {
-		fmt.Fprintf(w, "%s\t%s\t%s\n", integration.Name, integration.Spec.Context, string(integration.Status.Phase))
+		fmt.Fprintf(w, "%s\t%s\t%s\n", integration.Name, integration.Status.Context, string(integration.Status.Phase))
 	}
 	w.Flush()
 
diff --git a/pkg/stub/action/context/build.go b/pkg/stub/action/context/build.go
index 08394c9..eebf87e 100644
--- a/pkg/stub/action/context/build.go
+++ b/pkg/stub/action/context/build.go
@@ -136,7 +136,7 @@ func (action *buildAction) informIntegrations(context *v1alpha1.IntegrationConte
 	}
 	for _, integration := range list.Items {
 		integration := integration // pin
-		if integration.Spec.Context != context.Name {
+		if integration.Status.Context != context.Name {
 			continue
 		}
 
diff --git a/pkg/stub/action/integration/build_context.go b/pkg/stub/action/integration/build_context.go
index 97da4aa..9f25225 100644
--- a/pkg/stub/action/integration/build_context.go
+++ b/pkg/stub/action/integration/build_context.go
@@ -66,12 +66,12 @@ func (action *buildContextAction) Handle(integration *v1alpha1.Integration) erro
 			// amended to add/remove dependencies
 
 			//TODO: this is a very simple check, we may need to provide a deps comparison strategy
-			if !util.StringSliceContains(ctx.Spec.Dependencies, integration.Spec.Dependencies) {
+			if !util.StringSliceContains(ctx.Spec.Dependencies, integration.Status.Dependencies) {
 				// We need to re-generate a context or search for a new one that
 				// satisfies integrations needs so let's remove the association
 				// with a context
 				target := integration.DeepCopy()
-				target.Spec.Context = ""
+				target.Status.Context = ""
 				return sdk.Update(target)
 			}
 		}
@@ -79,7 +79,7 @@ func (action *buildContextAction) Handle(integration *v1alpha1.Integration) erro
 		if ctx.Status.Phase == v1alpha1.IntegrationContextPhaseError {
 			target := integration.DeepCopy()
 			target.Status.Image = ctx.ImageForIntegration()
-			target.Spec.Context = ctx.Name
+			target.Status.Context = ctx.Name
 			target.Status.Phase = v1alpha1.IntegrationPhaseError
 
 			target.Status.Digest, err = digest.ComputeForIntegration(target)
@@ -95,7 +95,7 @@ func (action *buildContextAction) Handle(integration *v1alpha1.Integration) erro
 		if ctx.Status.Phase == v1alpha1.IntegrationContextPhaseReady {
 			target := integration.DeepCopy()
 			target.Status.Image = ctx.ImageForIntegration()
-			target.Spec.Context = ctx.Name
+			target.Status.Context = ctx.Name
 
 			dgst, err := digest.ComputeForIntegration(target)
 			if err != nil {
@@ -113,10 +113,10 @@ func (action *buildContextAction) Handle(integration *v1alpha1.Integration) erro
 			return sdk.Update(target)
 		}
 
-		if integration.Spec.Context == "" {
+		if integration.Status.Context == "" {
 			// We need to set the context
 			target := integration.DeepCopy()
-			target.Spec.Context = ctx.Name
+			target.Status.Context = ctx.Name
 			return sdk.Update(target)
 		}
 
@@ -137,7 +137,7 @@ func (action *buildContextAction) Handle(integration *v1alpha1.Integration) erro
 
 	// Set the context to have the same dependencies as the integrations
 	platformCtx.Spec = v1alpha1.IntegrationContextSpec{
-		Dependencies: integration.Spec.Dependencies,
+		Dependencies: integration.Status.Dependencies,
 		Repositories: integration.Spec.Repositories,
 		Traits:       integration.Spec.Traits,
 	}
@@ -149,7 +149,7 @@ func (action *buildContextAction) Handle(integration *v1alpha1.Integration) erro
 	// Set the context name so the next handle loop, will fall through the
 	// same path as integration with a user defined context
 	target := integration.DeepCopy()
-	target.Spec.Context = platformCtxName
+	target.Status.Context = platformCtxName
 
 	return sdk.Update(target)
 }
diff --git a/pkg/stub/action/integration/build_image.go b/pkg/stub/action/integration/build_image.go
index 44440cf..62058f5 100644
--- a/pkg/stub/action/integration/build_image.go
+++ b/pkg/stub/action/integration/build_image.go
@@ -62,13 +62,13 @@ func (action *buildImageAction) Handle(integration *v1alpha1.Integration) error
 
 	// in this phase the integration need to be associated to a context whose image
 	// will be used as base image for the integration images
-	if integration.Spec.Context == "" {
+	if integration.Status.Context == "" {
 		return fmt.Errorf("context is not set for integration: %s", integration.Name)
 	}
 
 	// look-up the integration context associated to this integration, this is needed
 	// to determine the base image
-	ctx := v1alpha1.NewIntegrationContext(integration.Namespace, integration.Spec.Context)
+	ctx := v1alpha1.NewIntegrationContext(integration.Namespace, integration.Status.Context)
 	if err := sdk.Get(&ctx); err != nil {
 		return errors.Wrapf(err, "unable to find integration context %s, %s", ctx.Name, err)
 	}
diff --git a/pkg/stub/action/integration/deploy.go b/pkg/stub/action/integration/deploy.go
index ad0d04a..7ceaeef 100644
--- a/pkg/stub/action/integration/deploy.go
+++ b/pkg/stub/action/integration/deploy.go
@@ -43,7 +43,10 @@ func (action *deployAction) CanHandle(integration *v1alpha1.Integration) bool {
 }
 
 func (action *deployAction) Handle(integration *v1alpha1.Integration) error {
-	ctxName := integration.Spec.Context
+	ctxName := integration.Status.Context
+	if ctxName == "" {
+		return errors.Errorf("no context set on integration %s", integration.Name)
+	}
 	ctx := v1alpha1.NewIntegrationContext(integration.Namespace, ctxName)
 
 	if err := sdk.Get(&ctx); err != nil {
diff --git a/pkg/stub/action/integration/initialize.go b/pkg/stub/action/integration/initialize.go
index b9ca930..c2e0289 100644
--- a/pkg/stub/action/integration/initialize.go
+++ b/pkg/stub/action/integration/initialize.go
@@ -68,6 +68,9 @@ func (action *initializeAction) Handle(integration *v1alpha1.Integration) error
 
 	target.Status.Phase = v1alpha1.IntegrationPhaseBuildingContext
 	target.Status.Digest = dgst
+	target.Status.Context = integration.Spec.Context
+	target.Status.Dependencies = integration.Spec.Dependencies
+	target.Status.Image = ""
 
 	logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)
 
diff --git a/pkg/stub/action/integration/monitor.go b/pkg/stub/action/integration/monitor.go
index d0e8107..7f3bf33 100644
--- a/pkg/stub/action/integration/monitor.go
+++ b/pkg/stub/action/integration/monitor.go
@@ -53,7 +53,7 @@ func (action *monitorAction) Handle(integration *v1alpha1.Integration) error {
 
 		target := integration.DeepCopy()
 		target.Status.Digest = hash
-		target.Status.Phase = v1alpha1.IntegrationPhaseBuildingContext
+		target.Status.Phase = ""
 
 		logrus.Info("Integration ", target.Name, " transitioning to state ", target.Status.Phase)
 
diff --git a/pkg/stub/action/integration/util.go b/pkg/stub/action/integration/util.go
index 26c1fd8..15230c7 100644
--- a/pkg/stub/action/integration/util.go
+++ b/pkg/stub/action/integration/util.go
@@ -27,8 +27,8 @@ import (
 
 // LookupContextForIntegration --
 func LookupContextForIntegration(integration *v1alpha1.Integration) (*v1alpha1.IntegrationContext, error) {
-	if integration.Spec.Context != "" {
-		name := integration.Spec.Context
+	if integration.Status.Context != "" {
+		name := integration.Status.Context
 		ctx := v1alpha1.NewIntegrationContext(integration.Namespace, name)
 
 		if err := sdk.Get(&ctx); err != nil {
@@ -46,14 +46,14 @@ func LookupContextForIntegration(integration *v1alpha1.Integration) (*v1alpha1.I
 	for _, ctx := range ctxList.Items {
 		ctx := ctx // pin
 		if ctx.Labels["camel.apache.org/context.type"] == v1alpha1.IntegrationContextTypePlatform {
-			ideps := len(integration.Spec.Dependencies)
+			ideps := len(integration.Status.Dependencies)
 			cdeps := len(ctx.Spec.Dependencies)
 
 			if ideps != cdeps {
 				continue
 			}
 
-			if util.StringSliceContains(ctx.Spec.Dependencies, integration.Spec.Dependencies) {
+			if util.StringSliceContains(ctx.Spec.Dependencies, integration.Status.Dependencies) {
 				return &ctx, nil
 			}
 		}
diff --git a/pkg/trait/classpath.go b/pkg/trait/classpath.go
index 3936584..619e6b3 100644
--- a/pkg/trait/classpath.go
+++ b/pkg/trait/classpath.go
@@ -54,8 +54,8 @@ func (t *classpathTrait) Configure(e *Environment) (bool, error) {
 func (t *classpathTrait) Apply(e *Environment) error {
 	ctx := e.Context
 
-	if ctx == nil && e.Integration.Spec.Context != "" {
-		name := e.Integration.Spec.Context
+	if ctx == nil && e.Integration.Status.Context != "" {
+		name := e.Integration.Status.Context
 		c := v1alpha1.NewIntegrationContext(e.Integration.Namespace, name)
 
 		if err := sdk.Get(&c); err != nil {
@@ -66,7 +66,7 @@ func (t *classpathTrait) Apply(e *Environment) error {
 	}
 
 	if ctx == nil {
-		return fmt.Errorf("unable to find integration context %s", e.Integration.Spec.Context)
+		return fmt.Errorf("unable to find integration context %s", e.Integration.Status.Context)
 	}
 
 	deps := make([]string, 0, 2+len(ctx.Status.Artifacts))
diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go
index 79862a6..4052e4c 100644
--- a/pkg/trait/dependencies.go
+++ b/pkg/trait/dependencies.go
@@ -46,28 +46,35 @@ func (t *dependenciesTrait) Configure(e *Environment) (bool, error) {
 }
 
 func (t *dependenciesTrait) Apply(e *Environment) error {
+	dependencies := make([]string, 0)
+	if e.Integration.Spec.Dependencies != nil {
+		for _, dep := range e.Integration.Spec.Dependencies {
+			util.StringSliceUniqueAdd(&dependencies, dep)
+		}
+	}
 	for _, s := range e.Integration.Spec.Sources {
 		meta := metadata.Extract(s)
 
 		switch s.InferLanguage() {
 		case v1alpha1.LanguageGroovy:
-			util.StringSliceUniqueAdd(&e.Integration.Spec.Dependencies, "runtime:groovy")
+			util.StringSliceUniqueAdd(&dependencies, "runtime:groovy")
 		case v1alpha1.LanguageKotlin:
-			util.StringSliceUniqueAdd(&e.Integration.Spec.Dependencies, "runtime:kotlin")
+			util.StringSliceUniqueAdd(&dependencies, "runtime:kotlin")
 		case v1alpha1.LanguageYamlFlow:
-			util.StringSliceUniqueAdd(&e.Integration.Spec.Dependencies, "runtime:yaml")
+			util.StringSliceUniqueAdd(&dependencies, "runtime:yaml")
 		}
 
 		// jvm runtime and camel-core required by default
-		util.StringSliceUniqueAdd(&e.Integration.Spec.Dependencies, "runtime:jvm")
-		util.StringSliceUniqueAdd(&e.Integration.Spec.Dependencies, "camel:core")
+		util.StringSliceUniqueAdd(&dependencies, "runtime:jvm")
+		util.StringSliceUniqueAdd(&dependencies, "camel:core")
 
 		for _, d := range meta.Dependencies {
-			util.StringSliceUniqueAdd(&e.Integration.Spec.Dependencies, d)
+			util.StringSliceUniqueAdd(&dependencies, d)
 		}
 	}
 
 	// sort the dependencies to get always the same list if they don't change
-	sort.Strings(e.Integration.Spec.Dependencies)
+	sort.Strings(dependencies)
+	e.Integration.Status.Dependencies = dependencies
 	return nil
 }
diff --git a/pkg/trait/springboot.go b/pkg/trait/springboot.go
index fb280ba..7c790e5 100644
--- a/pkg/trait/springboot.go
+++ b/pkg/trait/springboot.go
@@ -66,10 +66,10 @@ func (t *springBootTrait) Apply(e *Environment) error {
 	//
 
 	if e.IntegrationInPhase("") {
-		util.StringSliceUniqueAdd(&e.Integration.Spec.Dependencies, "runtime:spring-boot")
+		util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "runtime:spring-boot")
 
 		// sort the dependencies to get always the same list if they don't change
-		sort.Strings(e.Integration.Spec.Dependencies)
+		sort.Strings(e.Integration.Status.Dependencies)
 	}
 
 	if e.InPhase(v1alpha1.IntegrationContextPhaseReady, v1alpha1.IntegrationPhaseDeploying) {
diff --git a/pkg/trait/util.go b/pkg/trait/util.go
index ad6e1d3..3c73236 100644
--- a/pkg/trait/util.go
+++ b/pkg/trait/util.go
@@ -26,11 +26,11 @@ import (
 
 // GetIntegrationContext retrieves the context set on the integration
 func GetIntegrationContext(integration *v1alpha1.Integration) (*v1alpha1.IntegrationContext, error) {
-	if integration.Spec.Context == "" {
+	if integration.Status.Context== "" {
 		return nil, nil
 	}
 
-	name := integration.Spec.Context
+	name := integration.Status.Context
 	ctx := v1alpha1.NewIntegrationContext(integration.Namespace, name)
 	err := sdk.Get(&ctx)
 	return &ctx, err
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 18594ad..7cd9712 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -52,6 +52,10 @@ func StringSliceExists(slice []string, item string) bool {
 
 // StringSliceUniqueAdd append the given item if not already present in the slice
 func StringSliceUniqueAdd(slice *[]string, item string) bool {
+	if slice == nil {
+		newSlice := make([]string, 0)
+		slice = &newSlice
+	}
 	for _, i := range *slice {
 		if i == item {
 			return false