def add_info_url(self, base_labels, df_labels, plugin_labels): all_labels = base_labels.copy() all_labels.update(df_labels) all_labels.update(plugin_labels) info_url = LabelFormatter().vformat(self.info_url_format, [], all_labels) self.labels['url'] = info_url
def parse_and_add_tags(self): tags = [] name = self.get_component_name() floating_defined = 'floating' in self.tag_suffixes tag_conf = self.workflow.data.tag_conf for tag_suffix in self.tag_suffixes.get('unique', []): tag = '{}:{}'.format(name, tag_suffix) if tag not in tags: tags.append(tag) self.log.debug('Using additional unique tag %s', tag) tag_conf.add_unique_image(tag) for tag_suffix in self.tag_suffixes.get('floating', []): p_suffix = LabelFormatter().vformat(tag_suffix, [], self.labels) p_tag = '{}:{}'.format(name, p_suffix) if p_tag not in tags: tags.append(p_tag) self.log.debug('Using additional floating tag %s', p_tag) tag_conf.add_floating_image(p_tag) for tag_suffix in self.tag_suffixes.get('primary', []): p_suffix = LabelFormatter().vformat(tag_suffix, [], self.labels) p_tag = '{}:{}'.format(name, p_suffix) if p_tag not in tags: add_primary = True if not floating_defined and '-' not in p_suffix: add_primary = False tags.append(p_tag) if add_primary: self.log.debug('Using additional primary tag %s', p_tag) tag_conf.add_primary_image(p_tag) else: self.log.debug('Using additional floating tag %s', p_tag) tag_conf.add_floating_image(p_tag) return tags
def parse_and_add_tags(self): tags = [] name = self.get_component_name() for tag_suffix in self.tag_suffixes.get('unique', []): tag = '{}:{}'.format(name, tag_suffix) self.log.debug('Using additional unique tag %s', tag) self.workflow.tag_conf.add_unique_image(tag) tags.append(tag) for tag_suffix in self.tag_suffixes.get('primary', []): p_suffix = LabelFormatter().vformat(tag_suffix, [], self.labels) p_tag = '{}:{}'.format(name, p_suffix) self.log.debug('Using additional primary tag %s', p_tag) self.workflow.tag_conf.add_primary_image(p_tag) tags.append(p_tag) return tags
def test_label_formatter(labels, test_string, expected): if expected is not None: assert expected == LabelFormatter().vformat(test_string, [], labels) else: with pytest.raises(KeyError): LabelFormatter().vformat(test_string, [], labels)
def get_info_url(self, base_labels, df_labels, plugin_labels) -> str: all_labels = {**base_labels, **df_labels, **plugin_labels} info_url = LabelFormatter().vformat(self.info_url_format, [], all_labels) return info_url