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 2025/02/06 07:35:35 UTC
(camel-k) branch main updated: feat(ctrl): warning when missing maven settings
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
The following commit(s) were added to refs/heads/main by this push:
new 6b0cf3ba8 feat(ctrl): warning when missing maven settings
6b0cf3ba8 is described below
commit 6b0cf3ba84f95da83b5f08cb8f008db64e5355b4
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Wed Feb 5 07:44:30 2025 +0100
feat(ctrl): warning when missing maven settings
Closes #5876
---
pkg/apis/camel/v1/integrationplatform_types.go | 2 ++
pkg/controller/integrationplatform/monitor.go | 25 ++++++++++++++++++++++
pkg/controller/integrationplatform/monitor_test.go | 11 +++++++++-
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/pkg/apis/camel/v1/integrationplatform_types.go b/pkg/apis/camel/v1/integrationplatform_types.go
index 475ec0332..839a391a0 100644
--- a/pkg/apis/camel/v1/integrationplatform_types.go
+++ b/pkg/apis/camel/v1/integrationplatform_types.go
@@ -207,6 +207,8 @@ const (
IntegrationPlatformConditionCamelCatalogAvailable IntegrationPlatformConditionType = "CamelCatalogAvailable"
// IntegrationPlatformConditionKameletCatalogAvailable is the condition for the availability of a Kamelet catalog.
IntegrationPlatformConditionKameletCatalogAvailable IntegrationPlatformConditionType = "KameletCatalogAvailable"
+ // IntegrationPlatformConditionMavenSettingsAvailable is the condition for the availability of a Maven settings configuration.
+ IntegrationPlatformConditionMavenSettingsAvailable IntegrationPlatformConditionType = "MavenSettingsAvailable"
// IntegrationPlatformConditionCreatedReason represents the reason that the IntegrationPlatform is created.
IntegrationPlatformConditionCreatedReason = "IntegrationPlatformCreated"
diff --git a/pkg/controller/integrationplatform/monitor.go b/pkg/controller/integrationplatform/monitor.go
index 8d6420fe0..46a07be1a 100644
--- a/pkg/controller/integrationplatform/monitor.go
+++ b/pkg/controller/integrationplatform/monitor.go
@@ -125,6 +125,7 @@ func (action *monitorAction) Handle(ctx context.Context, platform *v1.Integratio
}
}
action.checkTraitAnnotationsDeprecatedNotice(platform)
+ action.checkMavenSettings(platform)
if err = action.addPlainQuarkusCatalog(ctx, catalog); err != nil {
// Only warn the user, we don't want to fail
action.L.Infof(
@@ -157,6 +158,30 @@ func (action *monitorAction) checkTraitAnnotationsDeprecatedNotice(platform *v1.
}
}
+func (action *monitorAction) checkMavenSettings(platform *v1.IntegrationPlatform) {
+ if platform.Status.Build.Maven.Settings.ConfigMapKeyRef != nil ||
+ platform.Status.Build.Maven.Settings.SecretKeyRef != nil {
+ platform.Status.SetCondition(
+ v1.IntegrationPlatformConditionMavenSettingsAvailable,
+ corev1.ConditionTrue,
+ "MavenSettingsAvailable",
+ "Maven settings are available.",
+ )
+ } else {
+ platform.Status.SetCondition(
+ v1.IntegrationPlatformConditionMavenSettingsAvailable,
+ corev1.ConditionFalse,
+ "MavenSettingsAvailable",
+ "Maven settings are missing. You need to provide at least a Maven proxy configuration for performance reasons.",
+ )
+ action.L.Infof(
+ "WARN: Maven settings are missing for platform %s. "+
+ "You need to provide at least a Maven proxy configuration for performance reasons.",
+ platform.Name,
+ )
+ }
+}
+
func specOrDefault(runtimeVersionSpec string) string {
if runtimeVersionSpec == "" {
return defaults.DefaultRuntimeVersion
diff --git a/pkg/controller/integrationplatform/monitor_test.go b/pkg/controller/integrationplatform/monitor_test.go
index 03313fc6f..b1404fd5d 100644
--- a/pkg/controller/integrationplatform/monitor_test.go
+++ b/pkg/controller/integrationplatform/monitor_test.go
@@ -70,6 +70,10 @@ func TestMonitorReady(t *testing.T) {
ip.Spec.Build.Registry.Address = "1.2.3.4"
ip.Spec.Build.RuntimeVersion = "1.2.3"
ip.Spec.Build.RuntimeProvider = v1.RuntimeProviderQuarkus
+ ip.Spec.Build.Maven.Settings.ConfigMapKeyRef = &corev1.ConfigMapKeySelector{
+ Key: "k",
+ LocalObjectReference: corev1.LocalObjectReference{Name: "v"},
+ }
ip.Status.Build.RuntimeVersion = "1.2.3"
ip.Status.Build.RuntimeProvider = v1.RuntimeProviderQuarkus
ip.Status.Build.Registry.Address = "1.2.3.4"
@@ -86,8 +90,11 @@ func TestMonitorReady(t *testing.T) {
assert.NotNil(t, answer)
assert.Equal(t, v1.IntegrationPlatformPhaseReady, answer.Status.Phase)
- assert.Equal(t, corev1.ConditionTrue, answer.Status.GetCondition(v1.IntegrationPlatformConditionTypeRegistryAvailable).Status)
+ assert.Equal(t, corev1.ConditionTrue,
+ answer.Status.GetCondition(v1.IntegrationPlatformConditionTypeRegistryAvailable).Status)
assert.Nil(t, answer.Status.GetCondition(v1.IntegrationPlatformConditionType("InsecureRegistryWarning")))
+ assert.Equal(t, corev1.ConditionTrue,
+ answer.Status.GetCondition(v1.IntegrationPlatformConditionMavenSettingsAvailable).Status)
assert.Equal(t, "3.2.1", answer.Status.Build.RuntimeCoreVersion)
}
@@ -142,6 +149,8 @@ func TestMonitorDriftDefault(t *testing.T) {
assert.NotNil(t, answer)
assert.Equal(t, v1.IntegrationPlatformPhaseReady, answer.Status.Phase)
+ assert.Equal(t, corev1.ConditionFalse,
+ answer.Status.GetCondition(v1.IntegrationPlatformConditionMavenSettingsAvailable).Status)
assert.Equal(t, "3.2.1", answer.Status.Build.RuntimeCoreVersion)
}