// Inserts or updates a routes in etcd. func (c *Client) Upsert(r *eskip.Route) error { if r.Id == "" { return missingRouteId } _, err := c.etcd.Set(c.routesRoot+"/"+r.Id, r.String(), 0) return err }
// generate weak random id for a route if // it doesn't have one. func ensureId(r *eskip.Route) error { if r.Id != "" { return nil } // using this to avoid adding a new dependency. id, err := flowid.NewFlowId(randomIdLength) if err != nil { return err } // replace characters that are not allowed // for eskip route ids. id = routeIdRx.ReplaceAllString(id, "x") r.Id = "route" + id return nil }
func (c *Client) etcdSet(r *eskip.Route) error { _, err := c.etcdRequest("PUT", c.routesRoot+"/"+r.Id, r.String()) return err }
func routesDiffer(left, right *eskip.Route) bool { return left.String() != right.String() }