mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
fix(edge-stack): add validation for edge stack name [EE-4283] (#8504)
This commit is contained in:
parent
defce0cf6d
commit
6d659b4a2c
5 changed files with 16 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { EditorType } from '@/react/edge/edge-stacks/types';
|
import { EditorType } from '@/react/edge/edge-stacks/types';
|
||||||
import { PortainerEndpointTypes } from '@/portainer/models/endpoint/models';
|
import { PortainerEndpointTypes } from '@/portainer/models/endpoint/models';
|
||||||
import { getValidEditorTypes } from '@/react/edge/edge-stacks/utils';
|
import { getValidEditorTypes } from '@/react/edge/edge-stacks/utils';
|
||||||
|
import { STACK_NAME_VALIDATION_REGEX } from '@/react/constants';
|
||||||
import { confirmWebEditorDiscard } from '@@/modals/confirm';
|
import { confirmWebEditorDiscard } from '@@/modals/confirm';
|
||||||
|
|
||||||
export default class CreateEdgeStackViewController {
|
export default class CreateEdgeStackViewController {
|
||||||
|
@ -38,6 +39,8 @@ export default class CreateEdgeStackViewController {
|
||||||
|
|
||||||
this.edgeGroups = null;
|
this.edgeGroups = null;
|
||||||
|
|
||||||
|
$scope.STACK_NAME_VALIDATION_REGEX = STACK_NAME_VALIDATION_REGEX;
|
||||||
|
|
||||||
this.createStack = this.createStack.bind(this);
|
this.createStack = this.createStack.bind(this);
|
||||||
this.validateForm = this.validateForm.bind(this);
|
this.validateForm = this.validateForm.bind(this);
|
||||||
this.createStackByMethod = this.createStackByMethod.bind(this);
|
this.createStackByMethod = this.createStackByMethod.bind(this);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
ng-model="$ctrl.formValues.Name"
|
ng-model="$ctrl.formValues.Name"
|
||||||
id="stack_name"
|
id="stack_name"
|
||||||
name="nameField"
|
name="nameField"
|
||||||
|
ng-pattern="$ctrl.formValues.DeploymentType === $ctrl.EditorType.Compose ? STACK_NAME_VALIDATION_REGEX : ''"
|
||||||
placeholder="e.g. mystack"
|
placeholder="e.g. mystack"
|
||||||
auto-focus
|
auto-focus
|
||||||
required
|
required
|
||||||
|
@ -23,7 +24,14 @@
|
||||||
<div class="help-block" ng-show="$ctrl.form.$invalid">
|
<div class="help-block" ng-show="$ctrl.form.$invalid">
|
||||||
<div class="small text-warning">
|
<div class="small text-warning">
|
||||||
<div ng-messages="$ctrl.form.$error">
|
<div ng-messages="$ctrl.form.$error">
|
||||||
<p ng-message="required" class="vertical-center"> <pr-icon icon="'alert-triangle'" mode="'warning'"></pr-icon> Name is required. </p>
|
<p ng-message="required" class="vertical-center">
|
||||||
|
<pr-icon icon="'alert-triangle'" mode="'warning'"></pr-icon>
|
||||||
|
<span>Name is required.</span>
|
||||||
|
</p>
|
||||||
|
<p ng-message="pattern" class="vertical-center">
|
||||||
|
<pr-icon icon="'alert-triangle'" mode="'warning'"></pr-icon>
|
||||||
|
<span>This field must consist of lower case alphanumeric characters, '_' or '-' (e.g. 'my-name', or 'abc-123').</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { STACK_NAME_VALIDATION_REGEX } from '@/constants';
|
import { STACK_NAME_VALIDATION_REGEX } from '@/react/constants';
|
||||||
|
|
||||||
angular.module('portainer.app').controller('StackDuplicationFormController', [
|
angular.module('portainer.app').controller('StackDuplicationFormController', [
|
||||||
'Notifications',
|
'Notifications',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
|
|
||||||
import { AccessControlFormData } from '@/portainer/components/accessControlForm/porAccessControlFormModel';
|
import { AccessControlFormData } from '@/portainer/components/accessControlForm/porAccessControlFormModel';
|
||||||
import { STACK_NAME_VALIDATION_REGEX } from '@/constants';
|
import { STACK_NAME_VALIDATION_REGEX } from '@/react/constants';
|
||||||
import { RepositoryMechanismTypes } from '@/kubernetes/models/deploy';
|
import { RepositoryMechanismTypes } from '@/kubernetes/models/deploy';
|
||||||
import { FeatureId } from '@/react/portainer/feature-flags/enums';
|
import { FeatureId } from '@/react/portainer/feature-flags/enums';
|
||||||
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
|
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
export const STACK_NAME_VALIDATION_REGEX = '^[-_a-z0-9]+$';
|
||||||
|
|
||||||
export const BROWSER_OS_PLATFORM = getOs();
|
export const BROWSER_OS_PLATFORM = getOs();
|
||||||
|
|
||||||
function getOs() {
|
function getOs() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue