From a1c2f5f0c6fbb56762b48a61e9d039a77c4e1b6f Mon Sep 17 00:00:00 2001 From: Felix Kronlage-Dammers Date: Sat, 28 Mar 2020 20:55:08 +0100 Subject: [PATCH] allow setting of api endpoint via config --- config/check.toml.example | 1 + main.go | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/check.toml.example b/config/check.toml.example index 4af5e04..9da0bd1 100644 --- a/config/check.toml.example +++ b/config/check.toml.example @@ -1,5 +1,6 @@ [general] [gridscale] +api = "https://api.gridscale.io" userid = "aaaa-bbbb-cccc-dddd-eeee" token = "gequ6ahs6Ushiu8Oophoh3ok8zahthoh5guongiep0ichoWe1eth0Ohzaa1oum8li" diff --git a/main.go b/main.go index dd088cb..67e0ff2 100644 --- a/main.go +++ b/main.go @@ -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() {