diff --git a/README.md b/README.md index c313798..de6a2ba 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ Container registration is an opt-in process. By default, Container-to-Consul wil | `consul.port` | The port that the service will be discovered on| `none` | | `consul.service` | The name of the service in Consul | `container name` | | `consul.tags` | The tags that will be added to the service in Consul | `[]` | +| `consul.meta` | The service [meta](https://developer.hashicorp.com/consul/api-docs/catalog#meta) as `key=value,key=value` | empty | | `consul.kv.` | Key/Value pairs | `{}` | ### Registration diff --git a/coverage/coverage.json b/coverage/coverage.json deleted file mode 100644 index 0f96786..0000000 --- a/coverage/coverage.json +++ /dev/null @@ -1 +0,0 @@ -{"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/consul/catalog.js":{"path":"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/consul/catalog.js","s":{"1":3,"2":1,"3":1,"4":1},"b":{},"f":{"1":3,"2":1,"3":1},"fnMap":{"1":{"name":"(anonymous_1)","line":4,"loc":{"start":{"line":4,"column":14},"end":{"line":4,"column":23}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":11},"end":{"line":8,"column":18}}},"3":{"name":"(anonymous_3)","line":12,"loc":{"start":{"line":12,"column":13},"end":{"line":12,"column":20}}}},"statementMap":{"1":{"start":{"line":5,"column":4},"end":{"line":5,"column":25}},"2":{"start":{"line":9,"column":4},"end":{"line":9,"column":58}},"3":{"start":{"line":13,"column":4},"end":{"line":13,"column":60}},"4":{"start":{"line":17,"column":0},"end":{"line":17,"column":25}}},"branchMap":{}},"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/consul/kv.js":{"path":"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/consul/kv.js","s":{"1":5,"2":1,"3":1,"4":1,"5":1,"6":1,"7":0,"8":1,"9":1},"b":{"1":[0,1]},"f":{"1":5,"2":1,"3":1,"4":1,"5":1},"fnMap":{"1":{"name":"(anonymous_1)","line":4,"loc":{"start":{"line":4,"column":14},"end":{"line":4,"column":23}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":7},"end":{"line":8,"column":16}}},"3":{"name":"(anonymous_3)","line":12,"loc":{"start":{"line":12,"column":6},"end":{"line":12,"column":19}}},"4":{"name":"(anonymous_4)","line":16,"loc":{"start":{"line":16,"column":6},"end":{"line":16,"column":12}}},"5":{"name":"(anonymous_5)","line":20,"loc":{"start":{"line":20,"column":9},"end":{"line":20,"column":24}}}},"statementMap":{"1":{"start":{"line":5,"column":4},"end":{"line":5,"column":25}},"2":{"start":{"line":9,"column":4},"end":{"line":9,"column":53}},"3":{"start":{"line":13,"column":4},"end":{"line":13,"column":52}},"4":{"start":{"line":17,"column":4},"end":{"line":17,"column":49}},"5":{"start":{"line":21,"column":4},"end":{"line":21,"column":30}},"6":{"start":{"line":23,"column":4},"end":{"line":25,"column":5}},"7":{"start":{"line":24,"column":6},"end":{"line":24,"column":24}},"8":{"start":{"line":27,"column":4},"end":{"line":27,"column":36}},"9":{"start":{"line":31,"column":0},"end":{"line":31,"column":20}}},"branchMap":{"1":{"line":23,"type":"if","locations":[{"start":{"line":23,"column":4},"end":{"line":23,"column":4}},{"start":{"line":23,"column":4},"end":{"line":23,"column":4}}]}}},"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/errors/skipError.js":{"path":"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/errors/skipError.js","s":{"1":1,"2":1},"b":{},"f":{"1":1},"fnMap":{"1":{"name":"(anonymous_1)","line":4,"loc":{"start":{"line":4,"column":14},"end":{"line":4,"column":20}}}},"statementMap":{"1":{"start":{"line":5,"column":4},"end":{"line":5,"column":15}},"2":{"start":{"line":9,"column":0},"end":{"line":9,"column":27}}},"branchMap":{}},"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/consul/index.js":{"path":"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/consul/index.js","s":{"1":1,"2":1,"3":1,"4":6,"5":6,"6":6,"7":6,"8":2,"9":2,"10":2,"11":2,"12":0,"13":0,"14":0,"15":0,"16":0,"17":2,"18":1,"19":2,"20":1,"21":2,"22":1,"23":2,"24":1,"25":1,"26":1,"27":1},"b":{"1":[6,6],"2":[2,0],"3":[1,1],"4":[1,1],"5":[1,1]},"f":{"1":6,"2":2,"3":1,"4":2,"5":1,"6":1,"7":1},"fnMap":{"1":{"name":"(anonymous_1)","line":7,"loc":{"start":{"line":7,"column":13},"end":{"line":7,"column":22}}},"2":{"name":"(anonymous_2)","line":15,"loc":{"start":{"line":15,"column":7},"end":{"line":15,"column":27}}},"3":{"name":"(anonymous_3)","line":45,"loc":{"start":{"line":45,"column":6},"end":{"line":45,"column":12}}},"4":{"name":"(anonymous_4)","line":59,"loc":{"start":{"line":59,"column":6},"end":{"line":59,"column":18}}},"5":{"name":"(anonymous_5)","line":67,"loc":{"start":{"line":67,"column":9},"end":{"line":67,"column":15}}},"6":{"name":"(anonymous_6)","line":71,"loc":{"start":{"line":71,"column":13},"end":{"line":71,"column":16}}},"7":{"name":"(anonymous_7)","line":75,"loc":{"start":{"line":75,"column":8},"end":{"line":75,"column":11}}}},"statementMap":{"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":31}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":37}},"3":{"start":{"line":4,"column":0},"end":{"line":4,"column":27}},"4":{"start":{"line":8,"column":4},"end":{"line":8,"column":28}},"5":{"start":{"line":9,"column":4},"end":{"line":9,"column":28}},"6":{"start":{"line":11,"column":4},"end":{"line":11,"column":26}},"7":{"start":{"line":12,"column":4},"end":{"line":12,"column":33}},"8":{"start":{"line":16,"column":4},"end":{"line":19,"column":5}},"9":{"start":{"line":17,"column":6},"end":{"line":17,"column":47}},"10":{"start":{"line":18,"column":6},"end":{"line":18,"column":33}},"11":{"start":{"line":20,"column":4},"end":{"line":37,"column":6}},"12":{"start":{"line":26,"column":10},"end":{"line":26,"column":19}},"13":{"start":{"line":27,"column":10},"end":{"line":33,"column":11}},"14":{"start":{"line":28,"column":12},"end":{"line":28,"column":36}},"15":{"start":{"line":30,"column":12},"end":{"line":32,"column":14}},"16":{"start":{"line":34,"column":10},"end":{"line":34,"column":22}},"17":{"start":{"line":39,"column":4},"end":{"line":41,"column":5}},"18":{"start":{"line":40,"column":6},"end":{"line":40,"column":26}},"19":{"start":{"line":42,"column":4},"end":{"line":42,"column":26}},"20":{"start":{"line":46,"column":4},"end":{"line":46,"column":34}},"21":{"start":{"line":60,"column":4},"end":{"line":62,"column":5}},"22":{"start":{"line":61,"column":6},"end":{"line":61,"column":32}},"23":{"start":{"line":64,"column":4},"end":{"line":64,"column":40}},"24":{"start":{"line":68,"column":4},"end":{"line":68,"column":37}},"25":{"start":{"line":72,"column":4},"end":{"line":72,"column":29}},"26":{"start":{"line":76,"column":4},"end":{"line":76,"column":24}},"27":{"start":{"line":80,"column":0},"end":{"line":80,"column":24}}},"branchMap":{"1":{"line":12,"type":"binary-expr","locations":[{"start":{"line":12,"column":14},"end":{"line":12,"column":23}},{"start":{"line":12,"column":27},"end":{"line":12,"column":32}}]},"2":{"line":16,"type":"if","locations":[{"start":{"line":16,"column":4},"end":{"line":16,"column":4}},{"start":{"line":16,"column":4},"end":{"line":16,"column":4}}]},"3":{"line":17,"type":"cond-expr","locations":[{"start":{"line":17,"column":37},"end":{"line":17,"column":40}},{"start":{"line":17,"column":43},"end":{"line":17,"column":46}}]},"4":{"line":39,"type":"if","locations":[{"start":{"line":39,"column":4},"end":{"line":39,"column":4}},{"start":{"line":39,"column":4},"end":{"line":39,"column":4}}]},"5":{"line":60,"type":"if","locations":[{"start":{"line":60,"column":4},"end":{"line":60,"column":4}},{"start":{"line":60,"column":4},"end":{"line":60,"column":4}}]}}},"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/container-to-consul.js":{"path":"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/container-to-consul.js","s":{"1":22,"2":22,"3":22,"4":22,"5":22,"6":21,"7":21,"8":21,"9":21,"10":21,"11":25,"12":2,"13":1,"14":1,"15":1,"16":25,"17":2,"18":1,"19":1,"20":1,"21":5,"22":5,"23":2,"24":1,"25":1,"26":4,"27":6,"28":6,"29":1,"30":1,"31":5,"32":4,"33":1,"34":1,"35":3,"36":3,"37":2,"38":2,"39":1,"40":2,"41":4,"42":4,"43":4,"44":2,"45":1,"46":1,"47":1,"48":2,"49":2,"50":2,"51":1,"52":1,"53":1,"54":1,"55":2,"56":2,"57":2,"58":0,"59":0,"60":0,"61":0,"62":0,"63":2,"64":2,"65":1,"66":1,"67":1,"68":1,"69":3,"70":3,"71":3,"72":3,"73":3,"74":3,"75":0,"76":3,"77":3,"78":9,"79":2,"80":2,"81":1,"82":2,"83":2,"84":2,"85":2,"86":1,"87":0,"88":2,"89":1,"90":1,"91":1,"92":2,"93":1,"94":3,"95":3,"96":3,"97":3,"98":1,"99":3,"100":3,"101":1,"102":3,"103":2,"104":3,"105":3,"106":5,"107":5,"108":1,"109":5,"110":22},"b":{"1":[1,1],"2":[2,1],"3":[1,0],"4":[4,1],"5":[5,4],"6":[1,1],"7":[2,0],"8":[0,0],"9":[3,0],"10":[0,3],"11":[3,3,3],"12":[3,0],"13":[2,2,1,1],"14":[1,1],"15":[1,1],"16":[1,2],"17":[3,1],"18":[1,2],"19":[3,2,1],"20":[2,1],"21":[3,2],"22":[1,4],"23":[5,3,1]},"f":{"1":21,"2":25,"3":5,"4":1,"5":4,"6":2,"7":2,"8":3,"9":3,"10":5},"fnMap":{"1":{"name":"(anonymous_1)","line":10,"loc":{"start":{"line":10,"column":13},"end":{"line":10,"column":22}}},"2":{"name":"(anonymous_2)","line":20,"loc":{"start":{"line":20,"column":15},"end":{"line":20,"column":18}}},"3":{"name":"(anonymous_3)","line":41,"loc":{"start":{"line":41,"column":7},"end":{"line":41,"column":10}}},"4":{"name":"(anonymous_4)","line":85,"loc":{"start":{"line":85,"column":20},"end":{"line":85,"column":33}}},"5":{"name":"(anonymous_5)","line":94,"loc":{"start":{"line":94,"column":19},"end":{"line":94,"column":31}}},"6":{"name":"(anonymous_6)","line":127,"loc":{"start":{"line":127,"column":21},"end":{"line":127,"column":33}}},"7":{"name":"(anonymous_7)","line":156,"loc":{"start":{"line":156,"column":19},"end":{"line":156,"column":29}}},"8":{"name":"(anonymous_8)","line":174,"loc":{"start":{"line":174,"column":19},"end":{"line":174,"column":31}}},"9":{"name":"(anonymous_9)","line":240,"loc":{"start":{"line":240,"column":22},"end":{"line":240,"column":34}}},"10":{"name":"(anonymous_10)","line":265,"loc":{"start":{"line":265,"column":18},"end":{"line":265,"column":30}}}},"statementMap":{"1":{"start":{"line":3,"column":0},"end":{"line":3,"column":33}},"2":{"start":{"line":4,"column":0},"end":{"line":4,"column":35}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":35}},"4":{"start":{"line":6,"column":0},"end":{"line":6,"column":36}},"5":{"start":{"line":7,"column":0},"end":{"line":7,"column":48}},"6":{"start":{"line":11,"column":4},"end":{"line":11,"column":25}},"7":{"start":{"line":13,"column":4},"end":{"line":13,"column":44}},"8":{"start":{"line":14,"column":4},"end":{"line":14,"column":35}},"9":{"start":{"line":15,"column":4},"end":{"line":15,"column":50}},"10":{"start":{"line":17,"column":4},"end":{"line":17,"column":25}},"11":{"start":{"line":21,"column":4},"end":{"line":29,"column":7}},"12":{"start":{"line":22,"column":6},"end":{"line":28,"column":11}},"13":{"start":{"line":24,"column":27},"end":{"line":24,"column":60}},"14":{"start":{"line":26,"column":10},"end":{"line":26,"column":32}},"15":{"start":{"line":27,"column":10},"end":{"line":27,"column":22}},"16":{"start":{"line":30,"column":4},"end":{"line":38,"column":7}},"17":{"start":{"line":31,"column":6},"end":{"line":37,"column":11}},"18":{"start":{"line":33,"column":27},"end":{"line":33,"column":87}},"19":{"start":{"line":35,"column":10},"end":{"line":35,"column":32}},"20":{"start":{"line":36,"column":10},"end":{"line":36,"column":22}},"21":{"start":{"line":42,"column":4},"end":{"line":77,"column":9}},"22":{"start":{"line":44,"column":18},"end":{"line":50,"column":10}},"23":{"start":{"line":46,"column":10},"end":{"line":48,"column":11}},"24":{"start":{"line":47,"column":12},"end":{"line":47,"column":22}},"25":{"start":{"line":49,"column":10},"end":{"line":49,"column":22}},"26":{"start":{"line":52,"column":8},"end":{"line":70,"column":12}},"27":{"start":{"line":53,"column":10},"end":{"line":69,"column":15}},"28":{"start":{"line":55,"column":14},"end":{"line":68,"column":19}},"29":{"start":{"line":58,"column":18},"end":{"line":60,"column":19}},"30":{"start":{"line":59,"column":20},"end":{"line":59,"column":55}},"31":{"start":{"line":63,"column":18},"end":{"line":65,"column":19}},"32":{"start":{"line":64,"column":20},"end":{"line":64,"column":55}},"33":{"start":{"line":66,"column":18},"end":{"line":66,"column":40}},"34":{"start":{"line":67,"column":18},"end":{"line":67,"column":30}},"35":{"start":{"line":72,"column":18},"end":{"line":72,"column":42}},"36":{"start":{"line":73,"column":26},"end":{"line":73,"column":61}},"37":{"start":{"line":75,"column":8},"end":{"line":75,"column":30}},"38":{"start":{"line":76,"column":8},"end":{"line":76,"column":20}},"39":{"start":{"line":86,"column":4},"end":{"line":86,"column":87}},"40":{"start":{"line":86,"column":51},"end":{"line":86,"column":84}},"41":{"start":{"line":95,"column":4},"end":{"line":95,"column":16}},"42":{"start":{"line":97,"column":4},"end":{"line":107,"column":5}},"43":{"start":{"line":98,"column":6},"end":{"line":98,"column":50}},"44":{"start":{"line":101,"column":6},"end":{"line":104,"column":7}},"45":{"start":{"line":102,"column":8},"end":{"line":102,"column":33}},"46":{"start":{"line":103,"column":8},"end":{"line":103,"column":33}},"47":{"start":{"line":106,"column":6},"end":{"line":106,"column":31}},"48":{"start":{"line":109,"column":4},"end":{"line":109,"column":52}},"49":{"start":{"line":111,"column":4},"end":{"line":118,"column":9}},"50":{"start":{"line":112,"column":18},"end":{"line":112,"column":55}},"51":{"start":{"line":113,"column":18},"end":{"line":113,"column":112}},"52":{"start":{"line":115,"column":8},"end":{"line":115,"column":88}},"53":{"start":{"line":116,"column":8},"end":{"line":116,"column":30}},"54":{"start":{"line":117,"column":8},"end":{"line":117,"column":20}},"55":{"start":{"line":128,"column":4},"end":{"line":131,"column":57}},"56":{"start":{"line":133,"column":4},"end":{"line":135,"column":5}},"57":{"start":{"line":134,"column":6},"end":{"line":134,"column":31}},"58":{"start":{"line":137,"column":4},"end":{"line":145,"column":7}},"59":{"start":{"line":138,"column":6},"end":{"line":144,"column":7}},"60":{"start":{"line":139,"column":8},"end":{"line":141,"column":28}},"61":{"start":{"line":143,"column":8},"end":{"line":143,"column":81}},"62":{"start":{"line":147,"column":4},"end":{"line":147,"column":33}},"63":{"start":{"line":157,"column":4},"end":{"line":157,"column":54}},"64":{"start":{"line":159,"column":4},"end":{"line":165,"column":9}},"65":{"start":{"line":160,"column":18},"end":{"line":160,"column":72}},"66":{"start":{"line":161,"column":18},"end":{"line":161,"column":68}},"67":{"start":{"line":163,"column":8},"end":{"line":163,"column":30}},"68":{"start":{"line":164,"column":8},"end":{"line":164,"column":20}},"69":{"start":{"line":175,"column":4},"end":{"line":181,"column":6}},"70":{"start":{"line":182,"column":4},"end":{"line":185,"column":17}},"71":{"start":{"line":187,"column":4},"end":{"line":189,"column":5}},"72":{"start":{"line":188,"column":6},"end":{"line":188,"column":43}},"73":{"start":{"line":191,"column":4},"end":{"line":191,"column":50}},"74":{"start":{"line":193,"column":4},"end":{"line":195,"column":5}},"75":{"start":{"line":194,"column":6},"end":{"line":194,"column":87}},"76":{"start":{"line":196,"column":4},"end":{"line":227,"column":5}},"77":{"start":{"line":197,"column":6},"end":{"line":226,"column":9}},"78":{"start":{"line":198,"column":8},"end":{"line":225,"column":9}},"79":{"start":{"line":200,"column":12},"end":{"line":200,"column":42}},"80":{"start":{"line":201,"column":12},"end":{"line":203,"column":13}},"81":{"start":{"line":202,"column":14},"end":{"line":202,"column":52}},"82":{"start":{"line":204,"column":12},"end":{"line":204,"column":18}},"83":{"start":{"line":206,"column":12},"end":{"line":215,"column":13}},"84":{"start":{"line":207,"column":14},"end":{"line":207,"column":59}},"85":{"start":{"line":208,"column":14},"end":{"line":210,"column":15}},"86":{"start":{"line":209,"column":16},"end":{"line":209,"column":44}},"87":{"start":{"line":214,"column":14},"end":{"line":214,"column":32}},"88":{"start":{"line":216,"column":12},"end":{"line":216,"column":18}},"89":{"start":{"line":218,"column":12},"end":{"line":218,"column":50}},"90":{"start":{"line":219,"column":12},"end":{"line":219,"column":18}},"91":{"start":{"line":221,"column":12},"end":{"line":223,"column":38}},"92":{"start":{"line":223,"column":26},"end":{"line":223,"column":36}},"93":{"start":{"line":224,"column":12},"end":{"line":224,"column":18}},"94":{"start":{"line":229,"column":4},"end":{"line":229,"column":39}},"95":{"start":{"line":231,"column":4},"end":{"line":231,"column":19}},"96":{"start":{"line":241,"column":4},"end":{"line":241,"column":30}},"97":{"start":{"line":243,"column":4},"end":{"line":245,"column":5}},"98":{"start":{"line":244,"column":6},"end":{"line":244,"column":32}},"99":{"start":{"line":247,"column":4},"end":{"line":247,"column":32}},"100":{"start":{"line":248,"column":4},"end":{"line":250,"column":5}},"101":{"start":{"line":249,"column":6},"end":{"line":249,"column":37}},"102":{"start":{"line":251,"column":4},"end":{"line":253,"column":5}},"103":{"start":{"line":252,"column":6},"end":{"line":252,"column":33}},"104":{"start":{"line":254,"column":4},"end":{"line":254,"column":35}},"105":{"start":{"line":256,"column":4},"end":{"line":256,"column":16}},"106":{"start":{"line":266,"column":4},"end":{"line":266,"column":32}},"107":{"start":{"line":267,"column":4},"end":{"line":269,"column":5}},"108":{"start":{"line":268,"column":6},"end":{"line":268,"column":37}},"109":{"start":{"line":270,"column":4},"end":{"line":270,"column":16}},"110":{"start":{"line":275,"column":0},"end":{"line":275,"column":35}}},"branchMap":{"1":{"line":46,"type":"if","locations":[{"start":{"line":46,"column":10},"end":{"line":46,"column":10}},{"start":{"line":46,"column":10},"end":{"line":46,"column":10}}]},"2":{"line":46,"type":"binary-expr","locations":[{"start":{"line":46,"column":14},"end":{"line":46,"column":30}},{"start":{"line":46,"column":34},"end":{"line":46,"column":58}}]},"3":{"line":58,"type":"if","locations":[{"start":{"line":58,"column":18},"end":{"line":58,"column":18}},{"start":{"line":58,"column":18},"end":{"line":58,"column":18}}]},"4":{"line":63,"type":"if","locations":[{"start":{"line":63,"column":18},"end":{"line":63,"column":18}},{"start":{"line":63,"column":18},"end":{"line":63,"column":18}}]},"5":{"line":63,"type":"binary-expr","locations":[{"start":{"line":63,"column":22},"end":{"line":63,"column":38}},{"start":{"line":63,"column":42},"end":{"line":63,"column":66}}]},"6":{"line":101,"type":"if","locations":[{"start":{"line":101,"column":6},"end":{"line":101,"column":6}},{"start":{"line":101,"column":6},"end":{"line":101,"column":6}}]},"7":{"line":133,"type":"if","locations":[{"start":{"line":133,"column":4},"end":{"line":133,"column":4}},{"start":{"line":133,"column":4},"end":{"line":133,"column":4}}]},"8":{"line":138,"type":"if","locations":[{"start":{"line":138,"column":6},"end":{"line":138,"column":6}},{"start":{"line":138,"column":6},"end":{"line":138,"column":6}}]},"9":{"line":187,"type":"if","locations":[{"start":{"line":187,"column":4},"end":{"line":187,"column":4}},{"start":{"line":187,"column":4},"end":{"line":187,"column":4}}]},"10":{"line":193,"type":"if","locations":[{"start":{"line":193,"column":4},"end":{"line":193,"column":4}},{"start":{"line":193,"column":4},"end":{"line":193,"column":4}}]},"11":{"line":193,"type":"binary-expr","locations":[{"start":{"line":193,"column":8},"end":{"line":193,"column":38}},{"start":{"line":193,"column":42},"end":{"line":193,"column":77}},{"start":{"line":193,"column":81},"end":{"line":193,"column":105}}]},"12":{"line":196,"type":"if","locations":[{"start":{"line":196,"column":4},"end":{"line":196,"column":4}},{"start":{"line":196,"column":4},"end":{"line":196,"column":4}}]},"13":{"line":198,"type":"switch","locations":[{"start":{"line":199,"column":10},"end":{"line":204,"column":18}},{"start":{"line":205,"column":10},"end":{"line":216,"column":18}},{"start":{"line":217,"column":10},"end":{"line":219,"column":18}},{"start":{"line":220,"column":10},"end":{"line":224,"column":18}}]},"14":{"line":201,"type":"if","locations":[{"start":{"line":201,"column":12},"end":{"line":201,"column":12}},{"start":{"line":201,"column":12},"end":{"line":201,"column":12}}]},"15":{"line":208,"type":"if","locations":[{"start":{"line":208,"column":14},"end":{"line":208,"column":14}},{"start":{"line":208,"column":14},"end":{"line":208,"column":14}}]},"16":{"line":243,"type":"if","locations":[{"start":{"line":243,"column":4},"end":{"line":243,"column":4}},{"start":{"line":243,"column":4},"end":{"line":243,"column":4}}]},"17":{"line":243,"type":"binary-expr","locations":[{"start":{"line":243,"column":8},"end":{"line":243,"column":13}},{"start":{"line":243,"column":17},"end":{"line":243,"column":32}}]},"18":{"line":248,"type":"if","locations":[{"start":{"line":248,"column":4},"end":{"line":248,"column":4}},{"start":{"line":248,"column":4},"end":{"line":248,"column":4}}]},"19":{"line":248,"type":"binary-expr","locations":[{"start":{"line":248,"column":8},"end":{"line":248,"column":13}},{"start":{"line":248,"column":17},"end":{"line":248,"column":33}},{"start":{"line":248,"column":37},"end":{"line":248,"column":60}}]},"20":{"line":251,"type":"if","locations":[{"start":{"line":251,"column":4},"end":{"line":251,"column":4}},{"start":{"line":251,"column":4},"end":{"line":251,"column":4}}]},"21":{"line":251,"type":"binary-expr","locations":[{"start":{"line":251,"column":8},"end":{"line":251,"column":12}},{"start":{"line":251,"column":16},"end":{"line":251,"column":35}}]},"22":{"line":267,"type":"if","locations":[{"start":{"line":267,"column":4},"end":{"line":267,"column":4}},{"start":{"line":267,"column":4},"end":{"line":267,"column":4}}]},"23":{"line":267,"type":"binary-expr","locations":[{"start":{"line":267,"column":8},"end":{"line":267,"column":13}},{"start":{"line":267,"column":17},"end":{"line":267,"column":33}},{"start":{"line":267,"column":37},"end":{"line":267,"column":60}}]}}},"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/docker.js":{"path":"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/docker.js","s":{"1":7,"2":7,"3":7,"4":7,"5":6,"6":6,"7":6,"8":6,"9":6,"10":6,"11":6,"12":5,"13":4,"14":4,"15":4,"16":4,"17":4,"18":5,"19":1,"20":1,"21":2,"22":1,"23":1,"24":1,"25":1,"26":7},"b":{"1":[1,1]},"f":{"1":6,"2":6,"3":1},"fnMap":{"1":{"name":"(anonymous_1)","line":9,"loc":{"start":{"line":9,"column":14},"end":{"line":9,"column":34}}},"2":{"name":"(anonymous_2)","line":20,"loc":{"start":{"line":20,"column":8},"end":{"line":20,"column":11}}},"3":{"name":"(anonymous_3)","line":50,"loc":{"start":{"line":50,"column":13},"end":{"line":50,"column":16}}}},"statementMap":{"1":{"start":{"line":3,"column":0},"end":{"line":3,"column":39}},"2":{"start":{"line":4,"column":0},"end":{"line":4,"column":54}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":46}},"4":{"start":{"line":6,"column":0},"end":{"line":6,"column":36}},"5":{"start":{"line":10,"column":4},"end":{"line":10,"column":47}},"6":{"start":{"line":12,"column":4},"end":{"line":12,"column":50}},"7":{"start":{"line":13,"column":4},"end":{"line":13,"column":52}},"8":{"start":{"line":14,"column":4},"end":{"line":14,"column":32}},"9":{"start":{"line":15,"column":4},"end":{"line":17,"column":7}},"10":{"start":{"line":21,"column":4},"end":{"line":47,"column":9}},"11":{"start":{"line":22,"column":6},"end":{"line":22,"column":26}},"12":{"start":{"line":24,"column":6},"end":{"line":32,"column":9}},"13":{"start":{"line":25,"column":8},"end":{"line":25,"column":63}},"14":{"start":{"line":27,"column":8},"end":{"line":31,"column":13}},"15":{"start":{"line":29,"column":12},"end":{"line":29,"column":99}},"16":{"start":{"line":29,"column":50},"end":{"line":29,"column":71}},"17":{"start":{"line":30,"column":12},"end":{"line":30,"column":22}},"18":{"start":{"line":34,"column":6},"end":{"line":37,"column":9}},"19":{"start":{"line":35,"column":8},"end":{"line":35,"column":82}},"20":{"start":{"line":36,"column":8},"end":{"line":36,"column":28}},"21":{"start":{"line":41,"column":8},"end":{"line":43,"column":9}},"22":{"start":{"line":42,"column":10},"end":{"line":42,"column":30}},"23":{"start":{"line":45,"column":8},"end":{"line":45,"column":48}},"24":{"start":{"line":46,"column":8},"end":{"line":46,"column":37}},"25":{"start":{"line":51,"column":4},"end":{"line":51,"column":40}},"26":{"start":{"line":55,"column":0},"end":{"line":55,"column":24}}},"branchMap":{"1":{"line":41,"type":"if","locations":[{"start":{"line":41,"column":8},"end":{"line":41,"column":8}},{"start":{"line":41,"column":8},"end":{"line":41,"column":8}}]}}},"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/typedefs.js":{"path":"/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/typedefs.js","s":{},"b":{},"f":{},"fnMap":{},"statementMap":{},"branchMap":{}}} \ No newline at end of file diff --git a/coverage/lcov-report/base.css b/coverage/lcov-report/base.css deleted file mode 100644 index 29737bc..0000000 --- a/coverage/lcov-report/base.css +++ /dev/null @@ -1,213 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } -/* dark yellow (gold) */ -.medium .chart { border:1px solid #f9cd0b; } -.status-line.medium, .medium .cover-fill { background: #f9cd0b; } -/* light yellow */ -.medium { background: #fff4c2; } -/* light gray */ -span.cline-neutral { background: #eaeaea; } - -.cbranch-no { background: yellow !important; color: #111; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/coverage/lcov-report/index.html b/coverage/lcov-report/index.html deleted file mode 100644 index 749f73c..0000000 --- a/coverage/lcov-report/index.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - Code coverage report for All files - - - - - - - -
-
-

- / -

-
-
- 92.7% - Statements - 165/178 -
-
- 86.15% - Branches - 56/65 -
-
- 100% - Functions - 29/29 -
-
- 92.61% - Lines - 163/176 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
lib/
94.85%129/13686.79%46/53100%13/1394.78%127/134
lib/consul/
85%34/4083.33%10/12100%15/1585%34/40
lib/errors/
100%2/2100%0/0100%1/1100%2/2
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/con-tainer2sul.js.html b/coverage/lcov-report/lib/con-tainer2sul.js.html deleted file mode 100644 index 4886df6..0000000 --- a/coverage/lcov-report/lib/con-tainer2sul.js.html +++ /dev/null @@ -1,896 +0,0 @@ - - - - Code coverage report for lib/con-tainer2sul.js - - - - - - - -
-
-

- all files / lib/ con-tainer2sul.js -

-
-
- 94.5% - Statements - 103/109 -
-
- 86.27% - Branches - 44/51 -
-
- 100% - Functions - 10/10 -
-
- 94.44% - Lines - 102/108 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278  -  -22× -22× -22× -22× -22× -  -  -  -21× -  -21× -21× -21× -  -21× -  -  -  -25× - -  - -  - - -  -  -25× - -  - -  - - -  -  -  -  -  - -  - -  - - -  - -  -  - - -  - -  -  - - -  -  -  - - -  - - -  -  -  -  -  - - -  - - -  -  -  -  -  -  -  -  -  - -  -  -  -  -  -  -  -  - -  - - -  -  - - - -  -  - -  -  - -  - - - -  - - - -  -  -  -  -  -  -  -  -  -  - -  -  -  -  - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - -  - - - -  - - -  -  -  -  -  -  -  -  -  -  - -  -  -  -  -  -  - -  -  -  -  - - -  -  - -  - -  -  - - - -  - - - -  - -  - - - - -  -  -  -  -  - -  - - -  - -  - - -  -  -  -  - -  - -  -  -  -  -  -  -  -  -  - -  - - -  -  - - - -  - - -  - -  - -  -  -  -  -  -  -  -  -  - - - -  - -  -  -  -  -  -  -22× - 
'use strict';
- 
-const bunyan = require('bunyan');
-const Consul = require('./consul');
-const Docker = require('./docker');
-const Promise = require('bluebird');
-const SkipError = require('./errors/skipError');
- 
-class ConTainer2Sul {
-  constructor(config) {
-    this.config = config;
- 
-    this.consul = new Consul(config.consul);
-    this.docker = new Docker(this);
-    this.log = bunyan.createLogger(config.logger);
- 
-    this._attachEvents();
-  }
- 
-  _attachEvents() {
-    this.docker.events.on('start', msg => {
-      return this.docker.client.getContainer(msg.id)
-        .inspect()
-        .then(container => this.registerContainer(container))
-        .catch(error => {
-          this.log.error(error);
-          throw error;
-        });
-    });
-    this.docker.events.on('die', msg => {
-      return this.docker.client.getContainer(msg.id)
-        .inspect()
-        .then(container => this.deregisterService(this.containerServiceName(container)))
-        .catch(error => {
-          this.log.error(error);
-          throw error;
-        });
-    });
-  }
- 
-  start() {
-    return this.docker.start()
-      // deregister containers that do not run
-      .then(() => this.consul.kv.keys('docker/service-ids/')
-        .catch(error => {
-          if (error.statusCode && error.statusCode === 404) {
-            return [];
-          }
-          throw error;
-        }))
-      .then(keys => {
-        return Promise.all(keys.map(key => {
-          return this.consul.kv.get(key)
-            .then(containerId => {
-              return this.docker.client.getContainer(containerId)
-                .inspect()
-                .then(container => {
-                  Eif (container.State.Status !== 'running') {
-                    return this.deregisterService(key);
-                  }
-                })
-                .catch(error => {
-                  if (error.statusCode && error.statusCode === 404) {
-                    return this.deregisterService(key);
-                  }
-                  this.log.error(error);
-                  throw error;
-                });
-            });
-        }));
-      })
-      // register all containers
-      .then(() => this.docker.containers())
-      .then(containers => this.registerContainers(containers))
-      .catch(error => {
-        this.log.error(error);
-        throw error;
-      });
-  }
- 
-  /**
-   *
-   * @param {Container[]} containers
-   * @returns {Promise.<*>}
-   */
-  registerContainers(containers) {
-    return Promise.all(containers.map(container => this.registerContainer(container)));
-  }
- 
-  /**
-   *
-   * @param {Container} container
-   * @returns {Promise}
-   */
-  registerContainer(container) {
-    let service;
- 
-    try {
-      service = this.container2Service(container);
-    }
-    catch (e) {
-      if (e instanceof SkipError) {
-        this.log.info(e.message);
-        return Promise.resolve();
-      }
- 
-      return Promise.reject(e);
-    }
- 
-    this.log.info('registering container', service);
- 
-    return this.registerContainerKv(container)
-      .then(() => this.consul.catalog.register(service))
-      .then(() => this.consul.kv.set(`docker/service-ids/${this.containerServiceName(container)}`, container.Id))
-      .catch(error => {
-        this.consul.kv.delete(`services/${this.containerServiceName(container)}`, true);
-        this.log.error(error);
-        throw error;
-      });
-  }
- 
-  /**
-   * Registers key/value pairs for the container
-   *
-   * @param {Container} container
-   * @returns {Promise}
-   */
-  registerContainerKv(container) {
-    const
-      lbls = this._containerLabels(container),
-      promises = [],
-      serviceName = this.containerServiceName(container);
- 
-    Eif (!lbls) {
-      return Promise.resolve();
-    }
- 
-    Object.keys(lbls).forEach(label => {
-      if (label.startsWith('consul.kv.')) {
-        const
-          key = label.replace(/^consul\.kv\./, ''),
-          val = lbls[label];
- 
-        promises.push(this.consul.kv.set(`services/${serviceName}/${key}`, val));
-      }
-    });
- 
-    return Promise.all(promises);
-  }
- 
-  /**
-   * Un-register a service and related information from Consul
-   *
-   * @param {string} service
-   * @returns {Promise}
-   */
-  deregisterService(service) {
-    this.log.info('deregistering container', service);
- 
-    return this.consul.catalog.deregister({ Node: service })
-      .then(() => this.consul.kv.delete(`docker/service-ids/${service}`))
-      .then(() => this.consul.kv.delete(`services/${service}`, true))
-      .catch(error => {
-        this.log.error(error);
-        throw error;
-      });
-  }
- 
-  /**
-   * Given a container, returns a service definition ready to be consumed by Consul catalog/register API endpoint
-   *
-   * @param container
-   * @returns {Object}
-   */
-  container2Service(container) {
-    let service = {
-      Node: this.containerServiceName(container),
-      Address: this.docker.docker0,
-      Service: {
-        Service: this.containerServiceName(container)
-      }
-    };
-    let containerIPAddress = container
-      .NetworkSettings
-      .Networks[Object.keys(container.NetworkSettings.Networks)[0]]
-      .IPAddress;
- 
-    Eif (containerIPAddress !== '') {
-      service.Address = containerIPAddress;
-    }
- 
-    const lbls = this._containerLabels(container);
- 
-    Iif (Object.keys(lbls).length === 0 || lbls['consul.register'] === 'false' || !lbls['consul.register']) {
-      throw new SkipError(`Container ${this.containerServiceName(container)} skipped`);
-    }
-    Eif (lbls) {
-      Object.keys(lbls).forEach(label => {
-        switch (label) {
-          case 'consul.ip':
-            service.Address = lbls[label];
-            if (service.Address === 'host') {
-              service.Address = this.docker.docker0;
-            }
-            break;
-          case 'consul.port':
-            try {
-              service.Service.Port = parseInt(lbls[label]);
-              if (isNaN(service.Service.Port)) {
-                delete service.Service.Port;
-              }
-            }
-            catch (e) {
-              // do nothing
-            }
-            break;
-          case 'consul.service':
-            service.Service.Service = lbls[label];
-            break;
-          case 'consul.tags':
-            service.Service.Tags = lbls[label]
-              .split(',')
-              .map(tag => tag.trim());
-            break;
-        }
-      });
-    }
- 
-    this.log.debug('service', service);
- 
-    return service;
-  }
- 
-  /**
-   * Returns the service name for the container
-   *
-   * @param {Container} container
-   * @returns {string}
-   */
-  containerServiceName(container) {
-    let name = container.Name;
- 
-    if (!name && container.Names) {
-      name = container.Names[0];
-    }
- 
-    let lbls = container.Labels;
-    if (!lbls && container.Config && container.Config.Labels) {
-      lbls = container.Config.Labels;
-    }
-    if (lbls && lbls['consul.name']) {
-      name = lbls['consul.name'];
-    }
-    name = name.replace(/^\//, '');
- 
-    return name;
-  }
- 
-  /**
-   *
-   * @param container
-   * @returns {Object}
-   * @private
-   */
-  _containerLabels(container) {
-    let lbls = container.Labels;
-    if (!lbls && container.Config && container.Config.Labels) {
-      lbls = container.Config.Labels;
-    }
-    return lbls;
-  }
- 
-}
- 
- 
- 
-module.exports = ConTainer2Sul;
- 
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/consul/axios-instance.js.html b/coverage/lcov-report/lib/consul/axios-instance.js.html deleted file mode 100644 index e5a9f0c..0000000 --- a/coverage/lcov-report/lib/consul/axios-instance.js.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - Code coverage report for lib/consul/axios-instance.js - - - - - - - -
-
-

- all files / lib/consul/ axios-instance.js -

-
-
- 0% - Statements - 0/3 -
-
- 100% - Branches - 0/0 -
-
- 0% - Functions - 0/1 -
-
- 0% - Lines - 0/3 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6  -  -  -  -  - 
const axios = require('axios');
-module.exports = axios.create({
-  transformResponse: [function transformResponse(data) {
-    return JSON.parse(data);
-  }]
-}); 
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/consul/catalog.js.html b/coverage/lcov-report/lib/consul/catalog.js.html deleted file mode 100644 index 9849ffa..0000000 --- a/coverage/lcov-report/lib/consul/catalog.js.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Code coverage report for lib/consul/catalog.js - - - - - - - -
-
-

- all files / lib/consul/ catalog.js -

-
-
- 100% - Statements - 4/4 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 3/3 -
-
- 100% - Lines - 4/4 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17  -  -  -  - -  -  -  - -  -  -  - -  -  -  -
'use strict';
- 
-class Catalog {
-  constructor (consul) {
-    this.consul = consul;
-  }
- 
-  register (data) {
-    return this.consul._put('/v1/catalog/register', data);
-  }
- 
-  deregister (data) {
-    return this.consul._put('/v1/catalog/deregister', data);
-  }
-}
- 
-module.exports = Catalog;
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/consul/index.html b/coverage/lcov-report/lib/consul/index.html deleted file mode 100644 index 2c9f7a6..0000000 --- a/coverage/lcov-report/lib/consul/index.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - Code coverage report for lib/consul/ - - - - - - - -
-
-

- all files lib/consul/ -

-
-
- 85% - Statements - 34/40 -
-
- 83.33% - Branches - 10/12 -
-
- 100% - Functions - 15/15 -
-
- 85% - Lines - 34/40 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
catalog.js
100%4/4100%0/0100%3/3100%4/4
index.js
81.48%22/2790%9/10100%7/781.48%22/27
kv.js
88.89%8/950%1/2100%5/588.89%8/9
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/consul/index.js.html b/coverage/lcov-report/lib/consul/index.js.html deleted file mode 100644 index 92117ca..0000000 --- a/coverage/lcov-report/lib/consul/index.js.html +++ /dev/null @@ -1,302 +0,0 @@ - - - - Code coverage report for lib/consul/index.js - - - - - - - -
-
-

- all files / lib/consul/ index.js -

-
-
- 81.48% - Statements - 22/27 -
-
- 90% - Branches - 9/10 -
-
- 100% - Functions - 7/7 -
-
- 81.48% - Lines - 22/27 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80  - - - -  -  -  - - -  - - -  -  -  - - - -  - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - - -  - -  -  -  - -  -  -  -  -  -  -  -  -  -  -  -  -  - - -  -  - -  -  -  - -  -  -  - -  -  -  - -  -  -  -
'use strict';
-const axios = require('axios');
-const Catalog = require('./catalog');
-const Kv = require('./kv');
- 
-class Consul {
-  constructor(config) {
-    this.host = config.host;
-    this.port = config.port;
- 
-    this.acl = config.acl;
-    this.dc = config.dc || false;
-  }
- 
-  _send(method, uri, body) {
-    Eif (this.acl) {
-      uri += uri.indexOf('?') > -1 ? '&' : '?';
-      uri += `token=${this.acl}`;
-    }
-    let request = {
-      method,
-      baseURL: `http://${this.host}:${this.port}`,
-      url: `${uri}`,
-      transformResponse: [
-        (data) => {
-          let resp;
-          try {
-            resp = JSON.parse(data);
-          } catch (error) {
-            throw Error(
-              `[requestClient] Error parsingJSON data ${error}`
-            );
-          }
-          return resp;
-        },
-      ],
-    };
- 
-    if (body) {
-      request.data = body;
-    }
-    return axios(request);
-  }
- 
-  _get(uri) {
-    return this._send('GET', uri);
-  }
- 
-  /*
-  _post (uri, data) {
-    if (this.dc) {
-      data.Datacenter = this.dc;
-    }
- 
-    return this._send('POST', uri, data);
-  }
-  */
- 
-  _put(uri, data) {
-    if (this.dc) {
-      data.Datacenter = this.dc;
-    }
- 
-    return this._send('PUT', uri, data);
-  }
- 
-  _delete(uri) {
-    return this._send('DELETE', uri);
-  }
- 
-  get catalog() {
-    return new Catalog(this);
-  }
- 
-  get kv() {
-    return new Kv(this);
-  }
-}
- 
-module.exports = Consul;
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/consul/kv.js.html b/coverage/lcov-report/lib/consul/kv.js.html deleted file mode 100644 index 88aaf3b..0000000 --- a/coverage/lcov-report/lib/consul/kv.js.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - Code coverage report for lib/consul/kv.js - - - - - - - -
-
-

- all files / lib/consul/ kv.js -

-
-
- 88.89% - Statements - 8/9 -
-
- 50% - Branches - 1/2 -
-
- 100% - Functions - 5/5 -
-
- 88.89% - Lines - 8/9 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31  -  -  -  - -  -  -  - -  -  -  - -  -  -  - -  -  -  - -  - -  -  -  - -  -  -  -
'use strict';
- 
-class Kv {
-  constructor (consul) {
-    this.consul = consul;
-  }
- 
-  keys (prefix) {
-    return this.consul._get(`/v1/kv/${prefix}?keys`);
-  }
- 
-  set (key, value) {
-    return this.consul._put(`/v1/kv/${key}`, value);
-  }
- 
-  get (key) {
-    return this.consul._get(`/v1/kv/${key}?raw`);
-  }
- 
-  delete (key, recurse) {
-    let url = `/v1/kv/${key}`;
- 
-    Iif (recurse === true) {
-      url += '?recurse';
-    }
- 
-    return this.consul._delete(url);
-  }
-}
- 
-module.exports = Kv;
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/container-to-consul.js.html b/coverage/lcov-report/lib/container-to-consul.js.html deleted file mode 100644 index 1017754..0000000 --- a/coverage/lcov-report/lib/container-to-consul.js.html +++ /dev/null @@ -1,890 +0,0 @@ - - - - Code coverage report for lib/container-to-consul.js - - - - - - - -
-
-

- all files / lib/ container-to-consul.js -

-
-
- 93.64% - Statements - 103/110 -
-
- 86.27% - Branches - 44/51 -
-
- 100% - Functions - 10/10 -
-
- 93.58% - Lines - 102/109 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276  -  -22× -22× -22× -22× -22× -  -  -  -21× -  -21× -21× -21× -  -21× -  -  -  -25× - -  - -  - - -  -  -25× - -  - -  - - -  -  -  -  -  - -  - -  - - -  - -  -  - - -  - -  -  - - -  -  -  - - -  - - -  -  -  -  - - -  - - -  -  -  -  -  -  -  -  -  - -  -  -  -  -  -  -  -  - -  - - -  -  - - - -  -  - -  -  - -  - - - -  - - - -  -  -  -  -  -  -  -  -  -  - -  -  -  -  - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - -  - - - -  - - -  -  -  -  -  -  -  -  -  -  - -  -  -  -  -  -  - -  -  -  -  - - -  -  - -  - -  -  - - - -  - - - -  - -  - - - - -  -  -  -  -  -  - -  - - -  - -  - - -  -  -  -  - -  - -  -  -  -  -  -  -  -  -  - -  - - -  -  - - - -  - - -  - -  - -  -  -  -  -  -  -  -  -  - - - -  - -  -  -  -  -22× - 
'use strict';
- 
-const bunyan = require('bunyan');
-const Consul = require('./consul');
-const Docker = require('./docker');
-const Promise = require('bluebird');
-const SkipError = require('./errors/skipError');
- 
-class ContainertoConsul {
-  constructor(config) {
-    this.config = config;
- 
-    this.consul = new Consul(config.consul);
-    this.docker = new Docker(this);
-    this.log = bunyan.createLogger(config.logger);
- 
-    this._attachEvents();
-  }
- 
-  _attachEvents() {
-    this.docker.events.on('start', msg => {
-      return this.docker.client.getContainer(msg.id)
-        .inspect()
-        .then(container => this.registerContainer(container))
-        .catch(error => {
-          this.log.error(error);
-          throw error;
-        });
-    });
-    this.docker.events.on('die', msg => {
-      return this.docker.client.getContainer(msg.id)
-        .inspect()
-        .then(container => this.deregisterService(this.containerServiceName(container)))
-        .catch(error => {
-          this.log.error(error);
-          throw error;
-        });
-    });
-  }
- 
-  start() {
-    return this.docker.start()
-      // deregister containers that do not run
-      .then(() => this.consul.kv.keys('docker/service-ids/')
-        .catch(error => {
-          if (error.statusCode && error.statusCode === 404) {
-            return [];
-          }
-          throw error;
-        }))
-      .then(keys => {
-        return Promise.all(keys.map(key => {
-          return this.consul.kv.get(key)
-            .then(containerId => {
-              return this.docker.client.getContainer(containerId)
-                .inspect()
-                .then(container => {
-                  Eif (container.State.Status !== 'running') {
-                    return this.deregisterService(key);
-                  }
-                })
-                .catch(error => {
-                  if (error.statusCode && error.statusCode === 404) {
-                    return this.deregisterService(key);
-                  }
-                  this.log.error(error);
-                  throw error;
-                });
-            });
-        }));
-      })
-      .then(() => this.docker.containers())
-      .then(containers => this.registerContainers(containers))
-      .catch(error => {
-        this.log.error(error);
-        throw error;
-      });
-  }
- 
-  /**
-   *
-   * @param {Container[]} containers
-   * @returns {Promise.<*>}
-   */
-  registerContainers(containers) {
-    return Promise.all(containers.map(container => this.registerContainer(container)));
-  }
- 
-  /**
-   *
-   * @param {Container} container
-   * @returns {Promise}
-   */
-  registerContainer(container) {
-    let service;
- 
-    try {
-      service = this.container2Service(container);
-    }
-    catch (e) {
-      if (e instanceof SkipError) {
-        this.log.info(e.message);
-        return Promise.resolve();
-      }
- 
-      return Promise.reject(e);
-    }
- 
-    this.log.info('registering container', service);
- 
-    return this.registerContainerKv(container)
-      .then(() => this.consul.catalog.register(service))
-      .then(() => this.consul.kv.set(`docker/service-ids/${this.containerServiceName(container)}`, container.Id))
-      .catch(error => {
-        this.consul.kv.delete(`services/${this.containerServiceName(container)}`, true);
-        this.log.error(error);
-        throw error;
-      });
-  }
- 
-  /**
-   * Registers key/value pairs for the container
-   *
-   * @param {Container} container
-   * @returns {Promise}
-   */
-  registerContainerKv(container) {
-    const
-      lbls = this._containerLabels(container),
-      promises = [],
-      serviceName = this.containerServiceName(container);
- 
-    Eif (!lbls) {
-      return Promise.resolve();
-    }
- 
-    Object.keys(lbls).forEach(label => {
-      if (label.startsWith('consul.kv.')) {
-        const
-          key = label.replace(/^consul\.kv\./, ''),
-          val = lbls[label];
- 
-        promises.push(this.consul.kv.set(`services/${serviceName}/${key}`, val));
-      }
-    });
- 
-    return Promise.all(promises);
-  }
- 
-  /**
-   * Un-register a service and related information from Consul
-   *
-   * @param {string} service
-   * @returns {Promise}
-   */
-  deregisterService(service) {
-    this.log.info('deregistering container', service);
- 
-    return this.consul.catalog.deregister({ Node: service })
-      .then(() => this.consul.kv.delete(`docker/service-ids/${service}`))
-      .then(() => this.consul.kv.delete(`services/${service}`, true))
-      .catch(error => {
-        this.log.error(error);
-        throw error;
-      });
-  }
- 
-  /**
-   * Given a container, returns a service definition ready to be consumed by Consul catalog/register API endpoint
-   *
-   * @param container
-   * @returns {Object}
-   */
-  container2Service(container) {
-    let service = {
-      Node: this.containerServiceName(container),
-      Address: this.docker.docker0,
-      Service: {
-        Service: this.containerServiceName(container)
-      }
-    };
-    let containerIPAddress = container
-      .NetworkSettings
-      .Networks[Object.keys(container.NetworkSettings.Networks)[0]]
-      .IPAddress;
- 
-    Eif (containerIPAddress !== '') {
-      service.Address = containerIPAddress;
-    }
- 
-    const lbls = this._containerLabels(container);
- 
-    Iif (Object.keys(lbls).length === 0 || lbls['consul.register'] === 'false' || !lbls['consul.register']) {
-      throw new SkipError(`Container ${this.containerServiceName(container)} skipped`);
-    }
-    Eif (lbls) {
-      Object.keys(lbls).forEach(label => {
-        switch (label) {
-          case 'consul.ip':
-            service.Address = lbls[label];
-            if (service.Address === 'host') {
-              service.Address = this.docker.docker0;
-            }
-            break;
-          case 'consul.port':
-            try {
-              service.Service.Port = parseInt(lbls[label]);
-              if (isNaN(service.Service.Port)) {
-                delete service.Service.Port;
-              }
-            }
-            catch (e) {
-              // do nothing
-              this.log.error(e);
-            }
-            break;
-          case 'consul.service':
-            service.Service.Service = lbls[label];
-            break;
-          case 'consul.tags':
-            service.Service.Tags = lbls[label]
-              .split(',')
-              .map(tag => tag.trim());
-            break;
-        }
-      });
-    }
- 
-    this.log.debug('service', service);
- 
-    return service;
-  }
- 
-  /**
-   * Returns the service name for the container
-   *
-   * @param {Container} container
-   * @returns {string}
-   */
-  containerServiceName(container) {
-    let name = container.Name;
- 
-    if (!name && container.Names) {
-      name = container.Names[0];
-    }
- 
-    let lbls = container.Labels;
-    if (!lbls && container.Config && container.Config.Labels) {
-      lbls = container.Config.Labels;
-    }
-    if (lbls && lbls['consul.name']) {
-      name = lbls['consul.name'];
-    }
-    name = name.replace(/^\//, '');
- 
-    return name;
-  }
- 
-  /**
-   *
-   * @param container
-   * @returns {Object}
-   * @private
-   */
-  _containerLabels(container) {
-    let lbls = container.Labels;
-    if (!lbls && container.Config && container.Config.Labels) {
-      lbls = container.Config.Labels;
-    }
-    return lbls;
-  }
- 
-}
- 
-module.exports = ContainertoConsul;
- 
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/docker.js.html b/coverage/lcov-report/lib/docker.js.html deleted file mode 100644 index 97e61f9..0000000 --- a/coverage/lcov-report/lib/docker.js.html +++ /dev/null @@ -1,230 +0,0 @@ - - - - Code coverage report for lib/docker.js - - - - - - - -
-
-

- all files / lib/ docker.js -

-
-
- 100% - Statements - 26/26 -
-
- 100% - Branches - 2/2 -
-
- 100% - Functions - 3/3 -
-
- 100% - Lines - 25/25 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56  -  - - - - -  -  -  - -  - - - - -  -  -  -  -  - - -  - - -  - -  - - -  -  -  - - - -  -  -  -  - - -  -  - - -  -  -  -  - -  -  -  - - 
'use strict';
- 
-const DockerOde = require('dockerode');
-const DockerOdePromise = require('dockerode-promise');
-const DockerEvents = require('docker-events');
-const Promise = require('bluebird');
- 
-class Docker {
-  constructor (containertoConsul) {
-    this.containertoConsul = containertoConsul;
- 
-    this.config = containertoConsul.config.docker;
-    this.client = new DockerOdePromise(this.config);
-    this.docker0 = '172.17.0.1';
-    this.events = new DockerEvents({
-      docker: new DockerOde(this.config)
-    });
-  }
- 
-  start () {
-    return new Promise((resolve) => {
-      this.events.start();
- 
-      this.events.on('connect', () => {
-        this.containertoConsul.log.info('Connected to docker');
- 
-        return this.client.listNetworks()
-          .then(networks => {
-            this.docker0 = networks.filter(net => net.Name === 'bridge')[0].IPAM.Config[0].Gateway;
-            resolve();
-          });
-      });
- 
-      this.events.on('disconnect', () => {
-        this.containertoConsul.log.warn('Disconnected from Docker. Reconnecting');
-        return this.start();
-      });
-    })
-      .timeout(this.config.connectTimeout)
-      .catch(error => {
-        if (error instanceof Promise.TimeoutError) {
-          return this.start();
-        }
- 
-        this.containertoConsul.log.error(error);
-        return Promise.reject(error);
-      });
-  }
- 
-  containers () {
-    return this.client.listContainers();
-  }
-}
- 
-module.exports = Docker;
- 
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/errors/index.html b/coverage/lcov-report/lib/errors/index.html deleted file mode 100644 index 2a0038d..0000000 --- a/coverage/lcov-report/lib/errors/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Code coverage report for lib/errors/ - - - - - - - -
-
-

- all files lib/errors/ -

-
-
- 100% - Statements - 2/2 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 2/2 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
skipError.js
100%2/2100%0/0100%1/1100%2/2
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/errors/skipError.js.html b/coverage/lcov-report/lib/errors/skipError.js.html deleted file mode 100644 index 50dd2f3..0000000 --- a/coverage/lcov-report/lib/errors/skipError.js.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - Code coverage report for lib/errors/skipError.js - - - - - - - -
-
-

- all files / lib/errors/ skipError.js -

-
-
- 100% - Statements - 2/2 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 2/2 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10  -  -  -  - -  -  -  - - 
'use strict';
- 
-class SkipError extends Error {
-  constructor (msg) {
-    super(msg);
-  }
-}
- 
-module.exports = SkipError;
- 
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/index.html b/coverage/lcov-report/lib/index.html deleted file mode 100644 index 6afec62..0000000 --- a/coverage/lcov-report/lib/index.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - Code coverage report for lib/ - - - - - - - -
-
-

- all files lib/ -

-
-
- 94.85% - Statements - 129/136 -
-
- 86.79% - Branches - 46/53 -
-
- 100% - Functions - 13/13 -
-
- 94.78% - Lines - 127/134 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
container-to-consul.js
93.64%103/11086.27%44/51100%10/1093.58%102/109
docker.js
100%26/26100%2/2100%3/3100%25/25
typedefs.js
100%0/0100%0/0100%0/0100%0/0
-
-
- - - - - - - diff --git a/coverage/lcov-report/lib/typedefs.js.html b/coverage/lcov-report/lib/typedefs.js.html deleted file mode 100644 index 7b2b278..0000000 --- a/coverage/lcov-report/lib/typedefs.js.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - Code coverage report for lib/typedefs.js - - - - - - - -
-
-

- all files / lib/ typedefs.js -

-
-
- 100% - Statements - 0/0 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 0/0 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10  -  -  -  -  -  -  -  -  - 
/**
- @typedef
-   {
-    Id: String,
-    Labels: String[]
- 
- 
-   } Container
- 
- **/
-
-
- - - - - - - diff --git a/coverage/lcov-report/prettify.css b/coverage/lcov-report/prettify.css deleted file mode 100644 index b317a7c..0000000 --- a/coverage/lcov-report/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/lcov-report/prettify.js b/coverage/lcov-report/prettify.js deleted file mode 100644 index ef51e03..0000000 --- a/coverage/lcov-report/prettify.js +++ /dev/null @@ -1 +0,0 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/lcov-report/sort-arrow-sprite.png b/coverage/lcov-report/sort-arrow-sprite.png deleted file mode 100644 index 03f704a..0000000 Binary files a/coverage/lcov-report/sort-arrow-sprite.png and /dev/null differ diff --git a/coverage/lcov-report/sorter.js b/coverage/lcov-report/sorter.js deleted file mode 100644 index 6c5034e..0000000 --- a/coverage/lcov-report/sorter.js +++ /dev/null @@ -1,158 +0,0 @@ -var addSorting = (function () { - "use strict"; - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { return document.querySelector('.coverage-summary'); } - // returns the thead element of the summary table - function getTableHeader() { return getTable().querySelector('thead tr'); } - // returns the tbody element of the summary table - function getTableBody() { return getTable().querySelector('tbody'); } - // returns the th element for nth column - function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = colNode.innerHTML + ''; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function (a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function (a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function () { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i =0 ; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function () { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(cols); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); diff --git a/coverage/lcov.info b/coverage/lcov.info deleted file mode 100644 index 989d034..0000000 --- a/coverage/lcov.info +++ /dev/null @@ -1,362 +0,0 @@ -TN: -SF:/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/consul/catalog.js -FN:4,(anonymous_1) -FN:8,(anonymous_2) -FN:12,(anonymous_3) -FNF:3 -FNH:3 -FNDA:3,(anonymous_1) -FNDA:1,(anonymous_2) -FNDA:1,(anonymous_3) -DA:5,3 -DA:9,1 -DA:13,1 -DA:17,1 -LF:4 -LH:4 -BRF:0 -BRH:0 -end_of_record -TN: -SF:/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/consul/kv.js -FN:4,(anonymous_1) -FN:8,(anonymous_2) -FN:12,(anonymous_3) -FN:16,(anonymous_4) -FN:20,(anonymous_5) -FNF:5 -FNH:5 -FNDA:5,(anonymous_1) -FNDA:1,(anonymous_2) -FNDA:1,(anonymous_3) -FNDA:1,(anonymous_4) -FNDA:1,(anonymous_5) -DA:5,5 -DA:9,1 -DA:13,1 -DA:17,1 -DA:21,1 -DA:23,1 -DA:24,0 -DA:27,1 -DA:31,1 -LF:9 -LH:8 -BRDA:23,1,0,0 -BRDA:23,1,1,1 -BRF:2 -BRH:1 -end_of_record -TN: -SF:/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/errors/skipError.js -FN:4,(anonymous_1) -FNF:1 -FNH:1 -FNDA:1,(anonymous_1) -DA:5,1 -DA:9,1 -LF:2 -LH:2 -BRF:0 -BRH:0 -end_of_record -TN: -SF:/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/consul/index.js -FN:7,(anonymous_1) -FN:15,(anonymous_2) -FN:45,(anonymous_3) -FN:59,(anonymous_4) -FN:67,(anonymous_5) -FN:71,(anonymous_6) -FN:75,(anonymous_7) -FNF:7 -FNH:7 -FNDA:6,(anonymous_1) -FNDA:2,(anonymous_2) -FNDA:1,(anonymous_3) -FNDA:2,(anonymous_4) -FNDA:1,(anonymous_5) -FNDA:1,(anonymous_6) -FNDA:1,(anonymous_7) -DA:2,1 -DA:3,1 -DA:4,1 -DA:8,6 -DA:9,6 -DA:11,6 -DA:12,6 -DA:16,2 -DA:17,2 -DA:18,2 -DA:20,2 -DA:26,0 -DA:27,0 -DA:28,0 -DA:30,0 -DA:34,0 -DA:39,2 -DA:40,1 -DA:42,2 -DA:46,1 -DA:60,2 -DA:61,1 -DA:64,2 -DA:68,1 -DA:72,1 -DA:76,1 -DA:80,1 -LF:27 -LH:22 -BRDA:12,1,0,6 -BRDA:12,1,1,6 -BRDA:16,2,0,2 -BRDA:16,2,1,0 -BRDA:17,3,0,1 -BRDA:17,3,1,1 -BRDA:39,4,0,1 -BRDA:39,4,1,1 -BRDA:60,5,0,1 -BRDA:60,5,1,1 -BRF:10 -BRH:9 -end_of_record -TN: -SF:/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/container-to-consul.js -FN:10,(anonymous_1) -FN:20,(anonymous_2) -FN:41,(anonymous_3) -FN:85,(anonymous_4) -FN:94,(anonymous_5) -FN:127,(anonymous_6) -FN:156,(anonymous_7) -FN:174,(anonymous_8) -FN:240,(anonymous_9) -FN:265,(anonymous_10) -FNF:10 -FNH:10 -FNDA:21,(anonymous_1) -FNDA:25,(anonymous_2) -FNDA:5,(anonymous_3) -FNDA:1,(anonymous_4) -FNDA:4,(anonymous_5) -FNDA:2,(anonymous_6) -FNDA:2,(anonymous_7) -FNDA:3,(anonymous_8) -FNDA:3,(anonymous_9) -FNDA:5,(anonymous_10) -DA:3,22 -DA:4,22 -DA:5,22 -DA:6,22 -DA:7,22 -DA:11,21 -DA:13,21 -DA:14,21 -DA:15,21 -DA:17,21 -DA:21,25 -DA:22,2 -DA:24,1 -DA:26,1 -DA:27,1 -DA:30,25 -DA:31,2 -DA:33,1 -DA:35,1 -DA:36,1 -DA:42,5 -DA:44,5 -DA:46,2 -DA:47,1 -DA:49,1 -DA:52,4 -DA:53,6 -DA:55,6 -DA:58,1 -DA:59,1 -DA:63,5 -DA:64,4 -DA:66,1 -DA:67,1 -DA:72,3 -DA:73,3 -DA:75,2 -DA:76,2 -DA:86,2 -DA:95,4 -DA:97,4 -DA:98,4 -DA:101,2 -DA:102,1 -DA:103,1 -DA:106,1 -DA:109,2 -DA:111,2 -DA:112,2 -DA:113,1 -DA:115,1 -DA:116,1 -DA:117,1 -DA:128,2 -DA:133,2 -DA:134,2 -DA:137,0 -DA:138,0 -DA:139,0 -DA:143,0 -DA:147,0 -DA:157,2 -DA:159,2 -DA:160,1 -DA:161,1 -DA:163,1 -DA:164,1 -DA:175,3 -DA:182,3 -DA:187,3 -DA:188,3 -DA:191,3 -DA:193,3 -DA:194,0 -DA:196,3 -DA:197,3 -DA:198,9 -DA:200,2 -DA:201,2 -DA:202,1 -DA:204,2 -DA:206,2 -DA:207,2 -DA:208,2 -DA:209,1 -DA:214,0 -DA:216,2 -DA:218,1 -DA:219,1 -DA:221,1 -DA:223,2 -DA:224,1 -DA:229,3 -DA:231,3 -DA:241,3 -DA:243,3 -DA:244,1 -DA:247,3 -DA:248,3 -DA:249,1 -DA:251,3 -DA:252,2 -DA:254,3 -DA:256,3 -DA:266,5 -DA:267,5 -DA:268,1 -DA:270,5 -DA:275,22 -LF:109 -LH:102 -BRDA:46,1,0,1 -BRDA:46,1,1,1 -BRDA:46,2,0,2 -BRDA:46,2,1,1 -BRDA:58,3,0,1 -BRDA:58,3,1,0 -BRDA:63,4,0,4 -BRDA:63,4,1,1 -BRDA:63,5,0,5 -BRDA:63,5,1,4 -BRDA:101,6,0,1 -BRDA:101,6,1,1 -BRDA:133,7,0,2 -BRDA:133,7,1,0 -BRDA:138,8,0,0 -BRDA:138,8,1,0 -BRDA:187,9,0,3 -BRDA:187,9,1,0 -BRDA:193,10,0,0 -BRDA:193,10,1,3 -BRDA:193,11,0,3 -BRDA:193,11,1,3 -BRDA:193,11,2,3 -BRDA:196,12,0,3 -BRDA:196,12,1,0 -BRDA:198,13,0,2 -BRDA:198,13,1,2 -BRDA:198,13,2,1 -BRDA:198,13,3,1 -BRDA:201,14,0,1 -BRDA:201,14,1,1 -BRDA:208,15,0,1 -BRDA:208,15,1,1 -BRDA:243,16,0,1 -BRDA:243,16,1,2 -BRDA:243,17,0,3 -BRDA:243,17,1,1 -BRDA:248,18,0,1 -BRDA:248,18,1,2 -BRDA:248,19,0,3 -BRDA:248,19,1,2 -BRDA:248,19,2,1 -BRDA:251,20,0,2 -BRDA:251,20,1,1 -BRDA:251,21,0,3 -BRDA:251,21,1,2 -BRDA:267,22,0,1 -BRDA:267,22,1,4 -BRDA:267,23,0,5 -BRDA:267,23,1,3 -BRDA:267,23,2,1 -BRF:51 -BRH:44 -end_of_record -TN: -SF:/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/docker.js -FN:9,(anonymous_1) -FN:20,(anonymous_2) -FN:50,(anonymous_3) -FNF:3 -FNH:3 -FNDA:6,(anonymous_1) -FNDA:6,(anonymous_2) -FNDA:1,(anonymous_3) -DA:3,7 -DA:4,7 -DA:5,7 -DA:6,7 -DA:10,6 -DA:12,6 -DA:13,6 -DA:14,6 -DA:15,6 -DA:21,6 -DA:22,6 -DA:24,5 -DA:25,4 -DA:27,4 -DA:29,4 -DA:30,4 -DA:34,5 -DA:35,1 -DA:36,1 -DA:41,2 -DA:42,1 -DA:45,1 -DA:46,1 -DA:51,1 -DA:55,7 -LF:25 -LH:25 -BRDA:41,1,0,1 -BRDA:41,1,1,1 -BRF:2 -BRH:2 -end_of_record -TN: -SF:/Users/emmanuelnyachoke/Code/Mekom/con-tainer2sul/lib/typedefs.js -FNF:0 -FNH:0 -LF:0 -LH:0 -BRF:0 -BRH:0 -end_of_record diff --git a/e2e/docker/test-compose.yaml b/e2e/docker/test-compose.yaml index 8a47eac..b294d22 100644 --- a/e2e/docker/test-compose.yaml +++ b/e2e/docker/test-compose.yaml @@ -8,6 +8,7 @@ services: - "consul.service=nginx-register" - "consul.ip=10.0.0.1" - "consul.register=true" + - "consul.meta=metrics_path='/metrics'" nginx2: image: nginx:1-alpine labels: @@ -15,5 +16,6 @@ services: - "consul.tags=nginx" - "consul.ip=10.0.0.1" - "consul.register=true" + - "consul.meta=metrics_path=/metrics" nginx-ignore: image: nginx:1-alpine \ No newline at end of file diff --git a/lib/consul/index.js b/lib/consul/index.js index eef1602..adad908 100644 --- a/lib/consul/index.js +++ b/lib/consul/index.js @@ -24,6 +24,9 @@ class Consul { transformResponse: [ (data) => { let resp; + if (!data) { + return {}; + } try { resp = JSON.parse(data); } catch (error) { diff --git a/lib/container-to-consul.js b/lib/container-to-consul.js index 8a6c8f7..6631e00 100644 --- a/lib/container-to-consul.js +++ b/lib/container-to-consul.js @@ -5,6 +5,7 @@ const Consul = require('./consul'); const Docker = require('./docker'); const Promise = require('bluebird'); const SkipError = require('./errors/skipError'); +const parse = require('./parse-key-pair'); class ContainertoConsul { constructor(config) { @@ -43,7 +44,7 @@ class ContainertoConsul { // deregister containers that do not run .then(() => this.consul.kv.keys('docker/service-ids/') .catch(error => { - if (error.statusCode && error.statusCode === 404) { + if (error.response && error.response.status && error.response.status === 404) { return []; } throw error; @@ -176,7 +177,10 @@ class ContainertoConsul { Node: this.containerServiceName(container), Address: this.docker.docker0, Service: { - Service: this.containerServiceName(container) + Service: this.containerServiceName(container), + Meta: { + redis_version: '4.0' + } } }; let containerIPAddress = container @@ -222,6 +226,9 @@ class ContainertoConsul { .split(',') .map(tag => tag.trim()); break; + case 'consul.meta': + service.Service.Meta = parse(lbls[label]); + break; } }); } diff --git a/lib/parse-key-pair.js b/lib/parse-key-pair.js new file mode 100644 index 0000000..e87c5df --- /dev/null +++ b/lib/parse-key-pair.js @@ -0,0 +1,38 @@ +function parser(string, results) { + 'use strict'; + const result = /((?:"[^"]+[^\\]")|(?:'[^']+[^\\]')|(?:[^=]+))\s*=\s*("(?:[\s\S]*?[^\\])"|'(?:[\s\S]*?[^\\])'|(?:.*?[^\\])|$)(?:;|$)(?:\s*(.*))?/m.exec(string); + if (result && result[1]) { + const key = result[1].trim().replace(/(^\s*["'])|(["']\s*$)/g, ''); + if (typeof result[2] === 'string') { + const val = result[2].replace(/(^\s*[\\]?["'])|([\\]?["']\s*$)/g, ''); + // const val = result[2]; + if (/^[0-9-.,]+$/.test(val)) { + results[key] = parseFloat(val); + } else if (val === '') { + results[key] = undefined; + } else if (val.toLowerCase() === 'true') { + results[key] = true; + } else if (val.toLowerCase() === 'false') { + results[key] = false; + } else { + results[key] = val; + } + } else { + results[result[1].trim()] = undefined; + } + if (result[3] && result[3].length > 1) { + parser(result[3], results); + } + } +} + +module.exports = function (string, object) { + 'use strict'; + if (object) { + parser(string, object); + } else { + object = {}; + parser(string, object); + return object; + } +}; \ No newline at end of file diff --git a/test/lib/container-to-consul.test.js b/test/lib/container-to-consul.test.js index f72136c..0ab8d7c 100644 --- a/test/lib/container-to-consul.test.js +++ b/test/lib/container-to-consul.test.js @@ -236,7 +236,7 @@ describe('container-to-consul', () => { it('should not fail if no docker/service-ids key is stored in consul', () => { var error = new Error('test'); - error.statusCode = 404; + error.response = {status: 404}; containertoConsul.consul.kv.keys.rejects(error); @@ -420,6 +420,7 @@ describe('container-to-consul', () => { 'consul.port': '8888 consul port', 'consul.service': 'consul service', 'consul.tags': 'consul,tags', + 'consul.meta': 'key=value', 'consul.register': 'true' } }, @@ -436,6 +437,7 @@ describe('container-to-consul', () => { should(result.Service.Service).be.exactly('consul service'); should(result.Service.Port).be.exactly(8888); should(result.Service.Tags).match(['consul', 'tags']); + should(result.Service.Meta).match({key:'value'}); }); it('should not set the port if it does not manage to cast it to an int', () => {