4949 resolve_connector_name_and_directory ,
5050)
5151
52- AIRBYTE_INTERNAL_GCP_PROJECT = "dataline-integration-testing"
52+ GCP_PROJECT_ID : str = os .environ .get ("GCP_PROJECT_ID" , "" ) or "dataline-integration-testing"
53+ # We put the `or` outside the `get()` because we want the `GCP_PROJECT_ID`
54+ # env var to be ignored if it contains an empty string, such as in CI where the
55+ # workflow might set it to a value that is itself actually missing or unset.
56+ """The GCP project ID to use for fetching integration test secrets."""
57+
5358CONNECTOR_LABEL = "connector"
5459GLOBAL_MASK_KEYS_URL = "https://connectors.airbyte.com/files/registries/v0/specs_secrets_mask.yaml"
5560
@@ -83,8 +88,11 @@ def secrets_cli_group() -> None:
8388@click .option (
8489 "--gcp-project-id" ,
8590 type = str ,
86- default = AIRBYTE_INTERNAL_GCP_PROJECT ,
87- help = f"GCP project ID. Defaults to '{ AIRBYTE_INTERNAL_GCP_PROJECT } '." ,
91+ default = GCP_PROJECT_ID ,
92+ help = (
93+ "GCP project ID for retrieving integration tests credentials. "
94+ "Defaults to the value of the `GCP_PROJECT_ID` environment variable, if set."
95+ ),
8896)
8997@click .option (
9098 "--print-ci-secrets-masks" ,
@@ -95,7 +103,7 @@ def secrets_cli_group() -> None:
95103)
96104def fetch (
97105 connector : str | Path | None = None ,
98- gcp_project_id : str = AIRBYTE_INTERNAL_GCP_PROJECT ,
106+ gcp_project_id : str = GCP_PROJECT_ID ,
99107 print_ci_secrets_masks : bool = False ,
100108) -> None :
101109 """Fetch secrets for a connector from Google Secret Manager.
@@ -192,41 +200,41 @@ def fetch(
192200
193201
194202@secrets_cli_group .command ("list" )
195- @click .option (
196- "--connector-name" ,
203+ @click .argument (
204+ "connector" ,
205+ required = False ,
197206 type = str ,
198- help = "Name of the connector to fetch secrets for. Ignored if --connector-directory is provided." ,
199- )
200- @click .option (
201- "--connector-directory" ,
202- type = click .Path (exists = True , file_okay = False , path_type = Path ),
203- help = "Path to the connector directory." ,
207+ metavar = "[CONNECTOR]" ,
204208)
205209@click .option (
206210 "--gcp-project-id" ,
207211 type = str ,
208- default = AIRBYTE_INTERNAL_GCP_PROJECT ,
209- help = f"GCP project ID. Defaults to '{ AIRBYTE_INTERNAL_GCP_PROJECT } '." ,
212+ default = GCP_PROJECT_ID ,
213+ help = (
214+ "GCP project ID for retrieving integration tests credentials. "
215+ "Defaults to the value of the `GCP_PROJECT_ID` environment variable, if set."
216+ ),
210217)
211218def list_ (
212- connector_name : str | None = None ,
213- connector_directory : Path | None = None ,
214- gcp_project_id : str = AIRBYTE_INTERNAL_GCP_PROJECT ,
219+ connector : str | Path | None = None ,
220+ * ,
221+ gcp_project_id : str = GCP_PROJECT_ID ,
215222) -> None :
216223 """List secrets for a connector from Google Secret Manager.
217224
218225 This command fetches secrets for a connector from Google Secret Manager and prints
219226 them as a table.
220227
228+ [CONNECTOR] can be a connector name (e.g. 'source-pokeapi'), a path to a connector directory, or omitted to use the current working directory.
229+ If a string containing '/' is provided, it is treated as a path. Otherwise, it is treated as a connector name.
230+
221231 If no connector name or directory is provided, we will look within the current working
222232 directory. If the current working directory is not a connector directory (e.g. starting
223233 with 'source-') and no connector name or path is provided, the process will fail.
224234 """
225235 click .echo ("Scanning secrets..." , err = True )
226236
227- connector_name = connector_name or resolve_connector_name (
228- connector_directory = connector_directory or Path ().resolve ().absolute (),
229- )
237+ connector_name , _ = resolve_connector_name_and_directory (connector )
230238 secrets : list [Secret ] = _fetch_secret_handles ( # type: ignore
231239 connector_name = connector_name ,
232240 gcp_project_id = gcp_project_id ,
@@ -303,7 +311,7 @@ def _get_secret_url(secret_name: str, gcp_project_id: str) -> str:
303311
304312def _fetch_secret_handles (
305313 connector_name : str ,
306- gcp_project_id : str = AIRBYTE_INTERNAL_GCP_PROJECT ,
314+ gcp_project_id : str = GCP_PROJECT_ID ,
307315) -> list ["Secret" ]: # type: ignore
308316 """Fetch secrets from Google Secret Manager."""
309317 if not secretmanager :
0 commit comments