-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add check-local-portal-creds #244
Open
netsettler
wants to merge
4
commits into
master
Choose a base branch
from
kmp_misc_20230214
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
74deabd
Some small updates to Makefile, and a new check-local-portal-creds co…
netsettler de10c89
Fix problem cited in code review. Re-implement using more data-driven…
netsettler b1c291d
A bit more aesthetic refactoring.
netsettler 98bf458
Merge branch 'master' into kmp_misc_20230214
netsettler 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "dcicsnovault" | ||
version = "7.1.3" | ||
version = "7.2.0" | ||
description = "Storage support for 4DN Data Portals." | ||
authors = ["4DN-DCIC Team <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -144,6 +144,7 @@ PyYAML = ">=5.1,<5.5" | |
wheel = ">=0.29.0" | ||
|
||
[tool.poetry.scripts] | ||
check-local-portal-creds = "snovault.commands.check_local_portal_creds:main" | ||
wipe-test-indices = "snovault.commands.wipe_test_indices:main" | ||
|
||
[build-system] | ||
|
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,78 @@ | ||
import os | ||
import argparse | ||
|
||
from dcicutils.misc_utils import PRINT | ||
from dcicutils.command_utils import script_catch_errors | ||
|
||
|
||
REPO_NAME = os.path.basename(os.path.abspath(os.curdir)) | ||
|
||
|
||
def check_local_creds(appname): | ||
|
||
if not appname: | ||
if 'cgap' in REPO_NAME: | ||
appname = 'cgap' | ||
elif 'ff' in REPO_NAME or 'ffourfront' in REPO_NAME: | ||
appname = 'fourfront' | ||
else: | ||
PRINT("Can't figure out if this is cgap or fourfront.") | ||
exit(1) | ||
|
||
class WarningMaker: | ||
|
||
count = 0 | ||
|
||
@classmethod | ||
def warn(cls, *args, **kwargs): | ||
cls.count += 1 | ||
return PRINT(*args, **kwargs) | ||
|
||
warn = WarningMaker.warn | ||
|
||
if appname not in ['fourfront', 'ff', 'cgap']: | ||
raise RuntimeError(f"Unknown appname {appname!r}. Expected 'cgap' or 'fourfront' (or 'ff').") | ||
|
||
global_env_bucket = os.environ.get('GLOBAL_ENV_BUCKET') | ||
cgap_env_bucket = 'cgap-devtest-main-foursight-envs' | ||
fourfront_env_bucket = 'foursight-prod-envs' | ||
|
||
def check_global_env_bucket(var, val): | ||
if appname == 'cgap' and val != cgap_env_bucket: | ||
warn(f"{var} is {val!r}, but should be {cgap_env_bucket}.") | ||
elif appname == 'fourfront' and val != fourfront_env_bucket: | ||
warn(f"{var} is {val!r}, but should be {fourfront_env_bucket}.") | ||
|
||
check_global_env_bucket('GLOBAL_ENV_BUCKET', global_env_bucket) | ||
global_bucket_env = os.environ.get('GLOBAL_BUCKET_ENV') | ||
if global_bucket_env: | ||
if global_bucket_env == global_env_bucket: | ||
warn("GLOBAL_BUCKET_ENV is the same as GLOBAL_ENV_BUCKET," | ||
" but you can just get rid of GLOBAL_BUCKET_ENV now.") | ||
elif not global_env_bucket: | ||
warn("You need to set GLOBAL_ENV_BUCKET, not GLOBAL_BUCKET_ENV.") | ||
check_global_env_bucket('GLOBAL_BUCKET_ENV', global_bucket_env) | ||
for var in ['CHECK_RUNNER', 'ACCOUNT_NUMBER', 'ENV_NAME']: | ||
if os.environ.get(var): | ||
warn(f"The variable {var} has a non-null value but should be unset.") | ||
for var in ['Auth0Client', 'Auth0Secret']: | ||
if not os.environ.get(var): | ||
warn(f"The variable {var} has no value but should be set.") | ||
if WarningMaker.count == 0: | ||
PRINT("Things look good.") | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description='Echos version information from ~/.cgap-keys.json or override file.') | ||
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. This description seems lifted from somewhere else |
||
parser.add_argument('--appname', help='Name of app to check for (cgap or ff/fourfront)', type=str, default=None) | ||
args = parser.parse_args() | ||
|
||
appname = args.appname | ||
|
||
with script_catch_errors(): | ||
check_local_creds(appname=appname) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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.
Do you mean 'fourfront' not 'ffourfront'?
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.
Yep. Thanks for spotting that.
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.
@dmichaels-harvard, I re-implemented some details of this PR in a more data-driven style to make it harder for such typos to creep in. The whole thing was too dependent on incidental string constants. See commit de10c89 for details.
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.
OK and commit b1c291d adds a bit more change.