diff --git a/Makefile b/Makefile
index fe14c24..e30232d 100644
--- a/Makefile
+++ b/Makefile
@@ -16,9 +16,9 @@ package:
image:
$(REPO_ROOT)hack/scripts/image.sh
-.PHONY: hello-world
-hello-world:
- $(REPO_ROOT)hack/scripts/hello-world.sh
+.PHONY: examples
+examples:
+ $(REPO_ROOT)hack/scripts/examples.sh
.PHONY: docs
docs:
diff --git a/cmd/init.go b/cmd/init.go
index ddc5ba5..eab9320 100644
--- a/cmd/init.go
+++ b/cmd/init.go
@@ -30,7 +30,8 @@ you started.
}
func init() {
- initCmd.Flags().BoolVarP(&cfg.Flags.Quickstart, "quickstart", "", false, `use defaults to setup KubeFox for quickstart guide`)
+ initCmd.Flags().BoolVarP(&cfg.Flags.Quickstart, "quickstart", "", false, `use defaults to setup KubeFox for quickstart tutorial`)
+ initCmd.Flags().BoolVarP(&cfg.Flags.GraphQL, "graphql", "", false, `use defaults to setup KubeFox for graphql tutorial`)
rootCmd.AddCommand(initCmd)
}
diff --git a/cmd/version.go b/cmd/version.go
index 85e68be..b37af55 100644
--- a/cmd/version.go
+++ b/cmd/version.go
@@ -17,7 +17,7 @@ import (
// XXX Update this before making release. This is hardcoded to ensure that
// the correct version is shown when Fox is setup using `go install`.
-const version = "v0.8.3"
+const version = "v0.9.0"
type BuildInfo struct {
Version string `json:"version,omitempty"`
diff --git a/docs/fox_init.md b/docs/fox_init.md
index 2e79cbc..5f06915 100644
--- a/docs/fox_init.md
+++ b/docs/fox_init.md
@@ -15,8 +15,9 @@ fox init [flags]
### Options
```
+ --graphql use defaults to setup KubeFox for graphql tutorial
-h, --help help for init
- --quickstart use defaults to setup KubeFox for quickstart guide
+ --quickstart use defaults to setup KubeFox for quickstart tutorial
```
### Options inherited from parent commands
diff --git a/efs/embed.go b/efs/embed.go
index 903f632..9149233 100644
--- a/efs/embed.go
+++ b/efs/embed.go
@@ -14,6 +14,7 @@ import (
const (
HelloWorldPath = "hello-world"
+ GraphQLPath = "graphql"
)
// Go will not embed directories containing a go.mod file. To resolve this the
diff --git a/efs/graphql/app.yaml b/efs/graphql/app.yaml
new file mode 100644
index 0000000..942cded
--- /dev/null
+++ b/efs/graphql/app.yaml
@@ -0,0 +1,11 @@
+# Copyright 2023 XigXog
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# SPDX-License-Identifier: MPL-2.0
+
+name: graphql
+title: KubeFox GraphQL Demo
+description: A simple App demonstrating the use of KubeFox with Hasura GraphQL Engine.
diff --git a/efs/graphql/components/server/main.go b/efs/graphql/components/server/main.go
new file mode 100644
index 0000000..315d789
--- /dev/null
+++ b/efs/graphql/components/server/main.go
@@ -0,0 +1,79 @@
+// Copyright 2023 XigXog
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at https://mozilla.org/MPL/2.0/.
+//
+// SPDX-License-Identifier: MPL-2.0
+
+package main
+
+import (
+ "embed"
+ "html/template"
+
+ "github.com/xigxog/kubefox/kit"
+ "github.com/xigxog/kubefox/kit/graphql"
+)
+
+//go:embed static/*
+//go:embed templates/*
+var EFS embed.FS
+
+var (
+ tpl *template.Template
+ graphqlAdapter kit.ComponentDep
+ hasuraAdapter kit.ComponentDep
+)
+
+func main() {
+ k := kit.New()
+
+ var err error
+ tpl, err = template.ParseFS(EFS, "templates/*.html")
+ if err != nil {
+ k.Log().Fatal(err)
+ }
+
+ graphqlAdapter = k.HTTPAdapter("graphql")
+ hasuraAdapter = k.HTTPAdapter("hasura")
+
+ k.Static("/{{.Vars.subPath}}/hasura/static", "static", EFS)
+ k.Route("Path(`/{{.Vars.subPath}}/hasura/heroes`)", listHeroes)
+ k.Route("PathPrefix(`/{{.Vars.subPath}}/hasura`)", forwardHasura)
+
+ k.Start()
+}
+
+func listHeroes(k kit.Kontext) error {
+ client := graphql.New(k, graphqlAdapter)
+
+ // For additional documentation check out
+ // https://github.com/hasura/go-graphql-client.
+ var query struct {
+ Superhero []struct {
+ Name string `graphql:"superhero_name"`
+ RealName string `graphql:"full_name"`
+ Alignment struct {
+ Value string `graphql:"alignment"`
+ }
+ } `graphql:"superhero(order_by: {superhero_name: asc})"`
+ }
+ if err := client.Query(&query, nil); err != nil {
+ return err
+ }
+
+ return k.Resp().SendHTMLTemplate(tpl, "index.html", query)
+}
+
+func forwardHasura(k kit.Kontext) error {
+ req := k.Forward(hasuraAdapter)
+ req.RewritePath(k.PathSuffix())
+
+ resp, err := req.Send()
+ if err != nil {
+ return err
+ }
+
+ return k.Resp().Forward(resp)
+}
diff --git a/efs/graphql/components/server/static/favicon.ico b/efs/graphql/components/server/static/favicon.ico
new file mode 100644
index 0000000..7687308
Binary files /dev/null and b/efs/graphql/components/server/static/favicon.ico differ
diff --git a/efs/graphql/components/server/static/style.css b/efs/graphql/components/server/static/style.css
new file mode 100644
index 0000000..4d50b90
--- /dev/null
+++ b/efs/graphql/components/server/static/style.css
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2023 XigXog
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ */
+
+html {
+ font-family: sans-serif;
+}
+
+h1 {
+ text-align: center;
+}
+
+.styled-table {
+ border-collapse: collapse;
+ margin: 25px auto;
+ font-size: 0.9em;
+ min-width: 80%;
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
+}
+
+.styled-table th {
+ background-color: #009879;
+ color: white;
+ text-align: left;
+}
+
+.styled-table th,
+.styled-table td {
+ padding: 12px 15px;
+}
+
+.styled-table tr {
+ border-bottom: 1px solid #dddddd;
+}
+
+.styled-table tr:nth-of-type(even) {
+ background-color: #f3f3f3;
+}
+
+.styled-table tr:last-of-type {
+ border-bottom: 2px solid #009879;
+}
diff --git a/efs/graphql/components/server/templates/index.html b/efs/graphql/components/server/templates/index.html
new file mode 100644
index 0000000..e9457ba
--- /dev/null
+++ b/efs/graphql/components/server/templates/index.html
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+ KubeFox Hasura Demo
+
+
+
+
+
+
+ 🦸 Superheroes
+
+
+
+ Name |
+ Real Name |
+ Alignment |
+
+ {{ range .Superhero }}
+
+ {{.Name}} |
+ {{.RealName}} |
+ {{.Alignment.Value}} |
+
+ {{ end}}
+
+
+
diff --git a/efs/graphql/go.mod.trim b/efs/graphql/go.mod.trim
new file mode 100644
index 0000000..573bd74
--- /dev/null
+++ b/efs/graphql/go.mod.trim
@@ -0,0 +1,25 @@
+module github.com/xigxog/kubefox/graphql
+
+go 1.21
+
+require github.com/xigxog/kubefox v0.6.1
+
+require (
+ github.com/golang/protobuf v1.5.4 // indirect
+ github.com/google/uuid v1.6.0 // indirect
+ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
+ github.com/hasura/go-graphql-client v0.12.1 // indirect
+ go.opentelemetry.io/otel v1.24.0 // indirect
+ go.opentelemetry.io/otel/trace v1.24.0 // indirect
+ go.opentelemetry.io/proto/otlp v1.1.0 // indirect
+ go.uber.org/multierr v1.11.0 // indirect
+ go.uber.org/zap v1.27.0 // indirect
+ golang.org/x/net v0.22.0 // indirect
+ golang.org/x/sys v0.18.0 // indirect
+ golang.org/x/text v0.14.0 // indirect
+ google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect
+ google.golang.org/grpc v1.62.1 // indirect
+ google.golang.org/protobuf v1.33.0 // indirect
+ nhooyr.io/websocket v1.8.10 // indirect
+)
diff --git a/efs/graphql/go.sum b/efs/graphql/go.sum
new file mode 100644
index 0000000..58d3e64
--- /dev/null
+++ b/efs/graphql/go.sum
@@ -0,0 +1,48 @@
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
+github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
+github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
+github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
+github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
+github.com/hasura/go-graphql-client v0.12.1 h1:tL+BCoyubkYYyaQ+tJz+oPe/pSxYwOJHwe5SSqqi6WI=
+github.com/hasura/go-graphql-client v0.12.1/go.mod h1:F4N4kR6vY8amio3gEu3tjSZr8GPOXJr3zj72DKixfLE=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/xigxog/kubefox v0.6.1 h1:oAZYGvTMnN9GN4o1RlodVvQR45UaGku8/YREuXRi/20=
+github.com/xigxog/kubefox v0.6.1/go.mod h1:eIgVSKT2xPmKVYOBDaM5P+r0cpk2Kb3rp/8eju+2vE0=
+go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
+go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
+go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
+go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
+go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI=
+go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY=
+go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
+go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
+go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
+go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
+go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
+go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
+golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
+golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
+golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
+golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
+golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 h1:oqta3O3AnlWbmIE3bFnWbu4bRxZjfbWCp0cKSuZh01E=
+google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7/go.mod h1:VQW3tUculP/D4B+xVCo+VgSq8As6wA9ZjHl//pmk+6s=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 h1:8EeVk1VKMD+GD/neyEHGmz7pFblqPjHoi+PGQIlLx2s=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
+google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
+google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
+google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
+google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
+nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
diff --git a/efs/graphql/hack/environments/dev.yaml b/efs/graphql/hack/environments/dev.yaml
new file mode 100644
index 0000000..4b4d30e
--- /dev/null
+++ b/efs/graphql/hack/environments/dev.yaml
@@ -0,0 +1,38 @@
+# Copyright 2023 XigXog
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# SPDX-License-Identifier: MPL-2.0
+
+---
+apiVersion: kubefox.xigxog.io/v1alpha1
+kind: Environment
+metadata:
+ name: dev
+spec:
+ releasePolicy:
+ type: Testing
+data:
+ vars:
+ db: dev
+ #subPath: dev
+---
+apiVersion: kubefox.xigxog.io/v1alpha1
+kind: VirtualEnvironment
+metadata:
+ name: dev
+spec:
+ environment: dev
+---
+apiVersion: kubefox.xigxog.io/v1alpha1
+kind: VirtualEnvironment
+metadata:
+ name: dev-john
+spec:
+ environment: dev
+data:
+ vars:
+ db: john
+ subPath: john
diff --git a/efs/graphql/hack/environments/prod.yaml b/efs/graphql/hack/environments/prod.yaml
new file mode 100644
index 0000000..7eb70e8
--- /dev/null
+++ b/efs/graphql/hack/environments/prod.yaml
@@ -0,0 +1,27 @@
+# Copyright 2023 XigXog
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# SPDX-License-Identifier: MPL-2.0
+
+---
+apiVersion: kubefox.xigxog.io/v1alpha1
+kind: Environment
+metadata:
+ name: prod
+spec:
+ releasePolicy:
+ type: Stable
+data:
+ vars:
+ db: prod
+ subPath: prod
+---
+apiVersion: kubefox.xigxog.io/v1alpha1
+kind: VirtualEnvironment
+metadata:
+ name: prod
+spec:
+ environment: prod
diff --git a/efs/graphql/hack/hasura.yaml b/efs/graphql/hack/hasura.yaml
new file mode 100644
index 0000000..602fd03
--- /dev/null
+++ b/efs/graphql/hack/hasura.yaml
@@ -0,0 +1,153 @@
+# Copyright 2023 XigXog
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# SPDX-License-Identifier: MPL-2.0
+
+---
+apiVersion: v1
+kind: Pod
+metadata:
+ name: hasura-prod
+ labels:
+ app.kubernetes.io/component: hasura
+ app.kubernetes.io/instance: prod
+spec:
+ containers:
+ - name: hasura
+ image: hasura/graphql-engine:v2.37.0
+ env:
+ - name: HASURA_GRAPHQL_DEV_MODE
+ value: "true"
+ - name: HASURA_GRAPHQL_METADATA_DATABASE_URL
+ value: postgres://postgres:password@localhost:5432/postgres
+ - name: HASURA_GRAPHQL_ENABLE_CONSOLE
+ value: "true"
+ - name: PG_DATABASE_URL
+ value: postgres://postgres:password@localhost:5432/postgres
+ ports:
+ - name: http
+ containerPort: 8080
+ protocol: TCP
+ - name: postgres
+ image: ghcr.io/xigxog/postgres-superheroes:main
+ env:
+ - name: POSTGRES_PASSWORD
+ value: password
+---
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ app.kubernetes.io/component: hasura
+ app.kubernetes.io/instance: prod
+ name: hasura-prod
+spec:
+ type: ClusterIP
+ ports:
+ - name: http
+ port: 80
+ targetPort: 8080
+ protocol: TCP
+ selector:
+ app.kubernetes.io/component: hasura
+ app.kubernetes.io/instance: prod
+---
+apiVersion: v1
+kind: Pod
+metadata:
+ name: hasura-dev
+ labels:
+ app.kubernetes.io/component: hasura
+ app.kubernetes.io/instance: dev
+spec:
+ containers:
+ - name: hasura
+ image: hasura/graphql-engine:v2.37.0
+ env:
+ - name: HASURA_GRAPHQL_DEV_MODE
+ value: "true"
+ - name: HASURA_GRAPHQL_METADATA_DATABASE_URL
+ value: postgres://postgres:password@localhost:5432/postgres
+ - name: HASURA_GRAPHQL_ENABLE_CONSOLE
+ value: "true"
+ - name: PG_DATABASE_URL
+ value: postgres://postgres:password@localhost:5432/postgres
+ ports:
+ - name: http
+ containerPort: 8080
+ protocol: TCP
+ - name: postgres
+ image: ghcr.io/xigxog/postgres-superheroes:main
+ env:
+ - name: POSTGRES_PASSWORD
+ value: password
+---
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ app.kubernetes.io/component: hasura
+ app.kubernetes.io/instance: dev
+ name: hasura-dev
+spec:
+ type: ClusterIP
+ ports:
+ - name: http
+ port: 80
+ targetPort: 8080
+ protocol: TCP
+ selector:
+ app.kubernetes.io/component: hasura
+ app.kubernetes.io/instance: dev
+---
+apiVersion: v1
+kind: Pod
+metadata:
+ name: hasura-john
+ labels:
+ app.kubernetes.io/component: hasura
+ app.kubernetes.io/instance: john
+spec:
+ containers:
+ - name: hasura
+ image: hasura/graphql-engine:v2.37.0
+ env:
+ - name: HASURA_GRAPHQL_DEV_MODE
+ value: "true"
+ - name: HASURA_GRAPHQL_METADATA_DATABASE_URL
+ value: postgres://postgres:password@localhost:5432/postgres
+ - name: HASURA_GRAPHQL_ENABLE_CONSOLE
+ value: "true"
+ - name: PG_DATABASE_URL
+ value: postgres://postgres:password@localhost:5432/postgres
+ ports:
+ - name: http
+ containerPort: 8080
+ protocol: TCP
+ - name: postgres
+ image: ghcr.io/xigxog/postgres-superheroes:main
+ env:
+ - name: POSTGRES_PASSWORD
+ value: password
+---
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ app.kubernetes.io/component: hasura
+ app.kubernetes.io/instance: john
+ name: hasura-john
+spec:
+ type: ClusterIP
+ ports:
+ - name: http
+ port: 80
+ targetPort: 8080
+ protocol: TCP
+ selector:
+ app.kubernetes.io/component: hasura
+ app.kubernetes.io/instance: john
+
diff --git a/efs/graphql/hack/http-adapter.yaml b/efs/graphql/hack/http-adapter.yaml
new file mode 100644
index 0000000..ad707b4
--- /dev/null
+++ b/efs/graphql/hack/http-adapter.yaml
@@ -0,0 +1,24 @@
+# Copyright 2023 XigXog
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# SPDX-License-Identifier: MPL-2.0
+
+---
+apiVersion: kubefox.xigxog.io/v1alpha1
+kind: HTTPAdapter
+metadata:
+ name: graphql
+spec:
+ url: http://hasura-{{.Vars.db}}/v1/graphql
+ insecureSkipVerify: true
+---
+apiVersion: kubefox.xigxog.io/v1alpha1
+kind: HTTPAdapter
+metadata:
+ name: hasura
+spec:
+ url: http://hasura-{{.Vars.db}}/
+ insecureSkipVerify: true
\ No newline at end of file
diff --git a/efs/hello-world/go.mod.trim b/efs/hello-world/go.mod.trim
index bed6549..721fc7e 100644
--- a/efs/hello-world/go.mod.trim
+++ b/efs/hello-world/go.mod.trim
@@ -2,17 +2,22 @@ module github.com/xigxog/kubefox/quickstart
go 1.21
-require github.com/xigxog/kubefox v0.5.1
+require github.com/xigxog/kubefox v0.6.1
require (
- github.com/golang/protobuf v1.5.3 // indirect
- github.com/google/uuid v1.5.0 // indirect
+ github.com/golang/protobuf v1.5.4 // indirect
+ github.com/google/uuid v1.6.0 // indirect
+ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
+ go.opentelemetry.io/otel v1.24.0 // indirect
+ go.opentelemetry.io/otel/trace v1.24.0 // indirect
+ go.opentelemetry.io/proto/otlp v1.1.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- go.uber.org/zap v1.26.0 // indirect
- golang.org/x/net v0.20.0 // indirect
- golang.org/x/sys v0.16.0 // indirect
+ go.uber.org/zap v1.27.0 // indirect
+ golang.org/x/net v0.22.0 // indirect
+ golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
- google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect
- google.golang.org/grpc v1.60.1 // indirect
- google.golang.org/protobuf v1.32.0 // indirect
+ google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect
+ google.golang.org/grpc v1.62.1 // indirect
+ google.golang.org/protobuf v1.33.0 // indirect
)
diff --git a/efs/hello-world/go.sum b/efs/hello-world/go.sum
index aebbcad..b2ea64e 100644
--- a/efs/hello-world/go.sum
+++ b/efs/hello-world/go.sum
@@ -1,39 +1,44 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
-github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
-github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
-github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
+github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
-github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
-github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
+github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
-github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
-github.com/xigxog/kubefox v0.5.1 h1:DHbQPkG/24F6VaVq/o+4ZSgfHfkSBDbkp9cpunFfrNc=
-github.com/xigxog/kubefox v0.5.1/go.mod h1:yAM9kmrDh2o+ynzpKsLavRwYrS36L5MYBmUxXjYrjIw=
-go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
-go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
+github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/xigxog/kubefox v0.6.1 h1:oAZYGvTMnN9GN4o1RlodVvQR45UaGku8/YREuXRi/20=
+github.com/xigxog/kubefox v0.6.1/go.mod h1:eIgVSKT2xPmKVYOBDaM5P+r0cpk2Kb3rp/8eju+2vE0=
+go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
+go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
+go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
+go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
+go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI=
+go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY=
+go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
+go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
-go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
-go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
-golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
-golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
-golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
-golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
+go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
+golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
+golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
+golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
+golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
-golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac h1:nUQEQmH/csSvFECKYRv6HWEyypysidKl2I6Qpsglq/0=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA=
-google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
-google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
-google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
-google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
-google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
+google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 h1:oqta3O3AnlWbmIE3bFnWbu4bRxZjfbWCp0cKSuZh01E=
+google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7/go.mod h1:VQW3tUculP/D4B+xVCo+VgSq8As6wA9ZjHl//pmk+6s=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 h1:8EeVk1VKMD+GD/neyEHGmz7pFblqPjHoi+PGQIlLx2s=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
+google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
+google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
+google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
+google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/go.mod b/go.mod
index e7f7764..b6f6b08 100644
--- a/go.mod
+++ b/go.mod
@@ -12,7 +12,7 @@ require (
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
- github.com/xigxog/kubefox v0.5.2-0.20240312205058-8bdb1ef2df99
+ github.com/xigxog/kubefox v0.6.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.29.2
k8s.io/apimachinery v0.29.2
@@ -55,6 +55,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
+ github.com/hasura/go-graphql-client v0.12.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
@@ -126,6 +127,7 @@ require (
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect
+ nhooyr.io/websocket v1.8.10 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
diff --git a/go.sum b/go.sum
index a45458c..9219f7d 100644
--- a/go.sum
+++ b/go.sum
@@ -116,6 +116,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0Q
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hasura/go-graphql-client v0.12.1 h1:tL+BCoyubkYYyaQ+tJz+oPe/pSxYwOJHwe5SSqqi6WI=
+github.com/hasura/go-graphql-client v0.12.1/go.mod h1:F4N4kR6vY8amio3gEu3tjSZr8GPOXJr3zj72DKixfLE=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
@@ -234,8 +236,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
-github.com/xigxog/kubefox v0.5.2-0.20240312205058-8bdb1ef2df99 h1:F8fXQgL1ZcUc6lqS+5rWeKt/VW+ir+puUbDauw7HA2k=
-github.com/xigxog/kubefox v0.5.2-0.20240312205058-8bdb1ef2df99/go.mod h1:eIgVSKT2xPmKVYOBDaM5P+r0cpk2Kb3rp/8eju+2vE0=
+github.com/xigxog/kubefox v0.6.1 h1:oAZYGvTMnN9GN4o1RlodVvQR45UaGku8/YREuXRi/20=
+github.com/xigxog/kubefox v0.6.1/go.mod h1:eIgVSKT2xPmKVYOBDaM5P+r0cpk2Kb3rp/8eju+2vE0=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
@@ -396,6 +398,8 @@ k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7F
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98=
k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY=
k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
+nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
+nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
sigs.k8s.io/controller-runtime v0.17.2 h1:FwHwD1CTUemg0pW2otk7/U5/i5m2ymzvOXdbeGOUvw0=
sigs.k8s.io/controller-runtime v0.17.2/go.mod h1:+MngTvIQQQhfXtwfdGw/UOQ/aIaqsYywfCINOtwMO/s=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
diff --git a/hack/scripts/commit.sh b/hack/scripts/commit.sh
index 02b03a0..d0755a8 100755
--- a/hack/scripts/commit.sh
+++ b/hack/scripts/commit.sh
@@ -10,7 +10,7 @@
source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
${SCRIPTS}/clean.sh
-${SCRIPTS}/hello-world.sh
+${SCRIPTS}/examples.sh
${SCRIPTS}/docs.sh
${SCRIPTS}/addlicense.sh
diff --git a/hack/scripts/hello-world.sh b/hack/scripts/examples.sh
similarity index 70%
rename from hack/scripts/hello-world.sh
rename to hack/scripts/examples.sh
index 8b5a4d0..e3f0a91 100755
--- a/hack/scripts/hello-world.sh
+++ b/hack/scripts/examples.sh
@@ -7,6 +7,7 @@
#
# SPDX-License-Identifier: MPL-2.0
+# TODO clean this up
source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
@@ -22,7 +23,20 @@ cp -r "${KUBEFOX_SRC}/examples/go/hello-world/kubefox" "${HELLO_WORLD_SRC}"
sed -i '/go 1.21/c\go 1.21' go.mod
)
+GRAPHQL_SRC="efs/graphql"
+
+rm -rf "${GRAPHQL_SRC}"
+cp -r "${KUBEFOX_SRC}/examples/go/graphql" "${GRAPHQL_SRC}"
+(
+ cd "${GRAPHQL_SRC}"
+ go mod init github.com/xigxog/kubefox/graphql
+ go mod tidy
+ # Remove patch version from Go version.
+ sed -i '/go 1.21/c\go 1.21' go.mod
+)
+
# Go will not embed directories containing a go.mod file. To resolve this the
# extension .trim is added. This will be removed when Fox writes the template
# files to disk.
mv "${HELLO_WORLD_SRC}/go.mod" "${HELLO_WORLD_SRC}/go.mod.trim"
+mv "${GRAPHQL_SRC}/go.mod" "${GRAPHQL_SRC}/go.mod.trim"
diff --git a/internal/config/config.go b/internal/config/config.go
index 0e40269..57156a4 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -111,7 +111,7 @@ func (cfg *Config) Load() {
b, err := os.ReadFile(cfg.path)
if errors.Is(err, fs.ErrNotExist) {
- if cfg.Flags.Quickstart {
+ if cfg.Flags.Quickstart || cfg.Flags.GraphQL {
cfg.setupQuickstart("kind")
cfg.Fresh = true
cfg.Write()
diff --git a/internal/config/flags.go b/internal/config/flags.go
index 7fc4873..e865575 100644
--- a/internal/config/flags.go
+++ b/internal/config/flags.go
@@ -36,6 +36,7 @@ type Flags struct {
CreateTag bool
ForceBuild bool
Generate bool
+ GraphQL bool
NoCache bool
PushImage bool
Quickstart bool
diff --git a/internal/proxy/proxy.go b/internal/proxy/proxy.go
index 62a81ff..4ca85ac 100644
--- a/internal/proxy/proxy.go
+++ b/internal/proxy/proxy.go
@@ -44,6 +44,9 @@ func Start(port int, cfg *config.Config) {
cfg: cfg,
client: http.Client{
Timeout: time.Minute,
+ CheckRedirect: func(req *http.Request, via []*http.Request) error {
+ return http.ErrUseLastResponse
+ },
},
}
defer srv.Shutdown()
diff --git a/internal/repo/init.go b/internal/repo/init.go
index b6619ce..0fa74fa 100644
--- a/internal/repo/init.go
+++ b/internal/repo/init.go
@@ -39,12 +39,16 @@ func Init(cfg *config.Config) {
ctx, cancel := context.WithTimeout(context.Background(), cfg.Flags.Timeout)
defer cancel()
- if cfg.Flags.Quickstart {
+ if cfg.Flags.Quickstart || cfg.Flags.GraphQL {
c := kubernetes.NewClient(cfg)
p := c.CreatePlatform(ctx, "kubefox-demo", "demo")
c.WaitPlatformReady(time.Minute*5, p, nil)
- log.Info("KubeFox initialized for the quickstart guide!")
+ if cfg.Flags.Quickstart {
+ log.Info("KubeFox initialized for the quickstart guide!")
+ } else {
+ log.Info("KubeFox initialized for the GraphQL tutorial!")
+ }
} else {
log.InfoNewline()
@@ -63,6 +67,12 @@ func initApp(cfg *config.Config) {
return
}
+ if cfg.Flags.GraphQL {
+ initDir(efs.GraphQLPath, cfg.AppPath)
+ initGit(cfg.RepoPath, cfg)
+ return
+ }
+
app, err := ReadApp(cfg.AppPath)
if err != nil && !errors.Is(err, fs.ErrNotExist) {
log.Error("An KubeFox App definition already exists but appears to be invalid: %v.", err)
@@ -119,7 +129,7 @@ func initGit(repoPath string, cfg *config.Config) {
remoteURL = fmt.Sprintf("https://github.com/%s/%s.git", cfg.GitHub.Org.Name, filepath.Base(repoPath))
}
- if !cfg.Flags.Quickstart {
+ if !(cfg.Flags.Quickstart || cfg.Flags.GraphQL) {
remoteURL = foxutils.InputPrompt("Enter URL for remote Git repo", remoteURL, false)
if remoteURL != "" {
_, err := nr.CreateRemote(&gitcfg.RemoteConfig{