mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
Clean up error logs.
Use %v for errors, tidy some messages, make error messages start lowe-case (as per go guidelines). Just accumulated nits.
This commit is contained in:
@@ -175,7 +175,7 @@ func portsFromString(spec string) (servicePort int, containerPort int, err error
|
||||
pieces := strings.Split(spec, ":")
|
||||
if len(pieces) != 2 {
|
||||
glog.Infof("Bad port spec: %s", spec)
|
||||
return 0, 0, fmt.Errorf("Bad port spec: %s", spec)
|
||||
return 0, 0, fmt.Errorf("bad port spec: %s", spec)
|
||||
}
|
||||
servicePort, err = strconv.Atoi(pieces[0])
|
||||
if err != nil {
|
||||
@@ -207,7 +207,7 @@ func portsFromString(spec string) (servicePort int, containerPort int, err error
|
||||
|
||||
func ReadConfigData(location string) ([]byte, error) {
|
||||
if len(location) == 0 {
|
||||
return nil, fmt.Errorf("Location given but empty")
|
||||
return nil, fmt.Errorf("location given but empty")
|
||||
}
|
||||
|
||||
if location == "-" {
|
||||
@@ -233,21 +233,21 @@ func readConfigDataFromLocation(location string) ([]byte, error) {
|
||||
if strings.Index(location, "http://") == 0 || strings.Index(location, "https://") == 0 {
|
||||
resp, err := http.Get(location)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to access URL %s: %v\n", location, err)
|
||||
return nil, fmt.Errorf("unable to access URL %s: %v\n", location, err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("Unable to read URL, server reported %d %s", resp.StatusCode, resp.Status)
|
||||
return nil, fmt.Errorf("unable to read URL, server reported %d %s", resp.StatusCode, resp.Status)
|
||||
}
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to read URL %s: %v\n", location, err)
|
||||
return nil, fmt.Errorf("unable to read URL %s: %v\n", location, err)
|
||||
}
|
||||
return data, nil
|
||||
} else {
|
||||
data, err := ioutil.ReadFile(location)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to read %s: %v\n", location, err)
|
||||
return nil, fmt.Errorf("unable to read %s: %v\n", location, err)
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user