giredore/internal/configuration/envconfig.go
Stanislav N. aka pztrn 6ce7747dd5
Working with packages and allowed IPs.
giredorectl now able to interact with giredored about:

* Setting package data. There is no such thing as "create" or "update",
just set.

* Deleting package data.

* Setting allowed IP addresses. This is the only authorization method
ATM, more may come in future.
2019-10-07 18:21:26 +05:00

34 lines
1.0 KiB
Go

package configuration
import (
// other
"github.com/vrischmann/envconfig"
)
// This structure represents configuration that will be parsed via
// environment variables. This configuration has higher priority
// than configuration loaded from file.
type envConfig struct {
// DataDir is a directory where giredore will store it's data
// like dynamic configuration file.
DataDir string `envconfig:"default=/var/lib/giredore"`
// HTTP describes HTTP server configuration.
HTTP struct {
// Listen is an address on which HTTP server will listen.
Listen string `envconfig:"default=127.0.0.1:62222"`
// WaitForSeconds is a timeout during which we will wait for
// HTTP server be up. If timeout will pass and HTTP server won't
// start processing requests - giredore will exit.
WaitForSeconds int `envconfig:"default=10"`
}
}
// Initialize parses environment variables into structure.
func (cf *envConfig) Initialize() {
log.Info().Msg("Loading configuration...")
_ = envconfig.Init(cf)
log.Info().Msgf("Environment parsed: %+v", cf)
}