def _inject_redhat_defaults(self): envs = [{ 'name': 'JBOSS_IMAGE_NAME', 'value': '%s' % self.image['name'] }, { 'name': 'JBOSS_IMAGE_VERSION', 'value': '%s' % self.image['version'] }] labels = [{ 'name': 'name', 'value': '%s' % self.image['name'] }, { 'name': 'version', 'value': '%s' % self.image['version'] }] # do not override this label if it's already set if self.image.get('ports', []) and \ 'io.openshift.expose-services' not in [ k['name'] for k in self.image['labels'] ]: labels.append({ 'name': 'io.openshift.expose-services', 'value': self._generate_expose_services() }) redhat_override = {'envs': envs, 'labels': labels} descriptor = Overrides(redhat_override, None) descriptor.merge(self.image) self.image = descriptor
def test_overide_resource_remove_chksum(): image = Image( yaml.safe_load(""" from: foo name: test/foo version: 1.9 artifacts: - name: abs path: /tmp/abs md5: 'foo' sha1: 'foo' sha256: 'foo' """), 'foo') overrides = Overrides( yaml.safe_load(""" artifacts: - name: abs path: /tmp/over """), 'foo') overrides.merge(image) assert overrides['from'] == 'foo' assert overrides['artifacts'][0]['path'] == '/tmp/over' assert 'md5' not in overrides['artifacts'][0] assert 'sha1' not in overrides['artifacts'][0] assert 'sha256' not in overrides['artifacts'][0]
def override(self, overrides_path): logger.info("Using overrides file from '%s'." % overrides_path) descriptor = Overrides( tools.load_descriptor(overrides_path), os.path.dirname(os.path.abspath(overrides_path))) descriptor.merge(self.image) return descriptor
def _inject_redhat_defaults(self): envs = [{'name': 'JBOSS_IMAGE_NAME', 'value': '%s' % self.image['name']}, {'name': 'JBOSS_IMAGE_VERSION', 'value': '%s' % self.image['version']}] labels = [{'name': 'name', 'value': '%s' % self.image['name']}, {'name': 'version', 'value': '%s' % self.image['version']}] redhat_override = {'envs': envs, 'labels': labels} descriptor = Overrides(redhat_override, None) descriptor.merge(self.image) self.image = descriptor