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 9b7ce11cb795169a732162f16a58ac4e43522954 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Thu Dec 20 21:48:50 2018 +0100 create knative context #183 --- ...w.yaml => platform-integration-context-knative.yaml} | 5 +++-- deploy/resources.go | 17 +++++++++-------- pkg/builder/builder_steps.go | 8 ++++++++ pkg/builder/springboot/generator.go | 8 ++++++++ pkg/metadata/dependencies.go | 3 +++ pkg/stub/action/platform/create.go | 16 ++++++++++++++-- pkg/util/envvar/envvar.go | 3 ++- pkg/util/maven/maven_project.go | 4 +++- 8 files changed, 50 insertions(+), 14 deletions(-) diff --git a/deploy/platform-integration-context-flow.yaml b/deploy/platform-integration-context-knative.yaml similarity index 85% rename from deploy/platform-integration-context-flow.yaml rename to deploy/platform-integration-context-knative.yaml index 054f3c1..895ef39 100644 --- a/deploy/platform-integration-context-flow.yaml +++ b/deploy/platform-integration-context-knative.yaml @@ -1,7 +1,7 @@ apiVersion: camel.apache.org/v1alpha1 kind: IntegrationContext metadata: - name: flow + name: knative labels: app: "camel-k" camel.apache.org/context.created.by.kind: Operator @@ -11,4 +11,5 @@ spec: dependencies: - runtime:jvm - runtime:yaml - - camel:core \ No newline at end of file + - camel:core + - camel-k:knative \ No newline at end of file diff --git a/deploy/resources.go b/deploy/resources.go index 6ceed46..7f6a768 100644 --- a/deploy/resources.go +++ b/deploy/resources.go @@ -2723,12 +2723,12 @@ spec: camelVersion: "2.23.0" ` - Resources["platform-integration-context-flow.yaml"] = + Resources["platform-integration-context-groovy.yaml"] = ` apiVersion: camel.apache.org/v1alpha1 kind: IntegrationContext metadata: - name: flow + name: groovy labels: app: "camel-k" camel.apache.org/context.created.by.kind: Operator @@ -2737,15 +2737,15 @@ metadata: spec: dependencies: - runtime:jvm - - runtime:yaml + - runtime:groovy - camel:core ` - Resources["platform-integration-context-groovy.yaml"] = + Resources["platform-integration-context-jvm.yaml"] = ` apiVersion: camel.apache.org/v1alpha1 kind: IntegrationContext metadata: - name: groovy + name: jvm labels: app: "camel-k" camel.apache.org/context.created.by.kind: Operator @@ -2754,15 +2754,14 @@ metadata: spec: dependencies: - runtime:jvm - - runtime:groovy - camel:core ` - Resources["platform-integration-context-jvm.yaml"] = + Resources["platform-integration-context-knative.yaml"] = ` apiVersion: camel.apache.org/v1alpha1 kind: IntegrationContext metadata: - name: jvm + name: knative labels: app: "camel-k" camel.apache.org/context.created.by.kind: Operator @@ -2771,7 +2770,9 @@ metadata: spec: dependencies: - runtime:jvm + - runtime:yaml - camel:core + - camel-k:knative ` Resources["platform-integration-context-kotlin.yaml"] = ` diff --git a/pkg/builder/builder_steps.go b/pkg/builder/builder_steps.go index b50fb9b..e55f8cc 100644 --- a/pkg/builder/builder_steps.go +++ b/pkg/builder/builder_steps.go @@ -81,6 +81,14 @@ func GenerateProject(ctx *Context) error { } deps.AddGAV("org.apache.camel", artifactID, "") + case strings.HasPrefix(d, "camel-k:"): + artifactID := strings.TrimPrefix(d, "camel-k:") + + if !strings.HasPrefix(artifactID, "camel-") { + artifactID = "camel-" + artifactID + } + + deps.AddGAV("org.apache.camel.k", artifactID, version.Version) case strings.HasPrefix(d, "mvn:"): mid := strings.TrimPrefix(d, "mvn:") gav := strings.Replace(mid, "/", ":", -1) diff --git a/pkg/builder/springboot/generator.go b/pkg/builder/springboot/generator.go index a50e04f..e107a51 100644 --- a/pkg/builder/springboot/generator.go +++ b/pkg/builder/springboot/generator.go @@ -125,6 +125,14 @@ func GenerateProject(ctx *builder.Context) error { }, }, }) + case strings.HasPrefix(d, "camel-k:"): + artifactID := strings.TrimPrefix(d, "camel-k:") + + if !strings.HasPrefix(artifactID, "camel-") { + artifactID = "camel-" + artifactID + } + + deps.AddGAV("org.apache.camel.k", artifactID, version.Version) case strings.HasPrefix(d, "mvn:"): mid := strings.TrimPrefix(d, "mvn:") gav := strings.Replace(mid, "/", ":", -1) diff --git a/pkg/metadata/dependencies.go b/pkg/metadata/dependencies.go index c2bcc83..f70efdd 100644 --- a/pkg/metadata/dependencies.go +++ b/pkg/metadata/dependencies.go @@ -68,6 +68,9 @@ func decodeComponent(uri string) string { if component.GroupID == "org.apache.camel" && strings.HasPrefix(artifactID, "camel-") { return "camel:" + artifactID[6:] } + if component.GroupID == "org.apache.camel.k" && strings.HasPrefix(artifactID, "camel-") { + return "camel-k:" + artifactID[6:] + } return "mvn:" + component.GroupID + ":" + artifactID + ":" + component.Version } return "" diff --git a/pkg/stub/action/platform/create.go b/pkg/stub/action/platform/create.go index 5ab81ae..c5b70fd 100644 --- a/pkg/stub/action/platform/create.go +++ b/pkg/stub/action/platform/create.go @@ -28,10 +28,13 @@ var resources = []string{ "platform-integration-context-jvm.yaml", "platform-integration-context-groovy.yaml", "platform-integration-context-kotlin.yaml", - "platform-integration-context-yaml.yaml", "platform-integration-context-spring-boot.yaml", } +var knativeResources = []string{ + "platform-integration-context-knative.yaml", +} + // NewCreateAction returns a action that creates resources needed by the platform func NewCreateAction() Action { return &createAction{} @@ -49,14 +52,23 @@ func (action *createAction) CanHandle(platform *v1alpha1.IntegrationPlatform) bo } func (action *createAction) Handle(platform *v1alpha1.IntegrationPlatform) error { + logrus.Info("Installing platform resources") err := install.Resources(platform.Namespace, resources...) if err != nil { return err } + if platform.Spec.Profile == v1alpha1.TraitProfileKnative { + logrus.Info("Installing knative resources") + err := install.Resources(platform.Namespace, knativeResources...) + if err != nil { + return err + } + } + target := platform.DeepCopy() - logrus.Info("Platform ", target.Name, " transitioning to state ", v1alpha1.IntegrationPlatformPhaseStarting) target.Status.Phase = v1alpha1.IntegrationPlatformPhaseStarting + logrus.Info("Platform ", target.Name, " transitioning to state ", target.Status.Phase) return sdk.Update(target) } diff --git a/pkg/util/envvar/envvar.go b/pkg/util/envvar/envvar.go index d8739cf..ae0b998 100644 --- a/pkg/util/envvar/envvar.go +++ b/pkg/util/envvar/envvar.go @@ -35,7 +35,8 @@ func Remove(vars *[]v1.EnvVar, name string) { v := *vars for i := 0; i < len(v); i++ { if v[i].Name == name { - *vars = append(v[:i], v[i+1:]...) + v = append(v[:i], v[i+1:]...) + *vars = v return } } diff --git a/pkg/util/maven/maven_project.go b/pkg/util/maven/maven_project.go index cba227b..925d6e5 100644 --- a/pkg/util/maven/maven_project.go +++ b/pkg/util/maven/maven_project.go @@ -225,7 +225,9 @@ func (m Properties) MarshalXML(e *xml.Encoder, start xml.StartElement) error { } for k, v := range m { - e.Encode(propertiesEntry{XMLName: xml.Name{Local: k}, Value: v}) + if err := e.Encode(propertiesEntry{XMLName: xml.Name{Local: k}, Value: v}); err != nil { + return err + } } return e.EncodeToken(start.End())