Fix error type for NoK8sNetworkError

This fix changes type type for NoK8sNetworkError due to error handling, in #45.
Currently NoK8sNetworkError is not pointer type, just a string, hence we never
get *NoK8sNetworkError. This fix changes it based @One-ders patch.
This commit is contained in:
Tomofumi Hayashi
2018-04-23 15:51:11 +09:00
committed by Kuralamudhan Ramakrishnan
parent 82bece6d73
commit 0bdadc7f39
2 changed files with 15 additions and 11 deletions

View File

@@ -30,9 +30,11 @@ import (
)
// NoK8sNetworkError indicates error, no network in kubernetes
type NoK8sNetworkError string
type NoK8sNetworkError struct {
message string
}
func (e NoK8sNetworkError) Error() string { return string(e) }
func (e *NoK8sNetworkError) Error() string { return string(e.message) }
func createK8sClient(kubeconfig string) (*kubernetes.Clientset, error) {
@@ -258,7 +260,7 @@ func GetK8sNetwork(args *skel.CmdArgs, kubeconfig string) ([]map[string]interfac
}
if len(netAnnot) == 0 {
return podNet, NoK8sNetworkError("no kubernetes network found")
return podNet, &NoK8sNetworkError{"no kubernetes network found"}
}
netObjs, err := parsePodNetworkObject(netAnnot)