def run(self):
        """
        run the plugin
        """

        parser = df_parser(self.workflow.builder.df_path, workflow=self.workflow)
        dockerfile_labels = parser.labels
        labels = Labels(dockerfile_labels)

        component_label = labels.get_name(Labels.LABEL_TYPE_COMPONENT)

        try:
            component = dockerfile_labels[component_label]
        except KeyError:
            raise RuntimeError("missing label: {}".format(component_label))

        version_label = labels.get_name(Labels.LABEL_TYPE_VERSION)
        try:
            version = dockerfile_labels[version_label]
        except KeyError:
            raise RuntimeError('missing label: {}'.format(version_label))

        try:
            _, release = labels.get_name_and_value(Labels.LABEL_TYPE_RELEASE)
        except KeyError:
            release = None

        if release:
            if not self.append:
                self.log.debug("release set explicitly so not incrementing")
                if not is_scratch_build():
                    self.check_build_existence_for_explicit_release(component, version, release)
                return

        if self.append:
            next_release = self.get_next_release_append(component, version, release)
        elif is_scratch_build():
            metadata = get_build_json().get("metadata", {})
            next_release = metadata.get("name", "1")
        else:
            next_release = self.get_next_release_standard(component, version)

        # Always set preferred release label - other will be set if old-style
        # label is present
        release_label = labels.LABEL_NAMES[Labels.LABEL_TYPE_RELEASE][0]

        # No release labels are set so set them
        self.log.info("setting %s=%s", release_label, next_release)
        # Write the label back to the file (this is a property setter)
        dockerfile_labels[release_label] = next_release
def run ( self ) : parser = df_parser ( self . workflow . builder . df_path , workflow = self . workflow ) dockerfile_labels = parser . labels labels = Labels ( dockerfile_labels ) component_label = labels . get_name ( Labels . LABEL_TYPE_COMPONENT ) try : component = dockerfile_labels [ component_label ] except KeyError : raise RuntimeError ( "missing label: {}" . format ( component_label ) ) version_label = labels . get_name ( Labels . LABEL_TYPE_VERSION ) try : version = dockerfile_labels [ version_label ] except KeyError : raise RuntimeError ( 'missing label: {}' . format ( version_label ) ) try : _ , release = labels . get_name_and_value ( Labels . LABEL_TYPE_RELEASE ) except KeyError : release = None if release : if not self . append : self . log . debug ( "release set explicitly so not incrementing" ) if not is_scratch_build ( ) : self . check_build_existence_for_explicit_release ( component , version , release ) return if self . append : next_release = self . get_next_release_append ( component , version , release ) elif is_scratch_build ( ) : metadata = get_build_json ( ) . get ( "metadata" , { } ) next_release = metadata . get ( "name" , "1" ) else : next_release = self . get_next_release_standard ( component , version ) release_label = labels . LABEL_NAMES [ Labels . LABEL_TYPE_RELEASE ] [ 0 ] self . log . info ( "setting %s=%s" , release_label , next_release ) dockerfile_labels [ release_label ] = next_release
run the plugin