-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflags.py
More file actions
97 lines (79 loc) · 2.47 KB
/
flags.py
File metadata and controls
97 lines (79 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""Flags used across the Opal ADK."""
from typing import NewType
from absl import flags
ServiceAccount = NewType("ServiceAccount", str)
ProjectId = NewType("ProjectId", str)
Location = NewType("Location", str)
MapsAPIKey = NewType("MapsAPIKey", str)
_OPAL_ADK_GCP_SERVICE_ACCOUNT = flags.DEFINE_string(
"opal_adk_gcp_service_account",
required=False,
default=None,
help="GCP service account to use for Opal ADK.",
)
_OPAL_ADK_GCP_LOCATION = flags.DEFINE_string(
"opal_adk_gcp_location",
required=False,
default=None,
help="GCP location for Opal ADK resources.",
)
_OPAL_ADK_GCP_PROJECT_ID = flags.DEFINE_string(
"opal_adk_gcp_project_id",
required=False,
default=None,
help="GCP project ID for Opal ADK.",
)
_OPAL_ADK_MAPS_API_KEY = flags.DEFINE_string(
"opal_adk_maps_api_key",
required=False,
default=None,
help="API key for using the Google Maps API.",
)
_OPAL_ADK_DEBUG_LOGGING = flags.DEFINE_bool(
"opal_adk_debug_logging",
required=False,
default=False,
help=(
"True if debug logging should be enabled, this will print out fine"
" grained ADK logs."
),
)
_OPAL_ADK_ENVIRONMENT = flags.DEFINE_string(
"opal_adk_environment",
required=False,
default="dev",
help=(
"The current environment running Opal ADK. This should be dev,"
" autopush,staging or prod."
),
)
def get_service_account() -> ServiceAccount:
try:
return ServiceAccount(_OPAL_ADK_GCP_SERVICE_ACCOUNT.value)
except flags.UnparsedFlagAccessError:
return ServiceAccount(_OPAL_ADK_GCP_SERVICE_ACCOUNT.default)
def get_location() -> Location:
try:
return Location(_OPAL_ADK_GCP_LOCATION.value)
except flags.UnparsedFlagAccessError:
return Location(_OPAL_ADK_GCP_LOCATION.default)
def get_project_id() -> ProjectId:
try:
return ProjectId(_OPAL_ADK_GCP_PROJECT_ID.value)
except flags.UnparsedFlagAccessError:
return ProjectId(_OPAL_ADK_GCP_PROJECT_ID.default)
def get_maps_api_key() -> MapsAPIKey:
try:
return MapsAPIKey(_OPAL_ADK_MAPS_API_KEY.value)
except flags.UnparsedFlagAccessError:
return MapsAPIKey(_OPAL_ADK_MAPS_API_KEY.default)
def get_debug_logging() -> bool:
try:
return _OPAL_ADK_DEBUG_LOGGING.value
except flags.UnparsedFlagAccessError:
return _OPAL_ADK_DEBUG_LOGGING.default
def get_opal_adk_environment() -> str:
try:
return _OPAL_ADK_ENVIRONMENT.value
except flags.UnparsedFlagAccessError:
return _OPAL_ADK_ENVIRONMENT.default