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']}))
def labels(self): labels = [ Label({ 'name': 'name', 'value': '%s' % self._generator.image['name'] }), Label({ 'name': 'version', 'value': '%s' % self._generator.image['version'] }) ] return labels
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)
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"
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']}))
def _prepare(self): """Updates self._descriptor with objects and prepare sane label""" self._descriptor['labels'] = self._descriptor.get('labels', []) # we will persist cekit version in a label here, so we know which version of cekit # was used to build the image self['labels'].extend([{ 'name': 'org.concrt.version', 'value': cekit_version }, { 'name': 'io.cekit.version', 'value': cekit_version }]) # The description key available in image descriptor's # root is added as labels to the image key = 'description' # If we define the label in the image descriptor # we should *not* override it with value from # the root's key if key in self._descriptor and not self.label(key): value = self._descriptor[key] self._descriptor['labels'].append({'name': key, 'value': value}) # 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.label('description') if not self.label('summary') and description: self._descriptor['labels'].append({ 'name': 'summary', 'value': description['value'] }) 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'] = [ Resource(a, directory=self._artifact_dir) for a in self._descriptor.get('artifacts', []) ] if 'modules' in self._descriptor: self._descriptor['modules'] = Modules(self._descriptor['modules'], self.path) if 'packages' in self._descriptor: self._descriptor['packages'] = Packages( self._descriptor['packages']) if 'osbs' in self._descriptor: self._descriptor['osbs'] = Osbs(self._descriptor['osbs']) self._descriptor['volumes'] = [ Volume(x) for x in self._descriptor.get('volumes', []) ]