github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui/javascripts/fixtures.js (about) 1 // 2 // I intentionally am not using ember-data and the fixture 3 // adapter. I'm not confident the Consul UI API will be compatible 4 // without a bunch of wrangling, and it's really not enough updating 5 // of the models to justify the use of such a big component. getJSON 6 // *should* be enough. 7 // 8 9 window.fixtures = {} 10 11 // 12 // The array route, i.e /ui/<dc>/services, should return _all_ services 13 // in the DC 14 // 15 fixtures.services = [ 16 { 17 "Name": "vagrant-cloud-http", 18 "Checks": [ 19 { 20 "Name": "serfHealth", 21 "Status": "passing" 22 }, 23 { 24 "Name": "fooHealth", 25 "Status": "critical" 26 }, 27 { 28 "Name": "bazHealth", 29 "Status": "passing" 30 } 31 ], 32 "Nodes": [ 33 "node-10-0-1-109", 34 "node-10-0-1-102" 35 ] 36 }, 37 { 38 "Name": "vagrant-share-mux", 39 "Checks": [ 40 { 41 "Name": "serfHealth", 42 "Status": "critical" 43 }, 44 { 45 "Name": "fooHealth", 46 "Status": "passing" 47 }, 48 { 49 "Name": "bazHealth", 50 "Status": "passing" 51 } 52 ], 53 "Nodes": [ 54 "node-10-0-1-109", 55 "node-10-0-1-102" 56 ] 57 }, 58 ] 59 60 // 61 // This one is slightly more complicated to allow more UI interaction. 62 // It represents the route /ui/<dc>/services/<service> BUT it's what is 63 // BELOW the top-level key. 64 // 65 // So, what is actually returned should be similar to the /catalog/service/<service> 66 // endpoint. 67 fixtures.services_full = { 68 "vagrant-cloud-http": 69 // This array is what is actually expected from the API. 70 [ 71 { 72 "ServicePort": 80, 73 "ServiceTags": null, 74 "ServiceName": "vagrant-cloud-http", 75 "ServiceID": "vagrant-cloud-http", 76 "Address": "10.0.1.109", 77 "Node": "node-10-0-1-109", 78 "Checks": [ 79 { 80 "ServiceName": "", 81 "ServiceID": "", 82 "Notes": "", 83 "Status": "critical", 84 "Name": "Serf Health Status", 85 "CheckID": "serfHealth", 86 "Node": "node-10-0-1-109" 87 } 88 ] 89 }, 90 // A node 91 { 92 "ServicePort": 80, 93 "ServiceTags": null, 94 "ServiceName": "vagrant-cloud-http", 95 "ServiceID": "vagrant-cloud-http", 96 "Address": "10.0.1.102", 97 "Node": "node-10-0-1-102", 98 "Checks": [ 99 { 100 "ServiceName": "", 101 "ServiceID": "", 102 "Notes": "", 103 "Status": "passing", 104 "Name": "Serf Health Status", 105 "CheckID": "serfHealth", 106 "Node": "node-10-0-1-102" 107 } 108 ] 109 } 110 ], 111 "vagrant-share-mux": [ 112 // A node 113 { 114 "ServicePort": 80, 115 "ServiceTags": null, 116 "ServiceName": "vagrant-share-mux", 117 "ServiceID": "vagrant-share-mux", 118 "Address": "10.0.1.102", 119 "Node": "node-10-0-1-102", 120 "Checks": [ 121 { 122 "ServiceName": "vagrant-share-mux", 123 "ServiceID": "vagrant-share-mux", 124 "Notes": "", 125 "Output": "200 ok", 126 "Status": "passing", 127 "Name": "Foo Healthy", 128 "CheckID": "fooHealth", 129 "Node": "node-10-0-1-102" 130 } 131 ] 132 }, 133 // A node 134 { 135 "ServicePort": 80, 136 "ServiceTags": null, 137 "ServiceName": "vagrant-share-mux", 138 "ServiceID": "vagrant-share-mux", 139 "Address": "10.0.1.109", 140 "Node": "node-10-0-1-109", 141 "Checks": [ 142 { 143 "ServiceName": "", 144 "ServiceID": "", 145 "Notes": "", 146 "Output": "foobar baz", 147 "Status": "passing", 148 "Name": "Baz Status", 149 "CheckID": "bazHealth", 150 "Node": "node-10-0-1-109" 151 }, 152 { 153 "ServiceName": "", 154 "ServiceID": "", 155 "Notes": "", 156 "Output": "foobar baz", 157 "Status": "critical", 158 "Name": "Serf Health Status", 159 "CheckID": "serfHealth", 160 "Node": "node-10-0-1-109" 161 } 162 ] 163 } 164 ] 165 } 166 167 // 168 // /ui/<dc>/nodes 169 // all the nodes 170 // 171 fixtures.nodes = [ 172 { 173 "Address": "10.0.1.109", 174 "Name": "node-10-0-1-109", 175 "Services": [ 176 "vagrant-share-mux", 177 "vagrant-cloud-http" 178 ], 179 "Checks": [ 180 { 181 "Name": "serfHealth", 182 "Status": "critical" 183 }, 184 { 185 "Name": "bazHealth", 186 "Status": "passing" 187 } 188 ] 189 }, 190 { 191 "Address": "10.0.1.102", 192 "Name": "node-10-0-1-102", 193 "Services": [ 194 "vagrant-share-mux", 195 "vagrant-cloud-http" 196 ], 197 "Checks": [ 198 { 199 "Name": "fooHealth", 200 "Status": "passing" 201 } 202 ], 203 } 204 ] 205 206 // These are for retrieving individual nodes. Same story as services, 207 // the top level key is just for the demo. 208 fixtures.nodes_full = { 209 "node-10-0-1-109": 210 // This is what would be returned. 211 { 212 "Services": [ 213 { 214 "Port": 0, 215 "Tags": null, 216 "Service": "vagrant-share-mux", 217 "ID": "vagrant-share-mux" 218 }, 219 { 220 "Port": 80, 221 "Tags": null, 222 "Service": "vagrant-cloud-http", 223 "ID": "vagrant-cloud-http" 224 } 225 ], 226 "Node": { 227 "Address": "10.0.1.109", 228 "Node": "node-10-0-1-109" 229 }, 230 "Checks": [ 231 { 232 "ServiceName": "", 233 "ServiceID": "", 234 "Notes": "Checks the status of the serf agent", 235 "Status": "critical", 236 "Name": "Serf Health Status", 237 "CheckID": "serfHealth", 238 "Node": "node-10-0-1-109" 239 }, 240 { 241 "ServiceName": "", 242 "ServiceID": "", 243 "Notes": "", 244 "Output": "foobar baz", 245 "Status": "passing", 246 "Name": "Baz Status", 247 "CheckID": "bazHealth", 248 "Node": "node-10-0-1-109" 249 } 250 ] 251 }, 252 "node-10-0-1-102": { 253 "Services": [ 254 { 255 "Port": 0, 256 "Tags": null, 257 "Service": "vagrant-share-mux", 258 "ID": "vagrant-share-mux" 259 }, 260 { 261 "Port": 80, 262 "Tags": null, 263 "Service": "vagrant-cloud-http", 264 "ID": "vagrant-cloud-http" 265 } 266 ], 267 "Node": { 268 "Address": "10.0.1.102", 269 "Node": "node-10-0-1-102" 270 }, 271 "Checks": [ 272 { 273 "ServiceName": "", 274 "ServiceID": "", 275 "Notes": "Checks if the food is healthy", 276 "Output": "foobar baz", 277 "Status": "passing", 278 "Name": "Foo Healthy", 279 "CheckID": "fooStatus", 280 "Node": "node-10-0-1-102" 281 } 282 ] 283 } 284 } 285 286 fixtures.dcs = ['nyc1', 'sf1', 'sg1'] 287 288 fixtures.keys_full = { 289 "/": [ 290 'foobar', 291 'application', 292 'web/' 293 ], 294 "application": { 295 'key': 'application', 296 'value': 'foobarz' 297 }, 298 "foobar": { 299 'key': 'foobar', 300 'value': 'baz' 301 }, 302 "web/foo/bar": { 303 'key': 'web/foo/bar', 304 'value': 'baz' 305 }, 306 "web/foo/baz": { 307 'key': 'web/foo/baz', 308 'value': 'test' 309 }, 310 "web/": [ 311 "web/foo/" 312 ], 313 "web/foo/": [ 314 "web/foo/bar", 315 "web/foo/baz" 316 ] 317 };