Skip to content

Commit

Permalink
Merge pull request #2129 from arenadata/develop
Browse files Browse the repository at this point in the history
Release 2022.10.04
  • Loading branch information
kuhella authored Oct 4, 2022
2 parents e4e4e96 + 4b7bc3b commit 6d44175
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 23 deletions.
2 changes: 1 addition & 1 deletion conf/adcm/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

type: adcm
name: ADCM
version: 2.1
version: 2.2

actions:
run_ldap_sync:
Expand Down
1 change: 0 additions & 1 deletion python/cm/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
"WRONG_CLUSTER_ID_TYPE": ("cluster id must be integer", HTTP_400_BAD_REQUEST, ERR),
"OVERFLOW": ("integer or floats in a request cause an overflow", HTTP_400_BAD_REQUEST, ERR),
"WRONG_NAME": ("wrong name", HTTP_400_BAD_REQUEST, ERR),
"LONG_NAME": ("name is too long", HTTP_400_BAD_REQUEST, ERR),
"INVALID_INPUT": ("invalid input", HTTP_400_BAD_REQUEST, ERR),
"JSON_ERROR": ("json decoding error", HTTP_400_BAD_REQUEST, ERR),
"CONFIG_KEY_ERROR": ("error in json config", HTTP_400_BAD_REQUEST, ERR),
Expand Down
79 changes: 79 additions & 0 deletions python/cm/migrations/0094_increase_max_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Generated by Django 3.2.13 on 2022-10-04 08:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("cm", "0093_auto_20220928_0556"),
]

operations = [
migrations.AlterField(
model_name="prototype",
name="display_name",
field=models.CharField(blank=True, max_length=256),
),
migrations.AlterField(
model_name="prototype",
name="name",
field=models.CharField(max_length=256),
),
migrations.AlterField(
model_name="prototypeconfig",
name="name",
field=models.CharField(max_length=256),
),
migrations.AlterField(
model_name="prototypeconfig",
name="subname",
field=models.CharField(blank=True, max_length=256),
),
migrations.AlterField(
model_name="prototypeconfig",
name="display_name",
field=models.CharField(blank=True, max_length=256),
),
migrations.AlterField(
model_name="stageprototype",
name="name",
field=models.CharField(max_length=256),
),
migrations.AlterField(
model_name="stageprototypeconfig",
name="display_name",
field=models.CharField(blank=True, max_length=256),
),
migrations.AlterField(
model_name="stageprototypeconfig",
name="name",
field=models.CharField(max_length=256),
),
migrations.AlterField(
model_name="stageprototypeconfig",
name="subname",
field=models.CharField(blank=True, max_length=256),
),
migrations.AlterField(
model_name='stagesubaction',
name='name',
field=models.CharField(max_length=1000),
),
migrations.AlterField(
model_name='subaction',
name='name',
field=models.CharField(max_length=1000),
),
]
20 changes: 10 additions & 10 deletions python/cm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ class Prototype(ADCMModel):
type = models.CharField(max_length=16, choices=ObjectType.choices)
parent = models.ForeignKey("self", on_delete=models.CASCADE, null=True, default=None)
path = models.CharField(max_length=160, default="")
name = models.CharField(max_length=160)
display_name = models.CharField(max_length=160, blank=True)
name = models.CharField(max_length=256)
display_name = models.CharField(max_length=256, blank=True)
version = models.CharField(max_length=80)
version_order = models.PositiveIntegerField(default=0)
required = models.BooleanField(default=False)
Expand Down Expand Up @@ -1182,7 +1182,7 @@ def allowed(self, obj: ADCMEntity) -> bool:
class AbstractSubAction(ADCMModel):
action = None

name = models.CharField(max_length=160)
name = models.CharField(max_length=1000)
display_name = models.CharField(max_length=160, blank=True)
script = models.CharField(max_length=160)
script_type = models.CharField(max_length=16, choices=SCRIPT_TYPE)
Expand Down Expand Up @@ -1232,11 +1232,11 @@ class Meta:
class PrototypeConfig(ADCMModel):
prototype = models.ForeignKey(Prototype, on_delete=models.CASCADE)
action = models.ForeignKey(Action, on_delete=models.CASCADE, null=True, default=None)
name = models.CharField(max_length=160)
subname = models.CharField(max_length=160, blank=True)
name = models.CharField(max_length=256)
subname = models.CharField(max_length=256, blank=True)
default = models.TextField(blank=True)
type = models.CharField(max_length=16, choices=CONFIG_FIELD_TYPE)
display_name = models.CharField(max_length=160, blank=True)
display_name = models.CharField(max_length=256, blank=True)
description = models.TextField(blank=True)
limits = models.JSONField(default=dict)
ui_options = models.JSONField(blank=True, default=dict)
Expand Down Expand Up @@ -1462,7 +1462,7 @@ class Meta:
class StagePrototype(ADCMModel):
type = models.CharField(max_length=16, choices=ObjectType.choices)
parent = models.ForeignKey("self", on_delete=models.CASCADE, null=True, default=None)
name = models.CharField(max_length=160)
name = models.CharField(max_length=256)
path = models.CharField(max_length=160, default="")
display_name = models.CharField(max_length=1000, blank=True)
version = models.CharField(max_length=80)
Expand Down Expand Up @@ -1514,11 +1514,11 @@ class StageSubAction(AbstractSubAction):
class StagePrototypeConfig(ADCMModel):
prototype = models.ForeignKey(StagePrototype, on_delete=models.CASCADE)
action = models.ForeignKey(StageAction, on_delete=models.CASCADE, null=True, default=None)
name = models.CharField(max_length=160)
subname = models.CharField(max_length=160, blank=True)
name = models.CharField(max_length=256)
subname = models.CharField(max_length=256, blank=True)
default = models.TextField(blank=True)
type = models.CharField(max_length=16, choices=CONFIG_FIELD_TYPE)
display_name = models.CharField(max_length=160, blank=True)
display_name = models.CharField(max_length=256, blank=True)
description = models.TextField(blank=True)
limits = models.JSONField(default=dict)
ui_options = models.JSONField(blank=True, default=dict)
Expand Down
9 changes: 3 additions & 6 deletions python/cm/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
)

NAME_REGEX = r"[0-9a-zA-Z_\.-]+"
MAX_NAME_LENGTH = 256


def save_definition(path, fname, conf, obj_list, bundle_hash, adcm=False):
Expand Down Expand Up @@ -663,18 +662,16 @@ def cook_conf(obj, conf, name, subname):
cook_conf(proto, subconf, name, subname)


def validate_name(value, name):
def validate_name(value, err_msg):
if not isinstance(value, str):
err("WRONG_NAME", f"{name} should be string")
err("WRONG_NAME", f"{err_msg} should be string")
p = re.compile(NAME_REGEX)
msg1 = (
"{} is incorrect. Only latin characters, digits,"
" dots (.), dashes (-), and underscores (_) are allowed."
)
if p.fullmatch(value) is None:
err("WRONG_NAME", msg1.format(name))
if len(value) > MAX_NAME_LENGTH:
err("LONG_NAME", f"{name} is too long. Max length is {MAX_NAME_LENGTH}")
err("WRONG_NAME", msg1.format(err_msg))
return value


Expand Down
5 changes: 0 additions & 5 deletions tests/library/errorcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,6 @@ def __str__(self):
'PROVIDER_CONFLICT',
)

LONG_NAME = ADCMError(
'400 Bad Request',
'LONG_NAME',
)

WRONG_NAME = ADCMError(
'400 Bad Request',
'WRONG_NAME',
Expand Down

0 comments on commit 6d44175

Please sign in to comment.