You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/10/28 02:41:01 UTC
[camel-k] branch main updated: feat(controller): add Ready condition to IntegrationPlatform
This is an automated email from the ASF dual-hosted git repository.
tsato 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 3f632b042 feat(controller): add Ready condition to IntegrationPlatform
3f632b042 is described below
commit 3f632b042b1d77d5f1eae428b6ac31e00542fc89
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Thu Oct 27 18:04:23 2022 +0900
feat(controller): add Ready condition to IntegrationPlatform
---
e2e/namespace/install/cli/install_test.go | 3 ++
e2e/support/test_support.go | 32 ++++++++++++++++++----
pkg/apis/camel/v1/integrationplatform_types.go | 6 ++++
.../camel/v1/integrationplatform_types_support.go | 4 +--
pkg/controller/integrationplatform/create.go | 12 ++++++--
pkg/controller/integrationplatform/monitor.go | 4 +--
6 files changed, 49 insertions(+), 12 deletions(-)
diff --git a/e2e/namespace/install/cli/install_test.go b/e2e/namespace/install/cli/install_test.go
index f3a861a2b..ff0b98e17 100644
--- a/e2e/namespace/install/cli/install_test.go
+++ b/e2e/namespace/install/cli/install_test.go
@@ -32,6 +32,7 @@ import (
. "github.com/onsi/gomega"
"github.com/stretchr/testify/assert"
+ corev1 "k8s.io/api/core/v1"
. "github.com/apache/camel-k/e2e/support"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
@@ -48,6 +49,8 @@ func TestBasicInstallation(t *testing.T) {
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
Eventually(Platform(ns)).ShouldNot(BeNil())
+ Eventually(PlatformConditionStatus(ns, v1.IntegrationPlatformConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
})
}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index f4bfa833f..d6202f71d 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -647,11 +647,7 @@ func IntegrationCondition(ns string, name string, conditionType v1.IntegrationCo
if it == nil {
return nil
}
- c := it.Status.GetCondition(conditionType)
- if c == nil {
- return nil
- }
- return c
+ return it.Status.GetCondition(conditionType)
}
}
@@ -1538,6 +1534,32 @@ func PlatformPhase(ns string) func() v1.IntegrationPlatformPhase {
}
}
+func PlatformCondition(
+ ns string,
+ conditionType v1.IntegrationPlatformConditionType,
+) func() *v1.IntegrationPlatformCondition {
+ return func() *v1.IntegrationPlatformCondition {
+ p := Platform(ns)()
+ if p == nil {
+ return nil
+ }
+ return p.Status.GetCondition(conditionType)
+ }
+}
+
+func PlatformConditionStatus(
+ ns string,
+ conditionType v1.IntegrationPlatformConditionType,
+) func() corev1.ConditionStatus {
+ return func() corev1.ConditionStatus {
+ c := PlatformCondition(ns, conditionType)()
+ if c == nil {
+ return "Unknown"
+ }
+ return c.Status
+ }
+}
+
func PlatformProfile(ns string) func() v1.TraitProfile {
return func() v1.TraitProfile {
p := Platform(ns)()
diff --git a/pkg/apis/camel/v1/integrationplatform_types.go b/pkg/apis/camel/v1/integrationplatform_types.go
index 8f4551841..261f72c3a 100644
--- a/pkg/apis/camel/v1/integrationplatform_types.go
+++ b/pkg/apis/camel/v1/integrationplatform_types.go
@@ -197,6 +197,12 @@ const (
IntegrationPlatformPhaseError IntegrationPlatformPhase = "Error"
// IntegrationPlatformPhaseDuplicate when the IntegrationPlatform is duplicated
IntegrationPlatformPhaseDuplicate IntegrationPlatformPhase = "Duplicate"
+
+ // IntegrationPlatformConditionReady is the condition if the IntegrationPlatform is ready.
+ IntegrationPlatformConditionReady = "Ready"
+
+ // IntegrationPlatformConditionCreatedReason represents the reason that the IntegrationPlatform is created.
+ IntegrationPlatformConditionCreatedReason = "IntegrationPlatformCreated"
)
// IntegrationPlatformCondition describes the state of a resource at a certain point.
diff --git a/pkg/apis/camel/v1/integrationplatform_types_support.go b/pkg/apis/camel/v1/integrationplatform_types_support.go
index 32d3ccc34..0d9b0a2e4 100644
--- a/pkg/apis/camel/v1/integrationplatform_types_support.go
+++ b/pkg/apis/camel/v1/integrationplatform_types_support.go
@@ -109,7 +109,7 @@ func (in *IntegrationPlatformStatus) GetCondition(condType IntegrationPlatformCo
return nil
}
-// SetCondition --
+// SetCondition sets the condition with the given status, reason, and message.
func (in *IntegrationPlatformStatus) SetCondition(condType IntegrationPlatformConditionType, status corev1.ConditionStatus, reason string, message string) {
in.SetConditions(IntegrationPlatformCondition{
Type: condType,
@@ -121,7 +121,7 @@ func (in *IntegrationPlatformStatus) SetCondition(condType IntegrationPlatformCo
})
}
-// SetErrorCondition --
+// SetErrorCondition sets the condition with the given reason and error message.
func (in *IntegrationPlatformStatus) SetErrorCondition(condType IntegrationPlatformConditionType, reason string, err error) {
in.SetConditions(IntegrationPlatformCondition{
Type: condType,
diff --git a/pkg/controller/integrationplatform/create.go b/pkg/controller/integrationplatform/create.go
index 91e725a36..e42a6a4c1 100644
--- a/pkg/controller/integrationplatform/create.go
+++ b/pkg/controller/integrationplatform/create.go
@@ -20,12 +20,13 @@ package integrationplatform
import (
"context"
- platformutil "github.com/apache/camel-k/pkg/platform"
- "github.com/apache/camel-k/pkg/resources"
- "github.com/apache/camel-k/pkg/util/defaults"
+ corev1 "k8s.io/api/core/v1"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/install"
+ platformutil "github.com/apache/camel-k/pkg/platform"
+ "github.com/apache/camel-k/pkg/resources"
+ "github.com/apache/camel-k/pkg/util/defaults"
)
// NewCreateAction returns a action that creates resources needed by the platform.
@@ -67,6 +68,11 @@ func (action *createAction) Handle(ctx context.Context, platform *v1.Integration
}
platform.Status.Phase = v1.IntegrationPlatformPhaseReady
+ platform.Status.SetCondition(
+ v1.IntegrationPlatformConditionReady,
+ corev1.ConditionTrue,
+ v1.IntegrationPlatformConditionCreatedReason,
+ "integration platform created")
return platform, nil
}
diff --git a/pkg/controller/integrationplatform/monitor.go b/pkg/controller/integrationplatform/monitor.go
index e2c7d0c99..68884f7a7 100644
--- a/pkg/controller/integrationplatform/monitor.go
+++ b/pkg/controller/integrationplatform/monitor.go
@@ -21,7 +21,7 @@ import (
"context"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
- platformutils "github.com/apache/camel-k/pkg/platform"
+ platformutil "github.com/apache/camel-k/pkg/platform"
"github.com/apache/camel-k/pkg/util/defaults"
)
@@ -50,7 +50,7 @@ func (action *monitorAction) Handle(ctx context.Context, platform *v1.Integratio
}
// Refresh applied configuration
- if err := platformutils.ConfigureDefaults(ctx, action.client, platform, false); err != nil {
+ if err := platformutil.ConfigureDefaults(ctx, action.client, platform, false); err != nil {
return nil, err
}