From 574936d0945e0b87e8b5b8648198f9716f3c0564 Mon Sep 17 00:00:00 2001 From: Alexander VanTol Date: Fri, 25 Jan 2019 15:46:32 -0600 Subject: [PATCH] fix(conflict): correctly construct existing SA email (#53) * fix(conflict): correctly construct existing SA email * chore(deps): jenkins failing. needs latest version of pytest --- cirrus/google_cloud/manager.py | 16 +++++++++++----- dev-requirements.txt | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cirrus/google_cloud/manager.py b/cirrus/google_cloud/manager.py index 577189af..e1bf7eae 100644 --- a/cirrus/google_cloud/manager.py +++ b/cirrus/google_cloud/manager.py @@ -29,10 +29,13 @@ GoogleAPIError, GoogleNamingError, ) -from cirrus.google_cloud.iam import GooglePolicy -from cirrus.google_cloud.iam import GooglePolicyBinding -from cirrus.google_cloud.iam import GooglePolicyMember -from cirrus.google_cloud.iam import GooglePolicyRole +from cirrus.google_cloud.iam import ( + GooglePolicy, + GooglePolicyBinding, + GooglePolicyMember, + GooglePolicyRole, + get_iam_service_account_email, +) from cirrus.google_cloud.services import GoogleAdminService from cirrus.google_cloud.utils import get_valid_service_account_id_for_user @@ -722,7 +725,10 @@ def create_service_account(self, account_id): if err.resp.status == 409: # conflict, sa already exists. This is fine, don't raise an # error, pass back sa - return self.get_service_account(account_id) + account_email = get_iam_service_account_email( + self.project_id, account_id + ) + return self.get_service_account(account_email) raise diff --git a/dev-requirements.txt b/dev-requirements.txt index 9885b386..86ab7a93 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,5 +1,5 @@ mock==2.0.0 -pytest +pytest>=3.6 pytest-cov codacy-coverage Sphinx==1.6.5 \ No newline at end of file