mirror of
https://github.com/portainer/portainer.git
synced 2025-07-31 03:09:44 +02:00
feat(webhook) EE-2125 send registry auth haeder when update swarms service via webhook (#6220)
* feat(webhook) EE-2125 add some helpers to registry utils * feat(webhook) EE-2125 persist registryID when creating a webhook * feat(webhook) EE-2125 send registry auth header when executing a webhook * feat(webhook) EE-2125 send registryID to backend when creating a service with webhook * feat(webhook) EE-2125 use the initial registry ID to create webhook on editing service screen * feat(webhook) EE-2125 update webhook when update registry * feat(webhook) EE-2125 add endpoint of update webhook * feat(webhook) EE-2125 code cleanup * feat(webhook) EE-2125 fix a typo * feat(webhook) EE-2125 fix circle import issue with unit test Co-authored-by: Simon Meng <simon.meng@portainer.io>
This commit is contained in:
parent
aa8fc52106
commit
98972dec0d
12 changed files with 254 additions and 8 deletions
|
@ -336,7 +336,7 @@ angular.module('portainer.docker').controller('ServiceController', [
|
|||
Notifications.error('Failure', err, 'Unable to delete webhook');
|
||||
});
|
||||
} else {
|
||||
WebhookService.createServiceWebhook(service.Id, endpoint.Id)
|
||||
WebhookService.createServiceWebhook(service.Id, endpoint.Id, $scope.initialRegistryID)
|
||||
.then(function success(data) {
|
||||
$scope.WebhookExists = true;
|
||||
$scope.webhookID = data.Id;
|
||||
|
@ -348,6 +348,19 @@ angular.module('portainer.docker').controller('ServiceController', [
|
|||
}
|
||||
};
|
||||
|
||||
$scope.updateWebhookRegistryId = function () {
|
||||
const newRegistryID = _.get($scope.formValues.RegistryModel, 'Registry.Id', 0);
|
||||
const registryChanged = $scope.initialRegistryID != newRegistryID;
|
||||
|
||||
if ($scope.WebhookExists && registryChanged) {
|
||||
WebhookService.updateServiceWebhook($scope.webhookID, newRegistryID)
|
||||
.then(function success() {})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to update webhook');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.copyWebhook = function copyWebhook() {
|
||||
clipboard.copyText($scope.webhookURL);
|
||||
$('#copyNotification').show();
|
||||
|
@ -556,6 +569,7 @@ angular.module('portainer.docker').controller('ServiceController', [
|
|||
Notifications.error('Failure', data, 'Error');
|
||||
} else {
|
||||
Notifications.success('Service successfully updated', 'Service updated');
|
||||
$scope.updateWebhookRegistryId();
|
||||
}
|
||||
$scope.cancelChanges({});
|
||||
initView();
|
||||
|
@ -769,6 +783,7 @@ angular.module('portainer.docker').controller('ServiceController', [
|
|||
const image = $scope.service.Model.Spec.TaskTemplate.ContainerSpec.Image;
|
||||
RegistryService.retrievePorRegistryModelFromRepository(image, endpoint.Id).then((model) => {
|
||||
$scope.formValues.RegistryModel = model;
|
||||
$scope.initialRegistryID = _.get(model, 'Registry.Id', 0);
|
||||
});
|
||||
|
||||
// Default values
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue