-
Notifications
You must be signed in to change notification settings - Fork 304
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 a dogshell option to change Datadog site to call API #691
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,14 @@ def main(): | |
"-v", "--version", help="Dog API version", action="version", version="%(prog)s {0}".format(__version__) | ||
) | ||
|
||
parser.add_argument( | ||
"--site", | ||
help="Datadog site to send data, us (datadoghq.com), eu (datadoghq.eu) or us3 (us3.datadoghq.com), default: us", | ||
dest="site", | ||
default=os.environ.get("DD_SITE", os.environ.get("DATADOG_HOST")), | ||
choices=["datadoghq.com", "us", "datadoghq.eu", "eu", "us3.datadoghq.com", "us3"], | ||
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. Are you sure we want support 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. I thought we can be aligned with https://github.com/DataDog/datadogpy/blob/master/datadog/dogshell/wrap.py#L289 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. OK fair enough. 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. Thanks I will leave it. |
||
) | ||
|
||
config = DogshellConfig() | ||
|
||
# Set up subparsers for each service | ||
|
@@ -93,7 +101,8 @@ def main(): | |
ServiceLevelObjectiveClient.setup_parser(subparsers) | ||
|
||
args = parser.parse_args() | ||
config.load(args.config, args.api_key, args.app_key) | ||
|
||
config.load(args.config, args.api_key, args.app_key, args.site) | ||
|
||
# Initialize datadog.api package | ||
initialize(**config) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,16 @@ def report_warnings(res): | |
|
||
|
||
class DogshellConfig(IterableUserDict): | ||
def load(self, config_file, api_key, app_key): | ||
def load(self, config_file, api_key, app_key, site): | ||
config = configparser.ConfigParser() | ||
|
||
if site is not None: | ||
if site in ("us" or "datadoghq.com"): | ||
self["api_host"] = "https://datadoghq.com" | ||
elif site in ("datadoghq.eu", "eu"): | ||
self["api_host"] = "https://datadoghq.eu" | ||
elif site in ("us3.datadoghq.com", "us3"): | ||
self["api_host"] = "https://us3.datadoghq.com" | ||
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. We should probably raise an error if the value doesn't match. 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. Error is thrown by Is it cool? |
||
|
||
if api_key is not None and app_key is not None: | ||
self["api_key"] = api_key | ||
|
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.
Site and host have different semantic, I don't think we should use the same env var for this.
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 see, I will change it to
api_host