added RepositoryMechanismTypes constant

pull/5596/head
Felix Han 2021-09-07 00:28:39 +12:00
parent f3b8a9dc85
commit 3a066d0cd8
6 changed files with 24 additions and 17 deletions

View File

@ -15,3 +15,8 @@ export const KubernetesDeployRequestMethods = Object.freeze({
STRING: 'string', STRING: 'string',
URL: 'url', URL: 'url',
}); });
export const RepositoryMechanismTypes = Object.freeze({
WEBHOOK: 'Webhook',
INTERVAL: 'Interval',
});

View File

@ -4,7 +4,7 @@ import stripAnsi from 'strip-ansi';
import uuidv4 from 'uuid/v4'; import uuidv4 from 'uuid/v4';
import PortainerError from 'Portainer/error'; import PortainerError from 'Portainer/error';
import { KubernetesDeployManifestTypes, KubernetesDeployBuildMethods, KubernetesDeployRequestMethods } from 'Kubernetes/models/deploy'; import { KubernetesDeployManifestTypes, KubernetesDeployBuildMethods, KubernetesDeployRequestMethods, RepositoryMechanismTypes } from 'Kubernetes/models/deploy';
import { buildOption } from '@/portainer/components/box-selector'; import { buildOption } from '@/portainer/components/box-selector';
class KubernetesDeployController { class KubernetesDeployController {
/* @ngInject */ /* @ngInject */
@ -51,7 +51,7 @@ class KubernetesDeployController {
AdditionalFiles: [], AdditionalFiles: [],
ComposeFilePathInRepository: 'deployment.yml', ComposeFilePathInRepository: 'deployment.yml',
RepositoryAutomaticUpdates: true, RepositoryAutomaticUpdates: true,
RepositoryMechanism: 'Interval', RepositoryMechanism: RepositoryMechanismTypes.INTERVAL,
RepositoryFetchInterval: '5m', RepositoryFetchInterval: '5m',
RepositoryWebhookURL: this.WebhookHelper.returnStackWebhookUrl(uuidv4()), RepositoryWebhookURL: this.WebhookHelper.returnStackWebhookUrl(uuidv4()),
}; };

View File

@ -1,4 +1,5 @@
import uuidv4 from 'uuid/v4'; import uuidv4 from 'uuid/v4';
import { RepositoryMechanismTypes } from 'Kubernetes/models/deploy';
class KubernetesRedeployAppGitFormController { class KubernetesRedeployAppGitFormController {
/* @ngInject */ /* @ngInject */
constructor($async, $state, $analytics, StackService, ModalService, Notifications, WebhookHelper) { constructor($async, $state, $analytics, StackService, ModalService, Notifications, WebhookHelper) {
@ -24,7 +25,7 @@ class KubernetesRedeployAppGitFormController {
// auto upadte // auto upadte
AutoUpdate: { AutoUpdate: {
RepositoryAutomaticUpdates: false, RepositoryAutomaticUpdates: false,
RepositoryMechanism: 'Interval', RepositoryMechanism: RepositoryMechanismTypes.INTERVAL,
RepositoryFetchInterval: '5m', RepositoryFetchInterval: '5m',
RepositoryWebhookURL: '', RepositoryWebhookURL: '',
}, },

View File

@ -1,5 +1,5 @@
import uuidv4 from 'uuid/v4'; import uuidv4 from 'uuid/v4';
import { RepositoryMechanismTypes } from 'Kubernetes/models/deploy';
class StackRedeployGitFormController { class StackRedeployGitFormController {
/* @ngInject */ /* @ngInject */
constructor($async, $state, StackService, ModalService, Notifications, WebhookHelper, FormHelper) { constructor($async, $state, StackService, ModalService, Notifications, WebhookHelper, FormHelper) {
@ -28,7 +28,7 @@ class StackRedeployGitFormController {
// auto update // auto update
AutoUpdate: { AutoUpdate: {
RepositoryAutomaticUpdates: false, RepositoryAutomaticUpdates: false,
RepositoryMechanism: 'Interval', RepositoryMechanism: RepositoryMechanismTypes.INTERVAL,
RepositoryFetchInterval: '5m', RepositoryFetchInterval: '5m',
RepositoryWebhookURL: '', RepositoryWebhookURL: '',
}, },
@ -51,9 +51,9 @@ class StackRedeployGitFormController {
function autoSyncLabel(type) { function autoSyncLabel(type) {
switch (type) { switch (type) {
case 'Interval': case RepositoryMechanismTypes.INTERVAL:
return 'polling'; return 'polling';
case 'Webhook': case RepositoryMechanismTypes.WEBHOOK:
return 'webhook'; return 'webhook';
} }
return 'off'; return 'off';

View File

@ -1,4 +1,5 @@
import _ from 'lodash-es'; import _ from 'lodash-es';
import { RepositoryMechanismTypes } from 'Kubernetes/models/deploy';
import { StackViewModel, OrphanedStackViewModel } from '../../models/stack'; import { StackViewModel, OrphanedStackViewModel } from '../../models/stack';
angular.module('portainer.app').factory('StackService', [ angular.module('portainer.app').factory('StackService', [
@ -279,9 +280,9 @@ angular.module('portainer.app').factory('StackService', [
} else { } else {
const autoUpdate = {}; const autoUpdate = {};
if (gitConfig.AutoUpdate && gitConfig.AutoUpdate.RepositoryAutomaticUpdates) { if (gitConfig.AutoUpdate && gitConfig.AutoUpdate.RepositoryAutomaticUpdates) {
if (gitConfig.AutoUpdate.RepositoryMechanism === 'Interval') { if (gitConfig.AutoUpdate.RepositoryMechanism === RepositoryMechanismTypes.INTERVAL) {
autoUpdate.Interval = gitConfig.AutoUpdate.RepositoryFetchInterval; autoUpdate.Interval = gitConfig.AutoUpdate.RepositoryFetchInterval;
} else if (gitConfig.AutoUpdate.RepositoryMechanism === 'Webhook') { } else if (gitConfig.AutoUpdate.RepositoryMechanism === RepositoryMechanismTypes.WEBHOOK) {
autoUpdate.Webhook = gitConfig.AutoUpdate.RepositoryWebhookURL.split('/').reverse()[0]; autoUpdate.Webhook = gitConfig.AutoUpdate.RepositoryWebhookURL.split('/').reverse()[0];
} }
} }
@ -465,9 +466,9 @@ angular.module('portainer.app').factory('StackService', [
const autoUpdate = {}; const autoUpdate = {};
if (gitConfig.AutoUpdate.RepositoryAutomaticUpdates) { if (gitConfig.AutoUpdate.RepositoryAutomaticUpdates) {
if (gitConfig.AutoUpdate.RepositoryMechanism === 'Interval') { if (gitConfig.AutoUpdate.RepositoryMechanism === RepositoryMechanismTypes.INTERVAL) {
autoUpdate.Interval = gitConfig.AutoUpdate.RepositoryFetchInterval; autoUpdate.Interval = gitConfig.AutoUpdate.RepositoryFetchInterval;
} else if (gitConfig.AutoUpdate.RepositoryMechanism === 'Webhook') { } else if (gitConfig.AutoUpdate.RepositoryMechanism === RepositoryMechanismTypes.WEBHOOK) {
autoUpdate.Webhook = gitConfig.AutoUpdate.RepositoryWebhookURL.split('/').reverse()[0]; autoUpdate.Webhook = gitConfig.AutoUpdate.RepositoryWebhookURL.split('/').reverse()[0];
} }
} }

View File

@ -1,6 +1,6 @@
import angular from 'angular'; import angular from 'angular';
import uuidv4 from 'uuid/v4'; import uuidv4 from 'uuid/v4';
import { RepositoryMechanismTypes } from 'Kubernetes/models/deploy';
import { AccessControlFormData } from '../../../components/accessControlForm/porAccessControlFormModel'; import { AccessControlFormData } from '../../../components/accessControlForm/porAccessControlFormModel';
angular angular
@ -42,7 +42,7 @@ angular
ComposeFilePathInRepository: 'docker-compose.yml', ComposeFilePathInRepository: 'docker-compose.yml',
AccessControlData: new AccessControlFormData(), AccessControlData: new AccessControlFormData(),
RepositoryAutomaticUpdates: true, RepositoryAutomaticUpdates: true,
RepositoryMechanism: 'Interval', RepositoryMechanism: RepositoryMechanismTypes.INTERVAL,
RepositoryFetchInterval: '5m', RepositoryFetchInterval: '5m',
RepositoryWebhookURL: WebhookHelper.returnStackWebhookUrl(uuidv4()), RepositoryWebhookURL: WebhookHelper.returnStackWebhookUrl(uuidv4()),
}; };
@ -111,9 +111,9 @@ angular
function autoSyncLabel(type) { function autoSyncLabel(type) {
switch (type) { switch (type) {
case 'Interval': case RepositoryMechanismTypes.INTERVAL:
return 'polling'; return 'polling';
case 'Webhook': case RepositoryMechanismTypes.WEBHOOK:
return 'webhook'; return 'webhook';
} }
return 'off'; return 'off';
@ -166,9 +166,9 @@ angular
function getAutoUpdatesProperty(repositoryOptions) { function getAutoUpdatesProperty(repositoryOptions) {
if ($scope.formValues.RepositoryAutomaticUpdates) { if ($scope.formValues.RepositoryAutomaticUpdates) {
repositoryOptions.AutoUpdate = {}; repositoryOptions.AutoUpdate = {};
if ($scope.formValues.RepositoryMechanism === 'Interval') { if ($scope.formValues.RepositoryMechanism === RepositoryMechanismTypes.INTERVAL) {
repositoryOptions.AutoUpdate.Interval = $scope.formValues.RepositoryFetchInterval; repositoryOptions.AutoUpdate.Interval = $scope.formValues.RepositoryFetchInterval;
} else if ($scope.formValues.RepositoryMechanism === 'Webhook') { } else if ($scope.formValues.RepositoryMechanism === RepositoryMechanismTypes.WEBHOOK) {
repositoryOptions.AutoUpdate.Webhook = $scope.formValues.RepositoryWebhookURL.split('/').reverse()[0]; repositoryOptions.AutoUpdate.Webhook = $scope.formValues.RepositoryWebhookURL.split('/').reverse()[0];
} }
} }