Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query ingress enable switch #36

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
}
}