This is an automated email from the ASF dual-hosted git repository.

mykolabodnar pushed a commit to branch DLAB-1379
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/DLAB-1379 by this push:
     new 6c65e9c  [DLAB-1379] - SSN creation fixed
6c65e9c is described below

commit 6c65e9c853a355a7df992a5d258c8aca07392230
Author: Mykola_Bodnar1 <bodnarmyk...@gmail.com>
AuthorDate: Mon Dec 16 17:04:38 2019 +0200

    [DLAB-1379] - SSN creation fixed
---
 .../src/general/lib/gcp/actions_lib.py             | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py 
b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
index 202338d..a51fdc7 100644
--- a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
+++ b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
@@ -555,23 +555,23 @@ class GCPActions:
     def set_role_to_service_account(self, service_account_name, role_name, 
role_type='custom'):
         service_account_email = 
"{}@{}.iam.gserviceaccount.com".format(service_account_name, self.project)
         resource = "projects/{}/serviceAccounts/{}".format(self.project, 
service_account_email)
-        request = 
GCPActions().service_iam.projects().serviceAccounts().getIamPolicy(resource=resource)
-        serviceAccounts_policy = request.execute()
+
         print(serviceAccounts_policy)
-        params = {
-            "role": "projects/{}/roles/{}".format(self.project, 
role_name.replace('-', '_')),
-            "members": [
-                "serviceAccount:{}".format(service_account_email)
-            ]
-        }
-        if role_type == 'predefined':
-            params['role'] = "roles/{}".format(role_name)
-        serviceAccounts_policy['bindings'].append(params)
-        params = {
+        params =  {
             "policy": {
-                "bindings": serviceAccounts_policy['bindings']
+                "bindings": [
+                    {
+                        "role": "projects/{}/roles/{}".format(self.project, 
role_name.replace('-', '_')),
+                        "members": [
+                            "serviceAccount:{}".format(service_account_email)
+                        ]
+                    }
+                ]
             }
         }
+        if role_type == 'predefined':
+            params['role'] = "roles/{}".format(role_name)
+
         request = 
self.service_iam.projects().serviceAccounts().setIamPolicy(resource=resource, 
body=params)
         try:
             return request.execute()


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org
For additional commands, e-mail: commits-h...@dlab.apache.org

Reply via email to