Unverified Commit 933052a0 authored by Hussein Galal's avatar Hussein Galal Committed by GitHub

Fix condition for adding kubernetes endpoints (#3941)

* Fix condition for adding kubernetes endpoints Signed-off-by: 's avatargalal-hussein <hussein.galal.ahmed.11@gmail.com> * Fix condition for adding kubernetes endpoints Signed-off-by: 's avatargalal-hussein <hussein.galal.ahmed.11@gmail.com>
parent 4d6ddfea
...@@ -44,23 +44,17 @@ type handler struct { ...@@ -44,23 +44,17 @@ type handler struct {
// This controller will update the version.program/apiaddresses etcd key with a list of // This controller will update the version.program/apiaddresses etcd key with a list of
// api addresses endpoints found in the kubernetes service in the default namespace // api addresses endpoints found in the kubernetes service in the default namespace
func (h *handler) sync(key string, endpoint *v1.Endpoints) (*v1.Endpoints, error) { func (h *handler) sync(key string, endpoint *v1.Endpoints) (*v1.Endpoints, error) {
if endpoint == nil { if endpoint != nil &&
return nil, nil endpoint.Namespace == "default" &&
} endpoint.Name == "kubernetes" {
if endpoint.Namespace != "default" && endpoint.Name != "kubernetes" {
return nil, nil
}
w := &bytes.Buffer{} w := &bytes.Buffer{}
if err := json.NewEncoder(w).Encode(util.GetAddresses(endpoint)); err != nil { if err := json.NewEncoder(w).Encode(util.GetAddresses(endpoint)); err != nil {
return nil, err return nil, err
} }
_, err := h.etcdClient.Put(h.ctx, etcd.AddressKey, w.String()) _, err := h.etcdClient.Put(h.ctx, etcd.AddressKey, w.String())
if err != nil { if err != nil {
return nil, err return nil, err
} }
}
return endpoint, nil return endpoint, nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment