예제 #1
0
    def create_metadata_dockerfile(self):
        """Create a minimal Dockerfile on the metadata repository, copying all manifests
        inside the image and having nearly the same labels as its corresponding operator Dockerfile

        But some modifications on the labels are needed:

        - 'com.redhat.component' label should contain the metadata component name,
           otherwise it conflicts with the operator.
        - 'com.redhat.delivery.appregistry' should always be "true", regardless of
          the value coming from the operator Dockerfile
        - 'release' label should be removed, because we can't build the same NVR
          multiple times
        - 'version' label should contain both 'release' info and the target stream
        """
        operator_dockerfile = DockerfileParser('{}/{}/Dockerfile'.format(
            self.working_dir, self.operator_name))
        metadata_dockerfile = DockerfileParser('{}/{}/Dockerfile'.format(
            self.working_dir, self.metadata_repo))
        metadata_dockerfile.content = 'FROM scratch\nCOPY ./manifests /manifests'
        metadata_dockerfile.labels = operator_dockerfile.labels
        metadata_dockerfile.labels['com.redhat.component'] = (
            operator_dockerfile.labels['com.redhat.component'].replace(
                self.operator_name, self.metadata_name))
        metadata_dockerfile.labels['com.redhat.delivery.appregistry'] = 'true'
        metadata_dockerfile.labels['name'] = 'openshift/ose-{}'.format(
            self.metadata_name)
        # mangle version according to spec
        metadata_dockerfile.labels['version'] = '{}.{}.{}'.format(
            operator_dockerfile.labels['version'],
            operator_dockerfile.labels['release'], self.stream)
        del (metadata_dockerfile.labels['release'])
예제 #2
0
파일: bundle.py 프로젝트: vfreex/doozer
    def generate_bundle_dockerfile(self):
        """Create a Dockerfile with instructions to build the bundle container and a set of LABELs
        that allow the bundle to publish its manifests on operator's behalf.
        """
        operator_df = DockerfileParser('{}/Dockerfile'.format(
            self.operator_clone_path))
        bundle_df = DockerfileParser('{}/Dockerfile'.format(
            self.bundle_clone_path))

        bundle_df.content = 'FROM scratch\nCOPY ./manifests /manifests\nCOPY ./metadata /metadata'
        bundle_df.labels = operator_df.labels
        bundle_df.labels['com.redhat.component'] = self.bundle_brew_component
        bundle_df.labels['com.redhat.delivery.appregistry'] = False
        bundle_df.labels['name'] = self.get_bundle_image_name()
        bundle_df.labels['version'] = '{}.{}'.format(
            operator_df.labels['version'], operator_df.labels['release'])
        bundle_df.labels = {
            **bundle_df.labels,
            **self.redhat_delivery_tags,
            **self.operator_framework_tags
        }
        del (bundle_df.labels['release'])