Permalink
Browse files

Remove special filter handling.

  • Loading branch information...
1 parent a9fceaa commit 3f3ecd3be8bf65b589e885c0b43754e7cad97ef9 @willwhite willwhite committed Mar 12, 2013
Showing with 4 additions and 38 deletions.
  1. +4 −38 lib/ec2-api.js
View
@@ -63,45 +63,11 @@ exports.loadInstances = function(clients, filters, callback) {
return i;
});
- // Special filters
- var exclude = ['Class', 'Parameter', 'Environment', 'ClassParameter'];
-
_(filters).each(function(v, k) {
- if (_.indexOf(exclude, k) == -1) {
- i = i.filter(function(instance) {
- return _(instance[k]).isString() &&
- instance[k].toLowerCase() === v.toLowerCase();
- });
- } else {
- // Handle special filters
- i = i.filter(function(instance) {
- switch(k) {
- case 'Class':
- if (instance.PuppetClasses) {
- return _.has(JSON.parse(instance.PuppetClasses), filters.Class);
- } else { return false }
- case 'Parameter':
- // These are global parameters, not class parameters
- if (instance.PuppetParameters) {
- return _.has(JSON.parse(instance.PuppetParameters), filters.Parameter);
- } else { return false }
- case 'Environment':
- if (instance.PuppetEnvironment) {
- return instance.PuppetEnvironment === filters.Environment;
- } else { return false }
- case 'ClassParameter':
- if (instance.PuppetClasses) {
- var klass = filters.ClassParameter.split(':')[0];
- var param = filters.ClassParameter.split(':')[1];
- if (_.has(JSON.parse(instance.PuppetClasses), klass)) {
- return _.has(JSON.parse(instance.PuppetClasses)[klass], param)
- } else { return false; }
- } else { return false; }
- default:
- return false;
- }
- });
- }
+ i = i.filter(function(instance) {
+ return _(instance[k]).isString() &&
+ instance[k].toLowerCase() === v.toLowerCase();
+ });
});
return callback(null, i.value());

0 comments on commit 3f3ecd3

Please sign in to comment.