1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-07-12 22:41:07 +02:00

Add fixes for label selector and skipping things that don't match

This commit is contained in:
Asim Aslam
2019-11-26 22:28:08 +00:00
parent 3f3fd38601
commit 811275be26
3 changed files with 20 additions and 6 deletions

View File

@ -119,7 +119,14 @@ func (r *Request) Body(in interface{}) *Request {
// Params isused to set paramters on a request
func (r *Request) Params(p *Params) *Request {
for k, v := range p.LabelSelector {
r.params.Add("labelSelector", k+"="+v)
// create new key=value pair
value := fmt.Sprintf("%s=%s", k, v)
// check if there's an existing value
if label := r.params.Get("labelSelector"); len(label) > 0 {
value = fmt.Sprintf("%s,%s", label, value)
}
// set and overwrite the value
r.params.Set("labelSelector", value)
}
return r

View File

@ -126,9 +126,9 @@ func (c *client) Update(r *Resource) error {
switch r.Kind {
case "service":
req.Body(r.Value.(*Service).Spec)
req.Body(r.Value.(*Service))
case "deployment":
req.Body(r.Value.(*Deployment).Spec)
req.Body(r.Value.(*Deployment))
default:
return errors.New("unsupported resource")
}
@ -151,6 +151,5 @@ func (c *client) List(r *Resource) error {
labels := map[string]string{
"micro": "service",
}
return c.Get(r, labels)
}