45 lines
813 B
Go
45 lines
813 B
Go
package pihole
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
)
|
|
|
|
type Version struct {
|
|
Version Versions `json:"version"`
|
|
}
|
|
|
|
type Versions struct {
|
|
Core ModuleVersion `json:"core"`
|
|
Web ModuleVersion `json:"web"`
|
|
FTL ModuleVersion `json:"FTL"`
|
|
Docker DockerVersion `json:"docker"`
|
|
}
|
|
|
|
type ModuleVersion struct {
|
|
Local LocalVersion `json:"local"`
|
|
Remote LocalVersion `json:"remote"`
|
|
}
|
|
|
|
type LocalVersion struct {
|
|
Branch string `json:"branch"`
|
|
Version string `json:"version"`
|
|
Hash string `json:"hash"`
|
|
Date string `json:"date"`
|
|
}
|
|
|
|
type DockerVersion struct {
|
|
Local string `json:"local"`
|
|
Remote string `json:"remote"`
|
|
}
|
|
|
|
func (ph *PiHConnector) Version() Version {
|
|
version := &Version{}
|
|
|
|
err := json.Unmarshal(ph.get("info/version"), version)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
return *version
|
|
}
|