Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Platform options #296

Merged
merged 1 commit into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,50 @@ As example if you want to change the queue size of the seda component, you can u
camel.component.seda.queueSize = 10
```

==== Configure additional maven repositories

Additional maven repositories can be defined at platform installation time or at integration/context build time:


[source]
----
kamel cmd --repository http://repo1.my-company.com --repository http://repo2.my-company.com
----

A repository url follow conventions used to configuire additional repositories in https://karaf.apache.org[_Apache Karaf_] so it can be appended with zero or more of the following flags:

* **@snapshots**: the repository contains snapshots
* **@noreleases**: the repository does not contain any released artifacts
* **@id=repository.id**: the id for the repository

[source]
----
kamel install --repository http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases
----

This results in:

[source,xml]
----
<repositories>
<repository>
<id>apache</id>
<url>http://repository.apache.org/content/groups/snapshots-group</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
----

[NOTE]
====
The final repositories list is the sum of the repositories defined on the resource (integration/context) and the platform ones
====

=== Running Integrations in "Dev" Mode for Fast Feedback

If you want to iterate quickly on an integration to have fast feedback on the code you're writing, you can use by running it in **"dev" mode**:
Expand Down
3 changes: 3 additions & 0 deletions deploy/platform-cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ metadata:
name: camel-k
labels:
app: "camel-k"
spec:
build:
camelVersion: "2.23.0"
3 changes: 3 additions & 0 deletions deploy/resources.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/apis/camel/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ type IntegrationPlatformBuildSpec struct {
Registry string `json:"registry,omitempty"`
Organization string `json:"organization,omitempty"`
PushSecret string `json:"pushSecret,omitempty"`
CamelVersion string `json:"camelVersion,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
Repositories []string `json:"repositories,omitempty"`
}

// IntegrationPlatformBuildPublishStrategy enumerates all implemented build strategies
Expand Down
16 changes: 14 additions & 2 deletions pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 1 addition & 29 deletions pkg/builder/builder_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ limitations under the License.
package builder

import (
"encoding/xml"
"fmt"
"io/ioutil"
"os"
Expand All @@ -32,7 +31,6 @@ import (
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/operator-framework/operator-sdk/pkg/sdk"

"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/tar"

"gopkg.in/yaml.v2"
Expand All @@ -47,33 +45,7 @@ import (

// GenerateProject --
func GenerateProject(ctx *Context) error {
ctx.Project = maven.Project{
XMLName: xml.Name{Local: "project"},
XMLNs: "http://maven.apache.org/POM/4.0.0",
XMLNsXsi: "http://www.w3.org/2001/XMLSchema-instance",
XsiSchemaLocation: "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd",
ModelVersion: "4.0.0",
GroupID: "org.apache.camel.k.integration",
ArtifactID: "camel-k-integration",
Version: version.Version,
DependencyManagement: maven.DependencyManagement{
Dependencies: maven.Dependencies{
Dependencies: []maven.Dependency{
{
//TODO: camel version should be retrieved from an external request or provided as static version
GroupID: "org.apache.camel",
ArtifactID: "camel-bom",
Version: camel.Version,
Type: "pom",
Scope: "import",
},
},
},
},
Dependencies: maven.Dependencies{
Dependencies: make([]maven.Dependency, 0),
},
}
ctx.Project = NewProject(ctx)

//
// Repositories
Expand Down
61 changes: 61 additions & 0 deletions pkg/builder/builder_steps_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
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 builder

import (
"testing"

"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"

"github.com/stretchr/testify/assert"
)

func TestGenerateProject(t *testing.T) {
ctx := Context{
Request: Request{
Platform: v1alpha1.IntegrationPlatformSpec{
Build: v1alpha1.IntegrationPlatformBuildSpec{
CamelVersion: "2.22.1",
},
},
Repositories: []string{
"https://repository.apache.org/content/groups/snapshots-group@id=apache-snapshots@snapshots@noreleases",
"https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j-snapshots@snapshots@noreleases",
},
},
}

err := GenerateProject(&ctx)

assert.Nil(t, err)

assert.Equal(t, 1, len(ctx.Project.DependencyManagement.Dependencies.Dependencies))
assert.Equal(t, "org.apache.camel", ctx.Project.DependencyManagement.Dependencies.Dependencies[0].GroupID)
assert.Equal(t, "camel-bom", ctx.Project.DependencyManagement.Dependencies.Dependencies[0].ArtifactID)
assert.Equal(t, "2.22.1", ctx.Project.DependencyManagement.Dependencies.Dependencies[0].Version)
assert.Equal(t, "pom", ctx.Project.DependencyManagement.Dependencies.Dependencies[0].Type)
assert.Equal(t, "import", ctx.Project.DependencyManagement.Dependencies.Dependencies[0].Scope)

assert.Equal(t, 2, len(ctx.Project.Repositories.Repositories))
assert.Equal(t, "apache-snapshots", ctx.Project.Repositories.Repositories[0].ID)
assert.False(t, ctx.Project.Repositories.Repositories[0].Releases.Enabled)
assert.True(t, ctx.Project.Repositories.Repositories[0].Snapshots.Enabled)
assert.Equal(t, "ops4j-snapshots", ctx.Project.Repositories.Repositories[1].ID)
assert.False(t, ctx.Project.Repositories.Repositories[1].Releases.Enabled)
assert.True(t, ctx.Project.Repositories.Repositories[1].Snapshots.Enabled)
}
35 changes: 35 additions & 0 deletions pkg/builder/builder_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ limitations under the License.
package builder

import (
"encoding/xml"
"os"

"github.com/apache/camel-k/pkg/util/maven"
"github.com/apache/camel-k/version"

"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
)

Expand All @@ -41,3 +45,34 @@ func ArtifactIDs(artifacts []v1alpha1.Artifact) []string {

return result
}

// NewProject --
func NewProject(ctx *Context) maven.Project {
return maven.Project{
XMLName: xml.Name{Local: "project"},
XMLNs: "http://maven.apache.org/POM/4.0.0",
XMLNsXsi: "http://www.w3.org/2001/XMLSchema-instance",
XsiSchemaLocation: "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd",
ModelVersion: "4.0.0",
GroupID: "org.apache.camel.k.integration",
ArtifactID: "camel-k-integration",
Version: version.Version,
Properties: ctx.Request.Platform.Build.Properties,
DependencyManagement: maven.DependencyManagement{
Dependencies: maven.Dependencies{
Dependencies: []maven.Dependency{
{
GroupID: "org.apache.camel",
ArtifactID: "camel-bom",
Version: ctx.Request.Platform.Build.CamelVersion,
Type: "pom",
Scope: "import",
},
},
},
},
Dependencies: maven.Dependencies{
Dependencies: make([]maven.Dependency, 0),
},
}
}
47 changes: 18 additions & 29 deletions pkg/builder/springboot/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,33 @@ limitations under the License.
package springboot

import (
"encoding/xml"
"fmt"
"strings"

"github.com/apache/camel-k/pkg/builder"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/maven"
"github.com/apache/camel-k/version"
)

// GenerateProject --
func GenerateProject(ctx *builder.Context) error {
ctx.Project = maven.Project{
XMLName: xml.Name{Local: "project"},
XMLNs: "http://maven.apache.org/POM/4.0.0",
XMLNsXsi: "http://www.w3.org/2001/XMLSchema-instance",
XsiSchemaLocation: "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd",
ModelVersion: "4.0.0",
GroupID: "org.apache.camel.k.integration",
ArtifactID: "camel-k-integration",
Version: version.Version,
DependencyManagement: maven.DependencyManagement{
Dependencies: maven.Dependencies{
Dependencies: []maven.Dependency{
{
//TODO: camel version should be retrieved from an external request or provided as static version
GroupID: "org.apache.camel",
ArtifactID: "camel-bom",
Version: camel.Version,
Type: "pom",
Scope: "import",
},
},
},
},
Dependencies: maven.Dependencies{
Dependencies: make([]maven.Dependency, 0),
},
ctx.Project = builder.NewProject(ctx)

//
// Repositories
//

ctx.Project.Repositories = maven.Repositories{
Repositories: make([]maven.Repository, 0, len(ctx.Request.Repositories)),
}

for i, r := range ctx.Request.Repositories {
repo := maven.NewRepository(r)
if repo.ID == "" {
repo.ID = fmt.Sprintf("repo-%03d", i)
}

ctx.Project.Repositories.Repositories = append(ctx.Project.Repositories.Repositories, repo)
}

//
Expand Down Expand Up @@ -110,7 +99,7 @@ func GenerateProject(ctx *builder.Context) error {
deps.Add(maven.Dependency{
GroupID: "org.apache.camel",
ArtifactID: artifactID + "-starter",
Version: camel.Version,
Version: ctx.Request.Platform.Build.CamelVersion,
Exclusions: &maven.Exclusions{
Exclusions: []maven.Exclusion{
{
Expand Down
Loading