From 363d981fd1f3e506bdc653a38cf8ebd929e7c4a8 Mon Sep 17 00:00:00 2001 From: Serge Catudal Date: Thu, 4 Oct 2018 06:49:58 -0400 Subject: [PATCH] Add support for JaegerIngressSpec to all-in-one Signed-off-by: Serge Catudal --- pkg/apis/io/v1alpha1/types.go | 5 +-- pkg/apis/io/v1alpha1/zz_generated.deepcopy.go | 1 + pkg/deployment/all-in-one.go | 8 +++-- pkg/deployment/all-in-one_test.go | 36 +++++++++++++++++-- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/pkg/apis/io/v1alpha1/types.go b/pkg/apis/io/v1alpha1/types.go index dce0e3c6a..253aaface 100644 --- a/pkg/apis/io/v1alpha1/types.go +++ b/pkg/apis/io/v1alpha1/types.go @@ -53,8 +53,9 @@ type JaegerIngressSpec struct { // JaegerAllInOneSpec defines the options to be used when deploying the query type JaegerAllInOneSpec struct { - Image string `json:"image"` - Options Options `json:"options"` + Ingress JaegerIngressSpec `json:"ingress"` + Image string `json:"image"` + Options Options `json:"options"` } // JaegerCollectorSpec defines the options to be used when deploying the collector diff --git a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go index 6fa6b22bf..0b35a6266 100644 --- a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go @@ -55,6 +55,7 @@ func (in *JaegerAgentSpec) DeepCopy() *JaegerAgentSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JaegerAllInOneSpec) DeepCopyInto(out *JaegerAllInOneSpec) { *out = *in + in.Ingress.DeepCopyInto(&out.Ingress) in.Options.DeepCopyInto(&out.Options) return } diff --git a/pkg/deployment/all-in-one.go b/pkg/deployment/all-in-one.go index d848d84ca..2f385a226 100644 --- a/pkg/deployment/all-in-one.go +++ b/pkg/deployment/all-in-one.go @@ -144,9 +144,13 @@ func (a *AllInOne) Services() []*v1.Service { // Ingresses returns a list of ingress rules to be deployed along with the all-in-one deployment func (a *AllInOne) Ingresses() []*v1beta1.Ingress { - return []*v1beta1.Ingress{ - ingress.NewQueryIngress(a.jaeger), + if a.jaeger.Spec.AllInOne.Ingress.Enabled == nil || *a.jaeger.Spec.AllInOne.Ingress.Enabled == true { + return []*v1beta1.Ingress{ + ingress.NewQueryIngress(a.jaeger), + } } + + return []*v1beta1.Ingress{} } func (a *AllInOne) selector() map[string]string { diff --git a/pkg/deployment/all-in-one_test.go b/pkg/deployment/all-in-one_test.go index a6eeeb970..e849dc0b0 100644 --- a/pkg/deployment/all-in-one_test.go +++ b/pkg/deployment/all-in-one_test.go @@ -44,6 +44,38 @@ func TestAllInOneNumberOfServices(t *testing.T) { func TestAllInOneNumberOfIngresses(t *testing.T) { name := "TestAllInOneNumberOfIngresses" - ingresses := NewAllInOne(v1alpha1.NewJaeger(name)).Ingresses() - assert.Len(t, ingresses, 1) + newBool := func(value bool) *bool { + return &value + } + + subTestCases := []struct { + name string + ingressSpec v1alpha1.JaegerIngressSpec + expectedIngressesCount int + }{ + { + name: "IngressEnabledDefault", + ingressSpec: v1alpha1.JaegerIngressSpec{}, + expectedIngressesCount: 1, + }, + { + name: "IngressEnabledFalse", + ingressSpec: v1alpha1.JaegerIngressSpec{Enabled: newBool(false)}, + expectedIngressesCount: 0, + }, + { + name: "IngressEnabledTrue", + ingressSpec: v1alpha1.JaegerIngressSpec{Enabled: newBool(true)}, + expectedIngressesCount: 1, + }, + } + + for _, stc := range subTestCases { + t.Run(stc.name, func(t *testing.T) { + jaeger := v1alpha1.NewJaeger(name) + jaeger.Spec.AllInOne.Ingress = stc.ingressSpec + ingresses := NewAllInOne(jaeger).Ingresses() + assert.Len(t, ingresses, stc.expectedIngressesCount) + }) + } }