Merge "SourceContext: add same_project comparison" into feature/zuulv3

This commit is contained in:
Zuul 2017-09-23 17:20:52 +00:00 committed by Gerrit Code Review
commit b5bf39efb5
2 changed files with 8 additions and 1 deletions

View File

@ -513,7 +513,7 @@ class JobParser(object):
raise SecretNotFoundError(secret_name)
if secret_name == 'zuul':
raise Exception("Secrets named 'zuul' are not allowed.")
if secret.source_context != job.source_context:
if not secret.source_context.isSameProject(job.source_context):
raise Exception(
"Unable to use secret %s. Secrets must be "
"defined in the same project in which they "

View File

@ -627,6 +627,13 @@ class SourceContext(object):
return self.__class__(self.project, self.branch, self.path,
self.trusted)
def isSameProject(self, other):
if not isinstance(other, SourceContext):
return False
return (self.project == other.project and
self.branch == other.branch and
self.trusted == other.trusted)
def __ne__(self, other):
return not self.__eq__(other)