Skip to content

Commit

Permalink
Replacing envvar by CONF.get()
Browse files Browse the repository at this point in the history
  • Loading branch information
tdviet committed Nov 5, 2023
1 parent a1f9038 commit 4696394
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
3 changes: 3 additions & 0 deletions fedcloudclient/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"oidc_agent_account": "egi",
"min_access_token_time": 30,
"mytoken_server": "https://mytoken.data.kit.edu",
"os_protocol": "openid",
"os_auth_type": "v3oidcaccesstoken",
"os_identity_provider": "egi.eu",
}


Expand Down
44 changes: 18 additions & 26 deletions fedcloudclient/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,18 @@
optgroup,
)

from fedcloudclient.conf import CONF
from fedcloudclient.exception import TokenError
from fedcloudclient.locker_auth import LockerToken
from fedcloudclient.vault_auth import VaultToken

DEFAULT_MYTOKEN_SERVER = "https://mytoken.data.kit.edu"
DEFAULT_PROTOCOL = "openid"
DEFAULT_AUTH_TYPE = "v3oidcaccesstoken"
DEFAULT_IDENTITY_PROVIDER = "egi.eu"

ALL_SITES_KEYWORDS = {"ALL_SITES", "ALL-SITES"}

# Decorator for --oidc-access-token
oidc_access_token_params = click.option(
"--oidc-access-token",
help="OIDC access token",
envvar="OIDC_ACCESS_TOKEN",
default=CONF.get("oidc_access_token"),
metavar="token",
)

Expand All @@ -34,7 +30,7 @@
"--site",
help="Name of the site",
required=True,
envvar="EGI_SITE",
default=CONF.get("site"),
metavar="site-name",
)

Expand All @@ -61,7 +57,7 @@ def all_site_params(func):
@optgroup.option(
"--site",
help="Name of the site or ALL_SITES",
envvar="EGI_SITE",
default=CONF.get("site"),
metavar="site-name",
)
@optgroup.option(
Expand All @@ -82,7 +78,7 @@ def wrapper(*args, **kwargs):
"--project-id",
help="Project ID",
required=True,
envvar="OS_PROJECT_ID",
default=CONF.get("project_id"),
metavar="project-id",
)

Expand All @@ -100,7 +96,7 @@ def wrapper(*args, **kwargs):
"--vo",
help="Name of the VO",
required=True,
envvar="EGI_VO",
default=CONF.get("vo"),
metavar="vo-name",
)

Expand Down Expand Up @@ -129,26 +125,25 @@ def oidc_params(func):
@optgroup.option(
"--oidc-agent-account",
help="Account name in oidc-agent",
envvar="OIDC_AGENT_ACCOUNT",
default=CONF.get("oidc_agent_account"),
metavar="account",
)
@optgroup.option(
"--oidc-access-token",
help="OIDC access token",
envvar="OIDC_ACCESS_TOKEN",
default=CONF.get("oidc_access_token"),
metavar="token",
)
@optgroup.option(
"--mytoken",
help="Mytoken string",
envvar="FEDCLOUD_MYTOKEN",
default=CONF.get("mytoken"),
metavar="mytoken",
)
@optgroup.option(
"--mytoken-server",
help="Mytoken sever",
envvar="FEDCLOUD_MYTOKEN_SERVER",
default=DEFAULT_MYTOKEN_SERVER,
default=CONF.get("mytoken_server"),
metavar="url",
)
@wraps(func)
Expand Down Expand Up @@ -179,24 +174,21 @@ def openstack_params(func):
@optgroup.option(
"--openstack-auth-protocol",
help="Authentication protocol",
envvar="OPENSTACK_AUTH_PROTOCOL",
default=DEFAULT_PROTOCOL,
default=CONF.get("os_protocol"),
show_default=True,
metavar="",
)
@optgroup.option(
"--openstack-auth-provider",
help="Identity provider",
envvar="OPENSTACK_AUTH_PROVIDER",
default=DEFAULT_IDENTITY_PROVIDER,
default=CONF.get("os_identity_provider"),
show_default=True,
metavar="",
)
@optgroup.option(
"--openstack-auth-type",
help="Authentication type",
envvar="OPENSTACK_AUTH_TYPE",
default=DEFAULT_AUTH_TYPE,
default=CONF.get("os_auth_type"),
show_default=True,
metavar="",
)
Expand Down Expand Up @@ -357,31 +349,31 @@ def secret_token_params(func):
@optgroup.option(
"--locker-token",
help="Locker token",
envvar="FEDCLOUD_LOCKER_TOKEN",
edefault=CONF.get("locker_token"),
metavar="locker_token",
)
@optgroup.option(
"--vault-token",
help="Vault token",
envvar="FEDCLOUD_VAULT_TOKEN",
default=CONF.get("vault_token"),
metavar="vault_token",
)
@optgroup.option(
"--oidc-agent-account",
help="Account name in oidc-agent",
envvar="OIDC_AGENT_ACCOUNT",
default=CONF.get("oidc_agent_account"),
metavar="account",
)
@optgroup.option(
"--oidc-access-token",
help="OIDC access token",
envvar="OIDC_ACCESS_TOKEN",
default=CONF.get("oidc_access_token"),
metavar="token",
)
@optgroup.option(
"--mytoken",
help="Mytoken string",
envvar="FEDCLOUD_MYTOKEN",
default=CONF.get("mytoken"),
metavar="mytoken",
)
@wraps(func)
Expand Down

0 comments on commit 4696394

Please sign in to comment.