Skip to content

Commit

Permalink
Added env support to enable/disable gql introspection (#4672)
Browse files Browse the repository at this point in the history
* Added env support to enable/disable gql introspection

Signed-off-by: Saranya-jena <[email protected]>

* resolved comments

Signed-off-by: Saranya-jena <[email protected]>

* fixed imports

Signed-off-by: Saranya-jena <[email protected]>

* fixed build issues

Signed-off-by: Saranya-jena <[email protected]>

---------

Signed-off-by: Saranya-jena <[email protected]>
  • Loading branch information
Saranya-jena authored Jun 6, 2024
1 parent cc2aa27 commit dbf78d8
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions chaoscenter/graphql/server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/litmuschaos/chaos-operator v0.0.0-20240601063404-e96a7ee7f1f7
github.com/litmuschaos/chaos-scheduler v0.0.0-20220714173615-d7513d616a71
github.com/mrz1836/go-sanitize v1.3.2
github.com/openshift/origin v0.0.0-20160503220234-8f127d736703
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
Expand Down
1 change: 1 addition & 0 deletions chaoscenter/graphql/server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ github.com/opencontainers/selinux v1.3.1-0.20190929122143-5215b1806f52/go.mod h1
github.com/openebs/maya v1.12.1/go.mod h1:E9CmKbURtsthTyASz0piTxljLmGxjbaJ3aFhtWEko2Y=
github.com/openshift/api v0.0.0-20190924102528-32369d4db2ad/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY=
github.com/openshift/client-go v0.0.0-20190923180330-3b6373338c9b/go.mod h1:6rzn+JTr7+WYS2E1TExP4gByoABxMznR6y2SnUIkmxk=
github.com/openshift/origin v0.0.0-20160503220234-8f127d736703 h1:KLVRXtjLhZHVtrcdnuefaI2Bf182EEiTfEVDHokoyng=
github.com/openshift/origin v0.0.0-20160503220234-8f127d736703/go.mod h1:0Rox5r9C8aQn6j1oAOQ0c1uC86mYbUFObzjBRvUKHII=
github.com/openshift/prom-label-proxy v0.1.1-0.20191016113035-b8153a7f39f1/go.mod h1:p5MuxzsYP1JPsNGwtjtcgRHHlGziCJJfztff91nNixw=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down
11 changes: 9 additions & 2 deletions chaoscenter/graphql/server/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"strconv"

"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/api/middleware"
Expand All @@ -9,6 +11,7 @@ import (
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb"
dbSchemaChaosHub "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub"
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/projects"
"github.com/openshift/origin/Godeps/_workspace/src/github.com/Sirupsen/logrus"

"context"
"fmt"
Expand Down Expand Up @@ -116,8 +119,12 @@ func main() {
},
})

// to be removed in production
srv.Use(extension.Introspection{})
enableIntrospection, err := strconv.ParseBool(utils.Config.EnableGQLIntrospection)
if err != nil {
logrus.Errorf("unable to parse boolean value %v", err)
} else if err == nil && enableIntrospection == true {
srv.Use(extension.Introspection{})
}

// go routine for syncing chaos hubs
go chaoshub.NewService(dbSchemaChaosHub.NewChaosHubOperator(mongodbOperator)).RecurringHubSync()
Expand Down
1 change: 1 addition & 0 deletions chaoscenter/graphql/server/utils/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Configuration struct {
DefaultHubBranchName string `required:"true" split_words:"true"`
CustomChaosHubPath string `split_words:"true" default:"/tmp/"`
DefaultChaosHubPath string `split_words:"true" default:"/tmp/default/"`
EnableGQLIntrospection string `split_words:"true" default:"false"`
}

var Config Configuration
2 changes: 2 additions & 0 deletions chaoscenter/manifests/litmus-cluster-scope.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ spec:
fieldPath: metadata.namespace
- name: CHAOS_CENTER_SCOPE
value: "cluster"
- name: ENABLE_GQL_INTROSPECTION
value: "false"
- name: SUBSCRIBER_IMAGE
value: "litmuschaos/litmusportal-subscriber:ci"
- name: EVENT_TRACKER_IMAGE
Expand Down
2 changes: 2 additions & 0 deletions chaoscenter/manifests/litmus-namespaced-scope.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ spec:
value: ""
- name: CHAOS_CENTER_SCOPE
value: "namespace"
- name: ENABLE_GQL_INTROSPECTION
value: "false"
- name: INFRA_DEPLOYMENTS
value: '["app=chaos-exporter", "name=chaos-operator", "app=workflow-controller", "app=event-tracker"]'
- name: SERVER_SERVICE_NAME
Expand Down
2 changes: 2 additions & 0 deletions chaoscenter/manifests/litmus-without-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ spec:
fieldPath: metadata.namespace
- name: CHAOS_CENTER_SCOPE
value: "cluster"
- name: ENABLE_GQL_INTROSPECTION
value: "false"
- name: SUBSCRIBER_IMAGE
value: "litmuschaos/litmusportal-subscriber:ci"
- name: EVENT_TRACKER_IMAGE
Expand Down

0 comments on commit dbf78d8

Please sign in to comment.