You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/18 07:16:25 UTC

[GitHub] [airflow] potiuk opened a new pull request #9368: Adds GCP Secret Manager Hook

potiuk opened a new pull request #9368:
URL: https://github.com/apache/airflow/pull/9368


   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Target Github ISSUE in description if exists
   - [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#discussion_r442169817



##########
File path: tests/test_utils/gcp_system_helpers.py
##########
@@ -172,3 +173,29 @@ def grant_bucket_access(cls, bucket: str, account_email: str):
                 bucket_name,
             ]
         )
+
+    @classmethod
+    def delete_secret(cls, name: str, silent: bool = False):
+        cmd = ["gcloud", "secrets", "delete", name, "--project", GoogleSystemTest._project_id(), "--quiet"]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY, silent=silent)
+
+    @classmethod
+    def create_secret(cls, name: str, value: str):
+        with tempfile.NamedTemporaryFile(delete=False) as tmp:
+            tmp.write(value.encode("UTF-8"))
+        cmd = ["gcloud", "secrets", "create", name,
+               "--replication-policy", "automatic",
+               "--project", GoogleSystemTest._project_id(),
+               "--data-file", tmp.name]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY)
+        os.remove(tmp.name)

Review comment:
       Bad me! Fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#discussion_r442071856



##########
File path: tests/providers/google/cloud/_internal_client/tests_secret_manager_client.py
##########
@@ -0,0 +1,99 @@
+# pylint: disable=no-member
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from unittest import TestCase, mock
+
+from google.api_core.exceptions import NotFound
+from google.cloud.secretmanager_v1.types import AccessSecretVersionResponse
+
+from airflow.providers.google.cloud._internal_client.secret_client import _SecretManagerClient  # noqa
+from airflow.version import version
+
+INTERNAL_CLIENT_MODULE = "airflow.providers.google.cloud._internal_client.secret_client"
+
+
+# noinspection DuplicatedCode,PyUnresolvedReferences
+class TestSecretManagerClient(TestCase):
+
+    @mock.patch(INTERNAL_CLIENT_MODULE + ".SecretManagerServiceClient")
+    @mock.patch(INTERNAL_CLIENT_MODULE + ".ClientInfo")
+    def test_auth(self, mock_client_info, mock_secrets_client):
+        mock_client = mock.MagicMock()
+        mock_client_info_mock = mock.MagicMock()
+        mock_client_info.return_value = mock_client_info_mock
+        mock_secrets_client.return_value = mock_client

Review comment:
       Compressed in all places :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#issuecomment-645833163


   @ashb and @kaxil  - I'd love to get that one and the #8974 to be included in the first release of backports. I implemented the GCP Secret Manager Hook following what we agreed with HashiCorp. 
   
   Note that I renamed the secrets_manager into secret_manager (and SecretsManager into SecretManager) as this is the name of the GCP Service (no plural). I left Plural in the contrib folder for backwards compatibility (but deprecation warning points to singular name now). 
   
   @mik-laj @turbaszek -> would love if you take a look as well (I added hook  System Tests as well and it works nicely with the real GCP SecretManager).
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] turbaszek commented on a change in pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#discussion_r442028203



##########
File path: tests/providers/google/cloud/_internal_client/tests_secret_manager_client.py
##########
@@ -0,0 +1,99 @@
+# pylint: disable=no-member
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from unittest import TestCase, mock
+
+from google.api_core.exceptions import NotFound
+from google.cloud.secretmanager_v1.types import AccessSecretVersionResponse
+
+from airflow.providers.google.cloud._internal_client.secret_client import _SecretManagerClient  # noqa
+from airflow.version import version
+
+INTERNAL_CLIENT_MODULE = "airflow.providers.google.cloud._internal_client.secret_client"
+
+
+# noinspection DuplicatedCode,PyUnresolvedReferences
+class TestSecretManagerClient(TestCase):
+
+    @mock.patch(INTERNAL_CLIENT_MODULE + ".SecretManagerServiceClient")
+    @mock.patch(INTERNAL_CLIENT_MODULE + ".ClientInfo")
+    def test_auth(self, mock_client_info, mock_secrets_client):
+        mock_client = mock.MagicMock()
+        mock_client_info_mock = mock.MagicMock()
+        mock_client_info.return_value = mock_client_info_mock
+        mock_secrets_client.return_value = mock_client

Review comment:
       ```suggestion
           mock_client_info.return_value = mock.MagicMock()
           mock_secrets_client.return_value = mock.MagicMock()
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#discussion_r442128527



##########
File path: airflow/providers/google/PROVIDERS_CHANGES_2020.05.20.md
##########
@@ -87,7 +87,7 @@
 | [01f99426f](https://github.com/apache/airflow/commit/01f99426fddd2a24552f352edcb271fa78cf3b15) | 2020-03-28  | Add download/upload operators for GCS and Google Sheets (#7866)                                                                                                    |
 | [892522f8e](https://github.com/apache/airflow/commit/892522f8e2aeedc1ad842a08aaea967b0cae077f) | 2020-03-26  | Change signature of GSheetsHook methods (#7853)                                                                                                                    |
 | [bfd425157](https://github.com/apache/airflow/commit/bfd425157a746402b516f8fc9e48f4ddccd794ce) | 2020-03-26  | Improve idempotency in MLEngineHook.create_model (#7811)                                                                                                           |
-| [f9c226343](https://github.com/apache/airflow/commit/f9c226343d94a7732da280d1dd086bf1ba291c77) | 2020-03-26  | Fix CloudSecretsManagerBackend invalid connections_prefix (#7861)                                                                                                  |
+| [f9c226343](https://github.com/apache/airflow/commit/f9c226343d94a7732da280d1dd086bf1ba291c77) | 2020-03-26  | Fix CloudSecretManagerBackend invalid connections_prefix (#7861)                                                                                                  |

Review comment:
       resolved




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#issuecomment-645935758


   All fixed @ashb 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk merged pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #9368:
URL: https://github.com/apache/airflow/pull/9368


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#discussion_r442133536



##########
File path: tests/test_utils/gcp_system_helpers.py
##########
@@ -172,3 +173,29 @@ def grant_bucket_access(cls, bucket: str, account_email: str):
                 bucket_name,
             ]
         )
+
+    @classmethod
+    def delete_secret(cls, name: str, silent: bool = False):
+        cmd = ["gcloud", "secrets", "delete", name, "--project", GoogleSystemTest._project_id(), "--quiet"]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY, silent=silent)
+
+    @classmethod
+    def create_secret(cls, name: str, value: str):
+        with tempfile.NamedTemporaryFile(delete=False) as tmp:
+            tmp.write(value.encode("UTF-8"))
+        cmd = ["gcloud", "secrets", "create", name,
+               "--replication-policy", "automatic",
+               "--project", GoogleSystemTest._project_id(),
+               "--data-file", tmp.name]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY)
+        os.remove(tmp.name)

Review comment:
       Yep. This works, and is more robust.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#discussion_r442091612



##########
File path: airflow/providers/google/PROVIDERS_CHANGES_2020.05.20.md
##########
@@ -87,7 +87,7 @@
 | [01f99426f](https://github.com/apache/airflow/commit/01f99426fddd2a24552f352edcb271fa78cf3b15) | 2020-03-28  | Add download/upload operators for GCS and Google Sheets (#7866)                                                                                                    |
 | [892522f8e](https://github.com/apache/airflow/commit/892522f8e2aeedc1ad842a08aaea967b0cae077f) | 2020-03-26  | Change signature of GSheetsHook methods (#7853)                                                                                                                    |
 | [bfd425157](https://github.com/apache/airflow/commit/bfd425157a746402b516f8fc9e48f4ddccd794ce) | 2020-03-26  | Improve idempotency in MLEngineHook.create_model (#7811)                                                                                                           |
-| [f9c226343](https://github.com/apache/airflow/commit/f9c226343d94a7732da280d1dd086bf1ba291c77) | 2020-03-26  | Fix CloudSecretsManagerBackend invalid connections_prefix (#7861)                                                                                                  |
+| [f9c226343](https://github.com/apache/airflow/commit/f9c226343d94a7732da280d1dd086bf1ba291c77) | 2020-03-26  | Fix CloudSecretManagerBackend invalid connections_prefix (#7861)                                                                                                  |

Review comment:
       Yeah. it was search and replace. I am going to remove those and regenerate them in the "backport" providers and they will get corrected.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#discussion_r442076538



##########
File path: airflow/providers/google/cloud/secrets/secret_manager.py
##########
@@ -134,23 +131,12 @@ def get_variable(self, key: str) -> Optional[str]:
 
     def _get_secret(self, path_prefix: str, secret_id: str) -> Optional[str]:
         """
-        Get secret value from Parameter Store.
+        Get secret value from Secret_manager based on prefix.

Review comment:
       ```suggestion
           Get secret value from SecretManager based on prefix.
   ```
   
   maybe?

##########
File path: airflow/providers/google/PROVIDERS_CHANGES_2020.05.20.md
##########
@@ -87,7 +87,7 @@
 | [01f99426f](https://github.com/apache/airflow/commit/01f99426fddd2a24552f352edcb271fa78cf3b15) | 2020-03-28  | Add download/upload operators for GCS and Google Sheets (#7866)                                                                                                    |
 | [892522f8e](https://github.com/apache/airflow/commit/892522f8e2aeedc1ad842a08aaea967b0cae077f) | 2020-03-26  | Change signature of GSheetsHook methods (#7853)                                                                                                                    |
 | [bfd425157](https://github.com/apache/airflow/commit/bfd425157a746402b516f8fc9e48f4ddccd794ce) | 2020-03-26  | Improve idempotency in MLEngineHook.create_model (#7811)                                                                                                           |
-| [f9c226343](https://github.com/apache/airflow/commit/f9c226343d94a7732da280d1dd086bf1ba291c77) | 2020-03-26  | Fix CloudSecretsManagerBackend invalid connections_prefix (#7861)                                                                                                  |
+| [f9c226343](https://github.com/apache/airflow/commit/f9c226343d94a7732da280d1dd086bf1ba291c77) | 2020-03-26  | Fix CloudSecretManagerBackend invalid connections_prefix (#7861)                                                                                                  |

Review comment:
       This one should probably stay is it is? (it was right when then commits message was written after all)

##########
File path: tests/test_utils/gcp_system_helpers.py
##########
@@ -172,3 +173,29 @@ def grant_bucket_access(cls, bucket: str, account_email: str):
                 bucket_name,
             ]
         )
+
+    @classmethod
+    def delete_secret(cls, name: str, silent: bool = False):
+        cmd = ["gcloud", "secrets", "delete", name, "--project", GoogleSystemTest._project_id(), "--quiet"]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY, silent=silent)
+
+    @classmethod
+    def create_secret(cls, name: str, value: str):
+        with tempfile.NamedTemporaryFile(delete=False) as tmp:
+            tmp.write(value.encode("UTF-8"))
+        cmd = ["gcloud", "secrets", "create", name,
+               "--replication-policy", "automatic",
+               "--project", GoogleSystemTest._project_id(),
+               "--data-file", tmp.name]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY)
+        os.remove(tmp.name)

Review comment:
       Does this work?
   
   ```suggestion
           with tempfile.NamedTemporaryFile() as tmp:
               tmp.write(value.encode("UTF-8"))
               tmp.flush()
               cmd = ["gcloud", "secrets", "create", name,
                      "--replication-policy", "automatic",
                      "--project", GoogleSystemTest._project_id(),
                      "--data-file", tmp.name]
               cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY)
   ```
   
   (otherwise in case of error the file leaks.)

##########
File path: airflow/providers/google/README.md
##########
@@ -560,7 +560,7 @@ All classes in Airflow 2.0 are in `airflow.providers.google` package.
 
 | Airflow 2.0 protocols: `airflow.providers.google` package                                                                                                           | Airflow 1.10.* previous location (usually `airflow.contrib`)                                                                                                         |
 |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| [cloud.secrets.secrets_manager.CloudSecretsManagerBackend](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/secrets/secrets_manager.py) | [contrib.secrets.gcp_secrets_manager.CloudSecretsManagerBackend](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/secrets/gcp_secrets_manager.py) |
+| [cloud.secrets.secrets_manager.CloudSecretManagerBackend](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/secrets/secrets_manager.py) | [contrib.secrets.gcp_secrets_manager.CloudSecretManagerBackend](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/secrets/gcp_secrets_manager.py) |

Review comment:
       ```suggestion
   | [cloud.secrets.secrets_manager.CloudSecretManagerBackend](https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/secrets/secrets_manager.py) | [contrib.secrets.gcp_secrets_manager.CloudSecretsManagerBackend](https://github.com/apache/airflow/blob/v1-10-stable/airflow/contrib/secrets/gcp_secrets_manager.py) |
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#discussion_r442165228



##########
File path: tests/test_utils/gcp_system_helpers.py
##########
@@ -172,3 +173,29 @@ def grant_bucket_access(cls, bucket: str, account_email: str):
                 bucket_name,
             ]
         )
+
+    @classmethod
+    def delete_secret(cls, name: str, silent: bool = False):
+        cmd = ["gcloud", "secrets", "delete", name, "--project", GoogleSystemTest._project_id(), "--quiet"]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY, silent=silent)
+
+    @classmethod
+    def create_secret(cls, name: str, value: str):
+        with tempfile.NamedTemporaryFile(delete=False) as tmp:
+            tmp.write(value.encode("UTF-8"))
+        cmd = ["gcloud", "secrets", "create", name,
+               "--replication-policy", "automatic",
+               "--project", GoogleSystemTest._project_id(),
+               "--data-file", tmp.name]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY)
+        os.remove(tmp.name)

Review comment:
       Looks like you changed update_secret, but not create_secret. Could you change this one too please?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #9368: Adds GCP Secret Manager Hook

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #9368:
URL: https://github.com/apache/airflow/pull/9368#discussion_r442092323



##########
File path: tests/test_utils/gcp_system_helpers.py
##########
@@ -172,3 +173,29 @@ def grant_bucket_access(cls, bucket: str, account_email: str):
                 bucket_name,
             ]
         )
+
+    @classmethod
+    def delete_secret(cls, name: str, silent: bool = False):
+        cmd = ["gcloud", "secrets", "delete", name, "--project", GoogleSystemTest._project_id(), "--quiet"]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY, silent=silent)
+
+    @classmethod
+    def create_secret(cls, name: str, value: str):
+        with tempfile.NamedTemporaryFile(delete=False) as tmp:
+            tmp.write(value.encode("UTF-8"))
+        cmd = ["gcloud", "secrets", "create", name,
+               "--replication-policy", "automatic",
+               "--project", GoogleSystemTest._project_id(),
+               "--data-file", tmp.name]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY)
+        os.remove(tmp.name)

Review comment:
       execite_context never fails. But yeah. This way is nicer. 

##########
File path: tests/test_utils/gcp_system_helpers.py
##########
@@ -172,3 +173,29 @@ def grant_bucket_access(cls, bucket: str, account_email: str):
                 bucket_name,
             ]
         )
+
+    @classmethod
+    def delete_secret(cls, name: str, silent: bool = False):
+        cmd = ["gcloud", "secrets", "delete", name, "--project", GoogleSystemTest._project_id(), "--quiet"]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY, silent=silent)
+
+    @classmethod
+    def create_secret(cls, name: str, value: str):
+        with tempfile.NamedTemporaryFile(delete=False) as tmp:
+            tmp.write(value.encode("UTF-8"))
+        cmd = ["gcloud", "secrets", "create", name,
+               "--replication-policy", "automatic",
+               "--project", GoogleSystemTest._project_id(),
+               "--data-file", tmp.name]
+        cls.execute_with_ctx(cmd, key=GCP_SECRET_MANAGER_KEY)
+        os.remove(tmp.name)

Review comment:
       execite_with_context never fails. But yeah. This way is nicer. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org