Skip to content

Commit 504d286

Browse files
committed
drive-by-fix: CI should always print secret masks unless we ask not to
1 parent 434af51 commit 504d286

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

airbyte_cdk/cli/airbyte_cdk/_secrets.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ def secrets_cli_group() -> None:
9999
help="Print GitHub CI mask for secrets.",
100100
type=bool,
101101
is_flag=True,
102-
default=False,
102+
default=None,
103103
)
104104
def fetch(
105105
connector: str | Path | None = None,
106106
gcp_project_id: str = GCP_PROJECT_ID,
107-
print_ci_secrets_masks: bool = False,
107+
print_ci_secrets_masks: bool | None = None,
108108
) -> None:
109109
"""Fetch secrets for a connector from Google Secret Manager.
110110
@@ -181,22 +181,23 @@ def fetch(
181181
if secret_count == 0:
182182
raise exceptions[0]
183183

184-
if not print_ci_secrets_masks:
185-
return
186-
187-
if not os.environ.get("CI", None):
184+
if print_ci_secrets_masks and "CI" not in os.environ:
188185
click.echo(
189186
"The `--print-ci-secrets-masks` option is only available in CI environments. "
190187
"The `CI` env var is either not set or not set to a truthy value. "
191188
"Skipping printing secret masks.",
192189
err=True,
193190
)
194-
return
195-
196-
# Else print the CI mask
197-
_print_ci_secrets_masks(
198-
secrets_dir=secrets_dir,
199-
)
191+
print_ci_secrets_masks = False
192+
elif print_ci_secrets_masks is None:
193+
# If not explicitly set, we check if we are in a CI environment
194+
# and set to True if so.
195+
print_ci_secrets_masks = os.environ.get("CI", "") != ""
196+
197+
if print_ci_secrets_masks:
198+
_print_ci_secrets_masks(
199+
secrets_dir=secrets_dir,
200+
)
200201

201202

202203
@secrets_cli_group.command("list")

0 commit comments

Comments
 (0)