How to use the cekit.descriptor.Label function in cekit

To help you get started, we’ve selected a few cekit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cekit / cekit / tests / test_unit_descriptor.py View on Github external
def test_label():
    label = Label(yaml.safe_load("""
      name: "io.k8s.display-name"
      value: "JBoss A-MQ 6.2"
"""))
    assert label['name'] == "io.k8s.display-name"
    assert label['value'] == "JBoss A-MQ 6.2"
github cekit / cekit / cekit / generator / base.py View on Github external
def labels(self):
                labels = [
                    Label({'name': 'name', 'value': '%s' % self._generator.image['name']}),
                    Label({'name': 'version', 'value': '%s' % self._generator.image['version']})
                ]

                # do not override this label if it's already set
                if self._generator.image.get('ports', []) and \
                        'io.openshift.expose-services' not in [k['name'] for k in self._generator.image['labels']]:
                    labels.append(Label({'name': 'io.openshift.expose-services',
                                         'value': self._generator._generate_expose_services()}))

                return labels
github cekit / cekit / cekit / generator / base.py View on Github external
def add_build_labels(self):
        image_labels = self.image.labels
        # we will persist cekit version in a label here, so we know which version of cekit
        # was used to build the image
        image_labels.append(Label({'name': 'io.cekit.version', 'value': cekit_version}))

        for label in image_labels:
            if len(label.value) > 128:
                # breaks the line each time it reaches 128 characters
                label.value = "\\\n".join(re.findall("(?s).{,128}", label.value))[:]

        # If we define the label in the image descriptor
        # we should *not* override it with value from
        # the root's key
        if self.image.description and not self.image.label('description'):
            image_labels.append(Label({'name': 'description', 'value': self.image.description}))

        # Last - if there is no 'summary' label added to image descriptor
        # we should use the value of the 'description' key and create
        # a 'summary' label with it's content. If there is even that
        # key missing - we should not add anything.
        description = self.image.label('description')

        if not self.image.label('summary') and description:
            image_labels.append(Label({'name': 'summary', 'value': description['value']}))
github cekit / cekit / cekit / generator / base.py View on Github external
def labels(self):
                labels = [
                    Label({'name': 'name', 'value': '%s' % self._generator.image['name']}),
                    Label({'name': 'version', 'value': '%s' % self._generator.image['version']})
                ]

                # do not override this label if it's already set
                if self._generator.image.get('ports', []) and \
                        'io.openshift.expose-services' not in [k['name'] for k in self._generator.image['labels']]:
                    labels.append(Label({'name': 'io.openshift.expose-services',
                                         'value': self._generator._generate_expose_services()}))

                return labels
github cekit / cekit / cekit / generator / base.py View on Github external
def add_build_labels(self):
        image_labels = self.image.labels
        # we will persist cekit version in a label here, so we know which version of cekit
        # was used to build the image
        image_labels.append(Label({'name': 'io.cekit.version', 'value': cekit_version}))

        # If we define the label in the image descriptor
        # we should *not* override it with value from
        # the root's key
        if self.image.description and not self.image.label('description'):
            image_labels.append(Label({'name': 'description', 'value': self.image.description}))

        # Last - if there is no 'summary' label added to image descriptor
        # we should use the value of the 'description' key and create
        # a 'summary' label with it's content. If there is even that
        # key missing - we should not add anything.
        description = self.image.label('description')

        if not self.image.label('summary') and description:
            image_labels.append(Label({'name': 'summary', 'value': description['value']}))
github cekit / cekit / cekit / generator / base.py View on Github external
def add_build_labels(self):
        image_labels = self.image.labels
        # we will persist cekit version in a label here, so we know which version of cekit
        # was used to build the image
        image_labels.append(Label({'name': 'io.cekit.version', 'value': cekit_version}))

        # If we define the label in the image descriptor
        # we should *not* override it with value from
        # the root's key
        if self.image.description and not self.image.label('description'):
            image_labels.append(Label({'name': 'description', 'value': self.image.description}))

        # Last - if there is no 'summary' label added to image descriptor
        # we should use the value of the 'description' key and create
        # a 'summary' label with it's content. If there is even that
        # key missing - we should not add anything.
        description = self.image.label('description')

        if not self.image.label('summary') and description:
            image_labels.append(Label({'name': 'summary', 'value': description['value']}))
github cekit / cekit / cekit / generator / base.py View on Github external
def labels(self):
                labels = [
                    Label({'name': 'name', 'value': '%s' % self._generator.image['name']}),
                    Label({'name': 'version', 'value': '%s' % self._generator.image['version']})
                ]
                return labels
github cekit / cekit / cekit / descriptor / image.py View on Github external
def _prepare(self):
        self._descriptor['labels'] = [Label(x) for x in self._descriptor.get('labels', [])]
        self._descriptor['envs'] = [Env(x) for x in self._descriptor.get('envs', [])]
        self._descriptor['ports'] = [Port(x) for x in self._descriptor.get('ports', [])]
        if 'run' in self._descriptor:
            self._descriptor['run'] = Run(self._descriptor['run'])
        self._descriptor['artifacts'] = [create_resource(a, directory=self._artifact_dir)
                                         for a in self._descriptor.get('artifacts', [])]
        self._descriptor['modules'] = Modules(self._descriptor.get('modules', {}), self.path)
        self._descriptor['packages'] = Packages(self._descriptor.get('packages', {}), self.path)
        self._descriptor['osbs'] = Osbs(self._descriptor.get('osbs', {}), self.path)
        self._descriptor['volumes'] = [Volume(x) for x in self._descriptor.get('volumes', [])]

        # make sure image declarations override any module definitions
        self._image_overrides = {'artifacts': Image._to_dict(
            self.artifacts), 'modules': Image._to_dict(self.modules.install)}
        self._all_artifacts = Image._to_dict(self.artifacts)
github cekit / cekit / cekit / generator / base.py View on Github external
def labels(self):
                labels = [
                    Label({'name': 'name', 'value': '%s' % self._generator.image['name']}),
                    Label({'name': 'version', 'value': '%s' % self._generator.image['version']})
                ]
                return labels