From 0c430bc2b5d3ca0ceb0d35271fc7665fb1b1f447 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Josu=C3=A9=20Rodr=C3=ADguez?= Date: Fri, 21 Jul 2023 23:10:31 +0000 Subject: [PATCH] Some tests --- .vscode/settings.json | 4 ++++ exporter.sh | 7 +++++++ getter.sh | 6 ++++++ go.mod | 8 ++++++++ go.sum | 18 ++++++++++++++++++ handlers/controller/controllerHandlers.go | 3 ++- handlers/health/healthHandlers.go | 1 + handlers/management/managementHandlers.go | 3 ++- handlers/static/staticHandlers.go | 3 ++- handlers/virtualapi/virtualapiHandlers.go | 3 ++- monospace.json | 9 +++++++++ vscpweb.go | 11 ++++++----- 12 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 .vscode/settings.json create mode 100755 exporter.sh create mode 100755 getter.sh create mode 100644 monospace.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..33eaebb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "IDX.aI.enableCodebaseIndexing": true, + "IDX.corgiMode": true +} \ No newline at end of file diff --git a/exporter.sh b/exporter.sh new file mode 100755 index 0000000..284cc77 --- /dev/null +++ b/exporter.sh @@ -0,0 +1,7 @@ +#/usr/bin/env bash +# +# +#This is a bit of a setup to export the server +export port=8000 +export API_SERVICE="${port}-${HOSTNAME}.cluster-lknrrkkitbcdsvoir6wqg4mwt6.cloudworkstations.dev" +echo $API_SERVICE diff --git a/getter.sh b/getter.sh new file mode 100755 index 0000000..b4ad031 --- /dev/null +++ b/getter.sh @@ -0,0 +1,6 @@ +#/usr/bin/env bash +wget https://go.dev/dl/go1.20.6.linux-amd64.tar.gz +rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.6.linux-amd64.tar.gz +export PATH=$PATH:/usr/local/go/bin +rm go1.20.6* +go version diff --git a/go.mod b/go.mod index f12f975..3365cb2 100644 --- a/go.mod +++ b/go.mod @@ -22,4 +22,12 @@ replace virtualAPIHandlers v0.0.0 => ./handlers/virtualapi/ require staticHandlers v0.0.0 +require ( + github.com/keegancsmith/rpc v1.1.0 // indirect + github.com/stamblerre/gocode v1.0.0 // indirect + golang.org/x/mod v0.12.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/tools v0.11.0 // indirect +) + replace staticHandlers v0.0.0 => ./handlers/static/ diff --git a/go.sum b/go.sum index 433d671..ef2a570 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,20 @@ github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8= github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/keegancsmith/rpc v1.1.0 h1:bXVRk3EzbtrEegTGKxNTc+St1lR7t/Z1PAO8misBnCc= +github.com/keegancsmith/rpc v1.1.0/go.mod h1:Xow74TKX34OPPiPCdz6x1o9c0SCxRqGxDuKGk7ZOo8s= +github.com/stamblerre/gocode v1.0.0 h1:5aTRgkRTOS8mELHoKatkwhfX44OdEV3iwu3FCXyvLzk= +github.com/stamblerre/gocode v1.0.0/go.mod h1:ONyGamdxpnxaG2+XLyGkNuuoYISmz0QFVHScxvsXsqM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab h1:tpc/nJ4vD66vAk/2KN0sw/DvQIz2sKmCpWvyKtPmfMQ= +golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= +golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/handlers/controller/controllerHandlers.go b/handlers/controller/controllerHandlers.go index f01514a..04c0150 100644 --- a/handlers/controller/controllerHandlers.go +++ b/handlers/controller/controllerHandlers.go @@ -13,6 +13,7 @@ import ( // the special agent that each of them will already have installed in order to // connect to the cluster. func MasterHealthHandler(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf("Ëverything should be okay my boi") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, "Ëverything should be okay my boi") } diff --git a/handlers/health/healthHandlers.go b/handlers/health/healthHandlers.go index 81d0525..3b2ec63 100644 --- a/handlers/health/healthHandlers.go +++ b/handlers/health/healthHandlers.go @@ -19,4 +19,5 @@ import ( func MasterHealthHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) fmt.Fprintf(w, "Ëverything should be okay my boi") + fmt.Println("health handler") } diff --git a/handlers/management/managementHandlers.go b/handlers/management/managementHandlers.go index 869cf9e..fc1a92a 100644 --- a/handlers/management/managementHandlers.go +++ b/handlers/management/managementHandlers.go @@ -13,6 +13,7 @@ import ( // the special agent that each of them will already have installed in order to // connect to the cluster. func MasterHealthHandler(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf("Ëverything should be okay my boi") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, "Ëverything should be okay my boi") } diff --git a/handlers/static/staticHandlers.go b/handlers/static/staticHandlers.go index 7b182db..51cd2b3 100644 --- a/handlers/static/staticHandlers.go +++ b/handlers/static/staticHandlers.go @@ -13,6 +13,7 @@ import ( // the special agent that each of them will already have installed in order to // connect to the cluster. func MasterHealthHandler(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf("Ëverything should be okay my boi") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, "Ëverything should be okay my boi") } diff --git a/handlers/virtualapi/virtualapiHandlers.go b/handlers/virtualapi/virtualapiHandlers.go index 264e910..f5d73be 100644 --- a/handlers/virtualapi/virtualapiHandlers.go +++ b/handlers/virtualapi/virtualapiHandlers.go @@ -13,6 +13,7 @@ import ( // the special agent that each of them will already have installed in order to // connect to the cluster. func MasterHealthHandler(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf("Ëverything should be okay my boi") + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, "Ëverything should be okay my boi") } diff --git a/monospace.json b/monospace.json new file mode 100644 index 0000000..610b206 --- /dev/null +++ b/monospace.json @@ -0,0 +1,9 @@ +{ + "previews": [ + { + "command": ["go","run","vscpweb.go"], + "id": "web", + "manager": "web" + } + ] + } \ No newline at end of file diff --git a/vscpweb.go b/vscpweb.go index a977ad8..23a07ab 100644 --- a/vscpweb.go +++ b/vscpweb.go @@ -1,17 +1,17 @@ // This is a system for playing with SDN based openvswitches using a simple web // interface. This project will be combined with a CLI version or probably just // made compatible with a core version in the future. -package vscpweb +package main import ( "fmt" "net/http" hh "healthHandlers" - mh "managementHandlers" - vh "virtualAPIHandlers" - ch "controllerHandlers" - sh "staticHandlers" + //mh "managementHandlers" + //vh "virtualAPIHandlers" + //ch "controllerHandlers" + //sh "staticHandlers" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" @@ -92,6 +92,7 @@ func (s *server) MountHandlers() { //healthRouter.Get("/", )//this renders the health page "/health" //healthRouter.Get("/ping", )// "/rpiping" healthRouter.Get("/masterHealth", hh.MasterHealthHandler) //return a JSON with healt of the master "/free" + healthRouter.Get("/", hh.MasterHealthHandler) //return a JSON with healt of the master "/free" //controllerRouter.Delete("/flow", )//this is an external request "/flowdel" //controllerRouter.Get("/resetflows", )//not sure if here or managementRouter //controllerRouter.Get("/listswitch", ) -- 2.25.1