Skip to content

Commit

Permalink
Add query ingress enable switch (#36)
Browse files Browse the repository at this point in the history
* Add query ingress enable switch

Signed-off-by: Serge Catudal <serge.catudal@gmail.com>

* Fix format for query tests

Signed-off-by: Serge Catudal <serge.catudal@gmail.com>

* Rename the Ingress Spec structure to 'JaegerIngressSpec'

Signed-off-by: Serge Catudal <serge.catudal@gmail.com>
  • Loading branch information
secat authored and jpkrohling committed Sep 21, 2018
1 parent 5d0920e commit f8c1af1
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 9 deletions.
12 changes: 9 additions & 3 deletions pkg/apis/io/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ type JaegerStatus struct {

// JaegerQuerySpec defines the options to be used when deploying the query
type JaegerQuerySpec struct {
Size int `json:"size"`
Image string `json:"image"`
Options Options `json:"options"`
Ingress JaegerIngressSpec `json:"ingress"`
Size int `json:"size"`
Image string `json:"image"`
Options Options `json:"options"`
}

// JaegerIngressSpec defines the options to be used when deploying the query ingress
type JaegerIngressSpec struct {
Enabled *bool `json:"enabled"`
}

// JaegerAllInOneSpec defines the options to be used when deploying the query
Expand Down
22 changes: 22 additions & 0 deletions pkg/apis/io/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ func (q *Query) Services() []*v1.Service {

// Ingresses returns a list of ingress rules to be deployed along with the all-in-one deployment
func (q *Query) Ingresses() []*v1beta1.Ingress {
return []*v1beta1.Ingress{
ingress.NewQueryIngress(q.jaeger),
if q.jaeger.Spec.Query.Ingress.Enabled == nil || *q.jaeger.Spec.Query.Ingress.Enabled == true {
return []*v1beta1.Ingress{
ingress.NewQueryIngress(q.jaeger),
}
}

return []*v1beta1.Ingress{}
}

func (q *Query) selector() map[string]string {
Expand Down
39 changes: 35 additions & 4 deletions pkg/deployment/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,39 @@ func TestQueryServices(t *testing.T) {
}

func TestQueryIngresses(t *testing.T) {
query := NewQuery(v1alpha1.NewJaeger("TestQueryIngresses"))
svcs := query.Ingresses()

assert.Len(t, svcs, 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) {
query := NewQuery(v1alpha1.NewJaeger("TestQueryIngresses"))
query.jaeger.Spec.Query.Ingress = stc.ingressSpec
ingresses := query.Ingresses()

assert.Len(t, ingresses, stc.expectedIngressesCount)
})
}
}

0 comments on commit f8c1af1

Please sign in to comment.