Skip to content

Commit b1678d8

Browse files
committed
added checking agents group correctness provided in schema
1 parent 21091a9 commit b1678d8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

server/kraken/server/schema.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
from . import consts
3131
from . import schemaval
32-
from .models import Secret, Step, Run, Stage, Branch
32+
from .models import Secret, Step, Run, Stage, Branch, AgentsGroup
3333

3434

3535
log = logging.getLogger(__name__)
@@ -173,6 +173,18 @@ def check_and_correct_stage_schema(branch, stage_name, schema_code, context=None
173173
if field == 'ssh-key' and secret.kind != consts.SECRET_KIND_SSH_KEY:
174174
raise SchemaError("Type of '%s' secret should be SSH Username & Key" % value)
175175

176+
# check job environments
177+
for env in job['environments']:
178+
# check agents groups
179+
ag_name = env['agents_group']
180+
if ag_name == 'all' or '#' in ag_name:
181+
continue
182+
ag = AgentsGroup.query.filter_by(project=branch.project,
183+
name=ag_name,
184+
deleted=None).one_or_none()
185+
if ag is None:
186+
raise SchemaError("Cannot find %s agents group" % ag_name)
187+
176188
# TODO: check if git url is valid according to giturlparse
177189
return schema_code, schema
178190

0 commit comments

Comments
 (0)