allow setting of api endpoint via config

release/release-0.3.0
parent ded3792911
commit a1c2f5f0c6
No known key found for this signature in database
GPG Key ID: 0B266738824CE0F0
  1. 1
      config/check.toml.example
  2. 14
      main.go

@ -1,5 +1,6 @@
[general]
[gridscale]
api = "https://api.gridscale.io"
userid = "aaaa-bbbb-cccc-dddd-eeee"
token = "gequ6ahs6Ushiu8Oophoh3ok8zahthoh5guongiep0ichoWe1eth0Ohzaa1oum8li"

@ -25,6 +25,7 @@ var Checker CheckCommand
var Config CheckConfig
type CheckConfig struct {
Api string
UserId string
Token string
Client *gsclient.Client
@ -55,13 +56,22 @@ func config(configFile string) {
Config.Token = viper.GetString("gridscale.token")
}
if viper.IsSet("gridscale.api") {
Config.Api = viper.GetString("gridscale.api")
} else {
Config.Api = "https://api.gridscale.io"
}
if Checker.Debug {
viper.Debug()
}
config := gsclient.NewConfiguration(
"https://api.gridscale.io",
Config.Api,
Config.UserId,
Config.Token,
Checker.Debug, true, 120, 500,100)
Config.Client = gsclient.NewClient(config)
}
func main() {

Loading…
Cancel
Save