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:
[email protected]