You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/10/09 10:32:58 UTC

[camel-k] branch main updated (48c4ad30a -> 9d1143f80)

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

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


    from 48c4ad30a chore(deps): bump github.com/spf13/viper from 1.16.0 to 1.17.0
     new e3e947fb6 feat(core): Move jib plugins versions to camelcatalog
     new 9d1143f80 refactor: use existing getting for catalog versions

The 2 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/v1/camelcatalog_types_support.go | 10 ++++++++++
 pkg/cmd/version.go                              |  6 +++---
 pkg/cmd/version_test.go                         |  6 +++---
 pkg/trait/builder.go                            |  8 ++++++--
 pkg/util/jib/configuration.go                   | 26 +++++++++++++++----------
 pkg/util/jib/configuration_test.go              | 19 +++++++++++++++---
 6 files changed, 54 insertions(+), 21 deletions(-)


[camel-k] 01/02: feat(core): Move jib plugins versions to camelcatalog

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

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

commit e3e947fb6151aab653a762522ab86f8fe051fb30
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Thu Oct 5 17:22:01 2023 +0200

    feat(core): Move jib plugins versions to camelcatalog
    
    Ref #4703
    
    Extracted jib plugin versions to camel-k-runtime:
    * use .spec.runtime.metadata values
    * set default values for catalog backward compatibility
---
 pkg/apis/camel/v1/camelcatalog_types_support.go | 10 ++++++++++
 pkg/trait/builder.go                            |  8 ++++++--
 pkg/util/jib/configuration.go                   | 26 +++++++++++++++----------
 pkg/util/jib/configuration_test.go              | 19 +++++++++++++++---
 4 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/pkg/apis/camel/v1/camelcatalog_types_support.go b/pkg/apis/camel/v1/camelcatalog_types_support.go
index ddc597c6b..98a016170 100644
--- a/pkg/apis/camel/v1/camelcatalog_types_support.go
+++ b/pkg/apis/camel/v1/camelcatalog_types_support.go
@@ -202,6 +202,16 @@ func (c *CamelCatalogSpec) GetQuarkusToolingImage() string {
 	return c.Runtime.Metadata["quarkus.native-builder-image"]
 }
 
+// GetJibMavenPluginVersion returns the Jib plugin version required to publish an integration kit based on this catalog with jib strategy.
+func (c *CamelCatalogSpec) GetJibMavenPluginVersion() string {
+	return c.Runtime.Metadata["jib.maven-plugin.version"]
+}
+
+// GetJibLayerFilterExtensionMavenVersion returns the Jib layer filter plugin version required to publish an integration kit based on this catalog with jib strategy.
+func (c *CamelCatalogSpec) GetJibLayerFilterExtensionMavenVersion() string {
+	return c.Runtime.Metadata["jib.layer-filter-extension-maven.version"]
+}
+
 // HasCapability checks if the given capability is present in the catalog.
 func (c *CamelCatalogSpec) HasCapability(capability string) bool {
 	_, ok := c.Runtime.Capabilities[capability]
diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go
index f1c6a7f49..805ba37ef 100644
--- a/pkg/trait/builder.go
+++ b/pkg/trait/builder.go
@@ -350,8 +350,12 @@ func (t *builderTrait) builderTask(e *Environment, taskConf *v1.BuildConfigurati
 	}
 
 	if e.Platform.Status.Build.PublishStrategy == v1.IntegrationPlatformBuildPublishStrategyJib {
-		if err := jib.CreateProfileConfigmap(e.Ctx, e.Client, e.IntegrationKit); err != nil {
-			return nil, fmt.Errorf("could not create default maven jib profile: %w. ", err)
+		profile, err := jib.JibMavenProfile(e.CamelCatalog.GetJibMavenPluginVersion(), e.CamelCatalog.GetJibLayerFilterExtensionMavenVersion())
+		if err != nil {
+			return nil, fmt.Errorf("error generating default maven jib profile: %w. ", err)
+		}
+		if err := jib.CreateProfileConfigmap(e.Ctx, e.Client, e.IntegrationKit, profile); err != nil {
+			return nil, fmt.Errorf("could not create default maven jib profile configmap: %w. ", err)
 		}
 		t.MavenProfiles = append(t.MavenProfiles, "configmap:"+e.IntegrationKit.Name+"-publish-jib-profile/profile.xml")
 	}
diff --git a/pkg/util/jib/configuration.go b/pkg/util/jib/configuration.go
index 4497f9c8d..ac54676e4 100644
--- a/pkg/util/jib/configuration.go
+++ b/pkg/util/jib/configuration.go
@@ -38,6 +38,8 @@ const JibMavenToImageParam = "-Djib.to.image="
 const JibMavenFromImageParam = "-Djib.from.image="
 const JibMavenInsecureRegistries = "-Djib.allowInsecureRegistries="
 const JibDigestFile = "target/jib-image.digest"
+const JibMavenPluginVersionDefault = "3.3.2"
+const JibLayerFilterExtensionMavenVersionDefault = "0.3.0"
 
 type JibBuild struct {
 	Plugins []maven.Plugin `xml:"plugins>plugin,omitempty"`
@@ -50,12 +52,7 @@ type JibProfile struct {
 }
 
 // Create a Configmap containing the default jib profile.
-func CreateProfileConfigmap(ctx context.Context, c client.Client, kit *v1.IntegrationKit) error {
-	profile, err := jibMavenProfile()
-	if err != nil {
-		return fmt.Errorf("error generating default maven jib profile: %w. ", err)
-	}
-
+func CreateProfileConfigmap(ctx context.Context, c client.Client, kit *v1.IntegrationKit, profile string) error {
 	annotations := util.CopyMap(kit.Annotations)
 	controller := true
 	blockOwnerDeletion := true
@@ -86,23 +83,32 @@ func CreateProfileConfigmap(ctx context.Context, c client.Client, kit *v1.Integr
 		},
 	}
 
-	err = c.Create(ctx, jibProfileConfigMap)
+	err := c.Create(ctx, jibProfileConfigMap)
 	if err != nil && !k8serrors.IsAlreadyExists(err) {
 		return fmt.Errorf("error creating the configmap containing the default maven jib profile: %s: %w. ", kit.Name+"-publish-jib-profile", err)
 	}
 	return nil
 }
 
-func jibMavenProfile() (string, error) {
+// Create a maven profile defining jib plugin build.
+func JibMavenProfile(jibMavenPluginVersion string, jibLayerFilterExtensionMavenVersion string) (string, error) {
+	jibVersion := JibMavenPluginVersionDefault
+	if jibMavenPluginVersion != "" {
+		jibVersion = jibMavenPluginVersion
+	}
+	layerVersion := JibLayerFilterExtensionMavenVersionDefault
+	if jibLayerFilterExtensionMavenVersion != "" {
+		layerVersion = jibLayerFilterExtensionMavenVersion
+	}
 	jibPlugin := maven.Plugin{
 		GroupID:    "com.google.cloud.tools",
 		ArtifactID: "jib-maven-plugin",
-		Version:    "3.3.2",
+		Version:    jibVersion,
 		Dependencies: []maven.Dependency{
 			{
 				GroupID:    "com.google.cloud.tools",
 				ArtifactID: "jib-layer-filter-extension-maven",
-				Version:    "0.3.0",
+				Version:    layerVersion,
 			},
 		},
 		Configuration: v1.PluginConfiguration{
diff --git a/pkg/util/jib/configuration_test.go b/pkg/util/jib/configuration_test.go
index 9f5f8ca90..418885f57 100644
--- a/pkg/util/jib/configuration_test.go
+++ b/pkg/util/jib/configuration_test.go
@@ -32,11 +32,24 @@ import (
 )
 
 func TestJibMavenProfile(t *testing.T) {
-	profile, err := jibMavenProfile()
+	profile, err := JibMavenProfile("3.3.0", "0.2.0")
 
 	assert.NoError(t, err)
 	assert.True(t, strings.HasPrefix(profile, "<profile>"))
 	assert.True(t, strings.HasSuffix(profile, "</profile>"))
+	assert.True(t, strings.Contains(profile, "<version>3.3.0</version>"))
+	assert.True(t, strings.Contains(profile, "<version>0.2.0</version>"))
+
+}
+
+func TestJibMavenProfileDefaultValues(t *testing.T) {
+	profile, err := JibMavenProfile("", "")
+
+	assert.NoError(t, err)
+	assert.True(t, strings.HasPrefix(profile, "<profile>"))
+	assert.True(t, strings.HasSuffix(profile, "</profile>"))
+	assert.True(t, strings.Contains(profile, "<version>"+JibMavenPluginVersionDefault+"</version>"))
+	assert.True(t, strings.Contains(profile, "<version>"+JibLayerFilterExtensionMavenVersionDefault+"</version>"))
 
 }
 
@@ -58,7 +71,7 @@ func TestJibConfigMap(t *testing.T) {
 		},
 	}
 
-	err := CreateProfileConfigmap(ctx, c, kit)
+	err := CreateProfileConfigmap(ctx, c, kit, "<profile>awesomeprofile</profile>")
 	assert.NoError(t, err)
 
 	key := ctrl.ObjectKey{
@@ -71,5 +84,5 @@ func TestJibConfigMap(t *testing.T) {
 	assert.Equal(t, cm.OwnerReferences[0].Name, "test")
 	assert.Equal(t, cm.OwnerReferences[0].UID, types.UID("8dc44a2b-063c-490e-ae02-1fab285ac70a"))
 	assert.NotNil(t, cm.Data["profile.xml"])
-
+	assert.True(t, strings.Contains(cm.Data["profile.xml"], "awesome"))
 }


[camel-k] 02/02: refactor: use existing getting for catalog versions

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

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

commit 9d1143f803f0aded076aa05d94f16fe6d7c14d2e
Author: Gaelle Fournier <ga...@gmail.com>
AuthorDate: Thu Oct 5 19:22:13 2023 +0200

    refactor: use existing getting for catalog versions
---
 pkg/cmd/version.go      | 6 +++---
 pkg/cmd/version_test.go | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go
index 4cc93085c..1f635209d 100644
--- a/pkg/cmd/version.go
+++ b/pkg/cmd/version.go
@@ -153,9 +153,9 @@ func operatorInfo(ctx context.Context, c client.Client, namespace string) (map[s
 		return nil, err
 	}
 	if catalog != nil {
-		infos["Camel Quarkus version"] = catalog.CamelCatalogSpec.Runtime.Metadata["camel-quarkus.version"]
-		infos["Camel version"] = catalog.CamelCatalogSpec.Runtime.Metadata["camel.version"]
-		infos["Quarkus version"] = catalog.CamelCatalogSpec.Runtime.Metadata["quarkus.version"]
+		infos["Camel Quarkus version"] = catalog.CamelCatalogSpec.GetCamelQuarkusVersion()
+		infos["Camel version"] = catalog.CamelCatalogSpec.GetCamelVersion()
+		infos["Quarkus version"] = catalog.CamelCatalogSpec.GetQuarkusVersion()
 	}
 
 	return infos, nil
diff --git a/pkg/cmd/version_test.go b/pkg/cmd/version_test.go
index 053e0dae8..e911e12d3 100644
--- a/pkg/cmd/version_test.go
+++ b/pkg/cmd/version_test.go
@@ -101,9 +101,9 @@ func TestOperatorVersionVerbose(t *testing.T) {
 	assert.Nil(t, err)
 	assert.Equal(t, true, versionCmdOptions.Verbose)
 	assert.Contains(t, output, fmt.Sprintf("Camel K Operator %s\n", defaults.Version))
-	assert.Contains(t, output, fmt.Sprintf("Camel version: %s\n", catalog.Spec.Runtime.Metadata["camel.version"]))
-	assert.Contains(t, output, fmt.Sprintf("Camel Quarkus version: %s\n", catalog.Spec.Runtime.Metadata["camel-quarkus.version"]))
-	assert.Contains(t, output, fmt.Sprintf("Quarkus version: %s\n", catalog.Spec.Runtime.Metadata["quarkus.version"]))
+	assert.Contains(t, output, fmt.Sprintf("Camel version: %s\n", catalog.Spec.GetCamelVersion()))
+	assert.Contains(t, output, fmt.Sprintf("Camel Quarkus version: %s\n", catalog.Spec.GetCamelQuarkusVersion()))
+	assert.Contains(t, output, fmt.Sprintf("Quarkus version: %s\n", catalog.Spec.GetQuarkusVersion()))
 }
 
 func TestCompatibleVersions(t *testing.T) {