Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1449908 - Group replica sets by owner reference
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1449908 Use owner references to decide if a replica set is owned by a deployment. Change maps to use deployment UID instead of deployment name. This avoids problems when a deployment is deleted and another is created with the same name.
- Loading branch information
Showing
9 changed files
with
459 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
angular.module("openshiftConsole") | ||
.factory("OwnerReferencesService", function() { | ||
var getOwnerReferences = function(apiObject) { | ||
return _.get(apiObject, 'metadata.ownerReferences'); | ||
}; | ||
|
||
return { | ||
getOwnerReferences: getOwnerReferences, | ||
|
||
groupByControllerUID: function(apiObjects) { | ||
var objectsByControllerUID = {}; | ||
_.each(apiObjects, function(apiObject) { | ||
var hasController = false; | ||
_.each(getOwnerReferences(apiObject), function(ownerRef) { | ||
if (ownerRef.controller) { | ||
hasController = true; | ||
objectsByControllerUID[ownerRef.uid] = objectsByControllerUID[ownerRef.uid] || []; | ||
objectsByControllerUID[ownerRef.uid].push(apiObject); | ||
} | ||
}); | ||
|
||
if (!hasController) { | ||
objectsByControllerUID[''] = objectsByControllerUID[''] || []; | ||
objectsByControllerUID[''].push(apiObject); | ||
} | ||
}); | ||
|
||
return objectsByControllerUID; | ||
}, | ||
|
||
filterForController: function(apiObjects, controller) { | ||
var controllerUID = _.get(controller, 'metadata.uid'); | ||
return _.filter(apiObjects, function(apiObject) { | ||
return _.some(getOwnerReferences(apiObject), { | ||
uid: controllerUID, | ||
controller: true | ||
}); | ||
}); | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.