Check for all k8s topos before defaulting to container topo

- Show something from k8s by default if its around.
This commit is contained in:
Simon Howe
2016-08-23 14:13:54 +02:00
parent eeeb1385c5
commit 343a986951

View File

@@ -2,10 +2,16 @@ import _ from 'lodash';
import { is as isDeepEqual, Map as makeMap, Set as makeSet, List as makeList } from 'immutable';
const TOPOLOGY_DISPLAY_PRIORITY = {
services: 1,
containers: 2,
};
//
// top priority first
//
const TOPOLOGY_DISPLAY_PRIORITY = [
'services',
'deployments',
'replica-sets',
'pods',
'containers',
];
export function getDefaultTopology(topologies) {
@@ -13,7 +19,10 @@ export function getDefaultTopology(topologies) {
.flatMap(t => makeList([t]).concat(t.get('sub_topologies', makeList())));
return flatTopologies
.sortBy(t => TOPOLOGY_DISPLAY_PRIORITY[t.get('id')] || Infinity)
.sortBy(t => {
const index = TOPOLOGY_DISPLAY_PRIORITY.indexOf(t.get('id'));
return index === -1 ? Infinity : index;
})
.getIn([0, 'id']);
}