コード例 #1
0
def test_nest_default():
    with TemporaryDirectory() as registry_dir:
        expected_result = "tests/test_files/bundles/nest/bundle1result"
        folder_to_nest = "tests/test_files/bundles/nest/bundle1"

        yaml_files = []
        for filename in os.listdir(folder_to_nest):
            with open(folder_to_nest + "/" + filename) as f:
                yaml_files.append(f.read())

        with TemporaryDirectory() as temp_dir:
            nest_bundles(yaml_files, registry_dir, temp_dir)

        dcmp = dircmp(registry_dir, expected_result)
        assert (len(dcmp.diff_files) == 0)
コード例 #2
0
ファイル: api.py プロジェクト: ecordell/operator-courier
def nest(source_dir, output_dir):
    """Nest takes a flat bundle directory and version nests it
    to eventually be consumed as part of an operator-registry image build.

    This method will only extract valid operator manifest files and folders
    and ignore the rest.

    If the input directory is already nested, this method will copy the files and
    folders as is, with non-manifest files and folders excluded.


    :param source_dir: Path to local directory of yaml files to be read
    :param output_dir: Path of your directory to be populated.
                       If directory does not exist, it will be created.

    :raises OpCourierBadYaml: When an invalid yaml file is encountered
    """
    if source_dir and output_dir:
        nest_bundles(source_dir, output_dir)
コード例 #3
0
ファイル: api.py プロジェクト: ypresa1/operator-courier
def nest(source_dir, registry_dir):
    """Nest takes a flat bundle directory and version nests it
    to eventually be consumed as part of an operator-registry image build.

    :param source_dir: Path to local directory of yaml files to be read
    :param output_dir: Path of your directory to be populated.
                       If directory does not exist, it will be created.

    :raises OpCourierBadYaml: When an invalid yaml file is encountered
    :raises OpCourierBadArtifact: When a file is not any of {CSV, CRD, Package}
    """

    yaml_files = []

    if source_dir is not None:
        for filename in os.listdir(source_dir):
            if filename.endswith(".yaml") or filename.endswith(".yml"):
                with open(source_dir + "/" + filename) as f:
                    yaml_files.append(f.read())

    with TemporaryDirectory() as temp_dir:
        nest_bundles(yaml_files, registry_dir, temp_dir)
コード例 #4
0
def test_nest(folder_to_nest, expected_output_dir):
    with TemporaryDirectory() as output_dir:
        nest_bundles(folder_to_nest, output_dir)
        assert _get_dir_file_paths(output_dir) == _get_dir_file_paths(expected_output_dir)