@@ -132,8 +132,7 @@ def fetch(
132132 )
133133 # Fetch and write secrets
134134 secret_count = 0
135- failed_secrets = []
136- failed_secret_urls = []
135+ failed_secrets : List [str ] = []
137136
138137 for secret in secrets :
139138 secret_file_path = _get_secret_filepath (
@@ -149,8 +148,6 @@ def fetch(
149148 if error :
150149 secret_name = secret .name .split ("/secrets/" )[- 1 ] # Removes project prefix
151150 failed_secrets .append (secret_name )
152- secret_url = f"https://console.cloud.google.com/security/secret-manager/secret/{ secret_name } /versions?hl=en&project={ gcp_project_id } "
153- failed_secret_urls .append (secret_url )
154151 click .echo (f"Failed to retrieve secret '{ secret_name } ': { error } " , err = True )
155152 else :
156153 click .echo (f"Secret written to: { secret_file_path .absolute ()!s} " , err = True )
@@ -175,7 +172,7 @@ def fetch(
175172 raise ConnectorSecretWithNoValidVersionsError (
176173 connector_name = connector_name ,
177174 secret_names = failed_secrets ,
178- connector_secret_urls = failed_secret_urls ,
175+ gcp_project_id = gcp_project_id ,
179176 )
180177
181178 if not print_ci_secrets_masks :
@@ -259,8 +256,7 @@ def list_(
259256 for secret in secrets :
260257 full_secret_name = secret .name
261258 secret_name = full_secret_name .split ("/secrets/" )[- 1 ] # Removes project prefix
262- # E.g. https://console.cloud.google.com/security/secret-manager/secret/SECRET_SOURCE-SHOPIFY__CREDS/versions?hl=en&project=<gcp_project_id>
263- secret_url = f"https://console.cloud.google.com/security/secret-manager/secret/{ secret_name } /versions?hl=en&project={ gcp_project_id } "
259+ secret_url = _get_secret_url (secret_name , gcp_project_id )
264260 table .add_row (
265261 f"[link={ secret_url } ]{ secret_name } [/link]" ,
266262 "\n " .join ([f"{ k } ={ v } " for k , v in secret .labels .items ()]),
@@ -270,6 +266,19 @@ def list_(
270266 console .print (table )
271267
272268
269+ def _get_secret_url (secret_name : str , gcp_project_id : str ) -> str :
270+ """Generate a URL for a secret in the GCP Secret Manager console.
271+
272+ Args:
273+ secret_name: The name of the secret
274+ gcp_project_id: The GCP project ID
275+
276+ Returns:
277+ str: URL to the secret in the GCP console
278+ """
279+ return f"https://console.cloud.google.com/security/secret-manager/secret/{ secret_name } /versions?hl=en&project={ gcp_project_id } "
280+
281+
273282def _fetch_secret_handles (
274283 connector_name : str ,
275284 gcp_project_id : str = AIRBYTE_INTERNAL_GCP_PROJECT ,
0 commit comments