Пример #1
0
    def validate_config(self, config: Dict) -> Dict:
        """We only validate the config if passed.

        Also we use the BuildSpecification to check if this config was
        intended as job.
        """
        validate_build_spec_config(config)
        return config
Пример #2
0
    def validate_content(self, content):
        """We only validate the content if passed.

        Also we use the BuildSpecification to check if this content was
        intended as an experiment.
        """
        # content is optional
        if not content:
            return content

        validate_build_spec_config(content)
        return content
Пример #3
0
 def create(self, validated_data):
     """Check the params or set the value from the specification."""
     config = None
     if validated_data.get('config'):
         config = validate_build_spec_config(validated_data['config'])
     if not validated_data.get('tags') and config:
         validated_data['tags'] = config.tags
     return super().create(validated_data=validated_data)
Пример #4
0
    def validate_config(self, config):
        """We only validate the config if passed.

        Also we use the BuildSpecification to check if this config was
        intended as job.
        """
        spec = validate_build_spec_config(config)

        if spec.is_build:
            # Resume normal creation
            return config

        # Raise an error to tell the user to use job creation instead
        raise ValidationError(
            'Current job creation could not be performed.\n'
            'The reason is that the specification sent correspond '
            'to a `{}`.\n'.format(spec.kind))