-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fix Merging of variables #128
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cec2a89
update code pylint and flake8
sliu008 ab0a0c6
remove print
sliu008 d250120
add harmony deployment
sliu008 ae850b5
update harmony deployment url
sliu008 113bd04
update changelog
sliu008 dee1908
update changelog
sliu008 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import os | ||
import requests | ||
import json | ||
import logging | ||
import argparse | ||
from requests.auth import HTTPBasicAuth | ||
|
||
# Environment variables | ||
ENV = os.getenv('ENV') | ||
CMR_USER = os.getenv('CMR_USER') | ||
CMR_PASS = os.getenv('CMR_PASS') | ||
|
||
def bearer_token() -> str: | ||
tokens = [] | ||
headers = {'Accept': 'application/json'} | ||
url = f"https://{'uat.' if ENV == 'uat' else ''}urs.earthdata.nasa.gov/api/users" | ||
|
||
# First just try to get a token that already exists | ||
try: | ||
resp = requests.get(url + "/tokens", headers=headers, auth=HTTPBasicAuth(CMR_USER, CMR_PASS)) | ||
response_content = json.loads(resp.content) | ||
|
||
for x in response_content: | ||
tokens.append(x['access_token']) | ||
|
||
except Exception: # noqa E722 | ||
logging.warning("Error getting the token - check user name and password", exc_info=True) | ||
|
||
# No tokens exist, try to create one | ||
if not tokens: | ||
try: | ||
resp = requests.post(url + "/token", headers=headers, auth=HTTPBasicAuth(CMR_USER, CMR_PASS)) | ||
response_content = json.loads(resp.content) | ||
tokens.append(response_content['access_token']) | ||
except Exception: # noqa E722 | ||
logging.warning("Error getting the token - check user name and password", exc_info=True) | ||
|
||
# If still no token, then we can't do anything | ||
if not tokens: | ||
raise RuntimeError("Unable to get bearer token from EDL") | ||
|
||
return next(iter(tokens)) | ||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser(description="Update the service image tag.") | ||
parser.add_argument("--tag", help="The new tag version to update.", required=True) | ||
args = parser.parse_args() | ||
|
||
url = f"https://harmony.{'uat.' if ENV == 'uat' else ''}earthdata.nasa.gov/service-image-tag/podaac-concise" | ||
token = bearer_token() | ||
|
||
headers = { | ||
"Authorization": f"Bearer {token}", | ||
"Content-type": "application/json" | ||
} | ||
data = { | ||
"tag": args.tag | ||
} | ||
|
||
response = requests.put(url, headers=headers, json=data) | ||
|
||
print(response.status_code) | ||
try: | ||
print(response.json()) | ||
except json.JSONDecodeError: | ||
print("Response content is not in JSON format") |
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should consider turning this into a github action
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.
I'm unclear why it has to be a Python script specifically. Doesn't seem like anything that can't be done within bash + curl
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.
yea it could be i just wrote it in python