From 9e0896418d03111e02f027ca1c19c17912ee1d4c Mon Sep 17 00:00:00 2001 From: Sam Padgett Date: Fri, 13 Oct 2017 11:45:54 -0400 Subject: [PATCH] Revert "add "overwrite" option to attachPVC view" --- app/scripts/controllers/attachPVC.js | 80 ++++------------------------ app/views/attach-pvc.html | 14 ----- dist/scripts/scripts.js | 30 +++-------- dist/scripts/templates.js | 15 +----- 4 files changed, 20 insertions(+), 119 deletions(-) diff --git a/app/scripts/controllers/attachPVC.js b/app/scripts/controllers/attachPVC.js index 89b4ccf71f..e719e4444b 100644 --- a/app/scripts/controllers/attachPVC.js +++ b/app/scripts/controllers/attachPVC.js @@ -118,63 +118,6 @@ angular.module('openshiftConsole') $scope.$watchGroup(['attach.resource', 'attach.allContainers'], updateMountPaths); $scope.$watch('attach.containers', updateMountPaths, true); - var checkVolumeMountPath = function(newVolumeMount, container) { - var duplicateMount = _.find(container.volumeMounts, function(mount) { - return mount.mountPath === newVolumeMount && mount.name !== newVolumeMount.name; - }); - - // if a new volumeMount matches an existing mountPath, - // fail if their names differ. This can happen when the - // "overwrite" option is specified. - if (duplicateMount) { - displayError('The volume mount "' + duplicateMount.mountPath + '" with name "' + duplicateMount.name +'" already exists for container "' + container.name + '"'); - return false; - } - - return true; - }; - - var replaceExistingVolumeMount = function(newVolumeMount, container) { - // if the volume mount we are trying to add already exists, - // replace the existing mount with the newly created one. - // This can happen when the "overwrite" option is specified. - var index = _.findIndex(container.volumeMounts, { name: newVolumeMount.name }); - if (index === -1) { - return false; - } - - container.volumeMounts[index] = newVolumeMount; - return true; - }; - - var setVolumeMount = function(podTemplate, name, mountPath, subPath, readOnly) { - var success = true; - _.each(podTemplate.spec.containers, function(container) { - if (!isContainerSelected(container)) { - return; - } - - var newVolumeMount = - StorageService.createVolumeMount(name, mountPath, subPath, readOnly); - if (!container.volumeMounts) { - container.volumeMounts = []; - } - - if (!checkVolumeMountPath(newVolumeMount, container)) { - success = false; - return false; - } - - if (replaceExistingVolumeMount(newVolumeMount, container)) { - return false; - } - - container.volumeMounts.push(newVolumeMount); - }); - - return success; - }; - // load resources required to show the page (list of pvcs and deployment or deployment config) var load = function() { DataService.get(resourceGroupVersion, $routeParams.name, context).then( @@ -232,10 +175,16 @@ angular.module('openshiftConsole') var readOnly = $scope.attach.readOnly; if (mountPath) { // for each container in the pod spec, add the new volume mount - if(!setVolumeMount(podTemplate, name, mountPath, subPath, readOnly)) { - $scope.disableInputs = false; - return; - } + angular.forEach(podTemplate.spec.containers, function(container) { + if (isContainerSelected(container)) { + var newVolumeMount = + StorageService.createVolumeMount(name, mountPath, subPath, readOnly); + if (!container.volumeMounts) { + container.volumeMounts = []; + } + container.volumeMounts.push(newVolumeMount); + } + }); } // add the new volume to the pod template @@ -243,14 +192,7 @@ angular.module('openshiftConsole') if (!podTemplate.spec.volumes) { podTemplate.spec.volumes = []; } - - // if the newly created volume already exists, only - // fail if the "overwrite" option was not set - var volumeExists = _.some(podTemplate.spec.volumes, { name: newVolume.name }); - - if (!volumeExists) { - podTemplate.spec.volumes.push(newVolume); - } + podTemplate.spec.volumes.push(newVolume); DataService.update(resourceGroupVersion, resource.metadata.name, $scope.attach.resource, context).then( function() { diff --git a/app/views/attach-pvc.html b/app/views/attach-pvc.html index df3e6c2f7f..f0eb14a80f 100644 --- a/app/views/attach-pvc.html +++ b/app/views/attach-pvc.html @@ -83,7 +83,6 @@

Volume

ng-model="attach.mountPath" ng-pattern="/^\/.*$/" osc-unique="existingMountPaths" - osc-unique-disabled="attach.overwrite" placeholder="example: /data" autocorrect="off" autocapitalize="none" @@ -144,7 +143,6 @@

Volume

name="volumeName" ng-model="attach.volumeName" osc-unique="existingVolumeNames" - osc-unique-disabled="attach.overwrite" ng-pattern="/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/" maxlength="63" placeholder="(generated if empty)" @@ -173,18 +171,6 @@

Volume

-
-
- -
- Overwrite a volume mount if it already exists. -
-
-
-
\n" + "
\n" + "\n" + - "\n" + + "\n" + "
\n" + "Mount path for the volume inside the container. If not specified, the volume will not be mounted automatically.\n" + "
\n" + @@ -1020,7 +1020,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "
\n" + "\n" + "\n" + - "\n" + + "\n" + "
\n" + "Unique name used to identify this volume. If not specified, a volume name is generated.\n" + "
\n" + @@ -1043,17 +1043,6 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "
\n" + "
\n" + "\n" + - "
\n" + - "Overwrite a volume mount if it already exists.\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" +