How to use the cekit.descriptor.Packages function in cekit

To help you get started, we’ve selected a few cekit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cekit / cekit / tests / test_unit_descriptor.py View on Github external
def test_packages_content_sets_file(mocker):
    with mocker.mock_module.patch('cekit.descriptor.packages.os.path.exists') as exists_mock:
        exists_mock.return_value = True
        with mocker.mock_module.patch('cekit.descriptor.packages.open', mocker.mock_open(read_data='{"a": 12}')):
            pkg = Packages(
                {
                    'content_sets_file': "a_path.yaml",
                    'install': ['package_a', 'package_b']
                },
                "a/path"
            )

    assert 'package_a' in pkg['install']
    assert 'content_sets_file' not in pkg
    assert pkg['content_sets'] == {'a': 12}
github cekit / cekit / tests / test_unit_descriptor.py View on Github external
def test_packages_content_sets_and_content_sets_file():
    with pytest.raises(CekitError, match=r"You cannot specify 'content_sets' and 'content_sets_file' together in the packages section!"):
        Packages(
            {
                'content_sets': {
                    'x86_64': ['rhel-server-rhscl-7-rpms', 'rhel-7-server-rpms']
                },
                'content_sets_file': "a_path.yaml"
            },
            "a/path"
        )
github cekit / cekit / tests / test_unit_descriptor.py View on Github external
def test_packages():
    pkg = Packages(yaml.safe_load("""
      install:
          - pkg-foo"""), "a/path/image.yaml")

    assert 'pkg-foo' in pkg['install']
github cekit / cekit / tests / test_unit_descriptor.py View on Github external
def test_packages_invalid_old_repository_definition():
    with pytest.raises(CekitError, match=r"Cannot validate schema: Repository"):
        Packages(yaml.safe_load("""
        repositories:
            - repo-foo
            - repo-bar
        install:
            - pkg-foo"""), "a/path/image.yaml")
github cekit / cekit / tests / test_unit_descriptor.py View on Github external
def test_packages_content_sets():
    pkg = Packages(
        {
            'content_sets': {
                'x86_64': ['rhel-server-rhscl-7-rpms', 'rhel-7-server-rpms']
            },
            'install': ['package_a', 'package_b']
        },
        "a/path"
    )

    assert 'package_a' in pkg['install']
    assert 'content_sets_file' not in pkg
github cekit / cekit / cekit / descriptor / image.py View on Github external
def _prepare(self):
        self._descriptor['labels'] = [Label(x) for x in self._descriptor.get('labels', [])]
        self._descriptor['envs'] = [Env(x) for x in self._descriptor.get('envs', [])]
        self._descriptor['ports'] = [Port(x) for x in self._descriptor.get('ports', [])]
        if 'run' in self._descriptor:
            self._descriptor['run'] = Run(self._descriptor['run'])
        self._descriptor['artifacts'] = [create_resource(a, directory=self._artifact_dir)
                                         for a in self._descriptor.get('artifacts', [])]
        self._descriptor['modules'] = Modules(self._descriptor.get('modules', {}), self.path)
        self._descriptor['packages'] = Packages(self._descriptor.get('packages', {}), self.path)
        self._descriptor['osbs'] = Osbs(self._descriptor.get('osbs', {}), self.path)
        self._descriptor['volumes'] = [Volume(x) for x in self._descriptor.get('volumes', [])]

        # make sure image declarations override any module definitions
        self._image_overrides = {'artifacts': Image._to_dict(
            self.artifacts), 'modules': Image._to_dict(self.modules.install)}
        self._all_artifacts = Image._to_dict(self.artifacts)
github cekit / cekit / cekit / descriptor / image.py View on Github external
def packages(self):
        return self.get('packages', Packages({}, self.path))