Skip to content

Commit

Permalink
Fixed linking containers to volumes in template designer
Browse files Browse the repository at this point in the history
- Fixed linking container to a volume when the volume name is a
substring of the name of another volume

Change-Id: I58ebfadd1d8c3a89cb22ec0d504a10df9abf6f6c
Reviewed-on: https://bellevue-ci.eng.vmware.com:8080/36807
Upgrade-Verified: jenkins <[email protected]>
Closures-Verified: jenkins <[email protected]>
CS-Verified: jenkins <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
Reviewed-by: Iveta Ilieva <[email protected]>
  • Loading branch information
AleksandrovaP committed Jul 3, 2018
1 parent 1085e9a commit 0bd4b65
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions ui/app/src/js/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1359,21 +1359,32 @@ var utils = {

if (volumes) {

foundVolume = volumes.find((volume) => {
let volumeName = volume.name;
let idxContainerVolNameEnd = containerVolumeString.indexOf(':');
let idxContainerVolNameEnd = containerVolumeString.indexOf(':');

let containerVolumeName = (idxContainerVolNameEnd > -1)
&& containerVolumeString.substring(0, idxContainerVolNameEnd);
let containerVolumeName = (idxContainerVolNameEnd > -1)
&& containerVolumeString.substring(0, idxContainerVolNameEnd);

return containerVolumeName.indexOf(volumeName) > -1
|| volumeName.indexOf(containerVolumeName) > -1;
});
foundVolume = utils.findBestMatch(containerVolumeName, volumes);
}

return foundVolume;
},

findBestMatch: function(stringToBeMatched, allValues) {
if (!stringToBeMatched || !allValues) {
return null;
}

let searchIn = allValues.filter(a => a.name.indexOf(stringToBeMatched) > -1);

if (!searchIn) {
return null;
}

// returns the one that matches the best
return searchIn.reduce((a, b) => a.name.length <= b.name.length ? a : b);
},

createTagAssignmentRequest: function(resourceLink, originalTags, newTags) {
var tagInArray = function(tag, array) {
return array.find(item => item.key === tag.key && item.value === tag.value) !== undefined;
Expand Down

0 comments on commit 0bd4b65

Please sign in to comment.