From bdecdc58a0dd3b537b825ec02ba03e2c600b35a3 Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Tue, 21 May 2019 15:01:16 +0200 Subject: [PATCH] chore: support for health based on servlet available from 0.3.3-SNAPSHOT --- pkg/apis/camel/v1alpha1/integration_types.go | 19 ++++++++++--------- .../v1alpha1/integration_types_support.go | 15 ++++++++++++++- pkg/trait/probes.go | 14 ++++++++++++++ 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/pkg/apis/camel/v1alpha1/integration_types.go b/pkg/apis/camel/v1alpha1/integration_types.go index 7b6b5482a5..2e3e19799a 100644 --- a/pkg/apis/camel/v1alpha1/integration_types.go +++ b/pkg/apis/camel/v1alpha1/integration_types.go @@ -22,15 +22,16 @@ type IntegrationSpec struct { // IntegrationStatus defines the observed state of Integration type IntegrationStatus struct { - Phase IntegrationPhase `json:"phase,omitempty"` - Digest string `json:"digest,omitempty"` - Image string `json:"image,omitempty"` - Dependencies []string `json:"dependencies,omitempty"` - Context string `json:"context,omitempty"` - GeneratedSources []SourceSpec `json:"generatedSources,omitempty"` - Failure *Failure `json:"failure,omitempty"` - CamelVersion string `json:"camelVersion,omitempty"` - RuntimeVersion string `json:"runtimeVersion,omitempty"` + Phase IntegrationPhase `json:"phase,omitempty"` + Digest string `json:"digest,omitempty"` + Image string `json:"image,omitempty"` + Dependencies []string `json:"dependencies,omitempty"` + Context string `json:"context,omitempty"` + GeneratedSources []SourceSpec `json:"generatedSources,omitempty"` + Failure *Failure `json:"failure,omitempty"` + CamelVersion string `json:"camelVersion,omitempty"` + RuntimeVersion string `json:"runtimeVersion,omitempty"` + Configuration []ConfigurationSpec `json:"configuration,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/camel/v1alpha1/integration_types_support.go b/pkg/apis/camel/v1alpha1/integration_types_support.go index e801d743eb..3ed42f5ff7 100644 --- a/pkg/apis/camel/v1alpha1/integration_types_support.go +++ b/pkg/apis/camel/v1alpha1/integration_types_support.go @@ -99,13 +99,26 @@ func (is *IntegrationSpec) Configurations() []ConfigurationSpec { return is.Configuration } +// Configurations -- +func (is *IntegrationStatus) Configurations() []ConfigurationSpec { + if is == nil { + return []ConfigurationSpec{} + } + + return is.Configuration +} + // Configurations -- func (in *Integration) Configurations() []ConfigurationSpec { if in == nil { return []ConfigurationSpec{} } - return in.Spec.Configurations() + answer := make([]ConfigurationSpec, 0) + answer = append(answer, in.Status.Configuration...) + answer = append(answer, in.Spec.Configuration...) + + return answer } // NewSourceSpec -- diff --git a/pkg/trait/probes.go b/pkg/trait/probes.go index 4fb582d2c1..7d76132118 100644 --- a/pkg/trait/probes.go +++ b/pkg/trait/probes.go @@ -19,6 +19,7 @@ package trait import ( "sort" + "strconv" "github.com/apache/camel-k/pkg/apis/camel/v1alpha1" "github.com/apache/camel-k/pkg/util" @@ -69,6 +70,19 @@ func (t *probesTrait) Apply(e *Environment) error { // sort the dependencies to get always the same list if they don't change sort.Strings(e.Integration.Status.Dependencies) + + e.Integration.Status.Configuration = append(e.Integration.Status.Configuration, + // + // TODO: At the moment the servlet engine is used only for health but we need to + // have a dedicated servlet trait and maybe an option to create a dedicated + // server for management stuffs like health + // + v1alpha1.ConfigurationSpec{Type: "property", Value: "customizer.servlet.enabled=true"}, + v1alpha1.ConfigurationSpec{Type: "property", Value: "customizer.servlet.bindHost=" + t.BindHost}, + v1alpha1.ConfigurationSpec{Type: "property", Value: "customizer.servlet.bindPort=" + strconv.Itoa(t.BindPort)}, + v1alpha1.ConfigurationSpec{Type: "property", Value: "customizer.health.enabled=true"}, + v1alpha1.ConfigurationSpec{Type: "property", Value: "customizer.health.path=" + t.Path}, + ) } if e.IntegrationInPhase(v1alpha1.IntegrationPhaseDeploying) {