Switching to modules, removed vendored dependencies, linting with golangci-lint.

This commit is contained in:
2019-12-15 22:17:01 +05:00
parent d33062598e
commit 6b519c31a0
859 changed files with 315 additions and 336708 deletions

View File

@@ -26,10 +26,10 @@ import (
"strings"
// local
"gitlab.com/pztrn/opensaps/config/struct"
configstruct "go.dev.pztrn.name/opensaps/config/struct"
// other
"gitlab.com/pztrn/flagger"
"go.dev.pztrn.name/flagger"
"gopkg.in/yaml.v2"
)
@@ -55,6 +55,7 @@ func (conf Configuration) GetTempValue(key string) (string, error) {
if err != nil {
c.Log.Fatalln("Failed to get current user data: " + err.Error())
}
value = strings.Replace(value, "~", usr.HomeDir, 1)
}
@@ -66,14 +67,14 @@ func (conf Configuration) Initialize() {
tempconfig = make(map[string]string)
flag_configpath := flagger.Flag{
flagConfigpath := flagger.Flag{
Name: "config",
Description: "Path to configuration file.",
Type: "string",
DefaultValue: "~/.config/OpenSAPS/config.yaml",
}
c.Flagger.AddFlag(&flag_configpath)
_ = c.Flagger.AddFlag(&flagConfigpath)
}
// Initializes configuration root path for later usage.
@@ -103,20 +104,22 @@ func (conf Configuration) LoadConfigurationFromFile() {
if err != nil {
c.Log.Fatalln("Failed to get configuration file path from internal temporary configuration storage! OpenSAPS is BROKEN!")
}
c.Log.Infof("Loading configuration from '%s'...", configpath)
// Read file into memory.
config_bytes, err1 := ioutil.ReadFile(configpath)
configBytes, err1 := ioutil.ReadFile(configpath)
if err1 != nil {
c.Log.Fatalf("Error occured while reading configuration file: %s", err1.Error())
c.Log.Fatalf("Error occurred while reading configuration file: %s", err1.Error())
}
config = &configstruct.ConfigStruct{}
// Parse YAML.
err2 := yaml.Unmarshal(config_bytes, config)
err2 := yaml.Unmarshal(configBytes, config)
if err2 != nil {
c.Log.Fatalf("Failed to parse configuration file: %s", err2.Error())
}
c.Log.Debugln("Loaded configuration:", fmt.Sprintf("%+v", config))
}

View File

@@ -19,9 +19,9 @@ package config
import (
// local
"gitlab.com/pztrn/opensaps/config/interface"
"gitlab.com/pztrn/opensaps/config/struct"
"gitlab.com/pztrn/opensaps/context"
configurationinterface "go.dev.pztrn.name/opensaps/config/interface"
configstruct "go.dev.pztrn.name/opensaps/config/struct"
"go.dev.pztrn.name/opensaps/context"
)
var (

View File

@@ -19,7 +19,7 @@ package configurationinterface
import (
// local
"gitlab.com/pztrn/opensaps/config/struct"
configstruct "go.dev.pztrn.name/opensaps/config/struct"
)
type ConfigurationInterface interface {

View File

@@ -54,7 +54,7 @@ type ConfigWebhookRemote struct {
// Matrix pusher configuration.
type ConfigMatrix struct {
ApiRoot string `yaml:"api_root"`
APIRoot string `yaml:"api_root"`
User string `yaml:"user"`
Password string `yaml:"password"`
Room string `yaml:"room"`