Skip to content

Commit

Permalink
added checking agents group correctness provided in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
godfryd committed Nov 19, 2023
1 parent 21091a9 commit b1678d8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion server/kraken/server/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from . import consts
from . import schemaval
from .models import Secret, Step, Run, Stage, Branch
from .models import Secret, Step, Run, Stage, Branch, AgentsGroup


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

# check job environments
for env in job['environments']:
# check agents groups
ag_name = env['agents_group']
if ag_name == 'all' or '#' in ag_name:
continue
ag = AgentsGroup.query.filter_by(project=branch.project,
name=ag_name,
deleted=None).one_or_none()
if ag is None:
raise SchemaError("Cannot find %s agents group" % ag_name)

# TODO: check if git url is valid according to giturlparse
return schema_code, schema

Expand Down

0 comments on commit b1678d8

Please sign in to comment.