mirror of https://github.com/rancher/ui.git
Lowercase all the labels for scheduling (rancher/rancher#1844)
This commit is contained in:
parent
c6865c4d90
commit
175c70e790
|
|
@ -11,6 +11,29 @@ function splitEquals(str) {
|
||||||
return [ str.substr(0,idx) , str.substr(idx+1) ];
|
return [ str.substr(0,idx) , str.substr(idx+1) ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizedLabels(objects) {
|
||||||
|
var out = {};
|
||||||
|
objects.forEach((obj) => {
|
||||||
|
var labels = obj.get('labels')||{};
|
||||||
|
|
||||||
|
Object.keys(labels).filter((key) => {
|
||||||
|
return key.indexOf(C.LABEL.SYSTEM_PREFIX) !== 0;
|
||||||
|
}).forEach((key) => {
|
||||||
|
let normalizedKey = key.trim().toLowerCase();
|
||||||
|
if ( out[normalizedKey] )
|
||||||
|
{
|
||||||
|
out[normalizedKey].push(labels[key].toLowerCase());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out[normalizedKey] = [labels[key].toLowerCase()];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
rule: null,
|
rule: null,
|
||||||
instance: null,
|
instance: null,
|
||||||
|
|
@ -192,32 +215,18 @@ export default Ember.Component.extend({
|
||||||
return out;
|
return out;
|
||||||
}.property('isGlobal'),
|
}.property('isGlobal'),
|
||||||
|
|
||||||
hostLabelKeyChoices: function() {
|
normalizedHostLabels: function() {
|
||||||
var out = [];
|
return normalizedLabels(this.get('allHosts'));
|
||||||
this.get('allHosts').forEach((host) => {
|
|
||||||
var keys = Object.keys(host.get('labels')||{}).filter((key) => {
|
|
||||||
return key.indexOf(C.LABEL.SYSTEM_PREFIX) !== 0;
|
|
||||||
});
|
|
||||||
out.pushObjects(keys);
|
|
||||||
});
|
|
||||||
|
|
||||||
return out.map((key) => { return (key||'').toLowerCase(); }).sort().uniq();
|
|
||||||
}.property('allHosts.@each.labels'),
|
}.property('allHosts.@each.labels'),
|
||||||
|
|
||||||
|
hostLabelKeyChoices: function() {
|
||||||
|
return Object.keys(this.get('normalizedHostLabels')).sort().uniq();
|
||||||
|
}.property('normalizedHostLabels'),
|
||||||
|
|
||||||
hostLabelValueChoices: function() {
|
hostLabelValueChoices: function() {
|
||||||
var key = this.get('userKey');
|
var key = this.get('userKey').toLowerCase();
|
||||||
|
return ((this.get('normalizedHostLabels')[key])||[]).sort().uniq();
|
||||||
var out = [];
|
}.property('userKey','normalizedHostLabels'),
|
||||||
this.get('allHosts').forEach((host) => {
|
|
||||||
var label = (host.get('labels')||{})[key];
|
|
||||||
if ( label )
|
|
||||||
{
|
|
||||||
out.pushObject(label);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return out.map((key) => { return (key||'').toLowerCase(); }).sort().uniq();
|
|
||||||
}.property('userKey','allHosts.@each.labels'),
|
|
||||||
|
|
||||||
allContainers: function() {
|
allContainers: function() {
|
||||||
var out = [];
|
var out = [];
|
||||||
|
|
@ -233,31 +242,18 @@ export default Ember.Component.extend({
|
||||||
return out.sortBy('name','id').uniq();
|
return out.sortBy('name','id').uniq();
|
||||||
}.property('allHosts.@each.instancesUpdated'),
|
}.property('allHosts.@each.instancesUpdated'),
|
||||||
|
|
||||||
containerLabelKeyChoices: function() {
|
normalizedContainerLabels: function() {
|
||||||
var out = [];
|
return normalizedLabels(this.get('allContainers'));
|
||||||
this.get('allContainers').forEach((container) => {
|
}.property('allHosts.@each.labels'),
|
||||||
var keys = Object.keys(container.get('labels')||{}).filter((key) => {
|
|
||||||
return key.indexOf(C.LABEL.SYSTEM_PREFIX) !== 0;
|
|
||||||
});
|
|
||||||
out.pushObjects(keys);
|
|
||||||
});
|
|
||||||
|
|
||||||
return out.map((key) => { return (key||'').toLowerCase(); }).sort().uniq();
|
containerLabelKeyChoices: function() {
|
||||||
}.property('allContainers.@each.labels'),
|
return Object.keys(this.get('normalizedContainerLabels')).sort().uniq();
|
||||||
|
}.property('normalizedContainerLabels'),
|
||||||
|
|
||||||
containerLabelValueChoices: function() {
|
containerLabelValueChoices: function() {
|
||||||
var key = this.get('userKey');
|
var key = this.get('userKey').toLowerCase();
|
||||||
var out = [];
|
return ((this.get('normalizedContainerLabels')[key])||[]).sort().uniq();
|
||||||
this.get('allContainers').forEach((container) => {
|
}.property('userKey','normalizedContainerLabels'),
|
||||||
var label = (container.get('labels')||{})[key];
|
|
||||||
if ( label )
|
|
||||||
{
|
|
||||||
out.pushObject(label);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return out.map((key) => { return (key||'').toLowerCase(); }).sort().uniq();
|
|
||||||
}.property('userKey','allContainers.@each.labels'),
|
|
||||||
|
|
||||||
containerValueChoices: function() {
|
containerValueChoices: function() {
|
||||||
var out = [];
|
var out = [];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue