From 5af3bb820f999b6c3cd85bc2fcf8e4428318c29a Mon Sep 17 00:00:00 2001 From: subham sarkar Date: Wed, 8 Jun 2022 01:15:53 +0530 Subject: [PATCH] Make general improvements and fix a couple of bugs Signed-off-by: subham sarkar --- cmd/server/main.go | 8 ++-- cmd/server/stateful.go | 2 +- cmd/server/stateless.go | 2 +- config/app.go | 2 +- config/app_test.go | 2 - config/templates.go | 17 ++++---- config/templates_test.go | 1 - go.mod | 38 ++++++++--------- go.sum | 80 ++++++++++++++++++++---------------- infrastructure/postgresql.go | 2 +- interfaces/http/message.go | 2 +- interfaces/http/router.go | 2 +- provider/jira/client.go | 10 +++-- provider/jira/error.go | 5 +++ provider/jira/jira.go | 12 +++--- provider/jira/jira_test.go | 33 +++++++-------- provider/provider.go | 2 +- provider/slack/client.go | 4 +- provider/slack/error.go | 4 ++ provider/slack/slack.go | 12 +++--- service/error.go | 5 +++ service/message.go | 6 +-- service/provider.go | 6 +-- storage/config/error.go | 15 ++++--- storage/config/template.go | 3 +- storage/sql/error.go | 15 ++++--- templater/go.go | 1 - templater/humanize.go | 2 +- templater/humanize_test.go | 3 ++ 29 files changed, 165 insertions(+), 131 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 30d32ad..a51a428 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -2,11 +2,10 @@ package main import ( "flag" + "os" "github.com/labstack/echo-contrib/prometheus" - "github.com/labstack/gommon/log" - - "os" + log "github.com/sirupsen/logrus" "github.com/deepsourcelabs/hermes/config" "github.com/labstack/echo/v4" @@ -14,8 +13,7 @@ import ( ) func main() { - - var isStateless = flag.Bool("stateless", true, "-stateless") + isStateless := flag.Bool("stateless", true, "-stateless") flag.Parse() diff --git a/cmd/server/stateful.go b/cmd/server/stateful.go index b40622d..9b3cc46 100644 --- a/cmd/server/stateful.go +++ b/cmd/server/stateful.go @@ -9,7 +9,7 @@ import ( "github.com/deepsourcelabs/hermes/service" sqlStore "github.com/deepsourcelabs/hermes/storage/sql" "github.com/labstack/echo/v4" - "github.com/labstack/gommon/log" + log "github.com/sirupsen/logrus" "gorm.io/driver/postgres" "gorm.io/gorm" ) diff --git a/cmd/server/stateless.go b/cmd/server/stateless.go index 8511e4a..89dc01a 100644 --- a/cmd/server/stateless.go +++ b/cmd/server/stateless.go @@ -8,7 +8,7 @@ import ( "github.com/deepsourcelabs/hermes/service" configStore "github.com/deepsourcelabs/hermes/storage/config" "github.com/labstack/echo/v4" - "github.com/labstack/gommon/log" + log "github.com/sirupsen/logrus" ) func StartStatelessMode(cfg *config.AppConfig, e *echo.Echo) error { diff --git a/config/app.go b/config/app.go index c3e6efd..c4a646f 100644 --- a/config/app.go +++ b/config/app.go @@ -41,7 +41,7 @@ type AppConfig struct { } func (config *AppConfig) ReadEnv() error { - var k = koanf.New(".") + k := koanf.New(".") k.Load(env.Provider(envPrefix, ".", func(s string) string { return strings.Replace(strings.ToLower( strings.TrimPrefix(s, envPrefix)), "__", ".", -1) diff --git a/config/app_test.go b/config/app_test.go index a65c341..2ffea02 100644 --- a/config/app_test.go +++ b/config/app_test.go @@ -46,7 +46,6 @@ func TestAppConfig_Validate(t *testing.T) { func TestPGConfig_GetDSN(t *testing.T) { t.Run("get dsn", func(t *testing.T) { - want := "postgres://hermes:password@localhost:5432/hermesDB" pgConfig := &PGConfig{ @@ -95,6 +94,5 @@ func TestAppConfig_ReadEnv(t *testing.T) { if !reflect.DeepEqual(appConfig.Postgres, want) { t.Errorf("AppConfig.ReadEnv().Postgres = %v, want %v", appConfig.Postgres, want) } - }) } diff --git a/config/templates.go b/config/templates.go index 4602d7a..2537748 100644 --- a/config/templates.go +++ b/config/templates.go @@ -6,14 +6,16 @@ import ( "github.com/deepsourcelabs/hermes/domain" "github.com/fsnotify/fsnotify" - "github.com/labstack/gommon/log" + log "github.com/sirupsen/logrus" "gopkg.in/yaml.v3" ) var templateConfig *TemplateConfig -var osReadFile readFileFn = os.ReadFile -var osStat statFn = os.Stat +var ( + osReadFile readFileFn = os.ReadFile + osStat statFn = os.Stat +) type Template struct { ID string `yaml:"id,omitempty"` @@ -40,12 +42,12 @@ func (tc *TemplateConfig) Validate() error { return nil } -func (config *TemplateConfig) ReadYAML(configPath string) error { +func (tc *TemplateConfig) ReadYAML(configPath string) error { configBytes, err := osReadFile(path.Join(configPath, "./template.yaml")) if err != nil { return err } - return yaml.Unmarshal(configBytes, &config) + return yaml.Unmarshal(configBytes, &tc) } func InitTemplateConfig(templateConfigPath string) error { @@ -103,10 +105,11 @@ func StartTemplateConfigWatcher(configPath string) error { } } }() - err = watcher.Add(configPath) - if err != nil { + + if err := watcher.Add(configPath); err != nil { return err } + <-done return nil } diff --git a/config/templates_test.go b/config/templates_test.go index f086499..9d6611b 100644 --- a/config/templates_test.go +++ b/config/templates_test.go @@ -66,7 +66,6 @@ func TestTemplateConfig_ReadYAML(t *testing.T) { t.Errorf("TemplateConfig.ReadYAML() unexpected error = %v,", err) } }) - } func TestInitTemplateConfig(t *testing.T) { diff --git a/go.mod b/go.mod index f9a347d..2ce22d6 100644 --- a/go.mod +++ b/go.mod @@ -3,18 +3,17 @@ module github.com/deepsourcelabs/hermes go 1.17 require ( - github.com/fsnotify/fsnotify v1.5.1 + github.com/fsnotify/fsnotify v1.5.4 github.com/hoisie/mustache v0.0.0-20160804235033-6375acf62c69 github.com/knadh/koanf v1.4.1 github.com/labstack/echo-contrib v0.12.0 - github.com/labstack/echo/v4 v4.7.0 - github.com/labstack/gommon v0.3.1 - github.com/mitchellh/mapstructure v1.4.3 + github.com/labstack/echo/v4 v4.7.2 + github.com/mitchellh/mapstructure v1.5.0 github.com/segmentio/ksuid v1.0.4 github.com/sirupsen/logrus v1.8.1 - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b - gorm.io/driver/postgres v1.3.1 - gorm.io/gorm v1.23.1 + gopkg.in/yaml.v3 v3.0.1 + gorm.io/driver/postgres v1.3.7 + gorm.io/gorm v1.23.5 ) require ( @@ -23,31 +22,32 @@ require ( github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.11.0 // indirect + github.com/jackc/pgconn v1.12.1 // indirect github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.2.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.0 // indirect github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect - github.com/jackc/pgtype v1.10.0 // indirect - github.com/jackc/pgx/v4 v4.15.0 // indirect + github.com/jackc/pgtype v1.11.0 // indirect + github.com/jackc/pgx/v4 v4.16.1 // indirect github.com/jinzhu/inflection v1.0.0 // indirect - github.com/jinzhu/now v1.1.4 // indirect + github.com/jinzhu/now v1.1.5 // indirect github.com/kr/pretty v0.2.1 // indirect + github.com/labstack/gommon v0.3.1 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/prometheus/client_golang v1.12.1 // indirect + github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/common v0.34.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.1 // indirect - golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect - golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect + golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/net v0.0.0-20220607020251-c690dde0001d // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect golang.org/x/text v0.3.7 // indirect - golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect - google.golang.org/protobuf v1.27.1 // indirect + golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect + google.golang.org/protobuf v1.28.0 // indirect ) diff --git a/go.sum b/go.sum index 32b6834..7bd2635 100644 --- a/go.sum +++ b/go.sum @@ -82,18 +82,20 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= -github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= 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-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= 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-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= @@ -191,9 +193,8 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.10.1/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.11.0 h1:HiHArx4yFbwl91X3qqIHtUFoiIfLNJXCQRsnzkiwwaQ= -github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.12.1 h1:rsDFzIpRk7xT4B8FufgpCCeyjdNpKyghZeSefViE5W8= +github.com/jackc/pgconn v1.12.1/go.mod h1:ZkhRC59Llhrq3oSfrikvwQ5NaxYExr6twkdkMLaKono= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -209,33 +210,31 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns= -github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.0 h1:brH0pCGBDkBW07HWlN/oSBXrmo3WB0UvZd1pIuDcL8Y= +github.com/jackc/pgproto3/v2 v2.3.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.9.1/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgtype v1.10.0 h1:ILnBWrRMSXGczYvmkYD6PsYyVFUNLTnIUJHHDLmqk38= -github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.11.0 h1:u4uiGPz/1hryuXzyaBhSk6dnIyyG2683olG2OV+UUgs= +github.com/jackc/pgtype v1.11.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.14.1/go.mod h1:RgDuE4Z34o7XE92RpLsvFiOEfrAUT0Xt2KxvX73W06M= -github.com/jackc/pgx/v4 v4.15.0 h1:B7dTkXsdILD3MF987WGGCcg+tvLW6bZJdEcqVFeU//w= -github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw= +github.com/jackc/pgx/v4 v4.16.1 h1:JzTglcal01DrghUqt+PmzWsZx/Yh7SC/CTQmSBMTd0Y= +github.com/jackc/pgx/v4 v4.16.1/go.mod h1:SIhx0D5hoADaiXZVyv+3gSm3LCIIINTVO0PficsvWGQ= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.2.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= 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.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas= github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= @@ -265,8 +264,8 @@ 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/labstack/echo-contrib v0.12.0 h1:NPr1ez+XUa5s/4LujEon+32Bxg5DO6EKSW/va06pmLc= github.com/labstack/echo-contrib v0.12.0/go.mod h1:kR62TbwsBgmpV2HVab5iQRsQtLuhPyGqCBee88XRc4M= -github.com/labstack/echo/v4 v4.7.0 h1:8wHgZhoE9OT1NSLw6sfrX7ZGpWMtO5Zlfr68+BIo180= -github.com/labstack/echo/v4 v4.7.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= +github.com/labstack/echo/v4 v4.7.2 h1:Kv2/p8OaQ+M6Ex4eGimg9b9e6icoxA42JSlOR3msKtI= +github.com/labstack/echo/v4 v4.7.2/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o= github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -298,8 +297,8 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= -github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -327,8 +326,9 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= +github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/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= @@ -337,8 +337,9 @@ github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6T github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.34.0 h1:RBmGO9d/FVjqHT0yUGQwBJhkwKV+wPCn7KGpvfab0uE= +github.com/prometheus/common v0.34.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= @@ -411,8 +412,8 @@ golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -474,14 +475,17 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d h1:4SFsTMi4UahlKoloni7L4eYzhFRifURQLw+yv0QDCx8= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 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/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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= @@ -538,10 +542,14 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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= @@ -555,8 +563,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE= -golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20220411224347-583f2d630306 h1:+gHMid33q6pen7kv9xvT+JRinntgeXO2AeZVd0AWD3w= +golang.org/x/time v0.0.0-20220411224347-583f2d630306/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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= @@ -687,8 +695,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -707,12 +715,14 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/postgres v1.3.1 h1:Pyv+gg1Gq1IgsLYytj/S2k7ebII3CzEdpqQkPOdH24g= -gorm.io/driver/postgres v1.3.1/go.mod h1:WwvWOuR9unCLpGWCL6Y3JOeBWvbKi6JLhayiVclSZZU= -gorm.io/gorm v1.23.1 h1:aj5IlhDzEPsoIyOPtTRVI+SyaN1u6k613sbt4pwbxG0= -gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/postgres v1.3.7 h1:FKF6sIMDHDEvvMF/XJvbnCl0nu6KSKUaPXevJ4r+VYQ= +gorm.io/driver/postgres v1.3.7/go.mod h1:f02ympjIcgtHEGFMZvdgTxODZ9snAHDb4hXfigBVuNI= +gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +gorm.io/gorm v1.23.5 h1:TnlF26wScKSvknUC/Rn8t0NLLM22fypYBlvj1+aH6dM= +gorm.io/gorm v1.23.5/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= 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= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/infrastructure/postgresql.go b/infrastructure/postgresql.go index c89f950..1b712d4 100644 --- a/infrastructure/postgresql.go +++ b/infrastructure/postgresql.go @@ -20,7 +20,7 @@ func GetDB() *gorm.DB { return nil } -// InitPG initialises the postgres connection for the app. +// InitPG initializes the postgres connection for the app. func InitPG() error { dbURL := "postgres://hermes:password@localhost:5432/hermes" db, err := gorm.Open(postgres.Open(dbURL), &gorm.Config{}) diff --git a/interfaces/http/message.go b/interfaces/http/message.go index b3ca5e2..ec71285 100644 --- a/interfaces/http/message.go +++ b/interfaces/http/message.go @@ -20,7 +20,7 @@ func NewMessageHandler(messageService service.MessageService) MessageHandler { func (handler *messageHandler) PostMessage() echo.HandlerFunc { return func(c echo.Context) error { ctx := c.Request().Context() - var request = new(service.SendMessageRequest) + request := new(service.SendMessageRequest) if err := c.Bind(request); err != nil { return c.JSON(http.StatusBadRequest, ErrorResponse{"request malformed"}) } diff --git a/interfaces/http/router.go b/interfaces/http/router.go index e642dfb..b51b477 100644 --- a/interfaces/http/router.go +++ b/interfaces/http/router.go @@ -24,7 +24,7 @@ func NewRouter( } func (r *router) AddRoutes(e *echo.Echo) { - //templates + // templates e.POST("/templates", r.templateHandler.PostTemplate()) e.POST("/tenants/:tenant_id/messages", r.messageHandler.PostMessage()) } diff --git a/provider/jira/client.go b/provider/jira/client.go index bb59c04..47c50b3 100644 --- a/provider/jira/client.go +++ b/provider/jira/client.go @@ -11,8 +11,10 @@ import ( "github.com/deepsourcelabs/hermes/provider" ) -const postIssueURL = "https://api.atlassian.com/ex/jira/%s/rest/api/3/issue" -const accessibleResourcesURL = "https://api.atlassian.com/oauth/token/accessible-resources" +const ( + postIssueURL = "https://api.atlassian.com/ex/jira/%s/rest/api/3/issue" + accessibleResourcesURL = "https://api.atlassian.com/oauth/token/accessible-resources" +) type Client struct { HTTPClient provider.IHTTPClient @@ -67,7 +69,7 @@ func (c *Client) CreateIssue(request *CreateIssueRequest) (*CreateIssueResponse, return nil, handleHTTPFailure(resp) } - var response = new(CreateIssueResponse) + response := new(CreateIssueResponse) if err := json.NewDecoder(resp.Body).Decode(response); err != nil { return nil, errFailedPermenant("success but failed to parse response body") } @@ -105,7 +107,7 @@ func (c *Client) GetAccessibleResources(request *AccessibleResourcesRequest) (*A return nil, handleHTTPFailure(resp) } - var response = new(AccessibleResourcesResponse) + response := new(AccessibleResourcesResponse) if err := json.NewDecoder(resp.Body).Decode(response); err != nil { return nil, errFailedPermenant("success but failed to parse response body") } diff --git a/provider/jira/error.go b/provider/jira/error.go index 2f57757..71c29ff 100644 --- a/provider/jira/error.go +++ b/provider/jira/error.go @@ -19,18 +19,23 @@ func NewErr(statusCode int, systemCode, message, internal string, isFatal bool) isFatal: isFatal, } } + func (e *jiraError) Message() string { return e.message } + func (e *jiraError) IsFatal() bool { return e.isFatal } + func (e *jiraError) StatusCode() int { return e.statusCode } + func (e *jiraError) Error() string { return e.internal } + func (e *jiraError) SystemCode() string { return e.systemCode } diff --git a/provider/jira/jira.go b/provider/jira/jira.go index f0084e5..b783c8c 100644 --- a/provider/jira/jira.go +++ b/provider/jira/jira.go @@ -25,7 +25,7 @@ func NewJIRAProvider(httpClient *http.Client) provider.Provider { func (p *jiraSimple) Send(_ context.Context, notifier *domain.Notifier, body []byte) (*domain.Message, domain.IError) { // Extract and validate the payload. - var payload = new(Payload) + payload := new(Payload) if err := payload.Extract(body); err != nil { return nil, err } @@ -34,7 +34,7 @@ func (p *jiraSimple) Send(_ context.Context, notifier *domain.Notifier, body []b } // Extract and validate the configuration. - var opts = new(Opts) + opts := new(Opts) if err := opts.Extract(notifier.Config); err != nil { return nil, err } @@ -67,8 +67,8 @@ func (p *jiraSimple) Send(_ context.Context, notifier *domain.Notifier, body []b }, nil } -func (p *jiraSimple) GetOptValues(context.Context, *domain.NotifierSecret) (*map[string]interface{}, error) { - return &map[string]interface{}{}, nil +func (p *jiraSimple) GetOptValues(context.Context, *domain.NotifierSecret) (map[string]interface{}, error) { + return map[string]interface{}{}, nil } // Payload defines the primary content payload for the JIRA provider. @@ -111,7 +111,7 @@ type Opts struct { func (o *Opts) Extract(c *domain.NotifierConfiguration) domain.IError { if c == nil { - return errFailedOptsValidation("notifier config emtpy") + return errFailedOptsValidation("notifier config empty") } if err := mapstructure.Decode(c.Opts, o); err != nil { return errFailedOptsValidation("failed to decode configuration") @@ -127,7 +127,7 @@ func (o *Opts) Validate() domain.IError { return errFailedOptsValidation("options empty") } if o.IssueType == "" || o.ProjectKey == "" { - return errFailedOptsValidation("issue_type or project_key is emtpy") + return errFailedOptsValidation("issue_type or project_key is empty") } if o.Secret == nil || o.Secret.Token == "" { diff --git a/provider/jira/jira_test.go b/provider/jira/jira_test.go index b18d4bb..c81c6d1 100644 --- a/provider/jira/jira_test.go +++ b/provider/jira/jira_test.go @@ -13,9 +13,9 @@ import ( "github.com/deepsourcelabs/hermes/provider" ) -type mockHttp struct{} +type mockHTTP struct{} -func (*mockHttp) Do(_ *http.Request) (*http.Response, error) { +func (*mockHTTP) Do(_ *http.Request) (*http.Response, error) { return &http.Response{ Body: io.NopCloser(bytes.NewReader([]byte("{\"ok\":true}"))), StatusCode: http.StatusOK, @@ -28,16 +28,17 @@ func (*errHTTP) Do(_ *http.Request) (*http.Response, error) { return nil, errors.New("test") } -func Test_jiraSimple_Send(t *testing.T) { - +func TestJIRASimpleSend(t *testing.T) { type fields struct { httpClient provider.IHTTPClient } + type args struct { ctx context.Context notifier *domain.Notifier body []byte } + tests := []struct { name string fields fields @@ -48,7 +49,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "valid request", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -67,7 +68,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "no project_key", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -86,7 +87,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "no issue_type", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -105,7 +106,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "no summary in body", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -124,7 +125,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "no secret in config", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -143,7 +144,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "config not set", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -157,7 +158,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "opts not set", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -171,7 +172,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "no secret in config", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -190,7 +191,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "token not set", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -209,7 +210,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "body empty", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -228,7 +229,7 @@ func Test_jiraSimple_Send(t *testing.T) { { name: "no description in body", fields: fields{ - httpClient: new(mockHttp), + httpClient: new(mockHTTP), }, args: args{ ctx: context.Background(), @@ -286,7 +287,7 @@ func Test_jiraSimple_Send(t *testing.T) { } func TestOpts_Extract(t *testing.T) { - var got = new(Opts) + got := new(Opts) secret := &domain.NotifierSecret{Token: "token"} want := &Opts{ ProjectKey: "abc", diff --git a/provider/provider.go b/provider/provider.go index 7af07e1..b9dce5a 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -9,7 +9,7 @@ import ( type Provider interface { Send(context.Context, *domain.Notifier, []byte) (*domain.Message, domain.IError) - GetOptValues(context.Context, *domain.NotifierSecret) (*map[string]interface{}, error) + GetOptValues(context.Context, *domain.NotifierSecret) (map[string]interface{}, error) } type IHTTPClient interface { diff --git a/provider/slack/client.go b/provider/slack/client.go index a131893..f0cf832 100644 --- a/provider/slack/client.go +++ b/provider/slack/client.go @@ -53,7 +53,7 @@ func (c *Client) SendMessage(request *SendMessageRequest) (*SendMessageResponse, return nil, handleHTTPFailure(resp) } - var response = new(SendMessageResponse) + response := new(SendMessageResponse) if err := json.NewDecoder(resp.Body).Decode(response); err != nil { return nil, errFailedSendPermanent(err.Error()) } @@ -108,7 +108,7 @@ func (c *Client) GetChannels(request *GetChannelsRequest) (*GetChannelsResponse, return nil, handleHTTPFailure(resp) } - var response = new(GetChannelsResponse) + response := new(GetChannelsResponse) if err := json.NewDecoder(resp.Body).Decode(response); err != nil { return nil, errFailedOptsFetch(err.Error()) } diff --git a/provider/slack/error.go b/provider/slack/error.go index 8a50fed..77dbf03 100644 --- a/provider/slack/error.go +++ b/provider/slack/error.go @@ -23,15 +23,19 @@ func NewErr(statusCode int, systemCode, message, internal string, isFatal bool) func (e *slackError) Message() string { return e.message } + func (e *slackError) IsFatal() bool { return e.isFatal } + func (e *slackError) StatusCode() int { return e.statusCode } + func (e *slackError) Error() string { return e.internal } + func (e *slackError) SystemCode() string { return e.systemCode } diff --git a/provider/slack/slack.go b/provider/slack/slack.go index 19f1d37..29889bf 100644 --- a/provider/slack/slack.go +++ b/provider/slack/slack.go @@ -24,7 +24,7 @@ func NewSlackProvider(httpClient provider.IHTTPClient) provider.Provider { func (p *defaultSlack) Send(_ context.Context, notifier *domain.Notifier, body []byte) (*domain.Message, domain.IError) { // Extract and validate the payload. - var payload = new(Payload) + payload := new(Payload) if err := payload.Extract(body); err != nil { return nil, err } @@ -33,7 +33,7 @@ func (p *defaultSlack) Send(_ context.Context, notifier *domain.Notifier, body [ } // Extract and validate the configuration. - var opts = new(Opts) + opts := new(Opts) if err := opts.Extract(notifier.Config); err != nil { return nil, err } @@ -69,7 +69,7 @@ type Opts struct { func (o *Opts) Extract(c *domain.NotifierConfiguration) domain.IError { if c == nil { - return errFailedOptsValidation("notifier config emtpy") + return errFailedOptsValidation("notifier config empty") } if err := mapstructure.Decode(c.Opts, o); err != nil { return errFailedOptsValidation("failed to decode configuration") @@ -83,7 +83,7 @@ func (o *Opts) Validate() domain.IError { return errFailedOptsValidation("secret not defined in configuration") } if o.Channel == "" { - return errFailedOptsValidation("channel is emtpy") + return errFailedOptsValidation("channel is empty") } return nil } @@ -107,7 +107,7 @@ func (p *Payload) Validate() domain.IError { return nil } -func (p *defaultSlack) GetOptValues(_ context.Context, secret *domain.NotifierSecret) (*map[string]interface{}, error) { +func (p *defaultSlack) GetOptValues(_ context.Context, secret *domain.NotifierSecret) (map[string]interface{}, error) { request := &GetChannelsRequest{ BearerToken: secret.Token, } @@ -124,5 +124,5 @@ func (p *defaultSlack) GetOptValues(_ context.Context, secret *domain.NotifierSe "name": v.Name, }) } - return &map[string]interface{}{"channel": channels}, nil + return map[string]interface{}{"channel": channels}, nil } diff --git a/service/error.go b/service/error.go index 1fe688d..442e9ed 100644 --- a/service/error.go +++ b/service/error.go @@ -21,18 +21,23 @@ func NewErr(statusCode int, systemCode, message, internal string, isFatal bool) isFatal: isFatal, } } + func (e *serviceError) Message() string { return e.message } + func (e *serviceError) IsFatal() bool { return e.isFatal } + func (e *serviceError) StatusCode() int { return e.statusCode } + func (e *serviceError) Error() string { return e.message } + func (e *serviceError) SystemCode() string { return e.systemCode } diff --git a/service/message.go b/service/message.go index e56632c..b294091 100644 --- a/service/message.go +++ b/service/message.go @@ -21,8 +21,8 @@ func NewMessageService(templateRepository domain.TemplateRepository) MessageServ } type SendMessageRequest struct { - TenantID string `param:"tenant_id"` - Payload *map[string]interface{} `json:"payload"` + TenantID string `param:"tenant_id"` + Payload map[string]interface{} `json:"payload"` Recipients []struct { Notifier *domain.Notifier `json:"notifier"` Template *domain.Template `json:"template"` @@ -109,7 +109,7 @@ func (service *messageService) getTemplate( } func (*messageService) getBody( - _ context.Context, t *domain.Template, payload *map[string]interface{}, + _ context.Context, t *domain.Template, payload map[string]interface{}, ) ([]byte, domain.IError) { templater := t.GetTemplater() body, err := templater.Execute(t.Pattern, payload) diff --git a/service/provider.go b/service/provider.go index 7718e31..80fabfd 100644 --- a/service/provider.go +++ b/service/provider.go @@ -20,8 +20,8 @@ type GetProviderReqeuest struct { } type GetProviderResponse struct { - Type string `json:"type"` - Values *map[string]interface{} `json:"values"` + Type string `json:"type"` + Values map[string]interface{} `json:"values"` } type providerService struct{} @@ -30,7 +30,7 @@ func NewProviderService() ProviderService { return &providerService{} } -func (service *providerService) GetProvider(ctx context.Context, request *GetProviderReqeuest) (*GetProviderResponse, domain.IError) { +func (*providerService) GetProvider(ctx context.Context, request *GetProviderReqeuest) (*GetProviderResponse, domain.IError) { provider := newProvider(request.Type) response, err := provider.GetOptValues(ctx, &domain.NotifierSecret{Token: request.Token}) if err != nil { diff --git a/storage/config/error.go b/storage/config/error.go index 984bf01..ac46fd8 100644 --- a/storage/config/error.go +++ b/storage/config/error.go @@ -10,7 +10,7 @@ type cfgError struct { isFatal bool } -func NewErr(statusCode int, systemCode string, message string, internal string, isFatal bool) domain.IError { +func NewErr(statusCode int, systemCode, message, internal string, isFatal bool) domain.IError { return &cfgError{ message: message, statusCode: statusCode, @@ -19,24 +19,27 @@ func NewErr(statusCode int, systemCode string, message string, internal string, isFatal: isFatal, } } + func (e *cfgError) Message() string { return e.message } + func (e *cfgError) IsFatal() bool { return e.isFatal } + func (e *cfgError) StatusCode() int { return e.statusCode } + func (e *cfgError) Error() string { return e.internal } + func (e *cfgError) SystemCode() string { return e.systemCode } -var ( - errDBErr = func(internal string) domain.IError { - return NewErr(500, "HE-STO-50010", "something went wrong", internal, true) - } -) +var errDBErr = func(internal string) domain.IError { + return NewErr(500, "HE-STO-50010", "something went wrong", internal, true) +} diff --git a/storage/config/template.go b/storage/config/template.go index 3e883e5..ee3b135 100644 --- a/storage/config/template.go +++ b/storage/config/template.go @@ -26,9 +26,10 @@ func (store *templateStore) Create(ctx context.Context, tmpl *domain.Template) d } func (store *templateStore) GetByID(ctx context.Context, id string) (*domain.Template, domain.IError) { - var t = new(config.Template) + t := new(config.Template) for _, v := range store.cfg.Templates { + v := v if v.ID == id { t = &v break diff --git a/storage/sql/error.go b/storage/sql/error.go index 9d4c59b..3a23aa4 100644 --- a/storage/sql/error.go +++ b/storage/sql/error.go @@ -10,7 +10,7 @@ type sqlError struct { isFatal bool } -func NewErr(statusCode int, systemCode string, message string, internal string, isFatal bool) domain.IError { +func NewErr(statusCode int, systemCode, message, internal string, isFatal bool) domain.IError { return &sqlError{ message: message, statusCode: statusCode, @@ -19,24 +19,27 @@ func NewErr(statusCode int, systemCode string, message string, internal string, isFatal: isFatal, } } + func (e *sqlError) Message() string { return e.message } + func (e *sqlError) IsFatal() bool { return e.isFatal } + func (e *sqlError) StatusCode() int { return e.statusCode } + func (e *sqlError) Error() string { return e.internal } + func (e *sqlError) SystemCode() string { return e.systemCode } -var ( - errDBErr = func(internal string) domain.IError { - return NewErr(500, "HE-STO-50010", "something went wrong", internal, true) - } -) +var errDBErr = func(internal string) domain.IError { + return NewErr(500, "HE-STO-50010", "something went wrong", internal, true) +} diff --git a/templater/go.go b/templater/go.go index 6238ba7..64ff547 100644 --- a/templater/go.go +++ b/templater/go.go @@ -15,7 +15,6 @@ func (*Go) Execute(pattern string, params interface{}) ([]byte, error) { "pluralWord": PluralWord, "truncateQuantity": TruncateQuantity, }).Parse(pattern) - if err != nil { return nil, err } diff --git a/templater/humanize.go b/templater/humanize.go index 6669a72..636381a 100644 --- a/templater/humanize.go +++ b/templater/humanize.go @@ -52,7 +52,7 @@ func Duration(seconds float64) string { } func Plural(quantity float64, singular, plural string) string { - var suffix = PluralWord(quantity, singular, plural) + suffix := PluralWord(quantity, singular, plural) return fmt.Sprintf("%d %s", int(quantity), suffix) } diff --git a/templater/humanize_test.go b/templater/humanize_test.go index 9ce095c..4015deb 100644 --- a/templater/humanize_test.go +++ b/templater/humanize_test.go @@ -112,6 +112,7 @@ func TestDuration(t *testing.T) { }) } } + func TestPlural(t *testing.T) { type args struct { quantity float64 @@ -142,6 +143,7 @@ func TestPlural(t *testing.T) { }) } } + func TestPluralWord(t *testing.T) { type args struct { quantity float64 @@ -172,6 +174,7 @@ func TestPluralWord(t *testing.T) { }) } } + func TestTruncateQuantity(t *testing.T) { type args struct { quantity float64