|
23 | 23 |
|
24 | 24 | import rich_click as click |
25 | 25 |
|
26 | | -from airbyte_cdk.test.standard_tests.test_resources import find_connector_root_from_name |
| 26 | +from airbyte_cdk.cli.airbyte_cdk._util import resolve_connector_name_and_directory |
27 | 27 |
|
28 | 28 | AIRBYTE_INTERNAL_GCP_PROJECT = "dataline-integration-testing" |
29 | 29 | CONNECTOR_LABEL = "connector" |
30 | 30 |
|
31 | 31 |
|
32 | | -@click.group(name="secrets") |
| 32 | +@click.group(name="secrets", help=__doc__.replace("\n", "\n\n")) |
33 | 33 | def secrets_cli_group() -> None: |
34 | | - """Secret management commands. |
35 | | -
|
36 | | - This module provides commands for managing secrets for Airbyte connectors. |
37 | | -
|
38 | | - Usage: |
39 | | - airbyte-cdk secrets fetch --connector-name source-github |
40 | | - airbyte-cdk secrets fetch --connector-directory /path/to/connector |
41 | | - airbyte-cdk secrets fetch # Run from within a connector directory |
42 | | -
|
43 | | - Usage without pre-installing (stateless): |
44 | | - pipx run airbyte-cdk[dev] secrets fetch ... |
45 | | - uvx airbyte-cdk[dev] secrets fetch ... |
46 | | -
|
47 | | - The 'fetch' command retrieves secrets from Google Secret Manager based on connector |
48 | | - labels and writes them to the connector's `secrets` directory. |
49 | | - """ |
| 34 | + """Secret management commands.""" |
50 | 35 | pass |
51 | 36 |
|
52 | 37 |
|
@@ -92,33 +77,20 @@ def fetch( |
92 | 77 | click.echo("Fetching secrets...") |
93 | 78 |
|
94 | 79 | # Resolve connector name/directory |
95 | | - if not connector_name and not connector_directory: |
96 | | - cwd = Path().resolve().absolute() |
97 | | - if cwd.name.startswith("source-") or cwd.name.startswith("destination-"): |
98 | | - connector_name = cwd.name |
99 | | - connector_directory = cwd |
100 | | - else: |
101 | | - raise ValueError( |
102 | | - "Either connector_name or connector_directory must be provided if not " |
103 | | - "running from a connector directory." |
104 | | - ) |
105 | | - |
106 | | - if connector_directory: |
107 | | - connector_directory = connector_directory.resolve().absolute() |
108 | | - if not connector_name: |
109 | | - connector_name = connector_directory.name |
110 | | - elif connector_name: |
111 | | - try: |
112 | | - connector_directory = find_connector_root_from_name(connector_name) |
113 | | - except FileNotFoundError as e: |
114 | | - raise FileNotFoundError( |
115 | | - f"Could not find connector directory for '{connector_name}'. " |
116 | | - "Please provide the --connector-directory option with the path to the connector. " |
117 | | - "Note: This command requires either running from within a connector directory, " |
118 | | - "being in the airbyte monorepo, or explicitly providing the connector directory path." |
119 | | - ) from e |
120 | | - else: |
121 | | - raise ValueError("Either connector_name or connector_directory must be provided.") |
| 80 | + try: |
| 81 | + connector_name, connector_directory = resolve_connector_name_and_directory( |
| 82 | + connector_name=connector_name, |
| 83 | + connector_directory=connector_directory, |
| 84 | + ) |
| 85 | + except FileNotFoundError as e: |
| 86 | + raise FileNotFoundError( |
| 87 | + f"Could not find connector directory for '{connector_name}'. " |
| 88 | + "Please provide the --connector-directory option with the path to the connector. " |
| 89 | + "Note: This command requires either running from within a connector directory, " |
| 90 | + "being in the airbyte monorepo, or explicitly providing the connector directory path." |
| 91 | + ) from e |
| 92 | + except ValueError as e: |
| 93 | + raise ValueError(str(e)) |
122 | 94 |
|
123 | 95 | # Create secrets directory if it doesn't exist |
124 | 96 | secrets_dir = connector_directory / "secrets" |
|
0 commit comments