Skip to content

Commit

Permalink
Updated all dependencies; fixed incompatibilties.
Browse files Browse the repository at this point in the history
  • Loading branch information
adewes committed Dec 13, 2021
1 parent c779196 commit e3772c3
Show file tree
Hide file tree
Showing 26 changed files with 245 additions and 201 deletions.
7 changes: 5 additions & 2 deletions cmd/helpers/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ func Decorate(commands []cli.Command, decorator Decorator, service string) []cli
}

func Settings(definitions *eps.Definitions) (*eps.Settings, error) {
settingsPaths := helpers.SettingsPaths()
return helpers.Settings(settingsPaths, definitions)
if settingsPaths, fs, err := helpers.SettingsPaths("EPS_SETTINGS"); err != nil {
return nil, err
} else {
return helpers.Settings(settingsPaths, fs, definitions)
}
}

var CommonCommands = []cli.Command{
Expand Down
8 changes: 6 additions & 2 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"github.com/iris-connect/eps"
cmdHelpers "github.com/iris-connect/eps/cmd/helpers"
"github.com/iris-connect/eps/definitions"
"github.com/iris-connect/eps/helpers"
"github.com/iris-connect/eps/metrics"
"github.com/iris-connect/eps/proxy"
"github.com/iris-connect/eps/proxy/helpers"
proxyHelpers "github.com/iris-connect/eps/proxy/helpers"
"github.com/urfave/cli"
"os"
"os/signal"
Expand Down Expand Up @@ -150,7 +151,10 @@ func CLI(settings *proxy.Settings) {
}

func main() {
if settings, err := helpers.Settings(helpers.SettingsPaths(), &definitions.Default); err != nil {
if settingsPaths, fs, err := helpers.SettingsPaths("PROXY_SETTINGS"); err != nil {
eps.Log.Error(err)
return
} else if settings, err := proxyHelpers.Settings(settingsPaths, fs, &definitions.Default); err != nil {
eps.Log.Error(err)
return
} else {
Expand Down
8 changes: 6 additions & 2 deletions cmd/sd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"github.com/iris-connect/eps"
cmdHelpers "github.com/iris-connect/eps/cmd/helpers"
"github.com/iris-connect/eps/definitions"
"github.com/iris-connect/eps/helpers"
"github.com/iris-connect/eps/metrics"
"github.com/iris-connect/eps/sd"
"github.com/iris-connect/eps/sd/helpers"
sdHelpers "github.com/iris-connect/eps/sd/helpers"
"github.com/urfave/cli"
"os"
"os/signal"
Expand Down Expand Up @@ -93,7 +94,10 @@ func CLI(settings *sd.Settings) {
}

func main() {
if settings, err := helpers.Settings(helpers.SettingsPaths(), &definitions.Default); err != nil {
if settingsPaths, fs, err := helpers.SettingsPaths("SD_SETTINGS"); err != nil {
eps.Log.Error(err)
return
} else if settings, err := sdHelpers.Settings(settingsPaths, fs, &definitions.Default); err != nil {
eps.Log.Error(err)
return
} else {
Expand Down
2 changes: 1 addition & 1 deletion forms/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ var SignedChangeRecordForm = forms.Form{
forms.IsOptional{Default: ""},
forms.IsString{},
forms.MatchesRegex{
Regex: regexp.MustCompile(`^([a-f0-9]{64}|)$`),
Regexp: regexp.MustCompile(`^([a-f0-9]{64}|)$`),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions forms/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var SignatureForm = forms.Form{
Validators: []forms.Validator{
forms.IsString{},
forms.MatchesRegex{
Regex: regexp.MustCompile(`^\d{10,100}$`),
Regexp: regexp.MustCompile(`^\d{10,100}$`),
},
},
},
Expand All @@ -54,7 +54,7 @@ var SignatureForm = forms.Form{
Validators: []forms.Validator{
forms.IsString{},
forms.MatchesRegex{
Regex: regexp.MustCompile(`^\d{10,100}$`),
Regexp: regexp.MustCompile(`^\d{10,100}$`),
},
},
},
Expand Down
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ module github.com/iris-connect/eps
go 1.16

require (
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/go-redis/redis v6.15.9+incompatible
github.com/golang/protobuf v1.5.2
github.com/kiprotect/go-helpers v0.0.0-20210719141457-5b87e3cc7847
github.com/kiprotect/go-helpers v0.0.0-20211210144244-79ce90e73e79
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.17.0 // indirect
github.com/prometheus/client_golang v1.11.0
github.com/protocolbuffers/protobuf v3.15.8+incompatible // indirect
github.com/sirupsen/logrus v1.8.1
github.com/urfave/cli v1.22.5
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
google.golang.org/grpc v1.37.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 // indirect
google.golang.org/protobuf v1.26.0
)

Expand Down
72 changes: 58 additions & 14 deletions go.sum

Large diffs are not rendered by default.

32 changes: 23 additions & 9 deletions helpers/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,44 @@ import (
epsForms "github.com/iris-connect/eps/forms"
"github.com/kiprotect/go-helpers/forms"
"github.com/kiprotect/go-helpers/settings"
"io/fs"
"os"
"path/filepath"
"strings"
)

var EnvSettingsName = "EPS_SETTINGS"

func SettingsPaths() []string {
envValue := os.Getenv(EnvSettingsName)
if envValue == "" {
return []string{}
func SettingsPaths(envSettingsName string) ([]string, fs.FS, error) {
if paths, err := RealSettingsPaths(envSettingsName); err != nil {
return nil, nil, err
} else {
modifiedPaths := make([]string, len(paths))
for i, path := range paths {
modifiedPaths[i] = path[1:]
}
return modifiedPaths, os.DirFS("/"), nil
}
}

func RealSettingsPaths(envSettingsName string) ([]string, error) {
envValue := os.Getenv(envSettingsName)
values := strings.Split(envValue, ":")
sanitizedValues := make([]string, 0, len(values))
for _, value := range values {
if value == "" {
continue
}
var err error
if value, err = filepath.Abs(value); err != nil {
return nil, err
}
sanitizedValues = append(sanitizedValues, value)
}
return sanitizedValues
return sanitizedValues, nil
}

func Settings(settingsPaths []string, definitions *eps.Definitions) (*eps.Settings, error) {
if rawSettings, err := settings.MakeSettings(settingsPaths); err != nil {
func Settings(settingsPaths []string, fs fs.FS, definitions *eps.Definitions) (*eps.Settings, error) {
eps.Log.Info(settingsPaths)
if rawSettings, err := settings.MakeSettings(settingsPaths, fs); err != nil {
return nil, err
} else if params, err := epsForms.SettingsForm.ValidateWithContext(rawSettings.Values, map[string]interface{}{"definitions": definitions}); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion proxy/forms.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var DirectorySettingsForm = forms.Form{
forms.IsList{
Validators: []forms.Validator{
forms.IsString{},
forms.MatchesRegex{Regex: regexp.MustCompile(`^\.`)},
forms.MatchesRegex{Regexp: regexp.MustCompile(`^\.`)},
},
},
},
Expand Down
25 changes: 3 additions & 22 deletions proxy/helpers/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,11 @@ import (
"github.com/iris-connect/eps"
"github.com/iris-connect/eps/proxy"
"github.com/kiprotect/go-helpers/settings"
"os"
"strings"
"io/fs"
)

var EnvSettingsName = "PROXY_SETTINGS"

func SettingsPaths() []string {
envValue := os.Getenv(EnvSettingsName)
if envValue == "" {
return []string{}
}
values := strings.Split(envValue, ":")
sanitizedValues := make([]string, 0, len(values))
for _, value := range values {
if value == "" {
continue
}
sanitizedValues = append(sanitizedValues, value)
}
return sanitizedValues
}

func Settings(settingsPaths []string, definitions *eps.Definitions) (*proxy.Settings, error) {
if rawSettings, err := settings.MakeSettings(settingsPaths); err != nil {
func Settings(settingsPaths []string, fs fs.FS, definitions *eps.Definitions) (*proxy.Settings, error) {
if rawSettings, err := settings.MakeSettings(settingsPaths, fs); err != nil {
return nil, err
} else if params, err := proxy.SettingsForm.ValidateWithContext(rawSettings.Values, map[string]interface{}{"definitions": definitions}); err != nil {
return nil, err
Expand Down
26 changes: 3 additions & 23 deletions sd/helpers/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,11 @@ import (
"github.com/iris-connect/eps"
"github.com/iris-connect/eps/sd"
"github.com/kiprotect/go-helpers/settings"
"os"
"strings"
"io/fs"
)

var EnvSettingsName = "SD_SETTINGS"

func SettingsPaths() []string {
envValue := os.Getenv(EnvSettingsName)
if envValue == "" {
return []string{}
}
values := strings.Split(envValue, ":")
sanitizedValues := make([]string, 0, len(values))
for _, value := range values {
if value == "" {
continue
}
sanitizedValues = append(sanitizedValues, value)
}
return sanitizedValues
}

func Settings(settingsPaths []string, definitions *eps.Definitions) (*sd.Settings, error) {

if rawSettings, err := settings.MakeSettings(settingsPaths); err != nil {
func Settings(settingsPaths []string, fs fs.FS, definitions *eps.Definitions) (*sd.Settings, error) {
if rawSettings, err := settings.MakeSettings(settingsPaths, fs); err != nil {
return nil, err
} else if params, err := sd.SettingsForm.ValidateWithContext(rawSettings.Values, map[string]interface{}{"definitions": definitions}); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion sd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ var GetRecordsForm = forms.Form{
forms.IsOptional{Default: ""},
forms.IsString{},
forms.MatchesRegex{
Regex: regexp.MustCompile(`^([a-f0-9]{64}|)$`),
Regexp: regexp.MustCompile(`^([a-f0-9]{64}|)$`),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package eps

type DatastoreSettings struct {
Type string `json:"type"`
Type string `json:"type"`
Settings interface{} `json:"settings"`
}

Expand Down
20 changes: 10 additions & 10 deletions settings/dev/001_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ vars:
directory:
type: json
settings:
path: "$DIR/directory.json"
path: "/$DIR/directory.json"
channels: # defines all the channels that we want to open when starting the server
- name: Stdout channel
type: stdout
Expand All @@ -17,26 +17,26 @@ channels: # defines all the channels that we want to open when starting the serv
settings:
bind_address: "localhost:4444"
tls:
ca_certificate_files: ["$DIR/certs/root.crt"]
certificate_file: "$DIR/certs/$OP.crt"
key_file: "$DIR/certs/$OP.key"
ca_certificate_files: ["/$DIR/certs/root.crt"]
certificate_file: "/$DIR/certs/$OP.crt"
key_file: "/$DIR/certs/$OP.key"
- name: main gRPC client # creates outgoing gRPC connections to deliver and receive messages
type: grpc_client
settings:
tls:
ca_certificate_files: ["$DIR/certs/root.crt"]
certificate_file: "$DIR/certs/$OP.crt"
key_file: "$DIR/certs/$OP.key"
ca_certificate_files: ["/$DIR/certs/root.crt"]
certificate_file: "/$DIR/certs/$OP.crt"
key_file: "/$DIR/certs/$OP.key"
- name: main JSON-RPC server # accepts incoming JSONRPC connections to deliver and receive messages
type: jsonrpc_server
settings:
bind_address: "localhost:5555"
cors:
allowed_hosts: ["^http(?:s)?://localhost\\:\\d+$"]
tls:
ca_certificate_files: ["$DIR/certs/root.crt"]
certificate_file: "$DIR/certs/$OP.crt"
key_file: "$DIR/certs/$OP.key"
ca_certificate_files: ["/$DIR/certs/root.crt"]
certificate_file: "/$DIR/certs/$OP.crt"
key_file: "/$DIR/certs/$OP.key"
- name: main JSON-RPC client # creates outgoing JSONRPC connections to deliver and receive messages
type: jsonrpc_client
settings:
Expand Down
32 changes: 16 additions & 16 deletions settings/dev/roles/hd-1/001_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ directory:
# to use the JSON directory, uncomment this and comment everything below...
# type: json
# settings:
# path: "$DIR/../../directory"
# path: "/$DIR/../../directory"
type: api
settings:
jsonrpc_client:
tls:
certificate_file: "$DIR/../../certs/hd-1.crt"
key_file: "$DIR/../../certs/hd-1.key"
ca_certificate_files: ["$DIR/../../certs/root.crt"]
ca_certificate_files: ["$DIR/../../certs/root.crt"]
ca_intermediate_certificate_files: ["$DIR/../../certs/intermediate.crt"]
certificate_file: "/$DIR/../../certs/hd-1.crt"
key_file: "/$DIR/../../certs/hd-1.key"
ca_certificate_files: ["/$DIR/../../certs/root.crt"]
ca_certificate_files: ["/$DIR/../../certs/root.crt"]
ca_intermediate_certificate_files: ["/$DIR/../../certs/intermediate.crt"]
endpoints: ["https://localhost:3322/jsonrpc"]
server_names: ["sd-1"]
channels: # defines all the channels that we want to open when starting the server
Expand All @@ -26,21 +26,21 @@ channels: # defines all the channels that we want to open when starting the serv
type: grpc_client
settings:
tls:
ca_certificate_files: ["$DIR/../../certs/root.crt"]
certificate_file: "$DIR/../../certs/hd-1.crt"
key_file: "$DIR/../../certs/hd-1.key"
ca_certificate_files: ["/$DIR/../../certs/root.crt"]
certificate_file: "/$DIR/../../certs/hd-1.crt"
key_file: "/$DIR/../../certs/hd-1.key"
- name: main JSON-RPC server # accepts incoming JSONRPC connections to deliver and receive messages
type: jsonrpc_server
settings:
bind_address: "localhost:5555"
cors:
allowed_hosts: ["^http(?:s)?://localhost\\:\\d+$"]
tls:
ca_certificate_files: ["$DIR/../../certs/root.crt"]
certificate_file: "$DIR/../../certs/hd-1.crt"
key_file: "$DIR/../../certs/hd-1.key"
ca_certificate_files: ["/$DIR/../../certs/root.crt"]
certificate_file: "/$DIR/../../certs/hd-1.crt"
key_file: "/$DIR/../../certs/hd-1.key"
signing:
certificate_file: "$DIR/../../certs/hd-1-sign.crt"
key_file: "$DIR/../../certs/hd-1-sign.key"
ca_certificate_file: "$DIR/../../certs/root.crt"
ca_intermediate_certificate_files: ["$DIR/../../certs/intermediate.crt"]
certificate_file: "/$DIR/../../certs/hd-1-sign.crt"
key_file: "/$DIR/../../certs/hd-1-sign.key"
ca_certificate_file: "/$DIR/../../certs/root.crt"
ca_intermediate_certificate_files: ["/$DIR/../../certs/intermediate.crt"]
Loading

0 comments on commit e3772c3

Please sign in to comment.