You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2020/11/10 10:20:20 UTC
[camel-k] 20/25: chore: Factorize integration re-initialization
logic
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 05a11fb2d9902439cf37880737cee76abad6eb46
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Tue Oct 27 17:12:56 2020 +0100
chore: Factorize integration re-initialization logic
---
pkg/apis/camel/v1/integration_types_support.go | 12 ++++++++++++
pkg/controller/integration/error.go | 3 +--
pkg/controller/integration/monitor.go | 9 ++-------
pkg/controller/integration/platform_setup.go | 6 +++---
4 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/pkg/apis/camel/v1/integration_types_support.go b/pkg/apis/camel/v1/integration_types_support.go
index 591afda..12479ae 100644
--- a/pkg/apis/camel/v1/integration_types_support.go
+++ b/pkg/apis/camel/v1/integration_types_support.go
@@ -52,6 +52,18 @@ func NewIntegrationList() IntegrationList {
}
// Sources return a new slice containing all the sources associated to the integration
+func (in *Integration) Initialize() {
+ profile := in.Status.Profile
+ if in.Spec.Profile != "" {
+ profile = in.Spec.Profile
+ }
+ in.Status = IntegrationStatus{
+ Phase: IntegrationPhaseInitialization,
+ Profile: profile,
+ }
+}
+
+// Sources return a new slice containing all the sources associated to the integration
func (in *Integration) Sources() []SourceSpec {
sources := make([]SourceSpec, 0, len(in.Spec.Sources)+len(in.Status.GeneratedSources))
sources = append(sources, in.Spec.Sources...)
diff --git a/pkg/controller/integration/error.go b/pkg/controller/integration/error.go
index 9e3ad90..5f19458 100644
--- a/pkg/controller/integration/error.go
+++ b/pkg/controller/integration/error.go
@@ -50,9 +50,8 @@ func (action *errorAction) Handle(ctx context.Context, integration *v1.Integrati
if hash != integration.Status.Digest {
action.L.Info("Integration needs a rebuild")
+ integration.Initialize()
integration.Status.Digest = hash
- integration.Status.Phase = v1.IntegrationPhaseInitialization
- integration.Status.InitializationTimestamp = nil
return integration, nil
}
diff --git a/pkg/controller/integration/monitor.go b/pkg/controller/integration/monitor.go
index 654d78b..dbfcbd6 100644
--- a/pkg/controller/integration/monitor.go
+++ b/pkg/controller/integration/monitor.go
@@ -22,11 +22,11 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
+
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/trait"
- "github.com/apache/camel-k/pkg/util/defaults"
"github.com/apache/camel-k/pkg/util/digest"
"github.com/apache/camel-k/pkg/util/kubernetes"
)
@@ -57,13 +57,8 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integra
if hash != integration.Status.Digest {
action.L.Info("Integration needs a rebuild")
+ integration.Initialize()
integration.Status.Digest = hash
- integration.Status.Phase = v1.IntegrationPhaseInitialization
- if integration.Spec.Profile != "" {
- integration.Status.Profile = integration.Spec.Profile
- }
- integration.Status.Version = defaults.Version
- integration.Status.InitializationTimestamp = nil
return integration, nil
}
diff --git a/pkg/controller/integration/platform_setup.go b/pkg/controller/integration/platform_setup.go
index fa4f40c..51c5a5b 100644
--- a/pkg/controller/integration/platform_setup.go
+++ b/pkg/controller/integration/platform_setup.go
@@ -20,13 +20,13 @@ package integration
import (
"context"
- "github.com/apache/camel-k/pkg/client"
- "github.com/apache/camel-k/pkg/platform"
- "github.com/apache/camel-k/pkg/util/knative"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/client"
+ "github.com/apache/camel-k/pkg/platform"
"github.com/apache/camel-k/pkg/trait"
+ "github.com/apache/camel-k/pkg/util/knative"
)
// NewPlatformSetupAction creates a new platform-setup action