Пример #1
0
class TestConfig(unittest.TestCase):
    def setUp(self):
        self.helper = TemplateHelper()

    def test_generate_component(self):
        self.assertEqual(self.helper.component("jboss-eap-7/eap70"), "jboss-eap-7-eap70-docker")

    def test_generate_component_for_beta_image(self):
        self.assertEqual(self.helper.component("jboss-eap-7-beta/eap70"), "jboss-eap-7-beta-eap70-docker")
    
    def test_generate_component_for_tech_preview_image(self):
        self.assertEqual(self.helper.component("jboss-eap-7-tech-preview/eap70"), "jboss-eap-7-tech-preview-eap70-docker")
Пример #2
0
    def render_from_template(self):
        if not self.cfg.get('labels'):
            self.cfg['labels'] = []

        labels = {}

        for label in self.cfg.get('labels'):
            labels[label['name']] = label['value']

        # https://github.com/jboss-dockerfiles/dogen/issues/129
        # https://github.com/jboss-dockerfiles/dogen/issues/137
        for label in ['maintainer', 'description']:
            value = self.cfg.get(label)

            if value and not label in labels:
                self.cfg['labels'].append({'name': label, 'value': value})
                labels[label] = value

        # https://github.com/jboss-dockerfiles/dogen/issues/195
        if 'summary' not in labels:
            if 'description' in labels:
                self.cfg['labels'].append({
                    'name': 'summary',
                    'value': labels.get('description')
                })

        if self.template:
            template_file = self.template
        else:
            self.log.debug("Using dogen provided template file")
            template_file = os.path.join(self.pwd, "templates",
                                         "template.jinja")

        self.log.info("Rendering Dockerfile...")
        loader = FileSystemLoader(os.path.dirname(template_file))
        env = Environment(loader=loader, trim_blocks=True, lstrip_blocks=True)
        env.globals['helper'] = TemplateHelper()
        template = env.get_template(os.path.basename(template_file))

        with open(self.dockerfile, 'wb') as f:
            f.write(template.render(self.cfg).encode('utf-8'))
        self.log.debug("Done")

        if self.template and Tools.is_url(self.template):
            self.log.debug("Removing temporary template file...")
            os.remove(self.template)
Пример #3
0
    def render_from_template(self):
        if self.template:
            template_file = self.template
        else:
            self.log.debug("Using dogen provided template file")
            template_file = os.path.join(self.pwd, "templates",
                                         "template.jinja")

        self.log.info("Rendering Dockerfile...")
        loader = FileSystemLoader(os.path.dirname(template_file))
        env = Environment(loader=loader, trim_blocks=True, lstrip_blocks=True)
        env.globals['helper'] = TemplateHelper()
        template = env.get_template(os.path.basename(template_file))

        with open(self.dockerfile, 'w') as f:
            f.write(template.render(self.cfg).encode('utf-8'))
        self.log.debug("Done")

        if self.template and Tools.is_url(self.template):
            self.log.debug("Removing temporary template file...")
            os.remove(self.template)
Пример #4
0
 def setUp(self):
     self.helper = TemplateHelper()
Пример #5
0
 def setUp(self):
     self.helper = TemplateHelper()