minor fixes and gofmt
This commit is contained in:
parent
f170df0a76
commit
c4d663c6ab
@ -19,18 +19,20 @@
|
||||
package raw
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
var argContainerHints = flag.String("container_hints", "/etc/cadvisor/container_hints.json", "container hints file")
|
||||
|
||||
type containerHints struct {
|
||||
AllHosts []containerHint `json:"all_hosts,omitempty"`
|
||||
}
|
||||
|
||||
type containerHint struct {
|
||||
FullName string `json:"full_path,omitempty"`
|
||||
FullName string `json:"full_path,omitempty"`
|
||||
NetworkInterface *networkInterface `json:"network_interface,omitempty"`
|
||||
}
|
||||
|
||||
@ -41,7 +43,7 @@ type networkInterface struct {
|
||||
|
||||
func getContainerHintsFromFile(containerHintsFile string) (containerHints, error) {
|
||||
dat, err := ioutil.ReadFile(containerHintsFile)
|
||||
if os.IsNotExist(err) {
|
||||
if os.IsNotExist(err) {
|
||||
return containerHints{}, nil
|
||||
}
|
||||
var cHints containerHints
|
||||
|
@ -18,8 +18,11 @@ func TestGetContainerHintsFromFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFileNotExist(t *testing.T) {
|
||||
_, err := getContainerHintsFromFile("/file_does_not_exist.json")
|
||||
if err != nil {
|
||||
cHints, err := getContainerHintsFromFile("/file_does_not_exist.json")
|
||||
if err != nil {
|
||||
t.Fatalf("getContainerHintsFromFile must not error for blank file: %s", err)
|
||||
}
|
||||
for _, container := range cHints.AllHosts {
|
||||
t.Logf("Container: %s", container)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user