Пример #1
0
 def validate(self):
     super().validate()
     if self.image():
         image_reference = self.image()
         # image must be a valid oci image reference
         allowed_characters = string.ascii_letters + string.digits + '.-_/:@'
         if any(map(lambda c: c not in allowed_characters, image_reference)):
             raise ModelValidationError(
                 'forbidden character in image reference: ' + str(image_reference)
             )
         if ':' not in image_reference:
             raise ModelValidationError(
                 'image reference must contain colon charater:' + str(image_reference)
             )
Пример #2
0
 def validate(self):
     super().validate()
     default_channel = self.default_channel()
     if default_channel not in self.channel_cfgs():
         raise ModelValidationError(
             'there is no element in channel_cfgs with name {name}'.format(
                 name=default_channel, ))
Пример #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # todo: make step name actually configurable (need concept to express
        # step-specific behaviour, first)
        if not self.step_name() == 'component_descriptor':
            raise ModelValidationError('component_descriptor step name must be component_descriptor')
Пример #4
0
    def create(name: str, variant_name: str, args_dict: dict):
        if name not in TRAITS:
            raise ModelValidationError('no such trait: ' + str(name))
        not_none(args_dict)

        ctor = TRAITS[name]

        return ctor(name=name, variant_name=variant_name, raw_dict=args_dict)
Пример #5
0
    def validate(self):
        super().validate()

        try:
            for label in self.source_labels():
                pass  # source_labels converts into cm.Label
        except dacite.DaciteError as e:
            raise ModelValidationError(f'Invalid {label=}') from e
Пример #6
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # todo: make step name actually configurable (need concept to express
        # step-specific behaviour, first)
        if not self.step_name() == DEFAULT_COMPONENT_DESCRIPTOR_STEP_NAME:
            raise ModelValidationError(
                f"component-descriptor step name must be '{DEFAULT_COMPONENT_DESCRIPTOR_STEP_NAME}'"
            )
Пример #7
0
 def validate(self):
     super().validate()
     for label in self.component_labels():
         try:
             dacite.from_dict(
                 data_class=Label,
                 data=label,
                 config=dacite.Config(strict=True),
             )
         except dacite.DaciteError as e:
             raise ModelValidationError(f"Invalid label '{label}'.") from e
Пример #8
0
    def create(
        name: str,
        variant_name: str,
        args_dict: dict,
        cfg_set,
    ):
        if name not in _traits():
            raise ModelValidationError('no such trait: ' + str(name))
        not_none(args_dict)

        ctor = _traits()[name]

        return ctor(
            name=name,
            variant_name=variant_name,
            raw_dict=args_dict,
            cfg_set=cfg_set,
        )
Пример #9
0
 def validate(self):
     super().validate()
     if self._preprocess() != 'finalize':
         raise ModelValidationError(
             "Only 'finalize' is supported as value for 'preprocess' in draft_release trait"
         )