Change CB initialization

This commit is contained in:
Mikhail Gordeev 2020-04-20 17:27:33 +03:00
parent 2b15168983
commit ae9fc14795
3 changed files with 13 additions and 9 deletions

View File

@ -30,7 +30,7 @@ def parse_args():
def main(): def main():
args = parse_args() args = parse_args()
cb = cloud_build.CB(args) cb = cloud_build.CB(config=args.config, no_tests=args.no_tests)
cb.create_images() cb.create_images()
cb.copy_external_files() cb.copy_external_files()
cb.sign() cb.sign()

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
from typing import Dict, List, Any, Union from typing import Dict, List, Union
from pathlib import Path from pathlib import Path
import contextlib import contextlib
@ -29,12 +29,17 @@ class Error(Exception):
class CB: class CB:
"""class for building cloud images""" """class for building cloud images"""
def __init__(self, args: Any) -> None: def __init__(
self,
config,
no_tests=False,
create_remote_dirs=False
) -> None:
self.initialized = False self.initialized = False
self._save_cwd = os.getcwd() self._save_cwd = os.getcwd()
self.parse_config(args.config) self.parse_config(config)
self.no_tests = getattr(args, 'no_tests', False) self.no_tests = no_tests
self._create_remote_dirs = getattr(args, 'create_remote_dirs', False) self._create_remote_dirs = create_remote_dirs
data_dir = (Path(self.expand_path(os.getenv('XDG_DATA_HOME', data_dir = (Path(self.expand_path(os.getenv('XDG_DATA_HOME',
'~/.local/share'))) '~/.local/share')))

View File

@ -1,6 +1,5 @@
from contextlib import ExitStack from contextlib import ExitStack
from pathlib import Path from pathlib import Path
from types import SimpleNamespace
from unittest import TestCase from unittest import TestCase
from unittest import mock from unittest import mock
@ -28,11 +27,11 @@ class TestIntegrationImages(TestCase):
{'XDG_DATA_HOME': cls.work_dir.as_posix()} {'XDG_DATA_HOME': cls.work_dir.as_posix()}
)) ))
cloud_build = CB(SimpleNamespace( cloud_build = CB(
config='tests/test_integration_images.yaml', config='tests/test_integration_images.yaml',
no_tests=True, no_tests=True,
create_remote_dirs=True, create_remote_dirs=True,
)) )
cloud_build.create_images() cloud_build.create_images()
cloud_build.copy_external_files() cloud_build.copy_external_files()
cloud_build.sign() cloud_build.sign()