fixed devices url
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Stefan Hoffmann 2021-02-06 22:44:05 +01:00
parent 737e4268fc
commit a1bb128291

10
main.go
View File

@ -68,7 +68,7 @@ func processUcAPIs(c Config) ([]node, []link) {
//get list of Unifi devices to display //get list of Unifi devices to display
var nodes []node var nodes []node
var links []link var links []link
d, err := getDevices(c, "ucDevices.json") d, err := getDevices(c.Unifi.UCDevicesURL)
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
@ -153,7 +153,7 @@ func processUNMSAPI(c Config) ([]node, []link) {
var links []link var links []link
var nodes []node var nodes []node
d, err := getDevices(c, "devices.json") d, err := getDevices(c.Unms.DevicesURL)
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
@ -279,9 +279,9 @@ func getFile(url string) []byte {
return byteValue return byteValue
} }
func getDevices(c Config, file string) (devices, error) { func getDevices(url string) (devices, error) {
// get devices from JSON file // get devices from JSON file
jsonFile := getFile(c.Unms.DevicesURL + file) jsonFile := getFile(url)
// read file to bytes // read file to bytes
// variable for d // variable for d
@ -289,7 +289,7 @@ func getDevices(c Config, file string) (devices, error) {
// unmarshal to struct // unmarshal to struct
err := json.Unmarshal(jsonFile, &d) err := json.Unmarshal(jsonFile, &d)
if err != nil { if err != nil {
fmt.Println("can´t get devices file from " + c.Unms.DevicesURL) fmt.Println("can´t get devices file from " + url)
log.Fatal(err) log.Fatal(err)
} }
return d, nil return d, nil