-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci_credentials: fix overwriting 'data' before getting nextPageToken #24265
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ Download a Service account json key that has access to Google Secrets Manager. | |
* Click on "ADD KEY -> Create new key" and select JSON. This will download a file on your computer | ||
|
||
### Setup ci_credentials | ||
* In your .zshrc, add: export GCP_GSM_CREDENTIALS=`cat <path to JSON file>` | ||
* In your .zshrc, add: `export GCP_GSM_CREDENTIALS=cat $(<path to JSON file>)` | ||
* Follow README.md under `tools/ci_credentials` | ||
|
||
After making a change, you have to reinstall it to run the bash command: `pip install --quiet -e ./tools/ci_*` | ||
|
@@ -44,12 +44,19 @@ The `VERSION=dev` will make it so it knows to use your local current working dir | |
ci_credentials --help | ||
``` | ||
|
||
### Write to storage | ||
### Write credentials for a specific connector to local storage | ||
To download GSM secrets to `airbyte-integrations/connectors/source-bings-ads/secrets`: | ||
```bash | ||
ci_credentials source-bing-ads write-to-storage | ||
``` | ||
|
||
### Write credentials for all connectors to local storage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👏 |
||
To download GSM secrets to for all available connectors into their respective `secrets` directories: | ||
```bash | ||
ci_credentials all write-to-storage | ||
``` | ||
|
||
|
||
### Update secrets | ||
To upload to GSM newly updated configurations from `airbyte-integrations/connectors/source-bings-ads/secrets/updated_configurations`: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,8 +81,8 @@ def __load_gsm_secrets(self) -> List[RemoteSecret]: | |
if next_token: | ||
params["pageToken"] = next_token | ||
|
||
data = self.api.get(url, params=params) | ||
for secret_info in data.get("secrets") or []: | ||
all_secrets_data = self.api.get(url, params=params) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👏 Nice rename |
||
for secret_info in all_secrets_data.get("secrets") or []: | ||
secret_name = secret_info["name"] | ||
connector_name = secret_info.get("labels", {}).get("connector") | ||
if not connector_name: | ||
|
@@ -103,14 +103,14 @@ def __load_gsm_secrets(self) -> List[RemoteSecret]: | |
self.logger.info(f"found GSM secret: {log_name} = > {filename}") | ||
|
||
versions_url = f"https://secretmanager.googleapis.com/v1/{secret_name}/versions" | ||
data = self.api.get(versions_url) | ||
enabled_versions = [version["name"] for version in data["versions"] if version["state"] == "ENABLED"] | ||
versions_data = self.api.get(versions_url) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Dreaming) If only python had an immutable variable feature There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lol, too spoiled by java's pickiness! |
||
enabled_versions = [version["name"] for version in versions_data["versions"] if version["state"] == "ENABLED"] | ||
if len(enabled_versions) > 1: | ||
self.logger.critical(f"{log_name} should have one enabled version at the same time!!!") | ||
enabled_version = enabled_versions[0] | ||
secret_url = f"https://secretmanager.googleapis.com/v1/{enabled_version}:access" | ||
data = self.api.get(secret_url) | ||
secret_value = data.get("payload", {}).get("data") | ||
secret_data = self.api.get(secret_url) | ||
secret_value = secret_data.get("payload", {}).get("data") | ||
if not secret_value: | ||
self.logger.warning(f"{log_name} has empty value") | ||
continue | ||
|
@@ -126,7 +126,7 @@ def __load_gsm_secrets(self) -> List[RemoteSecret]: | |
remote_secret = RemoteSecret(connector_name, filename, secret_value, enabled_version) | ||
secrets.append(remote_secret) | ||
|
||
next_token = data.get("nextPageToken") | ||
next_token = all_secrets_data.get("nextPageToken") | ||
if not next_token: | ||
break | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏