From da5a4d6714cc5e09160cb55c6e7f70c2ef63ec86 Mon Sep 17 00:00:00 2001 From: matias-portainer <104775949+matias-portainer@users.noreply.github.com> Date: Wed, 11 Oct 2023 11:30:23 -0300 Subject: [PATCH] fix(swarm/services): avoid sending credSpec object when empty EE-6178 (#10441) --- app/docker/views/services/edit/serviceController.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/docker/views/services/edit/serviceController.js b/app/docker/views/services/edit/serviceController.js index dace78d40..ad826a8bc 100644 --- a/app/docker/views/services/edit/serviceController.js +++ b/app/docker/views/services/edit/serviceController.js @@ -475,7 +475,7 @@ angular.module('portainer.docker').controller('ServiceController', [ ''; if (oldCredSpecId && !credSpecId) { delete config.TaskTemplate.ContainerSpec.Privileges.CredentialSpec; - } else if (oldCredSpecId !== credSpec) { + } else if (credSpec && oldCredSpecId !== credSpec) { config.TaskTemplate.ContainerSpec.Privileges = { ...(config.TaskTemplate.ContainerSpec.Privileges || {}), CredentialSpec: { @@ -855,6 +855,10 @@ angular.module('portainer.docker').controller('ServiceController', [ $scope.filterConfigs = filterConfigs; function filterConfigs(configs) { + if (!configs) { + return []; + } + return configs.filter((config) => $scope.service.ServiceConfigs.every((serviceConfig) => config.Id !== serviceConfig.Id)); }