Skip to content

Commit

Permalink
Check for all k8s topos before defaulting to container topo
Browse files Browse the repository at this point in the history
- Show something from k8s by default if its around.
  • Loading branch information
foot committed Aug 29, 2016
1 parent dd5dd28 commit c2ac5f6
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions client/app/scripts/utils/topology-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@ 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) {
const flatTopologies = 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']);
}

Expand Down

0 comments on commit c2ac5f6

Please sign in to comment.