Exemplo n.º 1
0
    def __init__(self, d: Dict[Any, Any]) -> None:
        validator = Validator(schema_data=schemas.config, source_data=d)
        validator.validate()
        config = self._merge_dicts(self._DEFAULTS, d)

        self.logging = LoggingConfig(config['logging'])
        self.vagrant = VagrantConfig(
            Path(config['vagrant']['vagrant_files_home']), )
        self.runner = RunnerConfig(
            token=config['runner']['token'],
            interval=timedelta(seconds=config['runner']['interval']),
            instances=config['runner']['instances'],
            endpoint=config['runner']['endpoint'],
        )
Exemplo n.º 2
0
    def __init__(self, job: Dict[str, Any]) -> None:
        validator = Validator(source_data=job, schema_data=schemas.job)
        validator.validate()

        self._secret = job['secret']
        self._after_failure = job[
            'after_failure'] if 'after_failure' in job else []
        self._commands = job['commands']
        self._env = job['env'] if 'env' in job else {}
        self._image = job['image']
        self._origin = job['repository']['origin']
        self._branch = job['repository']['branch']
        self._commit = job['repository']['commit']
        self._cwd = '/piper'
        self._private_key = Path(
            job['repository']
            ['private_key']) if 'private_key' in job['repository'] else None

        self._env = {k: str(v) for k, v in self._env.items()}
Exemplo n.º 3
0
    def __init__(self, d: Dict[Any, Any]) -> None:
        validator = Validator(schema_data=schemas.config, source_data=d)
        validator.validate()
        config = self._merge_dicts(self._DEFAULTS, d)

        self.logging = LoggingConfig(config['logging'])
        self.lxd = LxdConfig(
            verify=config['lxd']['verify'],
            profiles=config['lxd']['profiles'],
            endpoint=config['lxd']['endpoint'],
            cert=Path(config['lxd']['cert']),
            key=Path(config['lxd']['key']),
        )
        self.runner = RunnerConfig(
            token=config['runner']['token'],
            interval=timedelta(seconds=config['runner']['interval']),
            instances=config['runner']['instances'],
            endpoint=config['runner']['endpoint'],
        )
Exemplo n.º 4
0
    def __parse_config(self, config_file_path):
        """Parses the configuration file.

        Args:
            config_file_path: The path to the configuration file.

        Raises:
            YAMLError: Errors loading yaml files.
            SchemaError: The configuration file is malformed or invalid.
            InvalidArgumentError: The configuration has invalid values.
        """
        # Load before validation to check for well-formed YAML.
        with open(config_file_path) as config_file:
            self.config = safe_load(config_file)
        Validator(config_file_path, [_SCHEMA_FILE]).validate()

        for pkg_group_config in self.config['internal']:
            DependencyAnalysis.__add_package_group(pkg_group_config,
                                                   self.internal_groups)
        for pkg_group_config in yaml_optional_list(self.config, 'external'):
            DependencyAnalysis.__add_package_group(pkg_group_config,
                                                   self.external_groups)