controller: move schema bootstrapping code to shell script
diff --git a/controller/bootstrap-schema.sh b/controller/bootstrap-schema.sh
new file mode 100644
index 0000000..dc72ef2
--- /dev/null
+++ b/controller/bootstrap-schema.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+set -e
+
+trap "exit" INT TERM ERR
+trap "kill 0" EXIT
+
+kubectl -n dgraph port-forward svc/dgraph-alpha 8080 &
+sleep 1
+curl -X POST http://localhost:8080/admin/schema -d 'enum EventState { NEW PROCESSING DONE } type Ignore { x: Int }'
diff --git a/controller/main.go b/controller/main.go
index 9c3cd4b..5c3df86 100644
--- a/controller/main.go
+++ b/controller/main.go
@@ -94,44 +94,11 @@
func main() {
flag.Parse()
-
gqlClient, err := schema.NewDgraphClient(
*dgraphGqlAddress, *dgraphSchemaAddress)
if err != nil {
panic(err)
}
- err = gqlClient.SetSchema(`
-enum EventState {
- NEW
- PROCESSING
- DONE
-}
-
-type Foo { bar: Int }`)
- if err != nil {
- panic(err)
- }
- err = gqlClient.AddSchema(`
- type Image {
- id: ID!
- objectPath: String! @search(by: [exact])
- }
-
- type ImageSegment {
- id: ID!
- upperLeftX: Float!
- upperLeftY: Float!
- lowerRightX: Float!
- lowerRightY: Float!
- sourceImage: Image! @hasInverse(field: segments)
- }
-
- extend type Image {
- segments: [ImageSegment] @hasInverse(field: sourceImage)
- }`)
- if err != nil {
- panic(err)
- }
api := ApiHandler{gqlClient}
http.HandleFunc("/graphql", api.graphql)
http.HandleFunc("/add_schema", api.addSchema)