def execute_with_ctx(cmd: List[str], key: str = GCP_GCS_KEY): """ Executes command with context created by provide_gcp_context and activated service key. """ executor = get_executor() with provide_gcp_context(key), GoogleSystemTest.authentication(): env = os.environ.copy() executor.execute_cmd(cmd=cmd, env=env)
def _authenticate(): """ Authenticate with service account specified via key name. Required only when we use gcloud / gsutil. """ executor = get_executor() executor.execute_cmd([ "gcloud", "auth", "activate-service-account", f"--key-file={GoogleSystemTest._service_key()}", f"--project={GoogleSystemTest._project_id()}", ])
def _revoke_authentication(): """ Change default authentication to none - which is not existing one. """ executor = get_executor() executor.execute_cmd([ "gcloud", "config", "set", "account", "none", f"--project={GoogleSystemTest._project_id()}", ])
def execute_cmd(*args, **kwargs): executor = get_executor() return executor.execute_cmd(*args, **kwargs)