Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make general improvements and fix a couple of bugs #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ 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"
"github.com/labstack/echo/v4/middleware"
)

func main() {

var isStateless = flag.Bool("stateless", true, "-stateless")
isStateless := flag.Bool("stateless", true, "-stateless")

flag.Parse()

Expand Down
2 changes: 1 addition & 1 deletion cmd/server/stateful.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/stateless.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion config/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions config/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
}

})
}
17 changes: 10 additions & 7 deletions config/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with other receivers.

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 {
Expand Down Expand Up @@ -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
}
1 change: 0 additions & 1 deletion config/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func TestTemplateConfig_ReadYAML(t *testing.T) {
t.Errorf("TemplateConfig.ReadYAML() unexpected error = %v,", err)
}
})

}

func TestInitTemplateConfig(t *testing.T) {
Expand Down
38 changes: 19 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ module github.com/deepsourcelabs/hermes
go 1.17
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated modules


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 (
Expand All @@ -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
)
Loading