Adam Štrauch
69e46f577a
All checks were successful
continuous-integration/drone/push Build is passing
39 lines
1.9 KiB
Go
39 lines
1.9 KiB
Go
package common
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/kelseyhightower/envconfig"
|
|
)
|
|
|
|
// Config keeps info about configuration of this daemon
|
|
type Config struct {
|
|
DockerSocket string `envconfig:"DOCKER_SOCKET" default:"unix:///var/run/docker.sock"`
|
|
Token string `envconfig:"TOKEN" required:"true"`
|
|
AppsPath string `envconfig:"APPS_PATH" default:"/srv"` // Where applications are located
|
|
AppsBindIPHTTP string `envconfig:"APPS_BIND_IP_HTTP" default:"0.0.0.0"` // On what IP apps' HTTP port gonna be bound
|
|
AppsBindIPSSH string `envconfig:"APPS_BIND_IP_SSH" default:"0.0.0.0"` // On what IP apps' SSH ports gonna be bound
|
|
NATSURL string `envconfig:"NATS_URL" required:"true"`
|
|
NATSAlias string `envconfig:"NATS_ALIAS" required:"true"` // name/alias of the instance, ex. node-18
|
|
DatabasePath string `envconfig:"DATABASE_PATH" default:"/var/lib/node-api/rosti.db"`
|
|
SnapshotsPath string `envconfig:"SNAPSHOTS_PATH" default:"/mnt/apps/snapshots"` // snapshots path
|
|
SnapshotsS3AccessKey string `envconfig:"SNAPSHOTS_S3_ACCESS_KEY" required:"false"`
|
|
SnapshotsS3SecretKey string `envconfig:"SNAPSHOTS_S3_SECRET_KEY" required:"false"`
|
|
SnapshotsS3Endpoint string `envconfig:"SNAPSHOTS_S3_ENDPOINT" required:"false"`
|
|
SnapshotsS3SSL bool `envconfig:"SNAPSHOTS_S3_SSL" required:"false" default:"true"`
|
|
SnapshotsS3Bucket string `envconfig:"SNAPSHOTS_S3_BUCKET" required:"false" default:"snapshots"`
|
|
SnapshotsIndexLabel string `envconfig:"SNAPSHOTS_INDEX_LABEL" required:"false" default:"owner_id"` // Label that will be part of the object name and it will be used as index to quick listing
|
|
}
|
|
|
|
// GetConfig return configuration created based on environment variables
|
|
func GetConfig() *Config {
|
|
var config Config
|
|
|
|
err := envconfig.Process("", &config)
|
|
if err != nil {
|
|
log.Fatal(err.Error())
|
|
}
|
|
|
|
return &config
|
|
}
|