Tobias Trabelsi
7f2c465391
All checks were successful
ci/woodpecker/pr/pr Pipeline was successful
split pipeline
41 lines
1.6 KiB
Go
41 lines
1.6 KiB
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/jinzhu/configor"
|
|
)
|
|
|
|
type Config = struct {
|
|
LogLevel string `default:"Info" env:"WOODPECKER_AUTOSCALER_LOGLEVEL"`
|
|
CheckInterval int `default:"15" env:"WOODPECKER_AUTOSCALER_CHECK_INTERVAL"`
|
|
LabelSelector string `default:"uploadfilter24.eu/instance-role=Woodpecker" env:"WOODPECKER_AUTOSCALER_LABELSELECTOR"`
|
|
WoodpeckerInstance string `default:"" env:"WOODPECKER_AUTOSCALER_WOODPECKER_INSTANCE"`
|
|
WoodpeckerAgentSecret string `default:"" env:"WOODPECKER_AUTOSCALER_WOODPECKER_AGENT_SECRET"`
|
|
WoodpeckerApiToken string `default:"" env:"WOODPECKER_AUTOSCALER_WOODPECKER_API_TOKEN"`
|
|
Protocol string `default:"http" env:"WOODPECKER_AUTOSCALER_PROTOCOL"`
|
|
HcloudToken string `default:"" env:"WOODPECKER_AUTOSCALER_HCLOUD_TOKEN"`
|
|
InstanceType string `default:"" env:"WOODPECKER_AUTOSCALER_INSTANCE_TYPE"`
|
|
Region string `default:"" env:"WOODPECKER_AUTOSCALER_REGION"`
|
|
Datacenter string `default:"" env:"WOODPECKER_AUTOSCALER_DATACENTER"`
|
|
DryRun bool `default:"false" env:"WOODPECKER_AUTOSCALER_DRY_RUN"`
|
|
SSHKey string `default:"" env:"WOODPECKER_AUTOSCALER_SSH_KEY"`
|
|
}
|
|
|
|
func GenConfig() (cfg *Config, err error) {
|
|
|
|
cfg = &Config{}
|
|
|
|
err = configor.New(&configor.Config{
|
|
ENVPrefix: "WOODPECKER_AUTOSCALER",
|
|
AutoReload: true,
|
|
Silent: true,
|
|
AutoReloadInterval: time.Minute}).Load(cfg, "config.json")
|
|
if err != nil {
|
|
return nil, errors.New(fmt.Sprintf("Error generating Config: %s", err.Error()))
|
|
}
|
|
return cfg, nil
|
|
}
|