Skip to content

Commit

Permalink
Add query ingress enable switch
Browse files Browse the repository at this point in the history
  • Loading branch information
secat committed Sep 20, 2018
1 parent ab78bb8 commit 7957a2a
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 JaegerQueryIngressSpec `json:"ingress"`
Size int `json:"size"`
Image string `json:"image"`
Options Options `json:"options"`
}

// JaegerQueryIngressSpec defines the options to be used when deploying the query ingress
type JaegerQueryIngressSpec 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.JaegerQueryIngressSpec
expectedIngressesCount int
}{
{
name: "IngressEnabledDefault",
ingressSpec: v1alpha1.JaegerQueryIngressSpec{},
expectedIngressesCount: 1,
},
{
name: "IngressEnabledFalse",
ingressSpec: v1alpha1.JaegerQueryIngressSpec{Enabled:newBool(false)},
expectedIngressesCount: 0,
},
{
name: "IngressEnabledTrue",
ingressSpec: v1alpha1.JaegerQueryIngressSpec{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 7957a2a

Please sign in to comment.