Skip to content

Commit 88cef2c

Browse files
committed
Copy diode target parsing from SDK
1 parent 3d4c27e commit 88cef2c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

netbox_diode_plugin/plugin_config.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@ def _parse_diode_target(target: str) -> tuple[str, str, bool]:
2222
"""Parse the target into authority, path and tls_verify."""
2323
parsed_target = urlparse(target)
2424

25-
if parsed_target.scheme not in ["grpc", "grpcs"]:
26-
raise ValueError("target should start with grpc:// or grpcs://")
25+
if parsed_target.scheme not in ["grpc", "grpcs", "http", "https"]:
26+
raise ValueError("target should start with grpc:// or grpcs:// or http:// or https://")
2727

28-
tls_verify = parsed_target.scheme == "grpcs"
28+
tls_verify = parsed_target.scheme in ["grpcs", "https"]
2929

3030
authority = parsed_target.netloc
3131

32+
if ":" not in authority:
33+
if parsed_target.scheme in ["grpc", "http"]:
34+
authority += ":80"
35+
elif parsed_target.scheme in ["grpcs", "https"]:
36+
authority += ":443"
37+
3238
return authority, parsed_target.path, tls_verify
3339

3440

0 commit comments

Comments
 (0)