mirror of https://github.com/statping/statping
refactor
parent
25913d6458
commit
0d82b59586
2
Makefile
2
Makefile
|
@ -130,7 +130,7 @@ print_details:
|
|||
build-all: xgo-install build-mac build-linux build-linux build-alpine
|
||||
|
||||
download-key:
|
||||
wget -O statping.gpg https://s3-us-west-2.amazonaws.com/assets.statping.com/UIDHJI2I292HDH20FJOIJOUIF29UHF827HHF9H2FHH27FGHRIEHFISUHFISHF.gpg
|
||||
wget -O statping.gpg $(KEY_URL)
|
||||
gpg --import statping.gpg
|
||||
|
||||
# build Statping for Mac, 64 and 32 bit
|
||||
|
|
|
@ -222,7 +222,7 @@ func runOnce() error {
|
|||
return errors.Wrap(err, "could not select all services")
|
||||
}
|
||||
for _, srv := range services.Services() {
|
||||
services.CheckService(srv, true)
|
||||
srv.CheckService(true)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"github.com/rendon/testcli"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -32,7 +31,7 @@ var (
|
|||
|
||||
func init() {
|
||||
dir = utils.Directory
|
||||
core.SampleHits = 480
|
||||
//core.SampleHits = 480
|
||||
}
|
||||
|
||||
func TestStartServerCommand(t *testing.T) {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
package main
|
|
@ -113,11 +113,11 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
if err = c.Connect(); err != nil {
|
||||
if err = configs.ConnectConfigs(c); err != nil {
|
||||
exit(err)
|
||||
}
|
||||
|
||||
if err := configs.MigrateDatabase(); err != nil {
|
||||
if err := c.MigrateDatabase(); err != nil {
|
||||
exit(err)
|
||||
}
|
||||
|
||||
|
@ -182,6 +182,7 @@ func httpServerProcess(process <-chan bool) {
|
|||
default:
|
||||
if err := handlers.RunHTTPServer(ipAddress, port); err != nil {
|
||||
log.Errorln(err)
|
||||
exit(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
package main
|
||||
|
||||
// AttachNotifiers will attach all the notifier's into the system
|
33
go.mod
33
go.mod
|
@ -1,10 +1,12 @@
|
|||
module github.com/hunterlong/statping
|
||||
|
||||
go 1.13
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1 // indirect
|
||||
github.com/GeertJohan/go.rice v1.0.0
|
||||
github.com/Microsoft/go-winio v0.4.14 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
|
||||
github.com/ararog/timeago v0.0.0-20160328174124-e9969cf18b8d
|
||||
github.com/daaku/go.zipexe v1.0.1 // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
|
@ -14,27 +16,28 @@ require (
|
|||
github.com/docker/go-units v0.4.0 // indirect
|
||||
github.com/fatih/structs v1.1.0
|
||||
github.com/go-mail/mail v2.3.1+incompatible
|
||||
github.com/go-yaml/yaml v2.1.0+incompatible
|
||||
github.com/gorilla/mux v1.7.3
|
||||
github.com/jinzhu/gorm v1.9.11
|
||||
github.com/go-sql-driver/mysql v1.5.0 // indirect
|
||||
github.com/google/martian v2.1.0+incompatible
|
||||
github.com/gorilla/mux v1.7.4
|
||||
github.com/jinzhu/gorm v1.9.12
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/lib/pq v1.2.0 // indirect
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
||||
github.com/lib/pq v1.3.0 // indirect
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/prometheus/common v0.2.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/common v0.9.1
|
||||
github.com/rendon/testcli v0.0.0-20161027181003-6283090d169f
|
||||
github.com/russross/blackfriday/v2 v2.0.1
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
github.com/sirupsen/logrus v1.4.1
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/stretchr/testify v1.5.1
|
||||
github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e
|
||||
golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba
|
||||
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 // indirect
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 // indirect
|
||||
google.golang.org/appengine v1.6.5 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/mail.v2 v2.3.1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
gopkg.in/yaml.v2 v2.2.7 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.8
|
||||
)
|
||||
|
|
185
go.sum
185
go.sum
|
@ -1,36 +1,32 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
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/GeertJohan/go.incremental v1.0.0 h1:7AH+pY1XUgQE4Y1HcXYaMqAI0m9yrFqo/jt0CW30vsg=
|
||||
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
|
||||
github.com/GeertJohan/go.rice v1.0.0 h1:KkI6O9uMaQU3VEKaj01ulavtF7o1fWT7+pk/4voiMLQ=
|
||||
github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0=
|
||||
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
|
||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
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/akavel/rsrc v0.8.0 h1:zjWn7ukO9Kc5Q62DOJCcxGpXC18RawVtYAGdz2aLlfw=
|
||||
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
||||
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/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
|
||||
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/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
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/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/ararog/timeago v0.0.0-20160328174124-e9969cf18b8d h1:ZX0t+GA3MWiP7LWt5xWOphWRQd5JwL4VW5uLW83KM8g=
|
||||
github.com/ararog/timeago v0.0.0-20160328174124-e9969cf18b8d/go.mod h1:EcJ034SpbWy4heOSDiBZJRn3b5wKJM1b4sFfYeVAkI4=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/daaku/go.zipexe v1.0.0 h1:VSOgZtH418pH9L16hC/JrgSNJbbAL26pj7lmD1+CGdY=
|
||||
github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E=
|
||||
github.com/daaku/go.zipexe v1.0.1 h1:wV4zMsDOI2SZ2m7Tdz1Ps96Zrx+TzaK15VbUaGozw0M=
|
||||
github.com/daaku/go.zipexe v1.0.1/go.mod h1:5xWogtqlYnfBXkSB1o9xysukNP9GTvaNkqzUZbt3Bw8=
|
||||
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=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3 h1:tkum0XDgfR0jcVVXuTsYv/erY2NnEDqwRojbxR1rBYA=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
|
||||
|
@ -41,190 +37,139 @@ github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKoh
|
|||
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
|
||||
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
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-mail/mail v2.3.1+incompatible h1:UzNOn0k5lpfVtO31cK3hn6I4VEVGhe3lX8AJBAxXExM=
|
||||
github.com/go-mail/mail v2.3.1+incompatible/go.mod h1:VPWjmmNyRsWXQZHVHT3g0YbIINUkSmuKOiLIDkWbL6M=
|
||||
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-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o=
|
||||
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
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-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/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/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
|
||||
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/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/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
|
||||
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/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
|
||||
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
|
||||
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
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/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q=
|
||||
github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs=
|
||||
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/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
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 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
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/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
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/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
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/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
||||
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
|
||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible/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-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
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=
|
||||
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229 h1:E2B8qYyeSgv5MXpmzZXRNp8IAQ4vjxIjhpAf5hv/tAg=
|
||||
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
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/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.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/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
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/common v0.2.0 h1:kUZDBDTdBVBYBj5Tmh2NZLlF60mfjA27rM34b+cVwNU=
|
||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U=
|
||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||
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/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/rendon/testcli v0.0.0-20161027181003-6283090d169f h1:onGP+qmYmjKs7pkmi9j0mwyr97/D5wki80e74aKIOxg=
|
||||
github.com/rendon/testcli v0.0.0-20161027181003-6283090d169f/go.mod h1:cq57a4l475CeMvE7RRpSui1MEqCmhirIt1E7kl8BC2Q=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
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/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e h1:nt2877sKfojlHCTOBXbpWjBkuWKritFaGIfgQwbQUls=
|
||||
github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e/go.mod h1:B4+Kq1u5FlULTjFSM707Q6e/cOHFv0z/6QRoxubDIQ8=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
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-20191119213627-4f8c1d86b1ba h1:9bFeDpN3gTqNanMVqNcoR/pJQuP5uroC3t1D7eXozTE=
|
||||
golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba/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=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
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-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 h1:p9xBe/w/OzkeYVKm234g55gMdD1nSIooTir5kV11kfA=
|
||||
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582/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=
|
||||
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-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/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 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b h1:ag/x1USPSsqHud38I9BAC88qdNLDHHtQ4mlgQIZPPNA=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/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/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/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/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
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=
|
||||
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=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
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/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
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/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/mail.v2 v2.3.1 h1:WYFn/oANrAGP2C0dcV6/pbkPzv8yGzqTjPmTeO7qoXk=
|
||||
gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
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/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -3,10 +3,9 @@ package handlers
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/hunterlong/statping/core"
|
||||
_ "github.com/hunterlong/statping/notifiers"
|
||||
"github.com/hunterlong/statping/source"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/hunterlong/statping/types/core"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -68,7 +67,7 @@ func TestSetupRoutes(t *testing.T) {
|
|||
Method: "GET",
|
||||
ExpectedStatus: 200,
|
||||
FuncTest: func() error {
|
||||
if core.CoreApp.Setup {
|
||||
if core.App.Setup {
|
||||
return errors.New("core has already been setup")
|
||||
}
|
||||
return nil
|
||||
|
@ -81,9 +80,9 @@ func TestSetupRoutes(t *testing.T) {
|
|||
Body: form.Encode(),
|
||||
ExpectedStatus: 200,
|
||||
HttpHeaders: []string{"Content-Type=application/x-www-form-urlencoded"},
|
||||
ExpectedFiles: []string{dir + "/config.yml", dir + "/handlers/" + types.SqliteFilename},
|
||||
ExpectedFiles: []string{dir + "/config.yml", dir + "/handlers/" + "statping.db"},
|
||||
FuncTest: func() error {
|
||||
if !core.CoreApp.Setup {
|
||||
if !core.App.Setup {
|
||||
return errors.New("core has not been setup")
|
||||
}
|
||||
return nil
|
||||
|
@ -110,7 +109,7 @@ func TestMainApiRoutes(t *testing.T) {
|
|||
ExpectedStatus: 200,
|
||||
ExpectedContains: []string{`"description":"This is an awesome test"`},
|
||||
FuncTest: func() error {
|
||||
if !core.CoreApp.Setup {
|
||||
if !core.App.Setup {
|
||||
return errors.New("database is not setup")
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -66,7 +66,7 @@ func apiServiceHandler(r *http.Request) interface{} {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return service
|
||||
return *service
|
||||
}
|
||||
|
||||
func apiCreateServiceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -100,7 +100,7 @@ func apiServiceUpdateHandler(w http.ResponseWriter, r *http.Request) {
|
|||
sendErrorJson(err, w, r)
|
||||
return
|
||||
}
|
||||
go services.CheckService(service, true)
|
||||
go service.CheckService(true)
|
||||
sendJsonAction(service, "update", w, r)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core"
|
||||
"github.com/hunterlong/statping/types/services"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
|
@ -17,7 +17,7 @@ func TestApiServiceRoutes(t *testing.T) {
|
|||
ExpectedStatus: 200,
|
||||
ResponseLen: 5,
|
||||
FuncTest: func() error {
|
||||
count := len(core.Services())
|
||||
count := len(services.Services())
|
||||
if count != 5 {
|
||||
return errors.Errorf("incorrect services count: %d", count)
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func TestApiServiceRoutes(t *testing.T) {
|
|||
ExpectedStatus: 200,
|
||||
ExpectedContains: []string{`"status":"success","type":"service","method":"create"`},
|
||||
FuncTest: func() error {
|
||||
count := len(core.Services())
|
||||
count := len(services.Services())
|
||||
if count != 6 {
|
||||
return errors.Errorf("incorrect services count: %d", count)
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ func TestApiServiceRoutes(t *testing.T) {
|
|||
ExpectedStatus: 200,
|
||||
ExpectedContains: []string{`"status":"success"`, `"method":"delete"`},
|
||||
FuncTest: func() error {
|
||||
count := len(core.Services())
|
||||
count := len(services.Services())
|
||||
if count != 5 {
|
||||
return errors.Errorf("incorrect services count: %d", count)
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ func processSetupHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
if err = configs.MigrateDatabase(); err != nil {
|
||||
if err = confg.MigrateDatabase(); err != nil {
|
||||
sendErrorJson(err, w, r)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -24,9 +24,18 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
func apiUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func getUser(r *http.Request) (*users.User, int64, error) {
|
||||
vars := mux.Vars(r)
|
||||
user, err := users.Find(utils.ToInt(vars["id"]))
|
||||
num := utils.ToInt(vars["id"])
|
||||
user, err := users.Find(num)
|
||||
if err != nil {
|
||||
return nil, num, err
|
||||
}
|
||||
return user, num, nil
|
||||
}
|
||||
|
||||
func apiUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
user, _, err := getUser(r)
|
||||
if err != nil {
|
||||
sendErrorJson(err, w, r)
|
||||
return
|
||||
|
@ -36,16 +45,15 @@ func apiUserHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func apiUserUpdateHandler(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
user, err := users.Find(utils.ToInt(vars["id"]))
|
||||
user, id, err := getUser(r)
|
||||
if err != nil {
|
||||
sendErrorJson(fmt.Errorf("user #%v was not found", vars["id"]), w, r)
|
||||
sendErrorJson(fmt.Errorf("user #%d was not found", id), w, r)
|
||||
return
|
||||
}
|
||||
|
||||
err = DecodeJSON(r, &user)
|
||||
if err != nil {
|
||||
sendErrorJson(fmt.Errorf("user #%v was not found", vars["id"]), w, r)
|
||||
sendErrorJson(fmt.Errorf("user #%d was not found", id), w, r)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -55,20 +63,19 @@ func apiUserUpdateHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
err = user.Update()
|
||||
if err != nil {
|
||||
sendErrorJson(fmt.Errorf("issue updating user #%v: %v", user.Id, err), w, r)
|
||||
sendErrorJson(fmt.Errorf("issue updating user #%d: %s", user.Id, err), w, r)
|
||||
return
|
||||
}
|
||||
sendJsonAction(user, "update", w, r)
|
||||
}
|
||||
|
||||
func apiUserDeleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
allUsers := users.All()
|
||||
if len(allUsers) == 1 {
|
||||
sendErrorJson(errors.New("cannot delete the last user"), w, r)
|
||||
return
|
||||
}
|
||||
user, err := users.Find(utils.ToInt(vars["id"]))
|
||||
user, _, err := getUser(r)
|
||||
if err != nil {
|
||||
sendErrorJson(err, w, r)
|
||||
return
|
||||
|
@ -88,7 +95,6 @@ func apiAllUsersHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func apiCreateUsersHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var user *users.User
|
||||
|
||||
err := DecodeJSON(r, &user)
|
||||
if err != nil {
|
||||
sendErrorJson(err, w, r)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package notifiers
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/types/notifications"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -39,7 +39,7 @@ func TestCommandNotifier(t *testing.T) {
|
|||
Command.Var2 = commandTest
|
||||
Command.Delay = time.Duration(100 * time.Millisecond)
|
||||
Command.Limits = 99
|
||||
err := notifier.AddNotifiers(Command)
|
||||
err := AddNotifiers(Command)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Hunter Long", Command.Author)
|
||||
assert.Equal(t, "sh", Command.Host)
|
||||
|
@ -70,7 +70,7 @@ func TestCommandNotifier(t *testing.T) {
|
|||
t.Run("Command OnSuccess Again", func(t *testing.T) {
|
||||
Command.OnSuccess(TestService)
|
||||
assert.Equal(t, 1, len(Command.Queue))
|
||||
go notifier.Queue(Command)
|
||||
go notifications.Queue(Command)
|
||||
time.Sleep(20 * time.Second)
|
||||
assert.Equal(t, 0, len(Command.Queue))
|
||||
})
|
||||
|
@ -91,7 +91,7 @@ func TestCommandNotifier(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("Command Queue", func(t *testing.T) {
|
||||
go notifier.Queue(Command)
|
||||
go notifications.Queue(Command)
|
||||
time.Sleep(5 * time.Second)
|
||||
assert.Equal(t, "sh", Command.Host)
|
||||
assert.Equal(t, commandTest, Command.Var1)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package notifiers
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -44,7 +43,7 @@ func TestDiscordNotifier(t *testing.T) {
|
|||
t.Run("Load discord", func(t *testing.T) {
|
||||
Discorder.Host = DISCORD_URL
|
||||
Discorder.Delay = time.Duration(100 * time.Millisecond)
|
||||
err := notifier.AddNotifiers(Discorder)
|
||||
err := AddNotifiers(Discorder)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Hunter Long", Discorder.Author)
|
||||
assert.Equal(t, DISCORD_URL, Discorder.Host)
|
||||
|
|
|
@ -17,7 +17,7 @@ package notifiers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/types/notifications"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
|
@ -79,7 +79,7 @@ func TestEmailNotifier(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("Add email Notifier", func(t *testing.T) {
|
||||
err := notifier.AddNotifiers(Emailer)
|
||||
err := AddNotifiers(Emailer)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Hunter Long", Emailer.Author)
|
||||
assert.Equal(t, EMAIL_HOST, Emailer.Host)
|
||||
|
@ -127,7 +127,7 @@ func TestEmailNotifier(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("email Run Queue", func(t *testing.T) {
|
||||
go notifier.Queue(Emailer)
|
||||
go notifications.Queue(Emailer)
|
||||
time.Sleep(6 * time.Second)
|
||||
assert.Equal(t, EMAIL_HOST, Emailer.Host)
|
||||
assert.Equal(t, 0, len(Emailer.Queue))
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package notifiers
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/types/notifications"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -49,7 +49,7 @@ func TestMobileNotifier(t *testing.T) {
|
|||
Mobile.Var2 = MOBILE_NUMBER
|
||||
Mobile.Delay = time.Duration(100 * time.Millisecond)
|
||||
Mobile.Limits = 10
|
||||
err := notifier.AddNotifiers(Mobile)
|
||||
err := AddNotifiers(Mobile)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Hunter Long", Mobile.Author)
|
||||
assert.Equal(t, MOBILE_ID, Mobile.Var1)
|
||||
|
@ -81,7 +81,7 @@ func TestMobileNotifier(t *testing.T) {
|
|||
assert.True(t, TestService.Online)
|
||||
Mobile.OnSuccess(TestService)
|
||||
assert.Equal(t, 1, len(Mobile.Queue))
|
||||
go notifier.Queue(Mobile)
|
||||
go notifications.Queue(Mobile)
|
||||
time.Sleep(20 * time.Second)
|
||||
assert.Equal(t, 1, len(Mobile.Queue))
|
||||
})
|
||||
|
@ -100,7 +100,7 @@ func TestMobileNotifier(t *testing.T) {
|
|||
|
||||
t.Run("Mobile Queue", func(t *testing.T) {
|
||||
t.SkipNow()
|
||||
go notifier.Queue(Mobile)
|
||||
go notifications.Queue(Mobile)
|
||||
time.Sleep(15 * time.Second)
|
||||
assert.Equal(t, MOBILE_ID, Mobile.Var1)
|
||||
assert.Equal(t, 0, len(Mobile.Queue))
|
||||
|
|
|
@ -2,8 +2,10 @@ package notifiers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/google/martian/log"
|
||||
"github.com/hunterlong/statping/types/notifications"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"github.com/pkg/errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -34,12 +36,12 @@ func contains(s string, arr []string) bool {
|
|||
// AddNotifier accept a Notifier interface to be added into the array
|
||||
func AddNotifiers(notifiers ...notifications.Notifier) error {
|
||||
for _, n := range notifiers {
|
||||
log.Infof("Installing %s Notifier...", n.Select().Method)
|
||||
if err := checkNotifierForm(n); err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "error with notifier form fields")
|
||||
}
|
||||
notifications.AllCommunications = append(notifications.AllCommunications, n)
|
||||
if _, err := notifications.Init(n); err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "error initiating notifier")
|
||||
}
|
||||
}
|
||||
startAllNotifiers()
|
||||
|
|
|
@ -16,10 +16,14 @@
|
|||
package notifiers
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/source"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/hunterlong/statping/types/core"
|
||||
"github.com/hunterlong/statping/types/failures"
|
||||
"github.com/hunterlong/statping/types/notifications"
|
||||
"github.com/hunterlong/statping/types/null"
|
||||
"github.com/hunterlong/statping/types/services"
|
||||
"github.com/hunterlong/statping/types/users"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
|
@ -37,7 +41,7 @@ var TestService = &services.Service{
|
|||
Name: "Interpol - All The Rage Back Home",
|
||||
Domain: "https://www.youtube.com/watch?v=-u6DvRyyKGU",
|
||||
ExpectedStatus: 200,
|
||||
Expected: types.NewNullString("test example"),
|
||||
Expected: null.NewNullString("test example"),
|
||||
Interval: 30,
|
||||
Type: "http",
|
||||
Method: "GET",
|
||||
|
@ -48,23 +52,23 @@ var TestService = &services.Service{
|
|||
CreatedAt: utils.Now().Add(-24 * time.Hour),
|
||||
}
|
||||
|
||||
var TestFailure = &types.Failure{
|
||||
var TestFailure = &failures.Failure{
|
||||
Issue: "testing",
|
||||
Service: 1,
|
||||
CreatedAt: utils.Now().Add(-12 * time.Hour),
|
||||
}
|
||||
|
||||
var TestUser = &types.User{
|
||||
var TestUser = &users.User{
|
||||
Username: "admin",
|
||||
Email: "info@email.com",
|
||||
}
|
||||
|
||||
var TestCore = &types.Core{
|
||||
var TestCore = &core.Core{
|
||||
Name: "testing notifiers",
|
||||
}
|
||||
|
||||
func CountNotifiers() int {
|
||||
return len(notifier.AllCommunications)
|
||||
return len(notifications.AllCommunications)
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -80,6 +84,6 @@ func injectDatabase() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
db.CreateTable(¬ifier.Notification{})
|
||||
notifier.SetDB(&database.Db{db, "sqlite3"})
|
||||
db.CreateTable(¬ifications.Notification{})
|
||||
notifications.SetDB(&database.Db{db, "sqlite3"})
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
package notifiers
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/notifiers"
|
||||
"github.com/hunterlong/statping/types/notifications"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -47,7 +48,7 @@ func TestSlackNotifier(t *testing.T) {
|
|||
Slacker.Host = SLACK_URL
|
||||
Slacker.Delay = time.Duration(100 * time.Millisecond)
|
||||
Slacker.Limits = 3
|
||||
err := notifier.AddNotifiers(Slacker)
|
||||
err := AddNotifiers(Slacker)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Hunter Long", Slacker.Author)
|
||||
assert.Equal(t, SLACK_URL, Slacker.Host)
|
||||
|
@ -83,7 +84,7 @@ func TestSlackNotifier(t *testing.T) {
|
|||
assert.True(t, TestService.Online)
|
||||
Slacker.OnSuccess(TestService)
|
||||
assert.Equal(t, 1, len(Slacker.Queue))
|
||||
go notifier.Queue(Slacker)
|
||||
go notifications.Queue(Slacker)
|
||||
time.Sleep(15 * time.Second)
|
||||
assert.Equal(t, 0, len(Slacker.Queue))
|
||||
})
|
||||
|
@ -106,7 +107,7 @@ func TestSlackNotifier(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("slack Queue", func(t *testing.T) {
|
||||
go notifier.Queue(Slacker)
|
||||
go notifications.Queue(Slacker)
|
||||
time.Sleep(10 * time.Second)
|
||||
assert.Equal(t, SLACK_URL, Slacker.Host)
|
||||
assert.Equal(t, 0, len(Slacker.Queue))
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package notifiers
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/types/notifications"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -49,7 +49,7 @@ func TestTelegramNotifier(t *testing.T) {
|
|||
Telegram.ApiSecret = telegramToken
|
||||
Telegram.Var1 = telegramChannel
|
||||
Telegram.Delay = time.Duration(1 * time.Second)
|
||||
err := notifier.AddNotifiers(Telegram)
|
||||
err := AddNotifiers(Telegram)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Hunter Long", Telegram.Author)
|
||||
assert.Equal(t, telegramToken, Telegram.ApiSecret)
|
||||
|
@ -96,7 +96,7 @@ func TestTelegramNotifier(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("Telegram Queue", func(t *testing.T) {
|
||||
go notifier.Queue(Telegram)
|
||||
go notifications.Queue(Telegram)
|
||||
time.Sleep(3 * time.Second)
|
||||
assert.Equal(t, telegramToken, Telegram.ApiSecret)
|
||||
assert.Equal(t, 0, len(Telegram.Queue))
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package notifiers
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/types/notifications"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -54,7 +54,7 @@ func TestTwilioNotifier(t *testing.T) {
|
|||
t.Run("Load Twilio", func(t *testing.T) {
|
||||
Twilio.ApiKey = TWILIO_SID
|
||||
Twilio.Delay = time.Duration(100 * time.Millisecond)
|
||||
err := notifier.AddNotifiers(Twilio)
|
||||
err := AddNotifiers(Twilio)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Hunter Long", Twilio.Author)
|
||||
assert.Equal(t, TWILIO_SID, Twilio.ApiKey)
|
||||
|
@ -100,7 +100,7 @@ func TestTwilioNotifier(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("Twilio Queue", func(t *testing.T) {
|
||||
go notifier.Queue(Twilio)
|
||||
go notifications.Queue(Twilio)
|
||||
time.Sleep(1 * time.Second)
|
||||
assert.Equal(t, TWILIO_SID, Twilio.ApiKey)
|
||||
assert.Equal(t, 0, len(Twilio.Queue))
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
package notifiers
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/types/notifications"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -44,7 +44,7 @@ func TestWebhookNotifier(t *testing.T) {
|
|||
Webhook.Host = webhookTestUrl
|
||||
Webhook.Delay = time.Duration(100 * time.Millisecond)
|
||||
Webhook.ApiKey = apiKey
|
||||
err := notifier.AddNotifiers(Webhook)
|
||||
err := AddNotifiers(Webhook)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "Hunter Long", Webhook.Author)
|
||||
assert.Equal(t, webhookTestUrl, Webhook.Host)
|
||||
|
@ -92,7 +92,7 @@ func TestWebhookNotifier(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("webhooker Queue", func(t *testing.T) {
|
||||
go notifier.Queue(Webhook)
|
||||
go notifications.Queue(Webhook)
|
||||
time.Sleep(8 * time.Second)
|
||||
assert.Equal(t, webhookTestUrl, Webhook.Host)
|
||||
assert.Equal(t, len(Webhook.Queue), 0)
|
||||
|
|
|
@ -2,7 +2,7 @@ package checkins
|
|||
|
||||
func (c *Checkin) LastHit() *CheckinHit {
|
||||
var hit *CheckinHit
|
||||
DBhits().Where("checkin = ?", c.Id).Last(&hit)
|
||||
DBhits().Where("checkin = ?", c.Id).Limit(1).Find(&hit)
|
||||
return hit
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package checkins
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c *Checkin) Samples() []database.DbObject {
|
||||
func Samples() {
|
||||
checkin1 := &Checkin{
|
||||
Name: "Example Checkin 1",
|
||||
ServiceId: 1,
|
||||
|
@ -14,6 +13,7 @@ func (c *Checkin) Samples() []database.DbObject {
|
|||
GracePeriod: 300,
|
||||
ApiKey: utils.RandomString(7),
|
||||
}
|
||||
checkin1.Create()
|
||||
|
||||
checkin2 := &Checkin{
|
||||
Name: "Example Checkin 2",
|
||||
|
@ -22,15 +22,12 @@ func (c *Checkin) Samples() []database.DbObject {
|
|||
GracePeriod: 300,
|
||||
ApiKey: utils.RandomString(7),
|
||||
}
|
||||
|
||||
return []database.DbObject{checkin1, checkin2}
|
||||
checkin2.Create()
|
||||
}
|
||||
|
||||
func (c *CheckinHit) Samples() []database.DbObject {
|
||||
func SamplesChkHits() {
|
||||
checkTime := time.Now().UTC().Add(-24 * time.Hour)
|
||||
|
||||
var hits []database.DbObject
|
||||
|
||||
for i := int64(1); i <= 2; i++ {
|
||||
checkHit := &CheckinHit{
|
||||
Checkin: i,
|
||||
|
@ -38,10 +35,8 @@ func (c *CheckinHit) Samples() []database.DbObject {
|
|||
CreatedAt: checkTime.UTC(),
|
||||
}
|
||||
|
||||
hits = append(hits, checkHit)
|
||||
checkHit.Create()
|
||||
|
||||
checkTime = checkTime.Add(10 * time.Minute)
|
||||
}
|
||||
|
||||
return hits
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import (
|
|||
func loadConfigEnvs() (*DbConfig, error) {
|
||||
var err error
|
||||
|
||||
log.Infof("Loading configs from environment variables")
|
||||
|
||||
loadDotEnvs()
|
||||
|
||||
dbConn := utils.Getenv("DB_CONN", "").(string)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package configs
|
||||
|
||||
import (
|
||||
"github.com/go-yaml/yaml"
|
||||
"github.com/hunterlong/statping/types/core"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
func loadConfigFile(directory string) (*DbConfig, error) {
|
||||
var configs *DbConfig
|
||||
|
||||
log.Debugln("Attempting to read config file at: " + directory + "/config.yml")
|
||||
log.Infof("Attempting to read config file at: %s/config.yml ", directory)
|
||||
file, err := utils.OpenFile(directory + "/config.yml")
|
||||
if err != nil {
|
||||
core.App.Setup = false
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
// Connect will attempt to connect to the sqlite, postgres, or mysql database
|
||||
func Connect(configs *DbConfig, retry bool, location string) error {
|
||||
func Connect(configs *DbConfig, retry bool) error {
|
||||
postgresSSL := os.Getenv("POSTGRES_SSLMODE")
|
||||
if database.Available() {
|
||||
return nil
|
||||
|
@ -28,7 +28,7 @@ func Connect(configs *DbConfig, retry bool, location string) error {
|
|||
configs.DbConn = ":memory"
|
||||
} else {
|
||||
conn = findDbFile(configs)
|
||||
configs.SqlFile = fmt.Sprintf("%s/%s", utils.Directory, conn)
|
||||
configs.SqlFile = conn
|
||||
log.Infof("SQL database file at: %s", configs.SqlFile)
|
||||
configs.DbConn = "sqlite3"
|
||||
}
|
||||
|
@ -84,15 +84,20 @@ func (c *DbConfig) waitForDb(configs *DbConfig) error {
|
|||
}
|
||||
|
||||
func InitialSetup(configs *DbConfig) error {
|
||||
var err error
|
||||
log.Infoln(fmt.Sprintf("Core database does not exist, creating now!"))
|
||||
|
||||
if err := configs.DropDatabase(); err != nil {
|
||||
return errors.Wrap(err, "error dropping database")
|
||||
}
|
||||
|
||||
if err := CreateDatabase(); err != nil {
|
||||
return errors.Wrap(err, "error creating database")
|
||||
}
|
||||
|
||||
if err := TriggerSamples(); err != nil {
|
||||
return errors.Wrap(err, "error creating database")
|
||||
}
|
||||
|
||||
username := utils.Getenv("ADMIN_USER", "admin").(string)
|
||||
password := utils.Getenv("ADMIN_PASSWORD", "admin").(string)
|
||||
|
||||
|
@ -106,5 +111,5 @@ func InitialSetup(configs *DbConfig) error {
|
|||
return errors.Wrap(err, "error creating admin")
|
||||
}
|
||||
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package configs
|
||||
|
||||
import (
|
||||
"github.com/go-yaml/yaml"
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/types/checkins"
|
||||
"github.com/hunterlong/statping/types/core"
|
||||
|
@ -15,34 +14,35 @@ import (
|
|||
"github.com/hunterlong/statping/types/services"
|
||||
"github.com/hunterlong/statping/types/users"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"gopkg.in/yaml.v2"
|
||||
"os"
|
||||
)
|
||||
|
||||
type SamplerFunc func()
|
||||
|
||||
type Sampler interface {
|
||||
Samples() []database.DbObject
|
||||
}
|
||||
|
||||
func TriggerSamples() error {
|
||||
return createSamples(
|
||||
&services.Service{},
|
||||
&users.User{},
|
||||
&hits.Hit{},
|
||||
&failures.Failure{},
|
||||
&groups.Group{},
|
||||
&checkins.Checkin{},
|
||||
&checkins.CheckinHit{},
|
||||
&incidents.Incident{},
|
||||
&incidents.IncidentUpdate{},
|
||||
core.Samples,
|
||||
users.Samples,
|
||||
messages.Samples,
|
||||
services.Samples,
|
||||
checkins.Samples,
|
||||
checkins.SamplesChkHits,
|
||||
failures.Samples,
|
||||
groups.Samples,
|
||||
hits.Samples,
|
||||
incidents.Samples,
|
||||
incidents.SamplesUpdates,
|
||||
)
|
||||
}
|
||||
|
||||
func createSamples(sm ...Sampler) error {
|
||||
func createSamples(sm ...SamplerFunc) error {
|
||||
for _, v := range sm {
|
||||
for _, sample := range v.Samples() {
|
||||
if err := sample.Create(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
v()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -103,11 +103,16 @@ func CreateDatabase() error {
|
|||
for _, table := range DbModels {
|
||||
if err := database.DB().CreateTable(table); err.Error() != nil {
|
||||
return err.Error()
|
||||
} else {
|
||||
log.Infof("Database table: '%T' was created", table)
|
||||
}
|
||||
}
|
||||
if err := database.DB().Table("core").CreateTable(&core.Core{}); err.Error() != nil {
|
||||
return err.Error()
|
||||
} else {
|
||||
log.Infof("Database table: '%s' was created", "core")
|
||||
}
|
||||
log.Infoln("Statping Database Created")
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
var log = utils.Log
|
||||
|
||||
func ConnectConfigs(configs *DbConfig) error {
|
||||
err := Connect(configs, true, utils.Directory)
|
||||
err := Connect(configs, true)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error connecting to database")
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package configs
|
||||
|
||||
import (
|
||||
"github.com/go-yaml/yaml"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
|
|
@ -43,7 +43,7 @@ import (
|
|||
//MigrateDatabase will migrate the database structure to current version.
|
||||
//This function will NOT remove previous records, tables or columns from the database.
|
||||
//If this function has an issue, it will ROLLBACK to the previous state.
|
||||
func MigrateDatabase() error {
|
||||
func (c *DbConfig) MigrateDatabase() error {
|
||||
|
||||
var DbModels = []interface{}{&services.Service{}, &users.User{}, &hits.Hit{}, &failures.Failure{}, &messages.Message{}, &groups.Group{}, &checkins.Checkin{}, &checkins.CheckinHit{}, ¬ifications.Notification{}, &incidents.Incident{}, &incidents.IncidentUpdate{}, &integrations.Integration{}}
|
||||
|
||||
|
@ -54,12 +54,12 @@ func MigrateDatabase() error {
|
|||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
if tx.Error() != nil {
|
||||
log.Errorln(tx.Error())
|
||||
return tx.Error()
|
||||
}
|
||||
for _, table := range DbModels {
|
||||
tx = tx.AutoMigrate(table)
|
||||
if tx.Error() != nil {
|
||||
log.Errorln(tx.Error())
|
||||
return tx.Error()
|
||||
}
|
||||
}
|
||||
if err := tx.Table("core").AutoMigrate(&core.Core{}); err.Error() != nil {
|
||||
tx.Rollback()
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/core"
|
||||
"github.com/hunterlong/statping/types/services"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -13,7 +11,6 @@ func NewCore() *Core {
|
|||
core := &Core{
|
||||
Started: time.Now().UTC(),
|
||||
}
|
||||
core.services = make(map[int64]*services.Service)
|
||||
return core
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,11 @@ import (
|
|||
)
|
||||
|
||||
func DB() database.Database {
|
||||
return database.DB().Table("core").Model(&Core{})
|
||||
return database.DB().Table("core")
|
||||
}
|
||||
|
||||
func Select() (*Core, error) {
|
||||
var c Core
|
||||
// SelectCore will return the CoreApp global variable and the settings/configs for Statping
|
||||
if !database.Available() {
|
||||
return nil, errors.New("database has not been initiated yet.")
|
||||
|
@ -22,10 +23,11 @@ func Select() (*Core, error) {
|
|||
if !exists {
|
||||
return nil, errors.New("core database has not been setup yet.")
|
||||
}
|
||||
db := DB().First(&App)
|
||||
db := database.DB().Find(&c).Debug()
|
||||
if db.Error() != nil {
|
||||
return nil, db.Error()
|
||||
}
|
||||
App = &c
|
||||
App.UseCdn = null.NewNullBool(os.Getenv("USE_CDN") == "true")
|
||||
return App, db.Error()
|
||||
|
||||
|
|
|
@ -16,12 +16,15 @@ func InitApp() error {
|
|||
//if err := InsertIntegratorDB(); err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
if _, err := services.SelectAllServices(true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := notifiers.AttachNotifiers(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//App.Notifications = notifications.AllCommunications
|
||||
//if err := integrations.AddIntegrations(); err != nil {
|
||||
// return err
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/types/null"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c *Core) Samples() []database.DbObject {
|
||||
func Samples() {
|
||||
apiKey := utils.Getenv("API_KEY", "samplekey")
|
||||
apiSecret := utils.Getenv("API_SECRET", "samplesecret")
|
||||
|
||||
|
@ -22,7 +21,5 @@ func (c *Core) Samples() []database.DbObject {
|
|||
UseCdn: null.NewNullBool(false),
|
||||
Footer: null.NewNullString(""),
|
||||
}
|
||||
|
||||
return []database.DbObject{core}
|
||||
|
||||
core.Create()
|
||||
}
|
||||
|
|
|
@ -9,6 +9,10 @@ var (
|
|||
App *Core
|
||||
)
|
||||
|
||||
func init() {
|
||||
App = new(Core)
|
||||
}
|
||||
|
||||
// Core struct contains all the required fields for Statping. All application settings
|
||||
// will be saved into 1 row in the 'core' table. You can use the core.CoreApp
|
||||
// global variable to interact with the attributes to the application, such as services.
|
||||
|
|
|
@ -2,30 +2,41 @@ package failures
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/prometheus/common/log"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (f *Failure) Samples() []database.DbObject {
|
||||
func Samples() {
|
||||
tx := DB().Begin()
|
||||
sg := new(sync.WaitGroup)
|
||||
|
||||
createdAt := time.Now().Add(-1 * types.Month)
|
||||
|
||||
for i := int64(1); i <= 5; i++ {
|
||||
log.Infoln(fmt.Sprintf("Adding %v Failure records to service", 5500))
|
||||
for i := int64(1); i <= 4; i++ {
|
||||
sg.Add(1)
|
||||
|
||||
for fi := 1; fi <= 5500; fi++ {
|
||||
createdAt = createdAt.Add(2 * time.Minute)
|
||||
log.Infoln(fmt.Sprintf("Adding %v Failure records to service", 730))
|
||||
|
||||
failure := &Failure{
|
||||
Service: i,
|
||||
Issue: "testing right here",
|
||||
CreatedAt: createdAt,
|
||||
go func() {
|
||||
defer sg.Done()
|
||||
for fi := 0.; fi <= float64(730); fi++ {
|
||||
createdAt = createdAt.Add(2 * time.Minute)
|
||||
failure := &Failure{
|
||||
Service: i,
|
||||
Issue: "testing right here",
|
||||
CreatedAt: createdAt.UTC(),
|
||||
}
|
||||
|
||||
tx = tx.Create(&failure)
|
||||
}
|
||||
|
||||
failure.Create()
|
||||
}
|
||||
}()
|
||||
}
|
||||
return nil
|
||||
sg.Wait()
|
||||
|
||||
if err := tx.Commit().Error(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,30 +5,34 @@ import (
|
|||
"sort"
|
||||
)
|
||||
|
||||
func DB() database.Database {
|
||||
return database.DB().Model(&Group{})
|
||||
}
|
||||
|
||||
func Find(id int64) (*Group, error) {
|
||||
var group *Group
|
||||
db := database.DB().Model(&Group{}).Where("id = ?", id).Find(&group)
|
||||
db := DB().Where("id = ?", id).Find(&group)
|
||||
return group, db.Error()
|
||||
}
|
||||
|
||||
func All() []*Group {
|
||||
var groups []*Group
|
||||
database.DB().Model(&Group{}).Find(&groups)
|
||||
DB().Find(&groups)
|
||||
return groups
|
||||
}
|
||||
|
||||
func (g *Group) Create() error {
|
||||
db := database.DB().Create(&g)
|
||||
db := DB().Create(&g)
|
||||
return db.Error()
|
||||
}
|
||||
|
||||
func (g *Group) Update() error {
|
||||
db := database.DB().Update(&g)
|
||||
db := DB().Update(&g)
|
||||
return db.Error()
|
||||
}
|
||||
|
||||
func (g *Group) Delete() error {
|
||||
db := database.DB().Delete(&g)
|
||||
db := DB().Delete(&g)
|
||||
return db.Error()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
package groups
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/types/null"
|
||||
)
|
||||
|
||||
func (g *Group) Samples() []database.DbObject {
|
||||
func Samples() {
|
||||
group1 := &Group{
|
||||
Name: "Main Services",
|
||||
Public: null.NewNullBool(true),
|
||||
Order: 2,
|
||||
}
|
||||
group1.Create()
|
||||
|
||||
group2 := &Group{
|
||||
Name: "Linked Services",
|
||||
Public: null.NewNullBool(false),
|
||||
Order: 1,
|
||||
}
|
||||
group2.Create()
|
||||
|
||||
group3 := &Group{
|
||||
Name: "Empty Group",
|
||||
Public: null.NewNullBool(false),
|
||||
Order: 3,
|
||||
}
|
||||
group3.Create()
|
||||
|
||||
return []database.DbObject{group1, group2, group3}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package hits
|
||||
|
||||
import "github.com/hunterlong/statping/database"
|
||||
import (
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
)
|
||||
|
||||
var log = utils.Log
|
||||
|
||||
func DB() database.Database {
|
||||
return database.DB().Model(&Hit{})
|
||||
|
|
|
@ -1,30 +1,41 @@
|
|||
package hits
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (u *Hit) Samples() []database.DbObject {
|
||||
createdAt := time.Now().Add(-1 * types.Month)
|
||||
var hits []database.DbObject
|
||||
var SampleHits = 9900.
|
||||
|
||||
func Samples() {
|
||||
tx := DB().Begin()
|
||||
sg := new(sync.WaitGroup)
|
||||
|
||||
createdAt := time.Now().Add(-1 * types.Month)
|
||||
for i := int64(1); i <= 4; i++ {
|
||||
sg.Add(1)
|
||||
|
||||
for i := int64(1); i <= 5; i++ {
|
||||
p := utils.NewPerlin(2, 2, 5, time.Now().UnixNano())
|
||||
|
||||
for hi := 1; hi <= 5500; hi++ {
|
||||
latency := p.Noise1D(float64(hi / 10))
|
||||
createdAt = createdAt.Add(1 * time.Minute)
|
||||
hit := &Hit{
|
||||
Service: i,
|
||||
CreatedAt: createdAt.UTC(),
|
||||
Latency: latency,
|
||||
go func() {
|
||||
defer sg.Done()
|
||||
for hi := 0.; hi <= SampleHits; hi++ {
|
||||
latency := p.Noise1D(hi / 500)
|
||||
createdAt = createdAt.Add(1 * time.Minute)
|
||||
hit := &Hit{
|
||||
Service: i,
|
||||
CreatedAt: createdAt.UTC(),
|
||||
Latency: latency,
|
||||
}
|
||||
tx = tx.Create(&hit)
|
||||
}
|
||||
hits = append(hits, hit)
|
||||
}
|
||||
}()
|
||||
}
|
||||
sg.Wait()
|
||||
|
||||
return hits
|
||||
if err := tx.Commit().Error(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +1,40 @@
|
|||
package incidents
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/database"
|
||||
)
|
||||
|
||||
func (s *Incident) Samples() []database.DbObject {
|
||||
func Samples() {
|
||||
incident1 := &Incident{
|
||||
Title: "Github Downtime",
|
||||
Description: "This is an example of a incident for a service.",
|
||||
ServiceId: 2,
|
||||
}
|
||||
incident1.Create()
|
||||
|
||||
i1 := &IncidentUpdate{
|
||||
IncidentId: incident1.Id,
|
||||
Message: "Github's page for Statping seems to be sending a 501 error.",
|
||||
Type: "Investigating",
|
||||
}
|
||||
i1.Create()
|
||||
|
||||
i2 := &IncidentUpdate{
|
||||
IncidentId: incident1.Id,
|
||||
Message: "Problem is continuing and we are looking at the issues.",
|
||||
Type: "Update",
|
||||
}
|
||||
i2.Create()
|
||||
|
||||
i3 := &IncidentUpdate{
|
||||
IncidentId: incident1.Id,
|
||||
Message: "Github is now back online and everything is working.",
|
||||
Type: "Resolved",
|
||||
}
|
||||
|
||||
return []database.DbObject{i1, i2, i3}
|
||||
i3.Create()
|
||||
}
|
||||
|
||||
func (s *IncidentUpdate) Samples() []database.DbObject {
|
||||
|
||||
return nil
|
||||
func SamplesUpdates() {
|
||||
u1 := &IncidentUpdate{
|
||||
IncidentId: 1,
|
||||
Message: "Github is now back online and everything is working.",
|
||||
Type: "Resolved",
|
||||
}
|
||||
u1.Create()
|
||||
}
|
||||
|
|
|
@ -2,29 +2,33 @@ package messages
|
|||
|
||||
import "github.com/hunterlong/statping/database"
|
||||
|
||||
func DB() database.Database {
|
||||
return database.DB().Model(&Message{})
|
||||
}
|
||||
|
||||
func Find(id int64) (*Message, error) {
|
||||
var user *Message
|
||||
db := database.DB().Model(&Message{}).Where("id = ?", id).Find(&user)
|
||||
db := DB().Where("id = ?", id).Find(&user)
|
||||
return user, db.Error()
|
||||
}
|
||||
|
||||
func All() []*Message {
|
||||
var messages []*Message
|
||||
database.DB().Model(&Message{}).Find(&messages)
|
||||
DB().Find(&messages)
|
||||
return messages
|
||||
}
|
||||
|
||||
func (m *Message) Create() error {
|
||||
db := database.DB().Create(&m)
|
||||
db := DB().Create(&m)
|
||||
return db.Error()
|
||||
}
|
||||
|
||||
func (m *Message) Update() error {
|
||||
db := database.DB().Update(&m)
|
||||
db := DB().Update(&m)
|
||||
return db.Error()
|
||||
}
|
||||
|
||||
func (m *Message) Delete() error {
|
||||
db := database.DB().Delete(&m)
|
||||
db := DB().Delete(&m)
|
||||
return db.Error()
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package messages
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/database"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (m *Message) Samples() []database.DbObject {
|
||||
func Samples() {
|
||||
m1 := &Message{
|
||||
Title: "Routine Downtime",
|
||||
Description: "This is an example a upcoming message for a service!",
|
||||
|
@ -14,6 +13,8 @@ func (m *Message) Samples() []database.DbObject {
|
|||
EndOn: time.Now().UTC().Add(2 * time.Hour),
|
||||
}
|
||||
|
||||
m1.Create()
|
||||
|
||||
m2 := &Message{
|
||||
Title: "Server Reboot",
|
||||
Description: "This is another example a upcoming message for a service!",
|
||||
|
@ -22,5 +23,5 @@ func (m *Message) Samples() []database.DbObject {
|
|||
EndOn: time.Now().UTC().Add(2 * time.Hour),
|
||||
}
|
||||
|
||||
return []database.DbObject{m1, m2}
|
||||
m2.Create()
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package notifications
|
|||
import (
|
||||
"fmt"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"github.com/pkg/errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
@ -91,18 +92,26 @@ func (n *Notification) GetValue(dbField string) string {
|
|||
// Init accepts the Notifier interface to initialize the notifier
|
||||
func Init(n Notifier) (*Notification, error) {
|
||||
err := install(n)
|
||||
var notify *Notification
|
||||
if err == nil {
|
||||
notify, _ = SelectNotification(n)
|
||||
notify, err := SelectNotification(n)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error selecting notification")
|
||||
}
|
||||
notify.CreatedAt = time.Now().UTC()
|
||||
notify.UpdatedAt = time.Now().UTC()
|
||||
if notify.Delay.Seconds() == 0 {
|
||||
notify.Delay = time.Duration(1 * time.Second)
|
||||
notify.Delay = 1 * time.Second
|
||||
}
|
||||
notify.testable = utils.IsType(n, new(Tester))
|
||||
notify.Form = n.Select().Form
|
||||
|
||||
AllCommunications = append(AllCommunications, n)
|
||||
|
||||
} else {
|
||||
return nil, errors.Wrap(err, "error installing notification")
|
||||
}
|
||||
return notify, err
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// ResetQueue will clear the notifiers Queue
|
||||
|
|
|
@ -149,7 +149,7 @@ func reverseLogs(input []*NotificationLog) []*NotificationLog {
|
|||
// SelectNotification returns the Notification struct from the database
|
||||
func SelectNotification(n Notifier) (*Notification, error) {
|
||||
notifier := n.Select()
|
||||
err := db.Model(&Notification{}).Where("method = ?", notifier.Method).Scan(¬ifier)
|
||||
err := DB().Where("method = ?", notifier.Method).Scan(¬ifier)
|
||||
return notifier, err.Error()
|
||||
}
|
||||
|
||||
|
@ -222,6 +222,8 @@ func install(n Notifier) error {
|
|||
return err
|
||||
}
|
||||
|
||||
AllCommunications = append(AllCommunications, n)
|
||||
|
||||
log.WithFields(utils.ToFields(n)).
|
||||
Debugln(fmt.Sprintf("Checking if notifier '%v' is installed", n.Select().Method))
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
|
@ -13,9 +14,11 @@ func DB() database.Database {
|
|||
}
|
||||
|
||||
func Find(id int64) (*Service, error) {
|
||||
var service *Service
|
||||
db := DB().Where("id = ?", id).Find(&service)
|
||||
return service, db.Error()
|
||||
srv := allServices[id]
|
||||
if srv == nil {
|
||||
return nil, errors.New("service not found")
|
||||
}
|
||||
return srv, nil
|
||||
}
|
||||
|
||||
func All() []*Service {
|
||||
|
@ -25,15 +28,14 @@ func All() []*Service {
|
|||
}
|
||||
|
||||
func (s *Service) Create() error {
|
||||
|
||||
err := s.Create()
|
||||
if err != nil {
|
||||
err := DB().Create(&s)
|
||||
if err.Error() != nil {
|
||||
log.Errorln(fmt.Sprintf("Failed to create service %v #%v: %v", s.Name, s.Id, err))
|
||||
return err
|
||||
return err.Error()
|
||||
}
|
||||
allServices[s.Id] = s
|
||||
|
||||
go ServiceCheckQueue(s, true)
|
||||
go ServiceCheckQueue(allServices[s.Id], true)
|
||||
reorderServices()
|
||||
//notifications.OnNewService(s)
|
||||
|
||||
|
@ -52,9 +54,8 @@ func (s *Service) Update() error {
|
|||
//}
|
||||
}
|
||||
s.Close()
|
||||
s.Start()
|
||||
s.SleepDuration = s.Duration()
|
||||
go ServiceCheckQueue(s, true)
|
||||
go ServiceCheckQueue(allServices[s.Id], true)
|
||||
|
||||
reorderServices()
|
||||
//notifier.OnUpdatedService(s.Service)
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
// Service hash example: sha256(name:EXAMPLEdomain:HTTP://DOMAIN.COMport:8080type:HTTPmethod:GET)
|
||||
func findServiceByHash(hash string) *Service {
|
||||
for _, service := range All() {
|
||||
if service.String() == hash {
|
||||
if service.Hash() == hash {
|
||||
return service
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func ServicesFromEnvFile() error {
|
|||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid service at index %d in SERVICES_FILE environment variable", k)
|
||||
}
|
||||
if findServiceByHash(svr.String()) == nil {
|
||||
if findServiceByHash(svr.Hash()) == nil {
|
||||
if err := svr.Create(); err != nil {
|
||||
return errors.Wrapf(err, "could not create service %s", svr.Name)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ func (s *Service) IsRunning() bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (s Service) String() string {
|
||||
func (s Service) Hash() string {
|
||||
format := fmt.Sprintf("name:%sdomain:%sport:%dtype:%smethod:%s", s.Name, s.Domain, s.Port, s.Type, s.Method)
|
||||
h := sha1.New()
|
||||
h.Write([]byte(format))
|
||||
|
@ -66,9 +66,11 @@ func SelectAllServices(start bool) (map[int64]*Service, error) {
|
|||
return allServices, nil
|
||||
}
|
||||
|
||||
for _, s := range allServices {
|
||||
for _, s := range All() {
|
||||
|
||||
allServices[s.Id] = s
|
||||
|
||||
if start {
|
||||
s.Start()
|
||||
CheckinProcess(s)
|
||||
}
|
||||
|
||||
|
@ -81,8 +83,6 @@ func SelectAllServices(start bool) (map[int64]*Service, error) {
|
|||
|
||||
// collect initial service stats
|
||||
s.UpdateStats()
|
||||
|
||||
allServices[s.Id] = s
|
||||
}
|
||||
|
||||
reorderServices()
|
||||
|
|
|
@ -20,17 +20,17 @@ func CheckServices() {
|
|||
log.Infoln(fmt.Sprintf("Starting monitoring process for %v Services", len(allServices)))
|
||||
for _, s := range allServices {
|
||||
//go CheckinRoutine()
|
||||
time.Sleep(200 * time.Millisecond) // short delay so requests don't run all at the same time.
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
go ServiceCheckQueue(s, true)
|
||||
}
|
||||
}
|
||||
|
||||
// CheckQueue is the main go routine for checking a service
|
||||
func ServiceCheckQueue(s *Service, record bool) {
|
||||
log.Infof("Starting new service '%s', checking every %0.2f seconds.", s.Name, s.Duration().Seconds())
|
||||
s.Start()
|
||||
s.Checkpoint = time.Now()
|
||||
s.SleepDuration = (time.Duration(s.Id) * 100) * time.Millisecond
|
||||
|
||||
CheckLoop:
|
||||
for {
|
||||
select {
|
||||
|
@ -38,7 +38,7 @@ CheckLoop:
|
|||
log.Infoln(fmt.Sprintf("Stopping service: %v", s.Name))
|
||||
break CheckLoop
|
||||
case <-time.After(s.SleepDuration):
|
||||
CheckService(s, record)
|
||||
s.CheckService(record)
|
||||
s.Checkpoint = s.Checkpoint.Add(s.Duration())
|
||||
sleep := s.Checkpoint.Sub(time.Now())
|
||||
if !s.Online {
|
||||
|
@ -217,16 +217,19 @@ func CheckHttp(s *Service, record bool) *Service {
|
|||
// recordSuccess will create a new 'hit' record in the database for a successful/online service
|
||||
func recordSuccess(s *Service) {
|
||||
s.LastOnline = time.Now().UTC()
|
||||
s.Online = true
|
||||
hit := &hits.Hit{
|
||||
Service: s.Id,
|
||||
Latency: s.Latency,
|
||||
PingTime: s.PingTime,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
}
|
||||
hit.Create()
|
||||
log.WithFields(utils.ToFields(hit, s)).Infoln(fmt.Sprintf("Service %v Successful Response: %0.2f ms | Lookup in: %0.2f ms", s.Name, hit.Latency*1000, hit.PingTime*1000))
|
||||
if err := hit.Create(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
log.WithFields(utils.ToFields(hit, s)).Infoln(
|
||||
fmt.Sprintf("Service #%d '%v' Successful Response: %0.2f ms | Lookup in: %0.2f ms | Online: %v | Interval: %d seconds", s.Id, s.Name, hit.Latency*1000, hit.PingTime*1000, s.Online, s.Interval))
|
||||
//notifier.OnSuccess(s)
|
||||
s.Online = true
|
||||
s.SuccessNotified = true
|
||||
}
|
||||
|
||||
|
@ -242,7 +245,9 @@ func recordFailure(s *Service, issue string) {
|
|||
log.WithFields(utils.ToFields(fail, s)).
|
||||
Warnln(fmt.Sprintf("Service %v Failing: %v | Lookup in: %0.2f ms", s.Name, issue, fail.PingTime*1000))
|
||||
|
||||
fail.Create()
|
||||
if err := fail.Create(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
s.Online = false
|
||||
s.SuccessNotified = false
|
||||
s.DownText = s.DowntimeText()
|
||||
|
@ -251,13 +256,13 @@ func recordFailure(s *Service, issue string) {
|
|||
|
||||
// Check will run checkHttp for HTTP services and checkTcp for TCP services
|
||||
// if record param is set to true, it will add a record into the database.
|
||||
func CheckService(srv *Service, record bool) {
|
||||
switch srv.Type {
|
||||
func (s *Service) CheckService(record bool) {
|
||||
switch s.Type {
|
||||
case "http":
|
||||
CheckHttp(srv, record)
|
||||
CheckHttp(s, record)
|
||||
case "tcp", "udp":
|
||||
CheckTcp(srv, record)
|
||||
CheckTcp(s, record)
|
||||
case "icmp":
|
||||
CheckIcmp(srv, record)
|
||||
CheckIcmp(s, record)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/types/null"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s *Service) Samples() []database.DbObject {
|
||||
func Samples() {
|
||||
createdOn := time.Now().Add(((-24 * 30) * 3) * time.Hour).UTC()
|
||||
s1 := &Service{
|
||||
Name: "Google",
|
||||
|
@ -22,6 +21,8 @@ func (s *Service) Samples() []database.DbObject {
|
|||
VerifySSL: null.NewNullBool(true),
|
||||
CreatedAt: createdOn,
|
||||
}
|
||||
s1.Create()
|
||||
|
||||
s2 := &Service{
|
||||
Name: "Statping Github",
|
||||
Domain: "https://github.com/hunterlong/statping",
|
||||
|
@ -35,6 +36,8 @@ func (s *Service) Samples() []database.DbObject {
|
|||
VerifySSL: null.NewNullBool(true),
|
||||
CreatedAt: createdOn,
|
||||
}
|
||||
s2.Create()
|
||||
|
||||
s3 := &Service{
|
||||
Name: "JSON Users Test",
|
||||
Domain: "https://jsonplaceholder.typicode.com/users",
|
||||
|
@ -49,6 +52,8 @@ func (s *Service) Samples() []database.DbObject {
|
|||
GroupId: 2,
|
||||
CreatedAt: createdOn,
|
||||
}
|
||||
s3.Create()
|
||||
|
||||
s4 := &Service{
|
||||
Name: "JSON API Tester",
|
||||
Domain: "https://jsonplaceholder.typicode.com/posts",
|
||||
|
@ -65,6 +70,8 @@ func (s *Service) Samples() []database.DbObject {
|
|||
GroupId: 2,
|
||||
CreatedAt: createdOn,
|
||||
}
|
||||
s4.Create()
|
||||
|
||||
s5 := &Service{
|
||||
Name: "Google DNS",
|
||||
Domain: "8.8.8.8",
|
||||
|
@ -77,6 +84,5 @@ func (s *Service) Samples() []database.DbObject {
|
|||
GroupId: 1,
|
||||
CreatedAt: createdOn,
|
||||
}
|
||||
|
||||
return []database.DbObject{s1, s2, s3, s4, s5}
|
||||
s5.Create()
|
||||
}
|
||||
|
|
|
@ -6,21 +6,25 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func DB() database.Database {
|
||||
return database.DB().Model(&User{})
|
||||
}
|
||||
|
||||
func Find(id int64) (*User, error) {
|
||||
var user *User
|
||||
db := database.DB().Model(&User{}).Where("id = ?", id).Find(&user)
|
||||
db := DB().Where("id = ?", id).Find(&user)
|
||||
return user, db.Error()
|
||||
}
|
||||
|
||||
func FindByUsername(username string) (*User, error) {
|
||||
var user *User
|
||||
db := database.DB().Model(&User{}).Where("username = ?", username).Find(&user)
|
||||
return user, db.Error()
|
||||
var user User
|
||||
db := DB().Where("username = ?", username).Find(&user)
|
||||
return &user, db.Error()
|
||||
}
|
||||
|
||||
func All() []*User {
|
||||
var users []*User
|
||||
database.DB().Model(&User{}).Find(&users)
|
||||
DB().Find(&users)
|
||||
return users
|
||||
}
|
||||
|
||||
|
@ -30,18 +34,18 @@ func (u *User) Create() error {
|
|||
u.ApiKey = utils.NewSHA1Hash(5)
|
||||
u.ApiSecret = utils.NewSHA1Hash(10)
|
||||
|
||||
db := database.DB().Create(&u)
|
||||
db := DB().Create(&u)
|
||||
return db.Error()
|
||||
}
|
||||
|
||||
func (u *User) Update() error {
|
||||
u.ApiKey = utils.NewSHA1Hash(5)
|
||||
u.ApiSecret = utils.NewSHA1Hash(10)
|
||||
db := database.DB().Update(&u)
|
||||
db := DB().Update(&u)
|
||||
return db.Error()
|
||||
}
|
||||
|
||||
func (u *User) Delete() error {
|
||||
db := database.DB().Delete(&u)
|
||||
db := DB().Delete(&u)
|
||||
return db.Error()
|
||||
}
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
package users
|
||||
|
||||
import (
|
||||
"github.com/hunterlong/statping/database"
|
||||
"github.com/hunterlong/statping/types/null"
|
||||
)
|
||||
|
||||
func (u *User) Samples() []database.DbObject {
|
||||
|
||||
var samples []database.DbObject
|
||||
|
||||
func Samples() {
|
||||
u2 := &User{
|
||||
Username: "testadmin",
|
||||
Password: "password123",
|
||||
|
@ -16,7 +12,7 @@ func (u *User) Samples() []database.DbObject {
|
|||
Admin: null.NewNullBool(true),
|
||||
}
|
||||
|
||||
samples = append(samples, u2)
|
||||
u2.Create()
|
||||
|
||||
u3 := &User{
|
||||
Username: "testadmin2",
|
||||
|
@ -25,7 +21,5 @@ func (u *User) Samples() []database.DbObject {
|
|||
Admin: null.NewNullBool(true),
|
||||
}
|
||||
|
||||
samples = append(samples, u3)
|
||||
|
||||
return samples
|
||||
u3.Create()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue