Skip to content

Commit

Permalink
floating tags
Browse files Browse the repository at this point in the history
OSBS-7169

Signed-off-by: Robert Cerven <rcerven@redhat.com>
  • Loading branch information
rcerven committed Apr 25, 2019
1 parent 571fe03 commit f2e2ae3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
9 changes: 5 additions & 4 deletions osbs/build/plugins_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def render_tag_from_config(self):
return

unique_tag = self.user_params.image_tag.value.split(':')[-1]
tag_suffixes = {'unique': [unique_tag], 'primary': []}
tag_suffixes = {'unique': [unique_tag], 'primary': [], 'floating': []}

if self.user_params.build_type.value == BUILD_TYPE_ORCHESTRATOR:
additional_tags = self.user_params.additional_tags.value or set()
Expand All @@ -475,10 +475,11 @@ def render_tag_from_config(self):
tag_suffixes['primary'].extend(['{version}-{release}'])
elif self.user_params.tags_from_yaml.value:
tag_suffixes['primary'].extend(['{version}-{release}'])
tag_suffixes['primary'].extend(additional_tags)
tag_suffixes['floating'].extend(additional_tags)
else:
tag_suffixes['primary'].extend(['latest', '{version}', '{version}-{release}'])
tag_suffixes['primary'].extend(additional_tags)
tag_suffixes['primary'].extend(['{version}-{release}'])
tag_suffixes['floating'].extend(['latest', '{version}'])
tag_suffixes['floating'].extend(additional_tags)

self.pt.set_plugin_arg(phase, plugin, 'tag_suffixes', tag_suffixes)

Expand Down
36 changes: 21 additions & 15 deletions tests/build_/test_plugins_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,39 +382,43 @@ def test_render_bump_release(self, disabled, release, flatpak):
assert plugin['args'].get('append', False) == flatpak

@pytest.mark.parametrize('from_container_yaml', (True, False))
@pytest.mark.parametrize(('extra_args', 'has_platform_tag', 'extra_tags', 'primary_tags'), (
@pytest.mark.parametrize(('extra_args', 'has_platform_tag', 'extra_tags', 'primary_tags',
'floating_tags'), (
# Worker build cases
({'build_type': BUILD_TYPE_WORKER, 'platform': 'x86_64'}, True, (), ()),
({'build_type': BUILD_TYPE_WORKER, 'platform': 'x86_64'}, True, ('tag1', 'tag2'), ()),
({'build_type': BUILD_TYPE_WORKER, 'platform': 'x86_64', 'scratch': True}, True, (), ()),
({'build_type': BUILD_TYPE_WORKER, 'platform': 'x86_64'}, True, (), (), ()),
({'build_type': BUILD_TYPE_WORKER, 'platform': 'x86_64'}, True, ('tag1', 'tag2'), (), ()),
({'build_type': BUILD_TYPE_WORKER, 'platform': 'x86_64', 'scratch': True}, True,
(), (), ()),
({'build_type': BUILD_TYPE_WORKER, 'platform': 'x86_64',
'isolated': True, 'release': '1.1'}, True, (), ()),
'isolated': True, 'release': '1.1'}, True, (), (), ()),
# Orchestrator build cases
({'build_type': BUILD_TYPE_ORCHESTRATOR, 'platforms': ['x86_64']},
False, ('tag1', 'tag2'), ('latest', '{version}', '{version}-{release}', 'tag1', 'tag2')),
False, ('tag1', 'tag2'), ('{version}-{release}',),
('latest', '{version}', 'tag1', 'tag2')),
({'build_type': BUILD_TYPE_ORCHESTRATOR, 'platforms': ['x86_64']},
False, (), ('latest', '{version}', '{version}-{release}')),
False, (), ('{version}-{release}',), ('latest', '{version}')),
({'build_type': BUILD_TYPE_ORCHESTRATOR, 'platforms': ['x86_64'], 'scratch': True},
False, ('tag1', 'tag2'), ()),
False, ('tag1', 'tag2'), (), ()),
({'build_type': BUILD_TYPE_ORCHESTRATOR, 'platforms': ['x86_64'], 'isolated': True,
'release': '1.1'},
False, ('tag1', 'tag2'), ('{version}-{release}',)),
False, ('tag1', 'tag2'), ('{version}-{release}',), ()),
# When build_type is not specified, no primary tags are set
({}, False, (), ()),
({}, False, ('tag1', 'tag2'), ()),
({'scratch': True}, False, (), ()),
({'isolated': True, 'release': '1.1'}, False, (), ()),
({}, False, (), (), ()),
({}, False, ('tag1', 'tag2'), (), ()),
({'scratch': True}, False, (), (), ()),
({'isolated': True, 'release': '1.1'}, False, (), (), ()),
))
def test_render_tag_from_config(self, tmpdir, from_container_yaml, extra_args,
has_platform_tag, extra_tags, primary_tags):
has_platform_tag, extra_tags, primary_tags, floating_tags):
kwargs = get_sample_prod_params(BUILD_TYPE_WORKER)
kwargs.pop('platforms', None)
kwargs.pop('platform', None)
expected_primary = set(primary_tags)
expected_floating = set(floating_tags)
exclude_for_override = set(['latest', '{version}'])

if from_container_yaml:
expected_primary -= exclude_for_override
expected_floating -= exclude_for_override

extra_args['tags_from_yaml'] = from_container_yaml
extra_args['additional_tags'] = extra_tags
Expand All @@ -435,6 +439,8 @@ def test_render_tag_from_config(self, tmpdir, from_container_yaml, extra_args,
assert unique_tag_suffix.endswith('-x86_64') == has_platform_tag
assert len(tag_suffixes['primary']) == len(expected_primary)
assert set(tag_suffixes['primary']) == expected_primary
assert len(tag_suffixes['floating']) == len(expected_floating)
assert set(tag_suffixes['floating']) == expected_floating

@pytest.mark.parametrize(('platforms'), (
(['x86_64', 'ppc64le']),
Expand Down

0 comments on commit f2e2ae3

Please sign in to comment.