Skip to content
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

restClient.Get always expects single value but always receives a list #90

Open
flashvoid opened this issue May 16, 2016 · 1 comment
Open
Assignees
Labels

Comments

@flashvoid
Copy link
Contributor

Relevant to https://github.com/romana/core/blob/fix/k8s-listener

Example in https://github.com/romana/core/blob/fix/k8s-listener/romana/kubernetes/listener.go#L286

    t := &tenant.Tenant{}
    err = l.restClient.Get(fmt.Sprintf("%s/tenants/%s", tenantURL, ns), t)

produces

2016/05/16 04:17:43 translateNetworkPolicy(): For namespace tenant-a got &tenant.Tenant{ID:0x0, ExternalID:"", Name:"", Segments:[]tenant.Segment(nil), Seq:0x0} / &errors.errorString{s:"Error json: cannot unmarshal array into Go value of type tenant.Tenant (<nil>) when parsing [{\"ID\":2,\"ExternalID\":\"680214b74eb14cd58a30a1c251aa2af6\",\"Name\":\"tenant-a\",\"Segments\":null,\"Seq\":2}]"}
2016/05/16 04:17:43 Error json: cannot unmarshal array into Go value of type tenant.Tenant (<nil>) when parsing [{"ID":2,"ExternalID":"680214b74eb14cd58a30a1c251aa2af6","Name":"tenant-a","Segments":null,"Seq":2}]

I couldn't find an easy way to fix it, changing tenant.go to return a single result doesn't help - clients always receive a list of httpResponses even if there is only one item.

Passing a slice of []Tenant{} into restClient.Get always returns empty slice because slice can't be modified by reference.

Need help.

@debedb
Copy link
Contributor

debedb commented Jun 15, 2016

This I think has been fixed, and findOne/findAll functionality from https://github.com/paninetworks/core/pull/9 obsoletes this problem.

pritesh added a commit that referenced this issue Nov 25, 2016
Better message when no segments were defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants