From 81b0110b68dfb74cf084245c879d728e526ab03a Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 13 Nov 2019 20:30:02 +0100 Subject: [PATCH 01/14] use log package --- database/database.go | 5 ++++- routes/healthz/healthz_endpoint.go | 4 ++-- start.go | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/database/database.go b/database/database.go index 72f55de..c62bfdf 100644 --- a/database/database.go +++ b/database/database.go @@ -1,8 +1,9 @@ package database import ( - "flag" "fmt" + "log" + "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" "log" @@ -54,6 +55,8 @@ func InitDB(dbname string, isTest bool) *gorm.DB { DropTables(db) } + log.Println("Database connection established") + return db } diff --git a/routes/healthz/healthz_endpoint.go b/routes/healthz/healthz_endpoint.go index 7883830..e1e26e6 100644 --- a/routes/healthz/healthz_endpoint.go +++ b/routes/healthz/healthz_endpoint.go @@ -1,10 +1,10 @@ package healthz import ( - "fmt" "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "github.com/gin-gonic/gin" + "log" "net/http" ) @@ -35,7 +35,7 @@ func getHealth(c *gin.Context) { if len(database.AMQP_URL) != 0 { err = amqp.CheckConnection() if err != nil { - fmt.Println(err.Error()) + log.Println(err.Error()) c.JSON(http.StatusInternalServerError, gin.H{ "success:": false, "message": err.Error(), diff --git a/start.go b/start.go index df9caf2..e3009e1 100644 --- a/start.go +++ b/start.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/healthz" "time" @@ -71,7 +71,7 @@ func main() { fmt.Println("Starting AMQP client") err := amqp.ConnectAMQP(database.AMQP_URL) if err != nil { - panic(err) + log.Panic(err) } // Periodically call the Ping function to check which simulators are still there @@ -83,12 +83,14 @@ func main() { case <-ticker.C: err = amqp.PingAMQP() if err != nil { - fmt.Println("AMQP Error: ", err.Error()) + log.Println("AMQP Error: ", err.Error()) } } } }() + + log.Printf("Connected AMQP client to %s", amqpurl) } // server at port 4000 to match frontend's redirect path r.Run(":4000") From cbefdd2d07b01951fbfa5c35ac9413824045d6f6 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 13 Nov 2019 20:31:06 +0100 Subject: [PATCH 02/14] add new config package --- config/config.go | 83 ++++++++++++++++++++++++++++++ database/database.go | 53 ++++++++----------- go.mod | 9 +++- go.sum | 34 ++++++++++++ routes/healthz/healthz_endpoint.go | 4 +- start.go | 38 ++++++++------ 6 files changed, 171 insertions(+), 50 deletions(-) create mode 100644 config/config.go diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..eaff987 --- /dev/null +++ b/config/config.go @@ -0,0 +1,83 @@ +package config + +import ( + "flag" + "log" + "os" + + "github.com/zpatrick/go-config" +) + +// Global configuration +var Config *config.Config + +func InitConfig() *config.Config { + var ( + dbHost = flag.String("dbhost", "/var/run/postgresql", "Host of the PostgreSQL database (default is /var/run/postgresql for localhost DB on Ubuntu systems)") + dbName = flag.String("dbname", "villas", "Name of the database to use (default is villasdb)") + dbUser = flag.String("dbuser", "", "Username of database connection (default is )") + dbPass = flag.String("dbpass", "", "Password of database connection (default is )") + dbInit = flag.Bool("dbinit", false, "Initialize database with test data (default is off)") + dbSSLMode = flag.String("dbsslmode", "disable", "SSL mode of DB (default is disable)") // TODO: change default for production + amqpURL = flag.String("amqp", "", "If set, use this url to connect to an AMQP broker (default is disabled)") + configFile = flag.String("configFile", "", "Path to YAML configuration file") + mode = flag.String("mode", "release", "Select debug/release/test mode (default is release)") + ) + flag.Parse() + + var dbInitStr string + if *dbInit { + dbInitStr = "true" + } else { + dbInitStr = "false" + } + + static := map[string]string{ + "db.host": *dbHost, + "db.name": *dbName, + "db.user": *dbUser, + "db.pass": *dbPass, + "db.init": dbInitStr, + "db.ssl": *dbSSLMode, + "amqp.url": *amqpURL, + "mode": *mode, + } + + mappings := map[string]string{ + "DB_HOST": "db.host", + "DB_NAME": "db.name", + "DB_USER": "db.user", + "DB_PASS": "db.pass", + "DB_SSLMOE": "db.ssl", + "DB_INIT": "db.init", + "AMQP_URL": "amqp.url", + } + + defaults := config.NewStatic(static) + env := config.NewEnvironment(mappings) + + var c *config.Config + if _, err := os.Stat(*configFile); os.IsExist(err) { + yamlFile := config.NewYAMLFile(*configFile) + c = config.NewConfig([]config.Provider{defaults, yamlFile, env}) + } else { + c = config.NewConfig([]config.Provider{defaults, env}) + } + + err := c.Load() + if err != nil { + log.Fatal("failed to parse config") + } + + settings, _ := c.Settings() + + log.Print("All settings:") + for key, val := range settings { + log.Printf(" %s = %s \n", key, val) + } + + // Save pointer to global variable + Config = c + + return c +} diff --git a/database/database.go b/database/database.go index c62bfdf..8f566aa 100644 --- a/database/database.go +++ b/database/database.go @@ -6,42 +6,24 @@ import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" - "log" + "github.com/zpatrick/go-config" ) -var DB_HOST string // host of the database system -var DB_NAME string // name of the production database -var DB_USER string // name of the database user -var DB_PASS string // database password -var DB_SSLMODE string // set to enable if database uses SSL -var AMQP_URL string // if set connect to AMQP broker using this URL - var DBpool *gorm.DB // database used by backend -// Initialize input command line flags -func init() { - flag.StringVar(&DB_HOST, "dbhost", "/var/run/postgresql", "Host of the PostgreSQL database (default is /var/run/postgresql for localhost DB on Ubuntu systems)") - flag.StringVar(&DB_NAME, "dbname", "villasdb", "Name of the database to use (default is villasdb)") - flag.StringVar(&DB_USER, "dbuser", "", "Username of database connection (default is )") - flag.StringVar(&DB_PASS, "dbpass", "", "Password of database connection (default is )") - flag.StringVar(&DB_SSLMODE, "dbsslmode", "disable", "SSL mode of DB (default is disable)") // TODO: change default for production - flag.StringVar(&AMQP_URL, "amqp", "", "If set, use this url to connect to an AMQP broker (default is disabled)") - flag.Parse() - fmt.Println("DB_HOST has value ", DB_HOST) - fmt.Println("DB_USER has value ", DB_USER) - fmt.Println("DB_NAME has value ", DB_NAME) - fmt.Println("DB_SSLMODE has value ", DB_SSLMODE) - fmt.Println("AMQP_URL has value ", AMQP_URL) -} - // Initialize connection to the database -func InitDB(dbname string, isTest bool) *gorm.DB { +func InitDB(cfg *config.Config) *gorm.DB { + name, err := cfg.String("db.name") + host, err := cfg.String("db.host") + user, err := cfg.String("db.user") + pass, err := cfg.String("db.pass") + sslmode, err := cfg.String("db.ssl") + init, err := cfg.Bool("db.init") + mode, err := cfg.String("mode") - dbinfo := fmt.Sprintf("host=%s sslmode=%s dbname=%s", - DB_HOST, DB_SSLMODE, dbname) - if DB_USER != "" && DB_PASS != "" { - dbinfo = fmt.Sprintf("host=%s sslmode=%s user=%s password=%s dbname=%s", - DB_HOST, DB_SSLMODE, DB_USER, DB_PASS, dbname) + dbinfo := fmt.Sprintf("host=%s sslmode=%s dbname=%s", host, sslmode, name) + if user != "" && pass != "" { + dbinfo += fmt.Sprintf(" user=%s password=%s", user, pass) } db, err := gorm.Open("postgres", dbinfo) @@ -50,9 +32,16 @@ func InitDB(dbname string, isTest bool) *gorm.DB { } DBpool = db - if isTest { - // drop tables for testing case + MigrateModels(db) + + if mode == "test" || init { DropTables(db) + log.Println("Database tables dropped") + } + + if init { + DBAddTestData(db) + log.Println("Database initialized with test data") } log.Println("Database connection established") diff --git a/go.mod b/go.mod index 56e36f6..09acda9 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,10 @@ module git.rwth-aachen.de/acs/public/villas/web-backend-go require ( - github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc + github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gin-gonic/gin v1.4.0 + github.com/go-ini/ini v1.51.0 // indirect github.com/go-openapi/jsonreference v0.19.3 // indirect github.com/go-openapi/spec v0.19.3 // indirect github.com/go-playground/locales v0.12.1 // indirect @@ -12,15 +13,19 @@ require ( github.com/leodido/go-urn v1.1.0 // indirect github.com/mailru/easyjson v0.7.0 // indirect github.com/nsf/jsondiff v0.0.0-20190712045011-8443391ee9b6 + github.com/prometheus/client_golang v1.2.1 + github.com/prometheus/common v0.7.0 github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94 github.com/stretchr/testify v1.4.0 github.com/swaggo/gin-swagger v1.2.0 github.com/swaggo/swag v1.6.2 github.com/tidwall/gjson v1.3.0 + github.com/zpatrick/go-config v0.0.0-20191104215613-50bc2709703f golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 // indirect - golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 // indirect golang.org/x/tools v0.0.0-20190916034716-92af9d69eff2 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/go-playground/validator.v9 v9.29.0 ) + +go 1.13 diff --git a/go.sum b/go.sum index 8b79982..f761a7f 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU= cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= @@ -15,9 +16,16 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -43,8 +51,12 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= github.com/gin-gonic/gin v1.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ= github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= +github.com/go-ini/ini v1.51.0 h1:VPJKXGzbKlyExUE8f41aV57yxkYx5R49yR6n7flp0M0= +github.com/go-ini/ini v1.51.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2 h1:A9+F4Dc/MCNB5jibxf6rRvOvR/iFgQdyNx9eIhnGqq0= @@ -82,10 +94,14 @@ github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -102,6 +118,7 @@ github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/ github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -131,8 +148,10 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -150,13 +169,23 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94 h1:0ngsPmuP6XIjiFRNFYlvKwSr5zff2v+uPHaffZ6/M4k= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -186,6 +215,8 @@ github.com/ugorji/go/codec v1.1.5-pre h1:5YV9PsFAN+ndcCtTM7s60no7nY7eTG3LPtxhSwu github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2tfCQDUqRd8fI= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/zpatrick/go-config v0.0.0-20191104215613-50bc2709703f h1:A3xgNrO0Yh+GQJuplpwSdCqT+xcGNPu2gtg+wvHuq8U= +github.com/zpatrick/go-config v0.0.0-20191104215613-50bc2709703f/go.mod h1:N7O1arBXMtrvgkF3kTwZdytK4gsAf13kfqv9Z6vk47Q= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -232,11 +263,13 @@ golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae h1:xiXzMMEQdQcric9hXtr1QU98MHunKK7OTtsoU6bYWs4= golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 h1:wYqz/tQaWUgGKyx+B/rssSE6wkIKdY5Ee6ryOmzarIg= golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= @@ -263,6 +296,7 @@ google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= diff --git a/routes/healthz/healthz_endpoint.go b/routes/healthz/healthz_endpoint.go index e1e26e6..f352405 100644 --- a/routes/healthz/healthz_endpoint.go +++ b/routes/healthz/healthz_endpoint.go @@ -2,6 +2,7 @@ package healthz import ( "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" + d "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "github.com/gin-gonic/gin" "log" @@ -32,7 +33,8 @@ func getHealth(c *gin.Context) { } // check if connection to AMQP broker is alive if backend was started with AMQP client - if len(database.AMQP_URL) != 0 { + url, _ := d.Config.String("amqp.url") + if len(url) != 0 { err = amqp.CheckConnection() if err != nil { log.Println(err.Error()) diff --git a/start.go b/start.go index e3009e1..1594e59 100644 --- a/start.go +++ b/start.go @@ -2,18 +2,21 @@ package main import ( "log" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/healthz" "time" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/healthz" + "github.com/gin-gonic/gin" - "github.com/swaggo/gin-swagger" + ginSwagger "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" + c "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" - _ "git.rwth-aachen.de/acs/public/villas/web-backend-go/doc/api" // doc/api folder is used by Swag CLI, you have to import it + docs "git.rwth-aachen.de/acs/public/villas/web-backend-go/doc/api" // doc/api folder is used by Swag CLI, you have to import it "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/dashboard" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/file" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/metrics" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/signal" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/simulationmodel" @@ -34,12 +37,16 @@ import ( // @host villas-new.k8s.fein-aachen.org // @BasePath /api/v2 func main() { - db := database.InitDB(database.DB_NAME, true) - database.MigrateModels(db) + log.Println("Starting VILLASweb-backend-go") + + c.InitConfig() + + db := database.InitDB(c.Config) defer db.Close() - // TODO the following line should be removed in production, it adds test data to the DB - database.DBAddTestData(db) + if m, _ := c.Config.String("mode"); m == "release" { + gin.SetMode(gin.ReleaseMode) + } r := gin.Default() @@ -60,20 +67,21 @@ func main() { user.RegisterUserEndpoints(api.Group("/users")) simulator.RegisterSimulatorEndpoints(api.Group("/simulators")) healthz.RegisterHealthzEndpoint(api.Group("/healthz")) - // register simulator action endpoint only if AMQP client is used - if len(database.AMQP_URL) != 0 { - amqp.RegisterAMQPEndpoint(api.Group("/simulators")) - } r.GET("swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) - if len(database.AMQP_URL) != 0 { - fmt.Println("Starting AMQP client") - err := amqp.ConnectAMQP(database.AMQP_URL) + amqpurl, _ := c.Config.String("amqp.url") + if amqpurl != "" { + log.Println("Starting AMQP client") + + err := amqp.ConnectAMQP(amqpurl) if err != nil { log.Panic(err) } + // register simulator action endpoint only if AMQP client is used + amqp.RegisterAMQPEndpoint(api.Group("/simulators")) + // Periodically call the Ping function to check which simulators are still there ticker := time.NewTicker(10 * time.Second) go func() { From 75d5e58a49787a71c57be09d1394a67ee401766b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 13 Nov 2019 20:34:24 +0100 Subject: [PATCH 03/14] ci: use environment variables --- .gitlab-ci.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a90d2a3..dad8f07 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,6 @@ services: - rabbitmq:latest variables: - TEST_FOLDER: database DOCKER_IMAGE: ${CI_REGISTRY}/acs/public/villas/web-backend-go DOCKER_IMAGE_DEV: ${CI_REGISTRY}/acs/public/villas/web-backend-go/dev POSTGRES_DB: testvillasdb @@ -79,6 +78,11 @@ test:apidoc: test:all: stage: test + variables: + DB_NAME: ${POSTGRES_DB} + DB_HOST: ${POSTGRES_HOST} + DB_USER: ${POSTGRES_USER} + DB_PASS: ${POSTGRES_PASSWORD} tags: - docker image: golang:1.12.9-buster @@ -88,29 +92,26 @@ test:all: -p 1 -covermode=count -coverprofile ./testcover.txt - -dbname ${POSTGRES_DB} - -dbhost ${POSTGRES_HOST} - -dbuser ${POSTGRES_USER} - -dbpass ${POSTGRES_PASSWORD} - -amqp ${AMQP_URL} - go tool cover -func=testcover.txt dependencies: - build:backend test:database: stage: test + variables: + TEST_FOLDER: database + MODE: test + DB_NAME: ${POSTGRES_DB} + DB_HOST: ${POSTGRES_HOST} + DB_USER: ${POSTGRES_USER} + DB_PASS: ${POSTGRES_PASSWORD} tags: - docker image: golang:1.12.9-buster script: - go mod tidy - cd ${TEST_FOLDER} - - go test -v -args - -dbname ${POSTGRES_DB} - -dbhost ${POSTGRES_HOST} - -dbuser ${POSTGRES_USER} - -dbpass ${POSTGRES_PASSWORD} - -amqp ${AMQP_URL} + - go test -v dependencies: - build:backend From e33c7970122bb4fbf0e1557753d3bf2d3dd2cfff Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 13 Nov 2019 20:34:43 +0100 Subject: [PATCH 04/14] docker: ensure that swaggo documentation is up to date --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 367db93..20ff517 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ RUN mkdir /build WORKDIR /build ADD . /build +RUN go install github.com/swaggo/swag/cmd/swag +RUN swag init -p pascalcase -g "start.go" -o "./doc/api/" RUN go build -o villasweb-backend FROM debian:buster From 085627f4e77e07142fa7eac6f45f9d3406ae05a9 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 13 Nov 2019 20:52:27 +0100 Subject: [PATCH 05/14] config: added base.host and base.path settings --- config/config.go | 22 ++++++++++++++-------- start.go | 9 ++++++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/config/config.go b/config/config.go index eaff987..7a8af4b 100644 --- a/config/config.go +++ b/config/config.go @@ -22,6 +22,8 @@ func InitConfig() *config.Config { amqpURL = flag.String("amqp", "", "If set, use this url to connect to an AMQP broker (default is disabled)") configFile = flag.String("configFile", "", "Path to YAML configuration file") mode = flag.String("mode", "release", "Select debug/release/test mode (default is release)") + baseHost = flag.String("base-host", "localhost:4000", "The host:port at which the backend is hosted (default: localhost:4000)") + basePath = flag.String("base-path", "/api/v2", "The path at which the API routes are located (default /api/v2)") ) flag.Parse() @@ -33,14 +35,16 @@ func InitConfig() *config.Config { } static := map[string]string{ - "db.host": *dbHost, - "db.name": *dbName, - "db.user": *dbUser, - "db.pass": *dbPass, - "db.init": dbInitStr, - "db.ssl": *dbSSLMode, - "amqp.url": *amqpURL, - "mode": *mode, + "db.host": *dbHost, + "db.name": *dbName, + "db.user": *dbUser, + "db.pass": *dbPass, + "db.init": dbInitStr, + "db.ssl": *dbSSLMode, + "amqp.url": *amqpURL, + "mode": *mode, + "base.host": *baseHost, + "base.path": *basePath, } mappings := map[string]string{ @@ -51,6 +55,8 @@ func InitConfig() *config.Config { "DB_SSLMOE": "db.ssl", "DB_INIT": "db.init", "AMQP_URL": "amqp.url", + "BASE_HOST": "base.host", + "BASE_PATH": "base.path", } defaults := config.NewStatic(static) diff --git a/start.go b/start.go index 1594e59..2ab7736 100644 --- a/start.go +++ b/start.go @@ -16,7 +16,6 @@ import ( docs "git.rwth-aachen.de/acs/public/villas/web-backend-go/doc/api" // doc/api folder is used by Swag CLI, you have to import it "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/dashboard" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/file" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/metrics" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/signal" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/simulationmodel" @@ -34,7 +33,6 @@ import ( // @contact.email sonja.happ@eonerc.rwth-aachen.de // @license.name GNU GPL 3.0 // @license.url http://www.gnu.de/documents/gpl-3.0.en.html -// @host villas-new.k8s.fein-aachen.org // @BasePath /api/v2 func main() { log.Println("Starting VILLASweb-backend-go") @@ -48,9 +46,14 @@ func main() { gin.SetMode(gin.ReleaseMode) } + baseHost, _ := c.Config.String("base.host") + basePath, _ := c.Config.String("base.path") + docs.SwaggerInfo.Host = baseHost + docs.SwaggerInfo.BasePath = basePath + r := gin.Default() - api := r.Group("/api/v2") + api := r.Group(basePath) // All endpoints require authentication except when someone wants to // login (POST /authenticate) From 0119a2947e1523ab89beece5801abb18e6fda47b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 13 Nov 2019 20:52:58 +0100 Subject: [PATCH 06/14] swaggo: update generated docs --- doc/api/docs.go | 242 ++++--------------------------------------- doc/api/swagger.json | 216 -------------------------------------- doc/api/swagger.yaml | 216 -------------------------------------- 3 files changed, 19 insertions(+), 655 deletions(-) diff --git a/doc/api/docs.go b/doc/api/docs.go index 1e0e093..06e00a1 100644 --- a/doc/api/docs.go +++ b/doc/api/docs.go @@ -1,12 +1,13 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2019-11-13 15:00:23.644372933 +0100 CET m=+0.089025380 +// 2019-11-13 20:52:36.885507 +0100 CET m=+0.101033324 package docs import ( "bytes" "encoding/json" + "strings" "github.com/alecthomas/template" "github.com/swaggo/swag" @@ -16,8 +17,8 @@ var doc = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { - "description": "This is the VILLASweb Backend API v2.0.\nParts of this API are still in development. Please check the [VILLASweb-backend-go repository](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) for more information.\nThis documentation is auto-generated based on the API documentation in the code. The tool [swag](https://github.com/swaggo/swag) is used to auto-generate API docs for the [gin-gonic](https://github.com/gin-gonic/gin) framework.", - "title": "VILLASweb Backend API", + "description": "{{.Description}}", + "title": "{{.Title}}", "contact": { "name": "Sonja Happ", "email": "sonja.happ@eonerc.rwth-aachen.de" @@ -26,10 +27,10 @@ var doc = `{ "name": "GNU GPL 3.0", "url": "http://www.gnu.de/documents/gpl-3.0.en.html" }, - "version": "2.0" + "version": "{{.Version}}" }, - "host": "localhost:4000", - "basePath": "/api/v2", + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", "paths": { "/authenticate": { "post": { @@ -60,21 +61,18 @@ var doc = `{ "200": { "description": "JSON web token, success status, message and authenticated user object", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseAuthenticate" } }, "401": { "description": "Unauthorized", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -111,28 +109,24 @@ var doc = `{ "200": { "description": "Dashboards which belong to scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboards" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -173,35 +167,30 @@ var doc = `{ "200": { "description": "Dashboard that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboard" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -238,35 +227,30 @@ var doc = `{ "200": { "description": "Dashboard that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboard" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -314,35 +298,30 @@ var doc = `{ "200": { "description": "Dashboard that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboard" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -377,35 +356,30 @@ var doc = `{ "200": { "description": "Dashboard that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboard" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -449,28 +423,24 @@ var doc = `{ "200": { "description": "Files which belong to simulation model or widget", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFiles" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -527,35 +497,30 @@ var doc = `{ "200": { "description": "File that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFile" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -597,35 +562,30 @@ var doc = `{ "200": { "description": "File that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFile" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -675,35 +635,30 @@ var doc = `{ "200": { "description": "File that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFile" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -738,35 +693,30 @@ var doc = `{ "200": { "description": "File that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFile" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -799,7 +749,6 @@ var doc = `{ "500": { "description": "Backend is NOT healthy", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -836,28 +785,24 @@ var doc = `{ "200": { "description": "Simulation models which belong to scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModels" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -898,35 +843,30 @@ var doc = `{ "200": { "description": "simulation model that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModel" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -963,35 +903,30 @@ var doc = `{ "200": { "description": "simulation model that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModel" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1039,35 +974,30 @@ var doc = `{ "200": { "description": "simulation model that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModel" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1102,35 +1032,30 @@ var doc = `{ "200": { "description": "simulation model that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModel" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1160,28 +1085,24 @@ var doc = `{ "200": { "description": "Scenarios to which user has access", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenarios" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1222,35 +1143,30 @@ var doc = `{ "200": { "description": "scenario that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenario" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1287,28 +1203,24 @@ var doc = `{ "200": { "description": "Scenario requested by user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenario" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1356,35 +1268,30 @@ var doc = `{ "200": { "description": "Updated scenario.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenario" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1419,28 +1326,24 @@ var doc = `{ "200": { "description": "Deleted scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenario" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1484,28 +1387,24 @@ var doc = `{ "200": { "description": "User that was added to scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1547,28 +1446,24 @@ var doc = `{ "200": { "description": "User that was deleted from scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1605,28 +1500,24 @@ var doc = `{ "200": { "description": "Array of users that have access to the scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUsers" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1670,28 +1561,24 @@ var doc = `{ "200": { "description": "Signals which belong to simulation model", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignals" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1732,35 +1619,30 @@ var doc = `{ "200": { "description": "Signal that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignal" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1797,35 +1679,30 @@ var doc = `{ "200": { "description": "Signal that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignal" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1870,35 +1747,30 @@ var doc = `{ "200": { "description": "Signal that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignal" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1933,35 +1805,30 @@ var doc = `{ "200": { "description": "Signal that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignal" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1991,28 +1858,24 @@ var doc = `{ "200": { "description": "Simulators requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulators" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2053,35 +1916,30 @@ var doc = `{ "200": { "description": "Simulator that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulator" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2118,35 +1976,30 @@ var doc = `{ "200": { "description": "Simulator that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulator" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2194,35 +2047,30 @@ var doc = `{ "200": { "description": "Simulator that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulator" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2257,35 +2105,30 @@ var doc = `{ "200": { "description": "Simulator that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulator" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2322,35 +2165,30 @@ var doc = `{ "200": { "description": "Action sent successfully", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2387,35 +2225,30 @@ var doc = `{ "200": { "description": "Simulation models requested by user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModels" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2445,28 +2278,24 @@ var doc = `{ "200": { "description": "Array of users", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUsers" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2507,28 +2336,24 @@ var doc = `{ "200": { "description": "Contains added user object", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2565,35 +2390,30 @@ var doc = `{ "200": { "description": "requested user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "403": { "description": "Access forbidden.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2641,42 +2461,36 @@ var doc = `{ "200": { "description": "Contains updated user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "400": { "description": "Bad request.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "403": { "description": "Access forbidden.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2711,28 +2525,24 @@ var doc = `{ "200": { "description": "deleted user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2769,28 +2579,24 @@ var doc = `{ "200": { "description": "Widgets to which belong to dashboard", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidgets" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2831,35 +2637,30 @@ var doc = `{ "200": { "description": "Widget that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidget" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2896,35 +2697,30 @@ var doc = `{ "200": { "description": "Widget that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidget" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2972,35 +2768,30 @@ var doc = `{ "200": { "description": "Widget that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidget" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -3035,35 +2826,30 @@ var doc = `{ "200": { "description": "Widget that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidget" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -3992,11 +3778,21 @@ type swaggerInfo struct { } // SwaggerInfo holds exported Swagger Info so clients can modify it -var SwaggerInfo = swaggerInfo{Schemes: []string{}} +var SwaggerInfo = swaggerInfo{ + Version: "2.0", + Host: "", + BasePath: "/api/v2", + Schemes: []string{}, + Title: "VILLASweb Backend API", + Description: "This is the VILLASweb Backend API v2.0.\nParts of this API are still in development. Please check the [VILLASweb-backend-go repository](https://git.rwth-aachen.de/acs/public/villas/web-backend-go) for more information.\nThis documentation is auto-generated based on the API documentation in the code. The tool [swag](https://github.com/swaggo/swag) is used to auto-generate API docs for the [gin-gonic](https://github.com/gin-gonic/gin) framework.", +} type s struct{} func (s *s) ReadDoc() string { + sInfo := SwaggerInfo + sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1) + t, err := template.New("swagger_info").Funcs(template.FuncMap{ "marshal": func(v interface{}) string { a, _ := json.Marshal(v) @@ -4008,7 +3804,7 @@ func (s *s) ReadDoc() string { } var tpl bytes.Buffer - if err := t.Execute(&tpl, SwaggerInfo); err != nil { + if err := t.Execute(&tpl, sInfo); err != nil { return doc } diff --git a/doc/api/swagger.json b/doc/api/swagger.json index a9fe6e4..908d1c4 100644 --- a/doc/api/swagger.json +++ b/doc/api/swagger.json @@ -13,7 +13,6 @@ }, "version": "2.0" }, - "host": "localhost:4000", "basePath": "/api/v2", "paths": { "/authenticate": { @@ -45,21 +44,18 @@ "200": { "description": "JSON web token, success status, message and authenticated user object", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseAuthenticate" } }, "401": { "description": "Unauthorized", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -96,28 +92,24 @@ "200": { "description": "Dashboards which belong to scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboards" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -158,35 +150,30 @@ "200": { "description": "Dashboard that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboard" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -223,35 +210,30 @@ "200": { "description": "Dashboard that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboard" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -299,35 +281,30 @@ "200": { "description": "Dashboard that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboard" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -362,35 +339,30 @@ "200": { "description": "Dashboard that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseDashboard" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -434,28 +406,24 @@ "200": { "description": "Files which belong to simulation model or widget", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFiles" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -512,35 +480,30 @@ "200": { "description": "File that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFile" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -582,35 +545,30 @@ "200": { "description": "File that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFile" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -660,35 +618,30 @@ "200": { "description": "File that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFile" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -723,35 +676,30 @@ "200": { "description": "File that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseFile" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -784,7 +732,6 @@ "500": { "description": "Backend is NOT healthy", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -821,28 +768,24 @@ "200": { "description": "Simulation models which belong to scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModels" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -883,35 +826,30 @@ "200": { "description": "simulation model that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModel" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -948,35 +886,30 @@ "200": { "description": "simulation model that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModel" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1024,35 +957,30 @@ "200": { "description": "simulation model that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModel" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1087,35 +1015,30 @@ "200": { "description": "simulation model that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModel" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1145,28 +1068,24 @@ "200": { "description": "Scenarios to which user has access", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenarios" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1207,35 +1126,30 @@ "200": { "description": "scenario that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenario" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1272,28 +1186,24 @@ "200": { "description": "Scenario requested by user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenario" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1341,35 +1251,30 @@ "200": { "description": "Updated scenario.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenario" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1404,28 +1309,24 @@ "200": { "description": "Deleted scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseScenario" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1469,28 +1370,24 @@ "200": { "description": "User that was added to scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1532,28 +1429,24 @@ "200": { "description": "User that was deleted from scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1590,28 +1483,24 @@ "200": { "description": "Array of users that have access to the scenario", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUsers" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1655,28 +1544,24 @@ "200": { "description": "Signals which belong to simulation model", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignals" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1717,35 +1602,30 @@ "200": { "description": "Signal that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignal" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1782,35 +1662,30 @@ "200": { "description": "Signal that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignal" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1855,35 +1730,30 @@ "200": { "description": "Signal that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignal" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1918,35 +1788,30 @@ "200": { "description": "Signal that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSignal" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -1976,28 +1841,24 @@ "200": { "description": "Simulators requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulators" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2038,35 +1899,30 @@ "200": { "description": "Simulator that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulator" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2103,35 +1959,30 @@ "200": { "description": "Simulator that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulator" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2179,35 +2030,30 @@ "200": { "description": "Simulator that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulator" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2242,35 +2088,30 @@ "200": { "description": "Simulator that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulator" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2307,35 +2148,30 @@ "200": { "description": "Action sent successfully", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2372,35 +2208,30 @@ "200": { "description": "Simulation models requested by user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseSimulationModels" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2430,28 +2261,24 @@ "200": { "description": "Array of users", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUsers" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2492,28 +2319,24 @@ "200": { "description": "Contains added user object", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2550,35 +2373,30 @@ "200": { "description": "requested user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "403": { "description": "Access forbidden.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2626,42 +2444,36 @@ "200": { "description": "Contains updated user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "400": { "description": "Bad request.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "403": { "description": "Access forbidden.", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2696,28 +2508,24 @@ "200": { "description": "deleted user", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseUser" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2754,28 +2562,24 @@ "200": { "description": "Widgets to which belong to dashboard", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidgets" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2816,35 +2620,30 @@ "200": { "description": "Widget that was added", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidget" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2881,35 +2680,30 @@ "200": { "description": "Widget that was requested", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidget" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -2957,35 +2751,30 @@ "200": { "description": "Widget that was updated", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidget" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } @@ -3020,35 +2809,30 @@ "200": { "description": "Widget that was deleted", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseWidget" } }, "400": { "description": "Bad request", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "404": { "description": "Not found", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "422": { "description": "Unprocessable entity", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } }, "500": { "description": "Internal server error", "schema": { - "type": "object", "$ref": "#/definitions/docs.ResponseError" } } diff --git a/doc/api/swagger.yaml b/doc/api/swagger.yaml index cb0175a..cf2a992 100644 --- a/doc/api/swagger.yaml +++ b/doc/api/swagger.yaml @@ -618,7 +618,6 @@ definitions: Z: type: integer type: object -host: localhost:4000 info: contact: email: sonja.happ@eonerc.rwth-aachen.de @@ -654,17 +653,14 @@ paths: object schema: $ref: '#/definitions/docs.ResponseAuthenticate' - type: object "401": description: Unauthorized schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error. schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Authentication for user tags: - authentication @@ -689,22 +685,18 @@ paths: description: Dashboards which belong to scenario schema: $ref: '#/definitions/docs.ResponseDashboards' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get all dashboards of scenario tags: - dashboards @@ -732,27 +724,22 @@ paths: description: Dashboard that was added schema: $ref: '#/definitions/docs.ResponseDashboard' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Add a dashboard to a scenario tags: - dashboards @@ -777,27 +764,22 @@ paths: description: Dashboard that was deleted schema: $ref: '#/definitions/docs.ResponseDashboard' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Delete a dashboard tags: - dashboards @@ -821,27 +803,22 @@ paths: description: Dashboard that was requested schema: $ref: '#/definitions/docs.ResponseDashboard' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get a dashboard tags: - dashboards @@ -874,27 +851,22 @@ paths: description: Dashboard that was updated schema: $ref: '#/definitions/docs.ResponseDashboard' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Update a dashboard tags: - dashboards @@ -924,22 +896,18 @@ paths: description: Files which belong to simulation model or widget schema: $ref: '#/definitions/docs.ResponseFiles' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get all files of a specific model or widget tags: - files @@ -980,27 +948,22 @@ paths: description: File that was added schema: $ref: '#/definitions/docs.ResponseFile' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Add a file to a specific model or widget tags: - files @@ -1025,27 +988,22 @@ paths: description: File that was deleted schema: $ref: '#/definitions/docs.ResponseFile' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Delete a file tags: - files @@ -1074,27 +1032,22 @@ paths: description: File that was requested schema: $ref: '#/definitions/docs.ResponseFile' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Download a file tags: - files @@ -1130,27 +1083,22 @@ paths: description: File that was updated schema: $ref: '#/definitions/docs.ResponseFile' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Update a file tags: - files @@ -1173,7 +1121,6 @@ paths: description: Backend is NOT healthy schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get health status of backend tags: - healthz @@ -1198,22 +1145,18 @@ paths: description: Simulation models which belong to scenario schema: $ref: '#/definitions/docs.ResponseSimulationModels' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get all simulation models of scenario tags: - models @@ -1241,27 +1184,22 @@ paths: description: simulation model that was added schema: $ref: '#/definitions/docs.ResponseSimulationModel' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Add a simulation model to a scenario tags: - models @@ -1286,27 +1224,22 @@ paths: description: simulation model that was deleted schema: $ref: '#/definitions/docs.ResponseSimulationModel' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Delete a simulation model tags: - models @@ -1330,27 +1263,22 @@ paths: description: simulation model that was requested schema: $ref: '#/definitions/docs.ResponseSimulationModel' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get a simulation model tags: - models @@ -1383,27 +1311,22 @@ paths: description: simulation model that was added schema: $ref: '#/definitions/docs.ResponseSimulationModel' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Update a simulation model tags: - models @@ -1423,22 +1346,18 @@ paths: description: Scenarios to which user has access schema: $ref: '#/definitions/docs.ResponseScenarios' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get all scenarios of requesting user tags: - scenarios @@ -1466,27 +1385,22 @@ paths: description: scenario that was added schema: $ref: '#/definitions/docs.ResponseScenario' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Add a scenario tags: - scenarios @@ -1511,22 +1425,18 @@ paths: description: Deleted scenario schema: $ref: '#/definitions/docs.ResponseScenario' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Delete a scenario tags: - scenarios @@ -1550,22 +1460,18 @@ paths: description: Scenario requested by user schema: $ref: '#/definitions/docs.ResponseScenario' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get scenario tags: - scenarios @@ -1598,27 +1504,22 @@ paths: description: Updated scenario. schema: $ref: '#/definitions/docs.ResponseScenario' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Update a scenario tags: - scenarios @@ -1648,22 +1549,18 @@ paths: description: User that was deleted from scenario schema: $ref: '#/definitions/docs.ResponseUser' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Delete a user from a scenario tags: - scenarios @@ -1692,22 +1589,18 @@ paths: description: User that was added to scenario schema: $ref: '#/definitions/docs.ResponseUser' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Add a user to a a scenario tags: - scenarios @@ -1732,22 +1625,18 @@ paths: description: Array of users that have access to the scenario schema: $ref: '#/definitions/docs.ResponseUsers' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get users of a scenario tags: - scenarios @@ -1777,22 +1666,18 @@ paths: description: Signals which belong to simulation model schema: $ref: '#/definitions/docs.ResponseSignals' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get all signals of one direction tags: - signals @@ -1821,27 +1706,22 @@ paths: description: Signal that was added schema: $ref: '#/definitions/docs.ResponseSignal' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Add a signal to a signal mapping of a model tags: - signals @@ -1866,27 +1746,22 @@ paths: description: Signal that was deleted schema: $ref: '#/definitions/docs.ResponseSignal' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Delete a signal tags: - signals @@ -1910,27 +1785,22 @@ paths: description: Signal that was requested schema: $ref: '#/definitions/docs.ResponseSignal' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get a signal tags: - signals @@ -1961,27 +1831,22 @@ paths: description: Signal that was updated schema: $ref: '#/definitions/docs.ResponseSignal' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Update a signal tags: - signals @@ -2001,22 +1866,18 @@ paths: description: Simulators requested schema: $ref: '#/definitions/docs.ResponseSimulators' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get all simulators tags: - simulators @@ -2044,27 +1905,22 @@ paths: description: Simulator that was added schema: $ref: '#/definitions/docs.ResponseSimulator' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Add a simulator tags: - simulators @@ -2089,27 +1945,22 @@ paths: description: Simulator that was deleted schema: $ref: '#/definitions/docs.ResponseSimulator' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Delete a simulator tags: - simulators @@ -2133,27 +1984,22 @@ paths: description: Simulator that was requested schema: $ref: '#/definitions/docs.ResponseSimulator' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get simulator tags: - simulators @@ -2186,27 +2032,22 @@ paths: description: Simulator that was updated schema: $ref: '#/definitions/docs.ResponseSimulator' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Update a simulator tags: - simulators @@ -2231,27 +2072,22 @@ paths: description: Action sent successfully schema: $ref: '#/definitions/docs.ResponseError' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Send an action to simulator (only available if backend server is started with -amqp parameter) tags: @@ -2277,27 +2113,22 @@ paths: description: Simulation models requested by user schema: $ref: '#/definitions/docs.ResponseSimulationModels' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get all simulation models in which the simulator is used tags: - simulators @@ -2317,22 +2148,18 @@ paths: description: Array of users schema: $ref: '#/definitions/docs.ResponseUsers' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get all users tags: - users @@ -2360,22 +2187,18 @@ paths: description: Contains added user object schema: $ref: '#/definitions/docs.ResponseUser' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Add a user tags: - users @@ -2400,22 +2223,18 @@ paths: description: deleted user schema: $ref: '#/definitions/docs.ResponseUser' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Delete a user tags: - users @@ -2439,27 +2258,22 @@ paths: description: requested user schema: $ref: '#/definitions/docs.ResponseUser' - type: object "403": description: Access forbidden. schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get user tags: - users @@ -2493,32 +2307,26 @@ paths: description: Contains updated user schema: $ref: '#/definitions/docs.ResponseUser' - type: object "400": description: Bad request. schema: $ref: '#/definitions/docs.ResponseError' - type: object "403": description: Access forbidden. schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Update a user tags: - users @@ -2543,22 +2351,18 @@ paths: description: Widgets to which belong to dashboard schema: $ref: '#/definitions/docs.ResponseWidgets' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get all widgets of dashboard tags: - widgets @@ -2586,27 +2390,22 @@ paths: description: Widget that was added schema: $ref: '#/definitions/docs.ResponseWidget' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Add a widget to a dashboard tags: - widgets @@ -2631,27 +2430,22 @@ paths: description: Widget that was deleted schema: $ref: '#/definitions/docs.ResponseWidget' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Delete a widget tags: - widgets @@ -2675,27 +2469,22 @@ paths: description: Widget that was requested schema: $ref: '#/definitions/docs.ResponseWidget' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Get a widget tags: - widgets @@ -2728,27 +2517,22 @@ paths: description: Widget that was updated schema: $ref: '#/definitions/docs.ResponseWidget' - type: object "400": description: Bad request schema: $ref: '#/definitions/docs.ResponseError' - type: object "404": description: Not found schema: $ref: '#/definitions/docs.ResponseError' - type: object "422": description: Unprocessable entity schema: $ref: '#/definitions/docs.ResponseError' - type: object "500": description: Internal server error schema: $ref: '#/definitions/docs.ResponseError' - type: object summary: Update a widget tags: - widgets From d546f7bc915ff49373996e48def1f05a11b192fc Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 13 Nov 2019 21:22:17 +0100 Subject: [PATCH 07/14] fix tests --- config/config.go | 11 ++++++----- database/database.go | 2 -- database/database_test.go | 4 +++- routes/dashboard/dashboard_test.go | 5 +++-- routes/file/file_test.go | 5 +++-- routes/healthz/healthz_test.go | 11 ++++++----- routes/scenario/scenario_test.go | 5 +++-- routes/signal/signal_test.go | 5 +++-- routes/simulationmodel/simulationmodel_test.go | 5 +++-- routes/simulator/simulator_test.go | 5 +++-- routes/user/user_test.go | 5 +++-- routes/widget/widget_test.go | 5 +++-- start.go | 13 ++++++------- 13 files changed, 45 insertions(+), 36 deletions(-) diff --git a/config/config.go b/config/config.go index 7a8af4b..c9dbf31 100644 --- a/config/config.go +++ b/config/config.go @@ -75,11 +75,12 @@ func InitConfig() *config.Config { log.Fatal("failed to parse config") } - settings, _ := c.Settings() - - log.Print("All settings:") - for key, val := range settings { - log.Printf(" %s = %s \n", key, val) + if m, _ := c.String("mode"); m != "test" { + settings, _ := c.Settings() + log.Print("All settings:") + for key, val := range settings { + log.Printf(" %s = %s \n", key, val) + } } // Save pointer to global variable diff --git a/database/database.go b/database/database.go index 8f566aa..d7f5eca 100644 --- a/database/database.go +++ b/database/database.go @@ -37,9 +37,7 @@ func InitDB(cfg *config.Config) *gorm.DB { if mode == "test" || init { DropTables(db) log.Println("Database tables dropped") - } - if init { DBAddTestData(db) log.Println("Database initialized with test data") } diff --git a/database/database_test.go b/database/database_test.go index cf33cc8..9506f80 100644 --- a/database/database_test.go +++ b/database/database_test.go @@ -7,12 +7,14 @@ import ( "testing" "github.com/stretchr/testify/assert" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" ) var db *gorm.DB func TestMain(m *testing.M) { - db = InitDB(DB_NAME, true) + c := config.InitConfig() + db = InitDB(c) // Verify that you can connect to the database err := db.DB().Ping() diff --git a/routes/dashboard/dashboard_test.go b/routes/dashboard/dashboard_test.go index ea36a75..6b08c38 100644 --- a/routes/dashboard/dashboard_test.go +++ b/routes/dashboard/dashboard_test.go @@ -2,6 +2,7 @@ package dashboard import ( "fmt" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" @@ -54,8 +55,8 @@ func addScenario(token string) (scenarioID uint) { } func TestMain(m *testing.M) { - - db = database.InitDB(database.DB_NAME, true) + c := config.InitConfig() + db = database.InitDB(c) defer db.Close() router = gin.Default() diff --git a/routes/file/file_test.go b/routes/file/file_test.go index 3d582ea..7626751 100644 --- a/routes/file/file_test.go +++ b/routes/file/file_test.go @@ -5,6 +5,7 @@ import ( "fmt" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/dashboard" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/simulationmodel" @@ -159,8 +160,8 @@ func addScenarioAndSimulatorAndSimulationModelAndDashboardAndWidget() (scenarioI } func TestMain(m *testing.M) { - - db = database.InitDB(database.DB_NAME, true) + c := config.InitConfig() + db = database.InitDB(c) defer db.Close() router = gin.Default() diff --git a/routes/healthz/healthz_test.go b/routes/healthz/healthz_test.go index f8c78d9..9d633a3 100644 --- a/routes/healthz/healthz_test.go +++ b/routes/healthz/healthz_test.go @@ -2,7 +2,7 @@ package healthz import ( "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" - //"git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/user" @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/assert" "net/http" - //"net/http" "testing" ) @@ -20,7 +19,8 @@ var db *gorm.DB func TestHealthz(t *testing.T) { // connect DB - db = database.InitDB(database.DB_NAME, true) + c := config.InitConfig() + db = database.InitDB(c) defer db.Close() assert.NoError(t, database.DBAddAdminAndUserAndGuest(db)) @@ -47,7 +47,7 @@ func TestHealthz(t *testing.T) { assert.Equalf(t, 500, code, "Response body: \n%v\n", resp) // reconnect DB - db = database.InitDB(database.DB_NAME, false) + db = database.InitDB(c) defer db.Close() // test healthz endpoint for connected DB and unconnected AMQP client @@ -56,7 +56,8 @@ func TestHealthz(t *testing.T) { assert.Equalf(t, 500, code, "Response body: \n%v\n", resp) // connect AMQP client (make sure that AMQP_URL is set via command line parameter -amqp) - err = amqp.ConnectAMQP(database.AMQP_URL) + url, _ := c.String("amqp.url") + err = amqp.ConnectAMQP(url) assert.NoError(t, err) // test healthz endpoint for connected DB and AMQP client diff --git a/routes/scenario/scenario_test.go b/routes/scenario/scenario_test.go index 88ca525..0df8b6e 100644 --- a/routes/scenario/scenario_test.go +++ b/routes/scenario/scenario_test.go @@ -3,6 +3,7 @@ package scenario import ( "fmt" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "github.com/jinzhu/gorm/dialects/postgres" @@ -32,8 +33,8 @@ type UserRequest struct { } func TestMain(m *testing.M) { - - db = database.InitDB(database.DB_NAME, true) + c := config.InitConfig() + db = database.InitDB(c) defer db.Close() router = gin.Default() diff --git a/routes/signal/signal_test.go b/routes/signal/signal_test.go index 852fd5c..7abeefe 100644 --- a/routes/signal/signal_test.go +++ b/routes/signal/signal_test.go @@ -2,6 +2,7 @@ package signal import ( "fmt" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" @@ -105,8 +106,8 @@ func addScenarioAndSimulatorAndSimulationModel() (scenarioID uint, simulatorID u } func TestMain(m *testing.M) { - - db = database.InitDB(database.DB_NAME, true) + c := config.InitConfig() + db = database.InitDB(c) defer db.Close() router = gin.Default() diff --git a/routes/simulationmodel/simulationmodel_test.go b/routes/simulationmodel/simulationmodel_test.go index 93b3239..a27a324 100644 --- a/routes/simulationmodel/simulationmodel_test.go +++ b/routes/simulationmodel/simulationmodel_test.go @@ -2,6 +2,7 @@ package simulationmodel import ( "fmt" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" @@ -94,8 +95,8 @@ func addScenarioAndSimulator() (scenarioID uint, simulatorID uint) { } func TestMain(m *testing.M) { - - db = database.InitDB(database.DB_NAME, true) + c := config.InitConfig() + db = database.InitDB(c) defer db.Close() router = gin.Default() diff --git a/routes/simulator/simulator_test.go b/routes/simulator/simulator_test.go index 2c36ebb..893bac9 100644 --- a/routes/simulator/simulator_test.go +++ b/routes/simulator/simulator_test.go @@ -12,6 +12,7 @@ import ( "github.com/gin-gonic/gin" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/user" ) @@ -27,8 +28,8 @@ type SimulatorRequest struct { } func TestMain(m *testing.M) { - - db = database.InitDB(database.DB_NAME, true) + c := config.InitConfig() + db = database.InitDB(c) defer db.Close() router = gin.Default() diff --git a/routes/user/user_test.go b/routes/user/user_test.go index 316cf6e..ae81318 100644 --- a/routes/user/user_test.go +++ b/routes/user/user_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/assert" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" ) var router *gin.Engine @@ -30,8 +31,8 @@ type UserRequest struct { } func TestMain(m *testing.M) { - - db = database.InitDB(database.DB_NAME, true) + c := config.InitConfig() + db = database.InitDB(c) defer db.Close() router = gin.Default() diff --git a/routes/widget/widget_test.go b/routes/widget/widget_test.go index 13f20d8..08c2d6a 100644 --- a/routes/widget/widget_test.go +++ b/routes/widget/widget_test.go @@ -2,6 +2,7 @@ package widget import ( "fmt" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/dashboard" @@ -79,8 +80,8 @@ func addScenarioAndDashboard(token string) (scenarioID uint, dashboardID uint) { } func TestMain(m *testing.M) { - - db = database.InitDB(database.DB_NAME, true) + c := config.InitConfig() + db = database.InitDB(c) defer db.Close() router = gin.Default() diff --git a/start.go b/start.go index 2ab7736..db48806 100644 --- a/start.go +++ b/start.go @@ -37,17 +37,16 @@ import ( func main() { log.Println("Starting VILLASweb-backend-go") - c.InitConfig() - - db := database.InitDB(c.Config) + c := c.InitConfig() + db := database.InitDB(c) defer db.Close() - if m, _ := c.Config.String("mode"); m == "release" { + if m, _ := c.String("mode"); m == "release" { gin.SetMode(gin.ReleaseMode) } - baseHost, _ := c.Config.String("base.host") - basePath, _ := c.Config.String("base.path") + baseHost, _ := c.String("base.host") + basePath, _ := c.String("base.path") docs.SwaggerInfo.Host = baseHost docs.SwaggerInfo.BasePath = basePath @@ -73,7 +72,7 @@ func main() { r.GET("swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) - amqpurl, _ := c.Config.String("amqp.url") + amqpurl, _ := c.String("amqp.url") if amqpurl != "" { log.Println("Starting AMQP client") From df93fa854f94c69ecb5bfc96db2b9dc67cc38b4c Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 13 Nov 2019 21:22:39 +0100 Subject: [PATCH 08/14] update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 4b8b4b3..9c4fad9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ villasweb-backend-go +routes/file/testfile.txt +routes/file/testfileupdated.txt From 2c5400a0ccda23acdf48445666b914f4a706402b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 13 Nov 2019 21:29:17 +0100 Subject: [PATCH 09/14] fix tests --- .gitlab-ci.yml | 11 ++++++--- config/config.go | 25 ++++++++++++--------- database/database.go | 1 + routes/healthz/healthz_test.go | 41 +++++++++++++++------------------- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dad8f07..b6c2331 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -76,13 +76,14 @@ test:apidoc: - doc/api/index.html - doc/api/swagger.json -test:all: +test:gotest: stage: test variables: DB_NAME: ${POSTGRES_DB} DB_HOST: ${POSTGRES_HOST} DB_USER: ${POSTGRES_USER} DB_PASS: ${POSTGRES_PASSWORD} + MODE: test tags: - docker image: golang:1.12.9-buster @@ -179,9 +180,13 @@ deploy:docker: # deploy:upload: # stage: deploy +# image: +# name: rclone/rclone:1.50 +# entrypoint: [""] +# before_script: +# - rclone config create fein webdav url ${DEPLOY_PATH} vendor other user ${DEPLOY_USER} pass ${DEPLOY_PASS} # script: -# - cd doc/api -# - rsync --copy-links --chown ${DEPLOY_USER}:${DEPLOY_USER} index.html swagger.json ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH} +# - rclone copy --include=index.html --include=swagger.json doc/api fein:villas/api/web # dependencies: # - test:apidoc # only: diff --git a/config/config.go b/config/config.go index c9dbf31..233ac96 100644 --- a/config/config.go +++ b/config/config.go @@ -9,9 +9,13 @@ import ( ) // Global configuration -var Config *config.Config +var Config *config.Config = nil func InitConfig() *config.Config { + if Config != nil { + return Config + } + var ( dbHost = flag.String("dbhost", "/var/run/postgresql", "Host of the PostgreSQL database (default is /var/run/postgresql for localhost DB on Ubuntu systems)") dbName = flag.String("dbname", "villas", "Name of the database to use (default is villasdb)") @@ -48,15 +52,16 @@ func InitConfig() *config.Config { } mappings := map[string]string{ - "DB_HOST": "db.host", - "DB_NAME": "db.name", - "DB_USER": "db.user", - "DB_PASS": "db.pass", - "DB_SSLMOE": "db.ssl", - "DB_INIT": "db.init", - "AMQP_URL": "amqp.url", - "BASE_HOST": "base.host", - "BASE_PATH": "base.path", + "DB_HOST": "db.host", + "DB_NAME": "db.name", + "DB_USER": "db.user", + "DB_PASS": "db.pass", + "DB_SSLMODE": "db.ssl", + "DB_INIT": "db.init", + "AMQP_URL": "amqp.url", + "BASE_HOST": "base.host", + "BASE_PATH": "base.path", + "MODE": "mode", } defaults := config.NewStatic(static) diff --git a/database/database.go b/database/database.go index d7f5eca..21d5d63 100644 --- a/database/database.go +++ b/database/database.go @@ -30,6 +30,7 @@ func InitDB(cfg *config.Config) *gorm.DB { if err != nil { log.Fatal(err) } + DBpool = db MigrateModels(db) diff --git a/routes/healthz/healthz_test.go b/routes/healthz/healthz_test.go index 9d633a3..e33152a 100644 --- a/routes/healthz/healthz_test.go +++ b/routes/healthz/healthz_test.go @@ -1,15 +1,16 @@ package healthz import ( + "net/http" + "os" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" + c "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/user" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "net/http" "testing" ) @@ -17,51 +18,45 @@ import ( var router *gin.Engine var db *gorm.DB +func TestMain(m *testing.M) { + c.InitConfig() + + os.Exit(m.Run()) +} + func TestHealthz(t *testing.T) { // connect DB - c := config.InitConfig() - db = database.InitDB(c) - defer db.Close() - - assert.NoError(t, database.DBAddAdminAndUserAndGuest(db)) + db = database.InitDB(c.Config) router = gin.Default() - api := router.Group("/api") - user.RegisterAuthenticate(api.Group("/authenticate")) - api.Use(user.Authentication(true)) - RegisterHealthzEndpoint(api.Group("/healthz")) - - // authenticate as normal user - token, err := helper.AuthenticateForTest(router, - "/api/authenticate", "POST", helper.UserACredentials) - assert.NoError(t, err) + RegisterHealthzEndpoint(router.Group("/healthz")) // close db connection - err = db.Close() + err := db.Close() assert.NoError(t, err) // test healthz endpoint for unconnected DB and AMQP client - code, resp, err := helper.TestEndpoint(router, token, "api/healthz", http.MethodGet, nil) + code, resp, err := helper.TestEndpoint(router, "", "healthz", http.MethodGet, nil) assert.NoError(t, err) assert.Equalf(t, 500, code, "Response body: \n%v\n", resp) // reconnect DB - db = database.InitDB(c) + db = database.InitDB(c.Config) defer db.Close() // test healthz endpoint for connected DB and unconnected AMQP client - code, resp, err = helper.TestEndpoint(router, token, "api/healthz", http.MethodGet, nil) + code, resp, err = helper.TestEndpoint(router, "", "healthz", http.MethodGet, nil) assert.NoError(t, err) assert.Equalf(t, 500, code, "Response body: \n%v\n", resp) // connect AMQP client (make sure that AMQP_URL is set via command line parameter -amqp) - url, _ := c.String("amqp.url") + url, _ := c.Config.String("amqp.url") err = amqp.ConnectAMQP(url) assert.NoError(t, err) // test healthz endpoint for connected DB and AMQP client - code, resp, err = helper.TestEndpoint(router, token, "api/healthz", http.MethodGet, nil) + code, resp, err = helper.TestEndpoint(router, "", "healthz", http.MethodGet, nil) assert.NoError(t, err) assert.Equalf(t, 200, code, "Response body: \n%v\n", resp) } From 7a64d4653a2d8cb78f428ae34afe0a0164c43fe2 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Thu, 14 Nov 2019 10:38:51 +0100 Subject: [PATCH 10/14] Some fixes with respect to config - resolve some name overlappings - InitConfig sets global config and returns error - Add missing error handling --- {config => configuration}/config.go | 34 +++--- database/database_test.go | 11 +- go.mod | 28 ++--- go.sum | 107 ++++++------------ routes/dashboard/dashboard_test.go | 9 +- routes/file/file_test.go | 9 +- routes/healthz/healthz_endpoint.go | 11 +- routes/healthz/healthz_test.go | 24 ++-- routes/scenario/scenario_test.go | 15 ++- routes/signal/signal_test.go | 9 +- .../simulationmodel/simulationmodel_test.go | 9 +- routes/simulator/simulator_test.go | 9 +- routes/user/user_test.go | 9 +- routes/widget/widget_test.go | 9 +- start.go | 35 ++++-- 15 files changed, 168 insertions(+), 160 deletions(-) rename {config => configuration}/config.go (80%) diff --git a/config/config.go b/configuration/config.go similarity index 80% rename from config/config.go rename to configuration/config.go index 233ac96..9a5d271 100644 --- a/config/config.go +++ b/configuration/config.go @@ -1,4 +1,4 @@ -package config +package configuration import ( "flag" @@ -9,16 +9,16 @@ import ( ) // Global configuration -var Config *config.Config = nil +var GolbalConfig *config.Config = nil -func InitConfig() *config.Config { - if Config != nil { - return Config +func InitConfig() error { + if GolbalConfig != nil { + return nil } var ( dbHost = flag.String("dbhost", "/var/run/postgresql", "Host of the PostgreSQL database (default is /var/run/postgresql for localhost DB on Ubuntu systems)") - dbName = flag.String("dbname", "villas", "Name of the database to use (default is villasdb)") + dbName = flag.String("dbname", "villasdb", "Name of the database to use (default is villasdb)") dbUser = flag.String("dbuser", "", "Username of database connection (default is )") dbPass = flag.String("dbpass", "", "Password of database connection (default is )") dbInit = flag.Bool("dbinit", false, "Initialize database with test data (default is off)") @@ -67,29 +67,31 @@ func InitConfig() *config.Config { defaults := config.NewStatic(static) env := config.NewEnvironment(mappings) - var c *config.Config if _, err := os.Stat(*configFile); os.IsExist(err) { yamlFile := config.NewYAMLFile(*configFile) - c = config.NewConfig([]config.Provider{defaults, yamlFile, env}) + GolbalConfig = config.NewConfig([]config.Provider{defaults, yamlFile, env}) } else { - c = config.NewConfig([]config.Provider{defaults, env}) + GolbalConfig = config.NewConfig([]config.Provider{defaults, env}) } - err := c.Load() + err := GolbalConfig.Load() if err != nil { log.Fatal("failed to parse config") + return err } - if m, _ := c.String("mode"); m != "test" { - settings, _ := c.Settings() + m, err := GolbalConfig.String("mode") + if err != nil { + return err + } + + if m != "test" { + settings, _ := GolbalConfig.Settings() log.Print("All settings:") for key, val := range settings { log.Printf(" %s = %s \n", key, val) } } - // Save pointer to global variable - Config = c - - return c + return nil } diff --git a/database/database_test.go b/database/database_test.go index 9506f80..2e94b77 100644 --- a/database/database_test.go +++ b/database/database_test.go @@ -6,18 +6,21 @@ import ( "os" "testing" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "github.com/stretchr/testify/assert" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" ) var db *gorm.DB func TestMain(m *testing.M) { - c := config.InitConfig() - db = InitDB(c) + err := configuration.InitConfig() + if err != nil { + panic(m) + } + db = InitDB(configuration.GolbalConfig) // Verify that you can connect to the database - err := db.DB().Ping() + err = db.DB().Ping() if err != nil { fmt.Println("Error: DB must ping to run tests") return diff --git a/go.mod b/go.mod index d2ce9c9..a97d22b 100644 --- a/go.mod +++ b/go.mod @@ -6,27 +6,19 @@ require ( github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gin-gonic/gin v1.4.0 github.com/go-ini/ini v1.51.0 // indirect - github.com/go-openapi/jsonreference v0.19.3 // indirect - github.com/go-openapi/spec v0.19.3 // indirect - github.com/go-playground/locales v0.12.1 // indirect - github.com/go-playground/universal-translator v0.16.0 // indirect - github.com/jinzhu/gorm v1.9.10 - github.com/leodido/go-urn v1.1.0 // indirect - github.com/mailru/easyjson v0.7.0 // indirect + github.com/go-playground/universal-translator v0.17.0 // indirect + github.com/jinzhu/gorm v1.9.11 + github.com/leodido/go-urn v1.2.0 // indirect github.com/nsf/jsondiff v0.0.0-20190712045011-8443391ee9b6 github.com/prometheus/client_golang v1.2.1 - github.com/prometheus/common v0.7.0 - github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94 + github.com/smartystreets/goconvey v1.6.4 // indirect + github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 github.com/stretchr/testify v1.4.0 github.com/swaggo/gin-swagger v1.2.0 - github.com/swaggo/swag v1.6.2 - github.com/tidwall/gjson v1.3.0 + github.com/swaggo/swag v1.6.3 + github.com/tidwall/gjson v1.3.4 github.com/zpatrick/go-config v0.0.0-20191104215613-50bc2709703f - golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 - golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 // indirect - golang.org/x/tools v0.0.0-20190916034716-92af9d69eff2 // indirect - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect - gopkg.in/go-playground/validator.v9 v9.29.0 + golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708 + gopkg.in/go-playground/validator.v9 v9.30.0 + gopkg.in/ini.v1 v1.51.0 // indirect ) - -go 1.13 diff --git a/go.sum b/go.sum index ab264a3..424b16c 100644 --- a/go.sum +++ b/go.sum @@ -8,21 +8,16 @@ github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -64,30 +59,17 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.19.2 h1:A9+F4Dc/MCNB5jibxf6rRvOvR/iFgQdyNx9eIhnGqq0= -github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= -github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.0 h1:BqWKpV1dFd+AuiKlgtddwVIFQsuMpxfBDBHGfM2yNpk= github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w= -github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= -github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= -github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/spec v0.19.0 h1:A4SZ6IWh3lnjH0rG0Z5lkxazMGBECtrZcbyYQi+64k4= github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc= -github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotfhkmOqEc= -github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= -github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= -github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -97,34 +79,37 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jinzhu/gorm v1.9.10 h1:HvrsqdhCW78xpJF67g1hMxS6eCToo9PZH4LDB8WKPac= -github.com/jinzhu/gorm v1.9.10/go.mod h1:Kh6hTsSGffh4ui079FHrR5Gg+5D0hgihqDcsDN2BBJY= +github.com/jinzhu/gorm v1.9.11 h1:gaHGvE+UnWGlbWG4Y3FUwY1EcZ5n6S9WtqBA/uySMLE= +github.com/jinzhu/gorm v1.9.11/go.mod h1:bu/pK8szGZ2puuErfU0RwyeNdsf3e6nCX/noXaVxkfw= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M= github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -132,26 +117,20 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8= -github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= -github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o= -github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q= +github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -169,18 +148,15 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 h1:D+CiwcpGTW6pL6bv6KI3KbyEyCKyS+1JWS2h8PNDnGA= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.2.1 h1:JnMpQc6ppsNgw9QPAGF6Dod479itz7lvlsMzzNayLOI= github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f h1:BVwpUVJDADN2ufcGik7W992pyps0wZ888b/y9GXcLTU= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= @@ -190,32 +166,33 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.7.0 h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 h1:/K3IL0Z1quvmJ7X0A1AwNEK7CRkVK3YwfOU/QAL4WGg= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.5 h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8= github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94 h1:0ngsPmuP6XIjiFRNFYlvKwSr5zff2v+uPHaffZ6/M4k= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 h1:WhxRHzgeVGETMlmVfqhRn8RIeeNoPr2Czh33I4Zdccw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= github.com/swaggo/gin-swagger v1.2.0 h1:YskZXEiv51fjOMTsXrOetAjrMDfFaXD79PEoQBOe2W0= github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI= github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y= -github.com/swaggo/swag v1.6.2 h1:WQMAtT/FmMBb7g0rAuHDhG3vvdtHKJ3WZ+Ssb0p4Y6E= -github.com/swaggo/swag v1.6.2/go.mod h1:YyZstMc22WYm6GEDx/CYWxq+faBbjQ5EqwQcrjREDBo= -github.com/tidwall/gjson v1.3.0 h1:kfpsw1W3trbg4Xm6doUtqSl9+LhLB6qJ9PkltVAQZYs= -github.com/tidwall/gjson v1.3.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= +github.com/swaggo/swag v1.6.3 h1:N+uVPGP4H2hXoss2pt5dctoSUPKKRInr6qcTMOm0usI= +github.com/swaggo/swag v1.6.3/go.mod h1:wcc83tB4Mb2aNiL/HP4MFeQdpHUrca+Rp/DRNgWAUio= +github.com/tidwall/gjson v1.3.4 h1:On5waDnyKKk3SWE4EthbjjirAWXp43xx5cKCUZY1eZw= +github.com/tidwall/gjson v1.3.4/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= @@ -234,9 +211,8 @@ go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU= -golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708 h1:pXVtWnwHkrWD9ru3sDxY/qFK/bfc0egRovX91EjWjf4= +golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -253,13 +229,9 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190611141213-3f473d35a33a h1:+KkCgOMgnKSgenxTBoiwkMqTiouMIy/3o8RLdmSbGoY= golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 h1:4dVFTC832rPn4pomLSz1vA+are2+dU19w1H8OngV7nc= -golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -277,11 +249,8 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae h1:xiXzMMEQdQcric9hXtr1QU98MHunKK7OTtsoU6bYWs4= golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 h1:wYqz/tQaWUgGKyx+B/rssSE6wkIKdY5Ee6ryOmzarIg= -golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY= golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -293,13 +262,10 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b h1:/mJ+GKieZA6hFDQGdWZrjj4AXPl5ylY+5HusG80roy0= golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190916034716-92af9d69eff2 h1:cvSBP3q8DeS4up5q8ssbGdEtSGiDgRV7HBvOpr3g5RM= -golang.org/x/tools v0.0.0-20190916034716-92af9d69eff2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= @@ -309,20 +275,19 @@ google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/go-playground/validator.v9 v9.29.0 h1:5ofssLNYgAA/inWn6rTZ4juWpRJUwEnXc1LG2IeXwgQ= -gopkg.in/go-playground/validator.v9 v9.29.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/go-playground/validator.v9 v9.30.0 h1:Wk0Z37oBmKj9/n+tPyBHZmeL19LaCoK3Qq48VwYENss= +gopkg.in/go-playground/validator.v9 v9.30.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= diff --git a/routes/dashboard/dashboard_test.go b/routes/dashboard/dashboard_test.go index 6b08c38..066c74c 100644 --- a/routes/dashboard/dashboard_test.go +++ b/routes/dashboard/dashboard_test.go @@ -2,7 +2,7 @@ package dashboard import ( "fmt" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" @@ -55,8 +55,11 @@ func addScenario(token string) (scenarioID uint) { } func TestMain(m *testing.M) { - c := config.InitConfig() - db = database.InitDB(c) + err := configuration.InitConfig() + if err != nil { + panic(m) + } + db = database.InitDB(configuration.GolbalConfig) defer db.Close() router = gin.Default() diff --git a/routes/file/file_test.go b/routes/file/file_test.go index 7626751..1241a38 100644 --- a/routes/file/file_test.go +++ b/routes/file/file_test.go @@ -3,9 +3,9 @@ package file import ( "bytes" "fmt" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/dashboard" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/simulationmodel" @@ -160,8 +160,11 @@ func addScenarioAndSimulatorAndSimulationModelAndDashboardAndWidget() (scenarioI } func TestMain(m *testing.M) { - c := config.InitConfig() - db = database.InitDB(c) + err := configuration.InitConfig() + if err != nil { + panic(m) + } + db = database.InitDB(configuration.GolbalConfig) defer db.Close() router = gin.Default() diff --git a/routes/healthz/healthz_endpoint.go b/routes/healthz/healthz_endpoint.go index f352405..aeedf87 100644 --- a/routes/healthz/healthz_endpoint.go +++ b/routes/healthz/healthz_endpoint.go @@ -2,7 +2,7 @@ package healthz import ( "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" - d "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "github.com/gin-gonic/gin" "log" @@ -33,7 +33,14 @@ func getHealth(c *gin.Context) { } // check if connection to AMQP broker is alive if backend was started with AMQP client - url, _ := d.Config.String("amqp.url") + url, err := configuration.GolbalConfig.String("amqp.url") + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{ + "success:": false, + "message": err.Error(), + }) + } + if len(url) != 0 { err = amqp.CheckConnection() if err != nil { diff --git a/routes/healthz/healthz_test.go b/routes/healthz/healthz_test.go index e33152a..756efef 100644 --- a/routes/healthz/healthz_test.go +++ b/routes/healthz/healthz_test.go @@ -1,16 +1,14 @@ package healthz import ( - "net/http" - "os" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" - c "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" + "net/http" "testing" ) @@ -18,22 +16,19 @@ import ( var router *gin.Engine var db *gorm.DB -func TestMain(m *testing.M) { - c.InitConfig() - - os.Exit(m.Run()) -} - func TestHealthz(t *testing.T) { + err := configuration.InitConfig() + assert.NoError(t, err) + // connect DB - db = database.InitDB(c.Config) + db = database.InitDB(configuration.GolbalConfig) router = gin.Default() RegisterHealthzEndpoint(router.Group("/healthz")) // close db connection - err := db.Close() + err = db.Close() assert.NoError(t, err) // test healthz endpoint for unconnected DB and AMQP client @@ -42,7 +37,7 @@ func TestHealthz(t *testing.T) { assert.Equalf(t, 500, code, "Response body: \n%v\n", resp) // reconnect DB - db = database.InitDB(c.Config) + db = database.InitDB(configuration.GolbalConfig) defer db.Close() // test healthz endpoint for connected DB and unconnected AMQP client @@ -51,7 +46,8 @@ func TestHealthz(t *testing.T) { assert.Equalf(t, 500, code, "Response body: \n%v\n", resp) // connect AMQP client (make sure that AMQP_URL is set via command line parameter -amqp) - url, _ := c.Config.String("amqp.url") + url, err := configuration.GolbalConfig.String("amqp.url") + assert.NoError(t, err) err = amqp.ConnectAMQP(url) assert.NoError(t, err) diff --git a/routes/scenario/scenario_test.go b/routes/scenario/scenario_test.go index 0df8b6e..47a49bb 100644 --- a/routes/scenario/scenario_test.go +++ b/routes/scenario/scenario_test.go @@ -2,17 +2,16 @@ package scenario import ( "fmt" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/user" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "github.com/jinzhu/gorm/dialects/postgres" "github.com/stretchr/testify/assert" "os" "testing" - - "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/user" ) var router *gin.Engine @@ -33,8 +32,12 @@ type UserRequest struct { } func TestMain(m *testing.M) { - c := config.InitConfig() - db = database.InitDB(c) + err := configuration.InitConfig() + if err != nil { + panic(m) + } + + db = database.InitDB(configuration.GolbalConfig) defer db.Close() router = gin.Default() diff --git a/routes/signal/signal_test.go b/routes/signal/signal_test.go index 7abeefe..9e54216 100644 --- a/routes/signal/signal_test.go +++ b/routes/signal/signal_test.go @@ -2,7 +2,7 @@ package signal import ( "fmt" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" @@ -106,8 +106,11 @@ func addScenarioAndSimulatorAndSimulationModel() (scenarioID uint, simulatorID u } func TestMain(m *testing.M) { - c := config.InitConfig() - db = database.InitDB(c) + err := configuration.InitConfig() + if err != nil { + panic(m) + } + db = database.InitDB(configuration.GolbalConfig) defer db.Close() router = gin.Default() diff --git a/routes/simulationmodel/simulationmodel_test.go b/routes/simulationmodel/simulationmodel_test.go index a27a324..b8cead2 100644 --- a/routes/simulationmodel/simulationmodel_test.go +++ b/routes/simulationmodel/simulationmodel_test.go @@ -2,7 +2,7 @@ package simulationmodel import ( "fmt" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" @@ -95,8 +95,11 @@ func addScenarioAndSimulator() (scenarioID uint, simulatorID uint) { } func TestMain(m *testing.M) { - c := config.InitConfig() - db = database.InitDB(c) + err := configuration.InitConfig() + if err != nil { + panic(m) + } + db = database.InitDB(configuration.GolbalConfig) defer db.Close() router = gin.Default() diff --git a/routes/simulator/simulator_test.go b/routes/simulator/simulator_test.go index 893bac9..100ce6e 100644 --- a/routes/simulator/simulator_test.go +++ b/routes/simulator/simulator_test.go @@ -11,8 +11,8 @@ import ( "github.com/gin-gonic/gin" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/user" ) @@ -28,8 +28,11 @@ type SimulatorRequest struct { } func TestMain(m *testing.M) { - c := config.InitConfig() - db = database.InitDB(c) + err := configuration.InitConfig() + if err != nil { + panic(m) + } + db = database.InitDB(configuration.GolbalConfig) defer db.Close() router = gin.Default() diff --git a/routes/user/user_test.go b/routes/user/user_test.go index ae81318..57a7743 100644 --- a/routes/user/user_test.go +++ b/routes/user/user_test.go @@ -14,8 +14,8 @@ import ( "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" ) var router *gin.Engine @@ -31,8 +31,11 @@ type UserRequest struct { } func TestMain(m *testing.M) { - c := config.InitConfig() - db = database.InitDB(c) + err := configuration.InitConfig() + if err != nil { + panic(m) + } + db = database.InitDB(configuration.GolbalConfig) defer db.Close() router = gin.Default() diff --git a/routes/widget/widget_test.go b/routes/widget/widget_test.go index 08c2d6a..d70dc11 100644 --- a/routes/widget/widget_test.go +++ b/routes/widget/widget_test.go @@ -2,7 +2,7 @@ package widget import ( "fmt" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/dashboard" @@ -80,8 +80,11 @@ func addScenarioAndDashboard(token string) (scenarioID uint, dashboardID uint) { } func TestMain(m *testing.M) { - c := config.InitConfig() - db = database.InitDB(c) + err := configuration.InitConfig() + if err != nil { + panic(m) + } + db = database.InitDB(configuration.GolbalConfig) defer db.Close() router = gin.Default() diff --git a/start.go b/start.go index deb7c3a..46fe506 100644 --- a/start.go +++ b/start.go @@ -11,18 +11,18 @@ import ( ginSwagger "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" - c "git.rwth-aachen.de/acs/public/villas/web-backend-go/config" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" docs "git.rwth-aachen.de/acs/public/villas/web-backend-go/doc/api" // doc/api folder is used by Swag CLI, you have to import it "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/dashboard" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/file" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/metrics" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/signal" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/simulationmodel" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/simulator" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/user" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/widget" - "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/metrics" ) // @title VILLASweb Backend API @@ -38,16 +38,35 @@ import ( func main() { log.Println("Starting VILLASweb-backend-go") - c := c.InitConfig() - db := database.InitDB(c) + err := configuration.InitConfig() + if err != nil { + log.Printf("Error during initialization of global configuration: %v, aborting.", err.Error()) + return + } + db := database.InitDB(configuration.GolbalConfig) defer db.Close() - if m, _ := c.String("mode"); m == "release" { + m, err := configuration.GolbalConfig.String("mode") + if err != nil { + log.Printf("Error reading mode from global configuration: %v, aborting.", err.Error()) + return + } + + if m == "release" { gin.SetMode(gin.ReleaseMode) } - baseHost, _ := c.String("base.host") - basePath, _ := c.String("base.path") + baseHost, err := configuration.GolbalConfig.String("base.host") + if err != nil { + log.Printf("Error reading base.host from global configuration: %v, aborting.", err.Error()) + return + } + basePath, err := configuration.GolbalConfig.String("base.path") + if err != nil { + log.Printf("Error reading base.path from global configuration: %v, aborting.", err.Error()) + return + } + docs.SwaggerInfo.Host = baseHost docs.SwaggerInfo.BasePath = basePath @@ -76,7 +95,7 @@ func main() { r.GET("swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) - amqpurl, _ := c.String("amqp.url") + amqpurl, _ := configuration.GolbalConfig.String("amqp.url") if amqpurl != "" { log.Println("Starting AMQP client") From a868dccc109ef0b4b9fc76e5ad5e07a85e2bb3e3 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Thu, 14 Nov 2019 10:41:09 +0100 Subject: [PATCH 11/14] Revolve name overlapping with docs package --- start.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/start.go b/start.go index 46fe506..273ac06 100644 --- a/start.go +++ b/start.go @@ -13,7 +13,7 @@ import ( "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" - docs "git.rwth-aachen.de/acs/public/villas/web-backend-go/doc/api" // doc/api folder is used by Swag CLI, you have to import it + apidocs "git.rwth-aachen.de/acs/public/villas/web-backend-go/doc/api" // doc/api folder is used by Swag CLI, you have to import it "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/dashboard" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/file" "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/metrics" @@ -67,8 +67,8 @@ func main() { return } - docs.SwaggerInfo.Host = baseHost - docs.SwaggerInfo.BasePath = basePath + apidocs.SwaggerInfo.Host = baseHost + apidocs.SwaggerInfo.BasePath = basePath metrics.InitCounters(db) From cb14ac5f9195b268d884ef3be1b6b271de7739b8 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Thu, 14 Nov 2019 10:54:15 +0100 Subject: [PATCH 12/14] fix testing of healthz endpoint --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b6c2331..ff7bf7c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -83,6 +83,7 @@ test:gotest: DB_HOST: ${POSTGRES_HOST} DB_USER: ${POSTGRES_USER} DB_PASS: ${POSTGRES_PASSWORD} + AMQP_URL: ${AMQP_URL} MODE: test tags: - docker @@ -160,6 +161,7 @@ test:healthz: extends: test:database variables: TEST_FOLDER: routes/healthz + AMQP_URL: ${AMQP_URL} # Stage: deploy ############################################################################## From e90e69a32627a4cb6d66ed299e5e45d3c6dd5363 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Thu, 14 Nov 2019 11:00:27 +0100 Subject: [PATCH 13/14] CI: fix naming of variable for amqp url (overlapping names) --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ff7bf7c..e290092 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ variables: POSTGRES_HOST: postgres RABBITMQ_DEFAULT_USER: villas RABBITMQ_DEFAULT_PASS: villas - AMQP_URL: 'amqp://villas:villas@rabbitmq:5672' + AMQPURL: 'amqp://villas:villas@rabbitmq:5672' stages: - prepare @@ -83,7 +83,7 @@ test:gotest: DB_HOST: ${POSTGRES_HOST} DB_USER: ${POSTGRES_USER} DB_PASS: ${POSTGRES_PASSWORD} - AMQP_URL: ${AMQP_URL} + AMQP_URL: ${AMQPURL} MODE: test tags: - docker @@ -161,7 +161,7 @@ test:healthz: extends: test:database variables: TEST_FOLDER: routes/healthz - AMQP_URL: ${AMQP_URL} + AMQP_URL: ${AMQPURL} # Stage: deploy ############################################################################## From 6d4c84ec4ec63c55ac9e7841c78a123c2ca4f080 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Thu, 14 Nov 2019 11:44:26 +0100 Subject: [PATCH 14/14] - InitDB returns error - Check more errors in InitDB - fix for healthz endpoint (error checking was wrong) - remove dbinit parameter from config due to redundancy with mode parameter --- configuration/config.go | 10 ----- database/database.go | 38 +++++++++++++++---- database/database_test.go | 6 ++- routes/dashboard/dashboard_test.go | 5 ++- routes/file/file_test.go | 5 ++- routes/healthz/healthz_endpoint.go | 10 ++++- routes/healthz/healthz_test.go | 7 +++- routes/scenario/scenario_test.go | 5 ++- routes/signal/signal_test.go | 6 ++- .../simulationmodel/simulationmodel_test.go | 6 ++- routes/simulator/simulator_test.go | 6 ++- routes/user/user_test.go | 6 ++- routes/widget/widget_test.go | 6 ++- start.go | 6 ++- 14 files changed, 91 insertions(+), 31 deletions(-) diff --git a/configuration/config.go b/configuration/config.go index 9a5d271..34029ab 100644 --- a/configuration/config.go +++ b/configuration/config.go @@ -21,7 +21,6 @@ func InitConfig() error { dbName = flag.String("dbname", "villasdb", "Name of the database to use (default is villasdb)") dbUser = flag.String("dbuser", "", "Username of database connection (default is )") dbPass = flag.String("dbpass", "", "Password of database connection (default is )") - dbInit = flag.Bool("dbinit", false, "Initialize database with test data (default is off)") dbSSLMode = flag.String("dbsslmode", "disable", "SSL mode of DB (default is disable)") // TODO: change default for production amqpURL = flag.String("amqp", "", "If set, use this url to connect to an AMQP broker (default is disabled)") configFile = flag.String("configFile", "", "Path to YAML configuration file") @@ -31,19 +30,11 @@ func InitConfig() error { ) flag.Parse() - var dbInitStr string - if *dbInit { - dbInitStr = "true" - } else { - dbInitStr = "false" - } - static := map[string]string{ "db.host": *dbHost, "db.name": *dbName, "db.user": *dbUser, "db.pass": *dbPass, - "db.init": dbInitStr, "db.ssl": *dbSSLMode, "amqp.url": *amqpURL, "mode": *mode, @@ -57,7 +48,6 @@ func InitConfig() error { "DB_USER": "db.user", "DB_PASS": "db.pass", "DB_SSLMODE": "db.ssl", - "DB_INIT": "db.init", "AMQP_URL": "amqp.url", "BASE_HOST": "base.host", "BASE_PATH": "base.path", diff --git a/database/database.go b/database/database.go index 21d5d63..21f83e9 100644 --- a/database/database.go +++ b/database/database.go @@ -3,6 +3,7 @@ package database import ( "fmt" "log" + "strings" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" @@ -12,14 +13,34 @@ import ( var DBpool *gorm.DB // database used by backend // Initialize connection to the database -func InitDB(cfg *config.Config) *gorm.DB { +func InitDB(cfg *config.Config) (*gorm.DB, error) { name, err := cfg.String("db.name") + if err != nil { + return nil, err + } host, err := cfg.String("db.host") + if err != nil { + return nil, err + } user, err := cfg.String("db.user") - pass, err := cfg.String("db.pass") + if err != nil && !strings.Contains(err.Error(), "Required setting 'db.user' not set") { + return nil, err + } + pass := "" + if user != "" { + pass, err = cfg.String("db.pass") + if err != nil { + return nil, err + } + } sslmode, err := cfg.String("db.ssl") - init, err := cfg.Bool("db.init") + if err != nil { + return nil, err + } mode, err := cfg.String("mode") + if err != nil { + return nil, err + } dbinfo := fmt.Sprintf("host=%s sslmode=%s dbname=%s", host, sslmode, name) if user != "" && pass != "" { @@ -28,24 +49,27 @@ func InitDB(cfg *config.Config) *gorm.DB { db, err := gorm.Open("postgres", dbinfo) if err != nil { - log.Fatal(err) + return nil, err } DBpool = db MigrateModels(db) - if mode == "test" || init { + if mode == "test" { DropTables(db) log.Println("Database tables dropped") - DBAddTestData(db) + err = DBAddTestData(db) + if err != nil { + return nil, err + } log.Println("Database initialized with test data") } log.Println("Database connection established") - return db + return db, nil } // Connection pool to already opened DB diff --git a/database/database_test.go b/database/database_test.go index 2e94b77..8bdba39 100644 --- a/database/database_test.go +++ b/database/database_test.go @@ -17,7 +17,11 @@ func TestMain(m *testing.M) { if err != nil { panic(m) } - db = InitDB(configuration.GolbalConfig) + + db, err = InitDB(configuration.GolbalConfig) + if err != nil { + panic(m) + } // Verify that you can connect to the database err = db.DB().Ping() diff --git a/routes/dashboard/dashboard_test.go b/routes/dashboard/dashboard_test.go index 066c74c..159e26a 100644 --- a/routes/dashboard/dashboard_test.go +++ b/routes/dashboard/dashboard_test.go @@ -59,7 +59,10 @@ func TestMain(m *testing.M) { if err != nil { panic(m) } - db = database.InitDB(configuration.GolbalConfig) + db, err = database.InitDB(configuration.GolbalConfig) + if err != nil { + panic(m) + } defer db.Close() router = gin.Default() diff --git a/routes/file/file_test.go b/routes/file/file_test.go index 1241a38..659752f 100644 --- a/routes/file/file_test.go +++ b/routes/file/file_test.go @@ -164,7 +164,10 @@ func TestMain(m *testing.M) { if err != nil { panic(m) } - db = database.InitDB(configuration.GolbalConfig) + db, err = database.InitDB(configuration.GolbalConfig) + if err != nil { + panic(m) + } defer db.Close() router = gin.Default() diff --git a/routes/healthz/healthz_endpoint.go b/routes/healthz/healthz_endpoint.go index aeedf87..f8d622c 100644 --- a/routes/healthz/healthz_endpoint.go +++ b/routes/healthz/healthz_endpoint.go @@ -4,9 +4,11 @@ import ( "git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp" "git.rwth-aachen.de/acs/public/villas/web-backend-go/configuration" "git.rwth-aachen.de/acs/public/villas/web-backend-go/database" + "git.rwth-aachen.de/acs/public/villas/web-backend-go/helper" "github.com/gin-gonic/gin" "log" "net/http" + "strings" ) func RegisterHealthzEndpoint(r *gin.RouterGroup) { @@ -28,17 +30,21 @@ func getHealth(c *gin.Context) { // check if DB connection is active db := database.GetDB() err := db.DB().Ping() - if err != nil { + if helper.DBError(c, err) { return } // check if connection to AMQP broker is alive if backend was started with AMQP client url, err := configuration.GolbalConfig.String("amqp.url") - if err != nil { + if err != nil && strings.Contains(err.Error(), "Required setting 'amqp.url' not set") { + c.JSON(http.StatusOK, gin.H{}) + return + } else if err != nil { c.JSON(http.StatusInternalServerError, gin.H{ "success:": false, "message": err.Error(), }) + return } if len(url) != 0 { diff --git a/routes/healthz/healthz_test.go b/routes/healthz/healthz_test.go index 756efef..f8984e7 100644 --- a/routes/healthz/healthz_test.go +++ b/routes/healthz/healthz_test.go @@ -21,7 +21,9 @@ func TestHealthz(t *testing.T) { assert.NoError(t, err) // connect DB - db = database.InitDB(configuration.GolbalConfig) + db, err = database.InitDB(configuration.GolbalConfig) + assert.NoError(t, err) + defer db.Close() router = gin.Default() @@ -37,7 +39,8 @@ func TestHealthz(t *testing.T) { assert.Equalf(t, 500, code, "Response body: \n%v\n", resp) // reconnect DB - db = database.InitDB(configuration.GolbalConfig) + db, err = database.InitDB(configuration.GolbalConfig) + assert.NoError(t, err) defer db.Close() // test healthz endpoint for connected DB and unconnected AMQP client diff --git a/routes/scenario/scenario_test.go b/routes/scenario/scenario_test.go index 47a49bb..ccf7244 100644 --- a/routes/scenario/scenario_test.go +++ b/routes/scenario/scenario_test.go @@ -37,7 +37,10 @@ func TestMain(m *testing.M) { panic(m) } - db = database.InitDB(configuration.GolbalConfig) + db, err = database.InitDB(configuration.GolbalConfig) + if err != nil { + panic(m) + } defer db.Close() router = gin.Default() diff --git a/routes/signal/signal_test.go b/routes/signal/signal_test.go index 9e54216..2c213e0 100644 --- a/routes/signal/signal_test.go +++ b/routes/signal/signal_test.go @@ -110,7 +110,11 @@ func TestMain(m *testing.M) { if err != nil { panic(m) } - db = database.InitDB(configuration.GolbalConfig) + + db, err = database.InitDB(configuration.GolbalConfig) + if err != nil { + panic(m) + } defer db.Close() router = gin.Default() diff --git a/routes/simulationmodel/simulationmodel_test.go b/routes/simulationmodel/simulationmodel_test.go index b8cead2..633a93a 100644 --- a/routes/simulationmodel/simulationmodel_test.go +++ b/routes/simulationmodel/simulationmodel_test.go @@ -99,7 +99,11 @@ func TestMain(m *testing.M) { if err != nil { panic(m) } - db = database.InitDB(configuration.GolbalConfig) + + db, err = database.InitDB(configuration.GolbalConfig) + if err != nil { + panic(m) + } defer db.Close() router = gin.Default() diff --git a/routes/simulator/simulator_test.go b/routes/simulator/simulator_test.go index 100ce6e..3a70111 100644 --- a/routes/simulator/simulator_test.go +++ b/routes/simulator/simulator_test.go @@ -32,7 +32,11 @@ func TestMain(m *testing.M) { if err != nil { panic(m) } - db = database.InitDB(configuration.GolbalConfig) + + db, err = database.InitDB(configuration.GolbalConfig) + if err != nil { + panic(m) + } defer db.Close() router = gin.Default() diff --git a/routes/user/user_test.go b/routes/user/user_test.go index 57a7743..2c37958 100644 --- a/routes/user/user_test.go +++ b/routes/user/user_test.go @@ -35,7 +35,11 @@ func TestMain(m *testing.M) { if err != nil { panic(m) } - db = database.InitDB(configuration.GolbalConfig) + + db, err = database.InitDB(configuration.GolbalConfig) + if err != nil { + panic(m) + } defer db.Close() router = gin.Default() diff --git a/routes/widget/widget_test.go b/routes/widget/widget_test.go index d70dc11..bfea61b 100644 --- a/routes/widget/widget_test.go +++ b/routes/widget/widget_test.go @@ -84,7 +84,11 @@ func TestMain(m *testing.M) { if err != nil { panic(m) } - db = database.InitDB(configuration.GolbalConfig) + + db, err = database.InitDB(configuration.GolbalConfig) + if err != nil { + panic(m) + } defer db.Close() router = gin.Default() diff --git a/start.go b/start.go index 273ac06..6bd8eb2 100644 --- a/start.go +++ b/start.go @@ -43,7 +43,11 @@ func main() { log.Printf("Error during initialization of global configuration: %v, aborting.", err.Error()) return } - db := database.InitDB(configuration.GolbalConfig) + db, err := database.InitDB(configuration.GolbalConfig) + if err != nil { + log.Printf("Error during initialization of database: %v, aborting.", err.Error()) + return + } defer db.Close() m, err := configuration.GolbalConfig.String("mode")