You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/02/21 17:47:42 UTC
[camel-k] branch master updated: add an option to set which runtime
version the operator should to run integrations #469
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push:
new 5e3d879 add an option to set which runtime version the operator should to run integrations #469
5e3d879 is described below
commit 5e3d879fdc8a84fe206275618d9239a4bf7abbc7
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Thu Feb 21 11:08:19 2019 +0100
add an option to set which runtime version the operator should to run integrations #469
---
assets/json-schema/Integration.json | 3 ++
assets/json-schema/IntegrationContext.json | 3 ++
assets/json-schema/IntegrationPlatform.json | 3 ++
cmd/util/publisher/publisher.go | 23 ++++++-----
pkg/apis/camel/v1alpha1/integration_types.go | 1 +
.../camel/v1alpha1/integrationcontext_types.go | 17 +++++----
.../camel/v1alpha1/integrationplatform_types.go | 1 +
pkg/builder/builder_steps.go | 15 +++++---
pkg/builder/builder_steps_test.go | 18 +++++----
pkg/builder/builder_types.go | 21 ++++++-----
pkg/builder/springboot/generator.go | 7 ++--
pkg/cmd/install.go | 44 +++++++++++++++-------
pkg/controller/integration/build_image.go | 15 ++++----
pkg/controller/integration/util.go | 4 +-
pkg/controller/integrationcontext/build.go | 17 +++++----
pkg/controller/integrationplatform/initialize.go | 13 ++++++-
pkg/trait/camel.go | 12 +++++-
pkg/trait/environment.go | 10 +++--
pkg/trait/rest-dsl.go | 2 +-
pkg/trait/types.go | 18 +++++++++
pkg/util/defaults/defaults.go | 5 +++
pkg/util/test/catalog_test.go | 5 ++-
test/builder_integration_test.go | 22 +++++++----
version/version.go | 5 ++-
24 files changed, 190 insertions(+), 94 deletions(-)
diff --git a/assets/json-schema/Integration.json b/assets/json-schema/Integration.json
index e60c5f4..8743c7e 100644
--- a/assets/json-schema/Integration.json
+++ b/assets/json-schema/Integration.json
@@ -270,6 +270,9 @@
},
"phase": {
"type": "string"
+ },
+ "runtimeVersion": {
+ "type": "string"
}
},
"additionalProperties": false,
diff --git a/assets/json-schema/IntegrationContext.json b/assets/json-schema/IntegrationContext.json
index f5453fd..5a3cf87 100644
--- a/assets/json-schema/IntegrationContext.json
+++ b/assets/json-schema/IntegrationContext.json
@@ -266,6 +266,9 @@
},
"publicImage": {
"type": "string"
+ },
+ "runtimeVersion": {
+ "type": "string"
}
},
"additionalProperties": false,
diff --git a/assets/json-schema/IntegrationPlatform.json b/assets/json-schema/IntegrationPlatform.json
index 25694d7..b5cd364 100644
--- a/assets/json-schema/IntegrationPlatform.json
+++ b/assets/json-schema/IntegrationPlatform.json
@@ -157,6 +157,9 @@
"type": "string"
},
"type": "array"
+ },
+ "runtimeVersion": {
+ "type": "string"
}
},
"additionalProperties": false,
diff --git a/cmd/util/publisher/publisher.go b/cmd/util/publisher/publisher.go
index 7313d58..120a90d 100644
--- a/cmd/util/publisher/publisher.go
+++ b/cmd/util/publisher/publisher.go
@@ -28,6 +28,8 @@ import (
"strings"
"time"
+ "github.com/apache/camel-k/pkg/util/defaults"
+
"github.com/apache/camel-k/pkg/apis"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"github.com/apache/camel-k/pkg/builder"
@@ -42,9 +44,10 @@ import (
// PublisherOptions --
type PublisherOptions struct {
- StartWith string
- EndWith string
- BuildAttempts int
+ StartWith string
+ EndWith string
+ RuntimeVersion string
+ BuildAttempts int
}
// Publishes predefined images for all Camel components
@@ -59,6 +62,7 @@ func main() {
cmd.Flags().StringVar(&options.StartWith, "start-with", "", "The component to start with")
cmd.Flags().StringVar(&options.EndWith, "end-with", "", "The component to end with")
+ cmd.Flags().StringVar(&options.RuntimeVersion, "runtime-version", defaults.RuntimeVersion, "The runtime version to use")
cmd.Flags().IntVar(&options.BuildAttempts, "attempts", 5, "The maximum number of build attempts for each image")
panicIfErr(cmd.Execute())
@@ -92,7 +96,7 @@ func (options *PublisherOptions) run(_ *cobra.Command, _ []string) {
if started {
fmt.Printf("building component %s\n", component)
- options.buildWithAttempts(component, catalog)
+ options.buildWithAttempts(component, options.RuntimeVersion, catalog)
} else {
fmt.Printf("skipping component %s\n", component)
}
@@ -105,10 +109,10 @@ func (options *PublisherOptions) run(_ *cobra.Command, _ []string) {
}
}
-func (options *PublisherOptions) buildWithAttempts(component string, catalog *camel.RuntimeCatalog) {
+func (options *PublisherOptions) buildWithAttempts(component string, runtimeVersion string, catalog *camel.RuntimeCatalog) {
var err error
for i := 0; i < options.BuildAttempts; i++ {
- err = options.build(component, catalog)
+ err = options.build(component, runtimeVersion, catalog)
if err != nil {
sleepTime := 5 * (i + 1)
fmt.Printf("waiting %d seconds to recover from error %v\n", sleepTime, err)
@@ -120,7 +124,7 @@ func (options *PublisherOptions) buildWithAttempts(component string, catalog *ca
panicIfErr(errors.Wrap(err, "build failed after maximum number of attempts"))
}
-func (options *PublisherOptions) build(component string, catalog *camel.RuntimeCatalog) error {
+func (options *PublisherOptions) build(component string, runtimeVersion string, catalog *camel.RuntimeCatalog) error {
dir, err := ioutil.TempDir(os.TempDir(), "camel-k-build-")
if err != nil {
return err
@@ -138,8 +142,9 @@ func (options *PublisherOptions) build(component string, catalog *camel.RuntimeC
Catalog: catalog,
Path: dir,
Request: builder.Request{
- C: cancellable.NewContext(),
- Catalog: catalog,
+ C: cancellable.NewContext(),
+ Catalog: catalog,
+ RuntimeVersion: runtimeVersion,
Platform: v1alpha1.IntegrationPlatformSpec{
Build: v1alpha1.IntegrationPlatformBuildSpec{
CamelVersion: catalog.Version,
diff --git a/pkg/apis/camel/v1alpha1/integration_types.go b/pkg/apis/camel/v1alpha1/integration_types.go
index e3dee63..3118324 100644
--- a/pkg/apis/camel/v1alpha1/integration_types.go
+++ b/pkg/apis/camel/v1alpha1/integration_types.go
@@ -30,6 +30,7 @@ type IntegrationStatus struct {
GeneratedSources []SourceSpec `json:"generatedSources,omitempty"`
Failure *Failure `json:"failure,omitempty"`
CamelVersion string `json:"camelVersion,omitempty"`
+ RuntimeVersion string `json:"runtimeVersion,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
diff --git a/pkg/apis/camel/v1alpha1/integrationcontext_types.go b/pkg/apis/camel/v1alpha1/integrationcontext_types.go
index f2e072a..c0b733c 100644
--- a/pkg/apis/camel/v1alpha1/integrationcontext_types.go
+++ b/pkg/apis/camel/v1alpha1/integrationcontext_types.go
@@ -18,14 +18,15 @@ type IntegrationContextSpec struct {
// IntegrationContextStatus defines the observed state of IntegrationContext
type IntegrationContextStatus struct {
- Phase IntegrationContextPhase `json:"phase,omitempty"`
- BaseImage string `json:"baseImage,omitempty"`
- Image string `json:"image,omitempty"`
- PublicImage string `json:"publicImage,omitempty"`
- Digest string `json:"digest,omitempty"`
- Artifacts []Artifact `json:"artifacts,omitempty"`
- Failure *Failure `json:"failure,omitempty"`
- CamelVersion string `json:"camelVersion,omitempty"`
+ Phase IntegrationContextPhase `json:"phase,omitempty"`
+ BaseImage string `json:"baseImage,omitempty"`
+ Image string `json:"image,omitempty"`
+ PublicImage string `json:"publicImage,omitempty"`
+ Digest string `json:"digest,omitempty"`
+ Artifacts []Artifact `json:"artifacts,omitempty"`
+ Failure *Failure `json:"failure,omitempty"`
+ CamelVersion string `json:"camelVersion,omitempty"`
+ RuntimeVersion string `json:"runtimeVersion,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
diff --git a/pkg/apis/camel/v1alpha1/integrationplatform_types.go b/pkg/apis/camel/v1alpha1/integrationplatform_types.go
index e2c94f0..6ea1271 100644
--- a/pkg/apis/camel/v1alpha1/integrationplatform_types.go
+++ b/pkg/apis/camel/v1alpha1/integrationplatform_types.go
@@ -76,6 +76,7 @@ type IntegrationPlatformBuildSpec struct {
Organization string `json:"organization,omitempty"`
PushSecret string `json:"pushSecret,omitempty"`
CamelVersion string `json:"camelVersion,omitempty"`
+ RuntimeVersion string `json:"runtimeVersion,omitempty"`
BaseImage string `json:"baseImage,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
LocalRepository string `json:"localRepository,omitempty"`
diff --git a/pkg/builder/builder_steps.go b/pkg/builder/builder_steps.go
index 0e925de..3fb2be5 100644
--- a/pkg/builder/builder_steps.go
+++ b/pkg/builder/builder_steps.go
@@ -36,7 +36,6 @@ import (
"github.com/pkg/errors"
"github.com/apache/camel-k/pkg/util/maven"
- "github.com/apache/camel-k/version"
)
// GenerateProject --
@@ -53,6 +52,7 @@ func GenerateProject(ctx *Context) error {
//
ctx.Project.Repositories = make([]maven.Repository, 0, len(ctx.Request.Repositories))
+ ctx.Project.PluginRepositories = make([]maven.Repository, 0, len(ctx.Request.Repositories))
for i, r := range ctx.Request.Repositories {
repo := maven.NewRepository(r)
@@ -61,13 +61,14 @@ func GenerateProject(ctx *Context) error {
}
ctx.Project.Repositories = append(ctx.Project.Repositories, repo)
+ ctx.Project.PluginRepositories = append(ctx.Project.PluginRepositories, repo)
}
//
// set-up dependencies
//
- ctx.Project.AddDependencyGAV("org.apache.camel.k", "camel-k-runtime-jvm", version.Version)
+ ctx.Project.AddDependencyGAV("org.apache.camel.k", "camel-k-runtime-jvm", ctx.Request.RuntimeVersion)
for _, d := range ctx.Request.Dependencies {
switch {
@@ -86,7 +87,7 @@ func GenerateProject(ctx *Context) error {
artifactID = "camel-" + artifactID
}
- ctx.Project.AddDependencyGAV("org.apache.camel.k", artifactID, version.Version)
+ ctx.Project.AddDependencyGAV("org.apache.camel.k", artifactID, ctx.Request.RuntimeVersion)
case strings.HasPrefix(d, "mvn:"):
mid := strings.TrimPrefix(d, "mvn:")
gav := strings.Replace(mid, "/", ":", -1)
@@ -95,7 +96,7 @@ func GenerateProject(ctx *Context) error {
case strings.HasPrefix(d, "runtime:"):
artifactID := strings.Replace(d, "runtime:", "camel-k-runtime-", 1)
- ctx.Project.AddDependencyGAV("org.apache.camel.k", artifactID, version.Version)
+ ctx.Project.AddDependencyGAV("org.apache.camel.k", artifactID, ctx.Request.RuntimeVersion)
default:
return fmt.Errorf("unknown dependency type: %s", d)
}
@@ -174,7 +175,7 @@ func ComputeDependencies(ctx *Context) error {
opts := make([]string, 0, 2)
opts = append(opts, maven.ExtraOptions(ctx.Request.Platform.Build.LocalRepository)...)
- opts = append(opts, fmt.Sprintf("org.apache.camel.k:camel-k-maven-plugin:%s:generate-dependency-list", version.Version))
+ opts = append(opts, fmt.Sprintf("org.apache.camel.k:camel-k-maven-plugin:%s:generate-dependency-list", ctx.Request.RuntimeVersion))
err = maven.Run(p, opts...)
if err != nil {
@@ -314,10 +315,12 @@ func ListPublishedImages(context *Context) ([]PublishedImage, error) {
for _, item := range list.Items {
ctx := item
- // TODO: add support for semver lookup
if ctx.Status.CamelVersion != context.Catalog.Version {
continue
}
+ if ctx.Status.RuntimeVersion != context.Request.RuntimeVersion {
+ continue
+ }
if ctx.Status.Phase != v1alpha1.IntegrationContextPhaseReady || ctx.Labels == nil {
continue
}
diff --git a/pkg/builder/builder_steps_test.go b/pkg/builder/builder_steps_test.go
index f884384..fc69f33 100644
--- a/pkg/builder/builder_steps_test.go
+++ b/pkg/builder/builder_steps_test.go
@@ -20,12 +20,12 @@ package builder
import (
"testing"
- "github.com/apache/camel-k/pkg/util/test"
+ "github.com/apache/camel-k/pkg/util/defaults"
- "github.com/apache/camel-k/pkg/util/maven"
- "github.com/apache/camel-k/version"
+ "github.com/apache/camel-k/pkg/util/test"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/pkg/util/maven"
"github.com/stretchr/testify/assert"
)
@@ -37,7 +37,8 @@ func TestGenerateJvmProject(t *testing.T) {
ctx := Context{
Catalog: catalog,
Request: Request{
- Catalog: catalog,
+ Catalog: catalog,
+ RuntimeVersion: defaults.RuntimeVersion,
Platform: v1alpha1.IntegrationPlatformSpec{
Build: v1alpha1.IntegrationPlatformBuildSpec{
CamelVersion: catalog.Version,
@@ -65,7 +66,7 @@ func TestGenerateJvmProject(t *testing.T) {
assert.Contains(t, ctx.Project.Dependencies, maven.Dependency{
GroupID: "org.apache.camel.k",
ArtifactID: "camel-k-runtime-jvm",
- Version: version.Version,
+ Version: defaults.RuntimeVersion,
Type: "jar",
})
assert.Contains(t, ctx.Project.Dependencies, maven.Dependency{
@@ -81,7 +82,8 @@ func TestGenerateGroovyProject(t *testing.T) {
ctx := Context{
Catalog: catalog,
Request: Request{
- Catalog: catalog,
+ Catalog: catalog,
+ RuntimeVersion: defaults.RuntimeVersion,
Platform: v1alpha1.IntegrationPlatformSpec{
Build: v1alpha1.IntegrationPlatformBuildSpec{
CamelVersion: catalog.Version,
@@ -110,13 +112,13 @@ func TestGenerateGroovyProject(t *testing.T) {
assert.Contains(t, ctx.Project.Dependencies, maven.Dependency{
GroupID: "org.apache.camel.k",
ArtifactID: "camel-k-runtime-jvm",
- Version: version.Version,
+ Version: defaults.RuntimeVersion,
Type: "jar",
})
assert.Contains(t, ctx.Project.Dependencies, maven.Dependency{
GroupID: "org.apache.camel.k",
ArtifactID: "camel-k-runtime-groovy",
- Version: version.Version,
+ Version: defaults.RuntimeVersion,
Type: "jar",
})
assert.Contains(t, ctx.Project.Dependencies, maven.Dependency{
diff --git a/pkg/builder/builder_types.go b/pkg/builder/builder_types.go
index c7a4e5b..2668e09 100644
--- a/pkg/builder/builder_types.go
+++ b/pkg/builder/builder_types.go
@@ -104,16 +104,17 @@ type Resource struct {
// Request --
type Request struct {
- C cancellable.Context
- Catalog *camel.RuntimeCatalog
- Meta metav1.ObjectMeta
- Platform v1alpha1.IntegrationPlatformSpec
- Dependencies []string
- Repositories []string
- Steps []Step
- BuildDir string
- Image string
- Resources []Resource
+ C cancellable.Context
+ Catalog *camel.RuntimeCatalog
+ RuntimeVersion string
+ Meta metav1.ObjectMeta
+ Platform v1alpha1.IntegrationPlatformSpec
+ Dependencies []string
+ Repositories []string
+ Steps []Step
+ BuildDir string
+ Image string
+ Resources []Resource
}
// Task --
diff --git a/pkg/builder/springboot/generator.go b/pkg/builder/springboot/generator.go
index 8d2258e..1062b9e 100644
--- a/pkg/builder/springboot/generator.go
+++ b/pkg/builder/springboot/generator.go
@@ -23,7 +23,6 @@ import (
"github.com/apache/camel-k/pkg/builder"
"github.com/apache/camel-k/pkg/util/maven"
- "github.com/apache/camel-k/version"
)
// GenerateProject --
@@ -57,7 +56,7 @@ func GenerateProject(ctx *builder.Context) error {
ctx.Project.AddDependency(maven.Dependency{
GroupID: "org.apache.camel.k",
ArtifactID: "camel-k-runtime-spring-boot",
- Version: version.Version,
+ Version: ctx.Request.RuntimeVersion,
Exclusions: &[]maven.Exclusion{
{
GroupID: "org.apache.camel",
@@ -125,7 +124,7 @@ func GenerateProject(ctx *builder.Context) error {
artifactID = "camel-" + artifactID
}
- ctx.Project.AddDependencyGAV("org.apache.camel.k", artifactID, version.Version)
+ ctx.Project.AddDependencyGAV("org.apache.camel.k", artifactID, ctx.Request.RuntimeVersion)
case strings.HasPrefix(d, "mvn:"):
mid := strings.TrimPrefix(d, "mvn:")
gav := strings.Replace(mid, "/", ":", -1)
@@ -142,7 +141,7 @@ func GenerateProject(ctx *builder.Context) error {
}
artifactID := strings.Replace(d, "runtime:", "camel-k-runtime-", 1)
- dependency := maven.NewDependency("org.apache.camel.k", artifactID, version.Version)
+ dependency := maven.NewDependency("org.apache.camel.k", artifactID, ctx.Request.RuntimeVersion)
ctx.Project.AddDependency(dependency)
default:
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index e207b22..8b59fd2 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -59,6 +59,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
cmd.Flags().StringVar(&impl.organization, "organization", "", "A organization on the Docker registry that can be used to publish images")
cmd.Flags().StringVar(&impl.pushSecret, "push-secret", "", "A secret used to push images to the Docker registry")
cmd.Flags().StringSliceVar(&impl.repositories, "repository", nil, "Add a maven repository")
+ cmd.Flags().BoolVar(&impl.snapshotRepositories, "snapshot-repositories", false, "Automatically include known snapshot repositories")
cmd.Flags().StringVar(&impl.localRepository, "local-repository", "", "Location of the local maven repository")
cmd.Flags().StringSliceVarP(&impl.properties, "property", "p", nil, "Add a camel property")
cmd.Flags().StringVar(&impl.camelVersion, "camel-version", "", "Set the camel version")
@@ -79,20 +80,21 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
type installCmdOptions struct {
*RootCmdOptions
- wait bool
- clusterSetupOnly bool
- skipClusterSetup bool
- exampleSetup bool
- registry string
- outputFormat string
- organization string
- pushSecret string
- camelVersion string
- baseImage string
- localRepository string
- repositories []string
- properties []string
- contexts []string
+ wait bool
+ clusterSetupOnly bool
+ skipClusterSetup bool
+ exampleSetup bool
+ snapshotRepositories bool
+ registry string
+ outputFormat string
+ organization string
+ pushSecret string
+ camelVersion string
+ baseImage string
+ localRepository string
+ repositories []string
+ properties []string
+ contexts []string
}
func (o *installCmdOptions) install(_ *cobra.Command, _ []string) error {
@@ -155,6 +157,20 @@ func (o *installCmdOptions) install(_ *cobra.Command, _ []string) error {
if len(o.repositories) > 0 {
platform.Spec.Build.Repositories = o.repositories
}
+ if o.snapshotRepositories {
+ if platform.Spec.Build.Repositories == nil {
+ platform.Spec.Build.Repositories = make([]string, 0)
+ }
+
+ platform.Spec.Build.Repositories = append(
+ platform.Spec.Build.Repositories,
+ "https://repository.apache.org/content/repositories/snapshots@id=apache.snapshots@snapshots",
+ )
+ platform.Spec.Build.Repositories = append(
+ platform.Spec.Build.Repositories,
+ "https://oss.sonatype.org/content/repositories/snapshots/@id=sonatype.snapshots@snapshots",
+ )
+ }
if o.camelVersion != "" {
platform.Spec.Build.CamelVersion = o.camelVersion
}
diff --git a/pkg/controller/integration/build_image.go b/pkg/controller/integration/build_image.go
index 6f2645f..136b33e 100644
--- a/pkg/controller/integration/build_image.go
+++ b/pkg/controller/integration/build_image.go
@@ -122,13 +122,14 @@ func (action *buildImageAction) handleBuildImageSubmitted(ctx context.Context, i
// happens asynchronously, a new context has to be created. the new context
// can be used also to stop the build.
r := builder.Request{
- C: cancellable.NewContext(),
- Catalog: env.CamelCatalog,
- Meta: integration.ObjectMeta,
- Steps: env.Steps,
- BuildDir: env.BuildDir,
- Platform: env.Platform.Spec,
- Image: ictx.Status.Image,
+ C: cancellable.NewContext(),
+ Catalog: env.CamelCatalog,
+ RuntimeVersion: env.RuntimeVersion,
+ Meta: integration.ObjectMeta,
+ Steps: env.Steps,
+ BuildDir: env.BuildDir,
+ Platform: env.Platform.Spec,
+ Image: ictx.Status.Image,
// Sources are added as part of the standard deployment bits
Resources: make([]builder.Resource, 0, len(integration.Spec.Sources)),
}
diff --git a/pkg/controller/integration/util.go b/pkg/controller/integration/util.go
index 9f95176..d471a0b 100644
--- a/pkg/controller/integration/util.go
+++ b/pkg/controller/integration/util.go
@@ -55,10 +55,12 @@ func LookupContextForIntegration(ctx context.Context, c k8sclient.Reader, integr
for _, ctx := range ctxList.Items {
ctx := ctx // pin
- // TODO: we should add support for semver lookup
if ctx.Status.CamelVersion != integration.Status.CamelVersion {
continue
}
+ if ctx.Status.RuntimeVersion != integration.Status.RuntimeVersion {
+ continue
+ }
if allowed, ok := allowedLookupLabels[ctx.Labels["camel.apache.org/context.type"]]; ok && allowed {
ideps := len(integration.Status.Dependencies)
diff --git a/pkg/controller/integrationcontext/build.go b/pkg/controller/integrationcontext/build.go
index 8dad883..13c0f6d 100644
--- a/pkg/controller/integrationcontext/build.go
+++ b/pkg/controller/integrationcontext/build.go
@@ -111,14 +111,15 @@ func (action *buildAction) handleBuildSubmitted(ctx context.Context, ictx *v1alp
// happens asynchronously, a new context has to be created. the new context
// can be used also to stop the build.
r := builder.Request{
- C: cancellable.NewContext(),
- Catalog: env.CamelCatalog,
- Meta: ictx.ObjectMeta,
- Dependencies: ictx.Spec.Dependencies,
- Repositories: repositories,
- Steps: env.Steps,
- BuildDir: env.BuildDir,
- Platform: env.Platform.Spec,
+ C: cancellable.NewContext(),
+ Catalog: env.CamelCatalog,
+ RuntimeVersion: env.RuntimeVersion,
+ Meta: ictx.ObjectMeta,
+ Dependencies: ictx.Spec.Dependencies,
+ Repositories: repositories,
+ Steps: env.Steps,
+ BuildDir: env.BuildDir,
+ Platform: env.Platform.Spec,
}
b.Submit(r, func(result *builder.Result) {
diff --git a/pkg/controller/integrationplatform/initialize.go b/pkg/controller/integrationplatform/initialize.go
index cda5272..946e56d 100644
--- a/pkg/controller/integrationplatform/initialize.go
+++ b/pkg/controller/integrationplatform/initialize.go
@@ -93,10 +93,12 @@ func (action *initializeAction) Handle(ctx context.Context, platform *v1alpha1.I
if target.Spec.Profile == "" {
target.Spec.Profile = platformutils.GetProfile(target)
}
-
if target.Spec.Build.CamelVersion == "" {
target.Spec.Build.CamelVersion = defaults.CamelVersion
}
+ if target.Spec.Build.RuntimeVersion == "" {
+ target.Spec.Build.RuntimeVersion = defaults.RuntimeVersion
+ }
if target.Spec.Build.BaseImage == "" {
target.Spec.Build.BaseImage = defaults.BaseImage
}
@@ -105,9 +107,18 @@ func (action *initializeAction) Handle(ctx context.Context, platform *v1alpha1.I
}
action.L.Infof("CamelVersion set to %s", target.Spec.Build.CamelVersion)
+ action.L.Infof("RuntimeVersion set to %s", target.Spec.Build.RuntimeVersion)
action.L.Infof("BaseImage set to %s", target.Spec.Build.BaseImage)
action.L.Infof("LocalRepository set to %s", target.Spec.Build.LocalRepository)
+ for i, r := range target.Spec.Build.Repositories {
+ if i == 0 {
+ action.L.Info("Repositories:")
+ }
+
+ action.L.Infof(" %d - %s", i, r)
+ }
+
action.L.Info("IntegrationPlatform state transition", "phase", target.Status.Phase)
err = action.client.Update(ctx, target)
diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go
index 98464a4..6094832 100644
--- a/pkg/trait/camel.go
+++ b/pkg/trait/camel.go
@@ -24,8 +24,9 @@ import (
)
type camelTrait struct {
- BaseTrait `property:",squash"`
- Version string `property:"version"`
+ BaseTrait `property:",squash"`
+ Version string `property:"version"`
+ RuntimeVersion string `property:"runtime-version"`
}
func newCamelTrait() *camelTrait {
@@ -43,6 +44,11 @@ func (t *camelTrait) Configure(e *Environment) (bool, error) {
}
func (t *camelTrait) Apply(e *Environment) error {
+ e.RuntimeVersion = e.DetermineRuntimeVersion()
+ if t.RuntimeVersion != "" {
+ e.RuntimeVersion = t.RuntimeVersion
+ }
+
if e.Integration != nil {
if e.CamelCatalog == nil {
version := e.DetermineCamelVersion()
@@ -63,6 +69,7 @@ func (t *camelTrait) Apply(e *Environment) error {
}
e.Integration.Status.CamelVersion = e.CamelCatalog.Version
+ e.Integration.Status.RuntimeVersion = e.RuntimeVersion
}
if e.IntegrationContext != nil {
@@ -85,6 +92,7 @@ func (t *camelTrait) Apply(e *Environment) error {
}
e.IntegrationContext.Status.CamelVersion = e.CamelCatalog.Version
+ e.IntegrationContext.Status.RuntimeVersion = e.RuntimeVersion
}
return nil
diff --git a/pkg/trait/environment.go b/pkg/trait/environment.go
index 8845f43..34567e6 100644
--- a/pkg/trait/environment.go
+++ b/pkg/trait/environment.go
@@ -29,9 +29,11 @@ type environmentTrait struct {
}
const (
- envVarNamespace = "NAMESPACE"
- envVarPodName = "POD_NAME"
- envVarCamelKVersion = "CAMEL_K_VERSION"
+ envVarNamespace = "NAMESPACE"
+ envVarPodName = "POD_NAME"
+ envVarCamelKVersion = "CAMEL_K_VERSION"
+ envVarCamelKRuntimeVersion = "CAMEL_K_RUNTIME_VERSION"
+ envVarCamelVersion = "CAMEL_VERSION"
)
func newEnvironmentTrait() *environmentTrait {
@@ -51,6 +53,8 @@ func (t *environmentTrait) Configure(e *Environment) (bool, error) {
func (t *environmentTrait) Apply(e *Environment) error {
envvar.SetVal(&e.EnvVars, envVarCamelKVersion, version.Version)
+ envvar.SetVal(&e.EnvVars, envVarCamelKRuntimeVersion, e.RuntimeVersion)
+ envvar.SetVal(&e.EnvVars, envVarCamelVersion, e.CamelCatalog.Version)
if t.ContainerMeta {
envvar.SetValFrom(&e.EnvVars, envVarNamespace, "metadata.namespace")
diff --git a/pkg/trait/rest-dsl.go b/pkg/trait/rest-dsl.go
index 9d9e117..f10f9b1 100644
--- a/pkg/trait/rest-dsl.go
+++ b/pkg/trait/rest-dsl.go
@@ -222,7 +222,7 @@ func (t *restDslTrait) generateProject(e *Environment) (maven.Project, error) {
{
GroupID: "org.apache.camel.k",
ArtifactID: "camel-k-maven-plugin",
- Version: version.Version,
+ Version: e.RuntimeVersion,
Executions: []maven.Execution{
{
Phase: "generate-resources",
diff --git a/pkg/trait/types.go b/pkg/trait/types.go
index 84bced3..d91e72c 100644
--- a/pkg/trait/types.go
+++ b/pkg/trait/types.go
@@ -94,6 +94,7 @@ func (trait *BaseTrait) InjectContext(ctx context.Context) {
// A Environment provides the context where the trait is executed
type Environment struct {
CamelCatalog *camel.RuntimeCatalog
+ RuntimeVersion string
Catalog *Catalog
C context.Context
Client client.Client
@@ -214,3 +215,20 @@ func (e *Environment) DetermineCamelVersion() string {
return version
}
+
+// DetermineRuntimeVersion --
+func (e *Environment) DetermineRuntimeVersion() string {
+ var version string
+
+ if e.Integration != nil {
+ version = e.Integration.Status.RuntimeVersion
+ }
+ if e.IntegrationContext != nil && version == "" {
+ version = e.IntegrationContext.Status.RuntimeVersion
+ }
+ if version == "" {
+ version = e.Platform.Spec.Build.RuntimeVersion
+ }
+
+ return version
+}
diff --git a/pkg/util/defaults/defaults.go b/pkg/util/defaults/defaults.go
index b4cca59..3b19a5f 100644
--- a/pkg/util/defaults/defaults.go
+++ b/pkg/util/defaults/defaults.go
@@ -17,10 +17,15 @@ limitations under the License.
package defaults
+import "github.com/apache/camel-k/version"
+
const (
// CamelVersion --
CamelVersion = "~2.23.x"
+ // RuntimeVersion --
+ RuntimeVersion = version.Version
+
// BaseImage --
BaseImage = "fabric8/s2i-java:3.0-java8"
diff --git a/pkg/util/test/catalog_test.go b/pkg/util/test/catalog_test.go
index d43c9e8..38a2cf2 100644
--- a/pkg/util/test/catalog_test.go
+++ b/pkg/util/test/catalog_test.go
@@ -20,7 +20,8 @@ package test
import (
"testing"
- "github.com/apache/camel-k/version"
+ "github.com/apache/camel-k/pkg/util/defaults"
+
"github.com/stretchr/testify/assert"
)
@@ -34,7 +35,7 @@ func TestRuntimeContainsEmbeddedArtifacts(t *testing.T) {
assert.Equal(t, 1, len(artifact.Schemes))
assert.Equal(t, "org.apache.camel.k", artifact.GroupID)
assert.Equal(t, "camel-knative", artifact.ArtifactID)
- assert.Equal(t, version.Version, artifact.Version)
+ assert.Equal(t, defaults.RuntimeVersion, artifact.Version)
scheme, found := catalog.GetScheme("knative")
assert.True(t, found)
diff --git a/test/builder_integration_test.go b/test/builder_integration_test.go
index b2e6e7a..293724c 100644
--- a/test/builder_integration_test.go
+++ b/test/builder_integration_test.go
@@ -26,6 +26,8 @@ import (
"testing"
"time"
+ "github.com/apache/camel-k/pkg/util/defaults"
+
"github.com/apache/camel-k/pkg/util/test"
"github.com/apache/camel-k/pkg/util/cancellable"
@@ -62,16 +64,18 @@ func TestBuildManagerBuild(t *testing.T) {
assert.Nil(t, err)
r := builder.Request{
- C: cancellable.NewContext(),
- Catalog: catalog,
+ C: cancellable.NewContext(),
+ Catalog: catalog,
+ RuntimeVersion: defaults.RuntimeVersion,
Meta: v1.ObjectMeta{
Name: "man-test",
ResourceVersion: "1",
},
Platform: v1alpha1.IntegrationPlatformSpec{
Build: v1alpha1.IntegrationPlatformBuildSpec{
- CamelVersion: catalog.Version,
- BaseImage: "docker.io/fabric8/s2i-java:3.0-java8",
+ CamelVersion: catalog.Version,
+ RuntimeVersion: defaults.RuntimeVersion,
+ BaseImage: "docker.io/fabric8/s2i-java:3.0-java8",
},
},
Dependencies: []string{
@@ -108,16 +112,18 @@ func TestBuildManagerFailedBuild(t *testing.T) {
assert.Nil(t, err)
r := builder.Request{
- C: cancellable.NewContext(),
- Catalog: catalog,
+ C: cancellable.NewContext(),
+ Catalog: catalog,
+ RuntimeVersion: defaults.RuntimeVersion,
Meta: v1.ObjectMeta{
Name: "man-test",
ResourceVersion: "1",
},
Platform: v1alpha1.IntegrationPlatformSpec{
Build: v1alpha1.IntegrationPlatformBuildSpec{
- CamelVersion: catalog.Version,
- BaseImage: "docker.io/fabric8/s2i-java:3.0-java8",
+ CamelVersion: catalog.Version,
+ RuntimeVersion: defaults.RuntimeVersion,
+ BaseImage: "docker.io/fabric8/s2i-java:3.0-java8",
},
},
Dependencies: []string{
diff --git a/version/version.go b/version/version.go
index 72892b7..9a73247 100644
--- a/version/version.go
+++ b/version/version.go
@@ -15,10 +15,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-// Do not change this file manually
package version
-var (
+// Do not change this file manually
+
+const (
// Version is the global Camel K Version
Version = "0.3.0-SNAPSHOT"
)