Use "push" flag for buildah
The push=False flag with use with kolla-build.conf is not working if we use buildah, clear example is the tripleo-build-containers-centos-7-buildah job, it's suppose to work like docker one but it's pushing too. Closes-Bug: #1822752 Change-Id: I01788b3c11ac701b2cf8c151f95ccad7046532de
This commit is contained in:
@@ -146,7 +146,7 @@ testscenarios===0.4
|
|||||||
testtools==2.2.0
|
testtools==2.2.0
|
||||||
tooz==1.58.0
|
tooz==1.58.0
|
||||||
traceback2==1.4.0
|
traceback2==1.4.0
|
||||||
tripleo-common==10.6.0
|
tripleo-common==10.6.1
|
||||||
ujson==1.35
|
ujson==1.35
|
||||||
unittest2==1.1.0
|
unittest2==1.1.0
|
||||||
vine==1.1.4
|
vine==1.1.4
|
||||||
|
@@ -16,5 +16,5 @@ simplejson>=3.5.1 # MIT
|
|||||||
six>=1.10.0 # MIT
|
six>=1.10.0 # MIT
|
||||||
osc-lib>=1.8.0 # Apache-2.0
|
osc-lib>=1.8.0 # Apache-2.0
|
||||||
websocket-client>=0.44.0 # LGPLv2+
|
websocket-client>=0.44.0 # LGPLv2+
|
||||||
tripleo-common>=10.6.0 # Apache-2.0
|
tripleo-common>=10.6.1 # Apache-2.0
|
||||||
cryptography>=2.1 # BSD/Apache-2.0
|
cryptography>=2.1 # BSD/Apache-2.0
|
||||||
|
@@ -1394,6 +1394,29 @@ class TestConfigParser(TestCase):
|
|||||||
config = utils.get_from_cfg(cfg, 'bar', 'foo')
|
config = utils.get_from_cfg(cfg, 'bar', 'foo')
|
||||||
self.assertEqual(config, 'baz')
|
self.assertEqual(config, 'baz')
|
||||||
|
|
||||||
|
def test_getboolean_config_value(self):
|
||||||
|
cfg = ConfigParser()
|
||||||
|
cfg.add_section('foo')
|
||||||
|
test_data_set = [
|
||||||
|
(True, 'True'),
|
||||||
|
(True, 'true'),
|
||||||
|
(False, 'False'),
|
||||||
|
(False, 'false')
|
||||||
|
]
|
||||||
|
for test_data in test_data_set:
|
||||||
|
expected_value, config_value = test_data
|
||||||
|
cfg.set('foo', 'bar', config_value)
|
||||||
|
obtained_value = utils.getboolean_from_cfg(cfg, 'bar', 'foo')
|
||||||
|
self.assertEqual(obtained_value, expected_value)
|
||||||
|
|
||||||
|
def test_getboolean_bad_config_value(self):
|
||||||
|
cfg = ConfigParser()
|
||||||
|
cfg.add_section('foo')
|
||||||
|
cfg.set('foo', 'bar', 'I am not a boolean')
|
||||||
|
self.assertRaises(exceptions.NotFound,
|
||||||
|
utils.getboolean_from_cfg,
|
||||||
|
cfg, 'bar', 'foo')
|
||||||
|
|
||||||
def test_get_config_value_multiple_files(self):
|
def test_get_config_value_multiple_files(self):
|
||||||
_, cfile1_name = tempfile.mkstemp(dir=self.tmp_dir, text=True)
|
_, cfile1_name = tempfile.mkstemp(dir=self.tmp_dir, text=True)
|
||||||
_, cfile2_name = tempfile.mkstemp(dir=self.tmp_dir, text=True)
|
_, cfile2_name = tempfile.mkstemp(dir=self.tmp_dir, text=True)
|
||||||
@@ -1411,7 +1434,7 @@ class TestConfigParser(TestCase):
|
|||||||
self.assertEqual(config, 'boop')
|
self.assertEqual(config, 'boop')
|
||||||
|
|
||||||
def test_get_config_value_bad_file(self):
|
def test_get_config_value_bad_file(self):
|
||||||
self.assertRaises(exceptions.NotFound,
|
self.assertRaises(AttributeError,
|
||||||
utils.get_from_cfg,
|
utils.get_from_cfg,
|
||||||
'does-not-exist', 'bar', 'foo')
|
'does-not-exist', 'bar', 'foo')
|
||||||
|
|
||||||
|
@@ -510,6 +510,8 @@ class TestContainerImageBuild(TestPluginV1):
|
|||||||
@mock.patch('tempfile.mkstemp')
|
@mock.patch('tempfile.mkstemp')
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
'tripleoclient.utils.get_from_cfg')
|
'tripleoclient.utils.get_from_cfg')
|
||||||
|
@mock.patch(
|
||||||
|
'tripleoclient.utils.getboolean_from_cfg')
|
||||||
@mock.patch('tripleo_common.image.builder.buildah.BuildahBuilder',
|
@mock.patch('tripleo_common.image.builder.buildah.BuildahBuilder',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
||||||
@@ -519,6 +521,7 @@ class TestContainerImageBuild(TestPluginV1):
|
|||||||
def test_container_image_build_with_buildah(self, mock_remove,
|
def test_container_image_build_with_buildah(self, mock_remove,
|
||||||
mock_read_conf,
|
mock_read_conf,
|
||||||
mock_builder, mock_buildah,
|
mock_builder, mock_buildah,
|
||||||
|
mock_kolla_boolean_cfg,
|
||||||
mock_kolla_cfg, mock_mkstemp,
|
mock_kolla_cfg, mock_mkstemp,
|
||||||
mock_mkdtemp, mock_fdopen):
|
mock_mkdtemp, mock_fdopen):
|
||||||
arglist = [
|
arglist = [
|
||||||
@@ -551,7 +554,11 @@ class TestContainerImageBuild(TestPluginV1):
|
|||||||
mock.call(mock_read_conf.return_value, 'namespace'),
|
mock.call(mock_read_conf.return_value, 'namespace'),
|
||||||
mock.call(mock_read_conf.return_value, 'registry'),
|
mock.call(mock_read_conf.return_value, 'registry'),
|
||||||
]
|
]
|
||||||
|
cfg_boolean_calls = [
|
||||||
|
mock.call(mock_read_conf.return_value, 'push'),
|
||||||
|
]
|
||||||
mock_kolla_cfg.assert_has_calls(cfg_calls)
|
mock_kolla_cfg.assert_has_calls(cfg_calls)
|
||||||
|
mock_kolla_boolean_cfg.assert_has_calls(cfg_boolean_calls)
|
||||||
mock_bb.build_all.assert_called_once()
|
mock_bb.build_all.assert_called_once()
|
||||||
|
|
||||||
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
||||||
|
@@ -1549,10 +1549,20 @@ def get_read_config(cfg):
|
|||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
def getboolean_from_cfg(cfg, param, section="DEFAULT"):
|
||||||
|
"""Return a parameter from Kolla config"""
|
||||||
|
return _get_from_cfg(cfg, cfg.getboolean, param, section)
|
||||||
|
|
||||||
|
|
||||||
def get_from_cfg(cfg, param, section="DEFAULT"):
|
def get_from_cfg(cfg, param, section="DEFAULT"):
|
||||||
|
"""Return a parameter from Kolla config"""
|
||||||
|
return _get_from_cfg(cfg, cfg.get, param, section)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_from_cfg(cfg, accessor, param, section):
|
||||||
"""Return a parameter from Kolla config"""
|
"""Return a parameter from Kolla config"""
|
||||||
try:
|
try:
|
||||||
val = cfg.get(section, param)
|
val = accessor(section, param)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise exceptions.NotFound(_("Unable to find {section}/{option} in "
|
raise exceptions.NotFound(_("Unable to find {section}/{option} in "
|
||||||
"{config}").format(section=param,
|
"{config}").format(section=param,
|
||||||
|
@@ -213,7 +213,8 @@ class BuildImage(command.Command):
|
|||||||
utils.get_from_cfg(kolla_cfg, "type"),
|
utils.get_from_cfg(kolla_cfg, "type"),
|
||||||
utils.get_from_cfg(kolla_cfg, "tag"),
|
utils.get_from_cfg(kolla_cfg, "tag"),
|
||||||
utils.get_from_cfg(kolla_cfg, "namespace"),
|
utils.get_from_cfg(kolla_cfg, "namespace"),
|
||||||
utils.get_from_cfg(kolla_cfg, "registry"))
|
utils.get_from_cfg(kolla_cfg, "registry"),
|
||||||
|
utils.getboolean_from_cfg(kolla_cfg, "push"))
|
||||||
bb.build_all()
|
bb.build_all()
|
||||||
elif parsed_args.list_dependencies:
|
elif parsed_args.list_dependencies:
|
||||||
deps = json.loads(result)
|
deps = json.loads(result)
|
||||||
|
Reference in New Issue
Block a user