Created
July 24, 2023 18:42
-
-
Save rssnyder/31c5eacbf9ed44fa66746a9e1ee90db4 to your computer and use it in GitHub Desktop.
get the latest version of the delegate for your harness account and update the image that the delegate upgrader uses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from requests import get, put | |
if __name__ == "__main__": | |
harness_account_id = "wlgELJ0TTre5aZhzpt8gVA" | |
harness_platform_api_key = "xxxxxxxxxx" | |
custom_delegate_location = "my_docker_repo/harness/delegate" | |
resp = get( | |
f'https://app.harness.io/ng/api/delegate-setup/latest-supported-version?accountIdentifier={harness_account_id}', | |
headers={ | |
'x-api-key': harness_platform_api_key | |
} | |
) | |
resp.raise_for_status() | |
latest = resp.json().get("resource", {}).get("latestSupportedVersion") | |
full_path = f"{custom_delegate_location}:{latest}" | |
print(f"setting to {full_path}") | |
resp = put( | |
f'https://app.harness.io/ng/api/delegate-setup/override-delegate-tag?accountIdentifier={harness_account_id}&delegateTag={full_path}', | |
headers={ | |
'x-api-key': harness_platform_api_key | |
} | |
) | |
resp.raise_for_status() | |
print(resp.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The only permissions needed for the API key used in this script is
delegate: edit
at the account level.