@@ -73,15 +73,11 @@ def secrets_cli_group() -> None:
7373
7474
7575@secrets_cli_group .command ()
76- @click .option (
77- "--connector-name" ,
76+ @click .argument (
77+ "connector" ,
78+ required = False ,
7879 type = str ,
79- help = "Name of the connector to fetch secrets for. Ignored if --connector-directory is provided." ,
80- )
81- @click .option (
82- "--connector-directory" ,
83- type = click .Path (exists = True , file_okay = False , path_type = Path ),
84- help = "Path to the connector directory." ,
80+ metavar = "[CONNECTOR]" ,
8581)
8682@click .option (
8783 "--gcp-project-id" ,
@@ -97,8 +93,7 @@ def secrets_cli_group() -> None:
9793 default = False ,
9894)
9995def fetch (
100- connector_name : str | None = None ,
101- connector_directory : Path | None = None ,
96+ connector : str | Path | None = None ,
10297 gcp_project_id : str = AIRBYTE_INTERNAL_GCP_PROJECT ,
10398 print_ci_secrets_masks : bool = False ,
10499) -> None :
@@ -107,24 +102,24 @@ def fetch(
107102 This command fetches secrets for a connector from Google Secret Manager and writes them
108103 to the connector's secrets directory.
109104
105+ [CONNECTOR] can be a connector name (e.g. 'source-pokeapi'), a path to a connector directory, or omitted to use the current working directory.
106+ If a string containing '/' is provided, it is treated as a path. Otherwise, it is treated as a connector name.
107+
110108 If no connector name or directory is provided, we will look within the current working
111109 directory. If the current working directory is not a connector directory (e.g. starting
112110 with 'source-') and no connector name or path is provided, the process will fail.
113111
114112 The `--print-ci-secrets-masks` option will print the GitHub CI mask for the secrets.
115113 This is useful for masking secrets in CI logs.
116114
117- WARNING: This action causes the secrets to be printed in clear text to `STDOUT`. For security
118- reasons, this function will only execute if the `CI` environment variable is set. Otherwise,
119- masks will not be printed .
115+ WARNING: The `--print-ci-secrets-masks` option causes the secrets to be printed in clear text to
116+ `STDOUT`. For security reasons, this argument will be ignored if the `CI` environment
117+ variable is not set .
120118 """
121119 click .echo ("Fetching secrets..." , err = True )
122120
123121 client = _get_gsm_secrets_client ()
124- connector_name , connector_directory = resolve_connector_name_and_directory (
125- connector_name = connector_name ,
126- connector_directory = connector_directory ,
127- )
122+ connector_name , connector_directory = resolve_connector_name_and_directory (connector )
128123 secrets_dir = _get_secrets_dir (
129124 connector_directory = connector_directory ,
130125 connector_name = connector_name ,
@@ -289,21 +284,7 @@ def _get_secrets_dir(
289284 connector_name : str ,
290285 ensure_exists : bool = True ,
291286) -> Path :
292- try :
293- connector_name , connector_directory = resolve_connector_name_and_directory (
294- connector_name = connector_name ,
295- connector_directory = connector_directory ,
296- )
297- except FileNotFoundError as e :
298- raise FileNotFoundError (
299- f"Could not find connector directory for '{ connector_name } '. "
300- "Please provide the --connector-directory option with the path to the connector. "
301- "Note: This command requires either running from within a connector directory, "
302- "being in the airbyte monorepo, or explicitly providing the connector directory path."
303- ) from e
304- except ValueError as e :
305- raise ValueError (str (e ))
306-
287+ _ = connector_name # Unused, but it may be used in the future for logging
307288 secrets_dir = connector_directory / "secrets"
308289 if ensure_exists :
309290 secrets_dir .mkdir (parents = True , exist_ok = True )
0 commit comments