Commit 2f03ea41 authored by Qinusty's avatar Qinusty
Browse files

source.py: Add UNKNOWN_ALIAS and URL_WITHOUT_ALIAS

Added configurable warnings for the two warnings raised relating to
alias validation.
parent 6a4a6479
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -757,6 +757,16 @@ class CoreWarnings():
    which is found to be invalid based on the configured track
    """

    URL_WITHOUT_ALIAS = "url-without-alias"
    """
    This warning will be produced when a source is configured with a url which does not contain an alias.
    """

    UNKNOWN_ALIAS = "unknown-alias"
    """
    This warning will be produced when a source is configured with a url which does not contain an alias.
    """


__CORE_WARNINGS = [
    value
+5 −2
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ from . import Plugin
from . import _yaml, utils
from ._exceptions import BstError, ImplError, ErrorDomain
from ._projectrefs import ProjectRefStorage
from .plugin import CoreWarnings


class Consistency():
@@ -469,10 +470,12 @@ class Source(Plugin):
        project = self._get_project()
        if alias.lower() in utils._URI_SCHEMES:
            self.warn("{}: The use of an alias in urls is strongly advised.".format(self._get_provenance()),
                      detail="See https://buildstream.gitlab.io/buildstream/format_project.html#source-aliases")
                      detail="See https://buildstream.gitlab.io/buildstream/format_project.html#source-aliases",
                      warning_token=CoreWarnings.URL_WITHOUT_ALIAS)

        elif not project.get_alias_uri(alias, first_pass=self.__first_pass) and len(url_parts) > 1:
            self.warn("{}: Unknown alias '{}' in url".format(self._get_provenance(), alias))
            self.warn("{}: Unknown alias '{}' in url".format(self._get_provenance(), alias),
                      warning_token=CoreWarnings.UNKNOWN_ALIAS)

    def get_source_fetchers(self):
        """Get the objects that are used for fetching