Last active
October 4, 2016 14:27
-
-
Save udryan10/5ce6d1c0ed86ad9cc476f491eff99f67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"k8s.io/client-go/1.4/kubernetes/fake" | |
"k8s.io/client-go/1.4/pkg/api" | |
) | |
/* | |
Issue: | |
Despite passing a service into fake.NewSimpleClientset(), I am never able to retrieve that object when doing: fakeClient.Core().Services("").Get("") | |
The code below is a working example of the problem | |
*/ | |
func main() { | |
services := | |
&api.Service{ | |
ObjectMeta: api.ObjectMeta{ | |
Name: "test", | |
Labels: map[string]string{ | |
"foo": "bar", | |
}, | |
Namespace: "test1", | |
}, | |
Spec: api.ServiceSpec{ | |
Ports: []api.ServicePort{ | |
api.ServicePort{ | |
Port: 80, | |
}, | |
}, | |
}, | |
} | |
fakeClient := fake.NewSimpleClientset(services) | |
service, err := fakeClient.Core().Services("test1").Get("test") | |
// this constantly returns: | |
// error: Service "test" not found | |
if err != nil { | |
fmt.Println("error: ", err) | |
return | |
} | |
fmt.Println(service) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment