Skip to content

Instantly share code, notes, and snippets.

@rssnyder
Created July 24, 2023 18:42
Show Gist options
  • Save rssnyder/31c5eacbf9ed44fa66746a9e1ee90db4 to your computer and use it in GitHub Desktop.
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
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)
@rssnyder
Copy link
Author

The only permissions needed for the API key used in this script is delegate: edit at the account level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment