Skip to content

Commit dbf78d8

Browse files
authored
Added env support to enable/disable gql introspection (#4672)
* 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]>
1 parent cc2aa27 commit dbf78d8

File tree

7 files changed

+18
-2
lines changed

7 files changed

+18
-2
lines changed

chaoscenter/graphql/server/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require (
1818
github.com/litmuschaos/chaos-operator v0.0.0-20240601063404-e96a7ee7f1f7
1919
github.com/litmuschaos/chaos-scheduler v0.0.0-20220714173615-d7513d616a71
2020
github.com/mrz1836/go-sanitize v1.3.2
21+
github.com/openshift/origin v0.0.0-20160503220234-8f127d736703
2122
github.com/pkg/errors v0.9.1
2223
github.com/sirupsen/logrus v1.9.3
2324
github.com/stretchr/testify v1.9.0

chaoscenter/graphql/server/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ github.com/opencontainers/selinux v1.3.1-0.20190929122143-5215b1806f52/go.mod h1
944944
github.com/openebs/maya v1.12.1/go.mod h1:E9CmKbURtsthTyASz0piTxljLmGxjbaJ3aFhtWEko2Y=
945945
github.com/openshift/api v0.0.0-20190924102528-32369d4db2ad/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY=
946946
github.com/openshift/client-go v0.0.0-20190923180330-3b6373338c9b/go.mod h1:6rzn+JTr7+WYS2E1TExP4gByoABxMznR6y2SnUIkmxk=
947+
github.com/openshift/origin v0.0.0-20160503220234-8f127d736703 h1:KLVRXtjLhZHVtrcdnuefaI2Bf182EEiTfEVDHokoyng=
947948
github.com/openshift/origin v0.0.0-20160503220234-8f127d736703/go.mod h1:0Rox5r9C8aQn6j1oAOQ0c1uC86mYbUFObzjBRvUKHII=
948949
github.com/openshift/prom-label-proxy v0.1.1-0.20191016113035-b8153a7f39f1/go.mod h1:p5MuxzsYP1JPsNGwtjtcgRHHlGziCJJfztff91nNixw=
949950
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=

chaoscenter/graphql/server/server.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"strconv"
5+
46
"github.com/gin-contrib/cors"
57
"github.com/gin-gonic/gin"
68
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/api/middleware"
@@ -9,6 +11,7 @@ import (
911
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb"
1012
dbSchemaChaosHub "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_hub"
1113
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/projects"
14+
"github.com/openshift/origin/Godeps/_workspace/src/github.com/Sirupsen/logrus"
1215

1316
"context"
1417
"fmt"
@@ -116,8 +119,12 @@ func main() {
116119
},
117120
})
118121

119-
// to be removed in production
120-
srv.Use(extension.Introspection{})
122+
enableIntrospection, err := strconv.ParseBool(utils.Config.EnableGQLIntrospection)
123+
if err != nil {
124+
logrus.Errorf("unable to parse boolean value %v", err)
125+
} else if err == nil && enableIntrospection == true {
126+
srv.Use(extension.Introspection{})
127+
}
121128

122129
// go routine for syncing chaos hubs
123130
go chaoshub.NewService(dbSchemaChaosHub.NewChaosHubOperator(mongodbOperator)).RecurringHubSync()

chaoscenter/graphql/server/utils/variables.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type Configuration struct {
4343
DefaultHubBranchName string `required:"true" split_words:"true"`
4444
CustomChaosHubPath string `split_words:"true" default:"/tmp/"`
4545
DefaultChaosHubPath string `split_words:"true" default:"/tmp/default/"`
46+
EnableGQLIntrospection string `split_words:"true" default:"false"`
4647
}
4748

4849
var Config Configuration

chaoscenter/manifests/litmus-cluster-scope.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ spec:
269269
fieldPath: metadata.namespace
270270
- name: CHAOS_CENTER_SCOPE
271271
value: "cluster"
272+
- name: ENABLE_GQL_INTROSPECTION
273+
value: "false"
272274
- name: SUBSCRIBER_IMAGE
273275
value: "litmuschaos/litmusportal-subscriber:ci"
274276
- name: EVENT_TRACKER_IMAGE

chaoscenter/manifests/litmus-namespaced-scope.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ spec:
249249
value: ""
250250
- name: CHAOS_CENTER_SCOPE
251251
value: "namespace"
252+
- name: ENABLE_GQL_INTROSPECTION
253+
value: "false"
252254
- name: INFRA_DEPLOYMENTS
253255
value: '["app=chaos-exporter", "name=chaos-operator", "app=workflow-controller", "app=event-tracker"]'
254256
- name: SERVER_SERVICE_NAME

chaoscenter/manifests/litmus-without-resources.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ spec:
257257
fieldPath: metadata.namespace
258258
- name: CHAOS_CENTER_SCOPE
259259
value: "cluster"
260+
- name: ENABLE_GQL_INTROSPECTION
261+
value: "false"
260262
- name: SUBSCRIBER_IMAGE
261263
value: "litmuschaos/litmusportal-subscriber:ci"
262264
- name: EVENT_TRACKER_IMAGE

0 commit comments

Comments
 (0)