-
Notifications
You must be signed in to change notification settings - Fork 1.8k
*: implement List and add necessary pieces #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or 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
Manual Testing: namespace := "default"
// Test cases for Memcached List
logrus.Println("TestCase: Get Memcached List")
l := getMemcachedList("Memcached", "cache.example.com/v1alpha1")
err := query.List(namespace, l)
if err != nil {
logrus.Infof("Failed to get list : %v", err)
}
logrus.Println("TestCase: Get NonExistant CR")
l = getMemcachedList("bad", "cache.example.com/v1alpha1")
err = query.List(namespace, l)
if err != nil {
logrus.Infof("Failed to get list: %v", err)
}
logrus.Println("TestCase: Get Memcached List with APIVersion: bad")
l = getMemcachedList("Memcached", "bad")
err = query.List(namespace, l)
if err != nil {
logrus.Infof("Failed to get list %v : %v", err)
}
// Test cases for pod List
logrus.Println("TestCase: Get Pod List")
pl := getPodList("Pod", "v1")
err = query.List(namespace, pl)
if err != nil {
logrus.Infof("Failed to get list : %v", err)
}
logrus.Println("TestCase: Get Pod List with Option")
pl = getPodList("Pod", "v1")
lset := map[string]string{
"name": "memcached-operator2",
}
ls := labels.SelectorFromSet(lset).String()
lop := &metav1.ListOptions{LabelSelector: ls}
err = query.List(namespace, pl, query.WithListOptions(lop))
if err != nil {
logrus.Infof("Failed to get list : %v", err)
}
if len(pl.Items) != 1 {
logrus.Infof("expect size of the list to be %v, got %v", 1, pl.Size())
}
logrus.Println("TestCase: Get Pod List with wrong label")
pl = getPodList("Pod", "v1")
lset = map[string]string{
"name": "bad",
}
ls = labels.SelectorFromSet(lset).String()
lop = &metav1.ListOptions{LabelSelector: ls}
err = query.List(namespace, pl, query.WithListOptions(lop))
if err != nil {
logrus.Infof("Failed to get list : %v", err)
}
if len(pl.Items) != 0 {
logrus.Infof("expect size of the list %b, got %v", 0, pl.Size())
}
func getMemcachedList(kind, APIVersion string) *v1alpha1.MemcachedList {
return &v1alpha1.MemcachedList{
TypeMeta: metav1.TypeMeta{
Kind: kind,
APIVersion: APIVersion,
},
}
}
func getPodList(kind, APIVersion string) *v1.PodList {
return &v1.PodList{
TypeMeta: metav1.TypeMeta{
Kind: kind,
APIVersion: APIVersion,
},
}
} Output:
|
PTAL cc/ @hasbro17 |
hasbro17
reviewed
Mar 26, 2018
pkg/sdk/query/query.go
Outdated
return nil | ||
} | ||
|
||
// List lists a list of kubernetes object and then unmarshals the retrieved data into the "into" object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List lists a list of kubernetes object and then unmarshals the retrieved data into the "into" object.
List retrieves the specified object list and unmarshals the retrieved data into the "into" object.
LGTM after nit. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
add
NewListOp()
factory function to create a listOpadd
RuntimeObjectIntoRuntimeObject()
which takes inruntime.Object
and unmarshal its content into anotherruntime.Object
of the same type.Implement
List
that allows user to to query a list of objects.