Skip to content

Commit 9b38d6f

Browse files
authored
🚚 release (#59)
2 parents 92130dd + b342971 commit 9b38d6f

File tree

7 files changed

+1928
-425
lines changed

7 files changed

+1928
-425
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @jajeffries @leoparente @ltucker @mfiedorowicz
1+
* @jajeffries @leoparente @ltucker @mfiedorowicz @MicahParks

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ pip install netboxlabs-diode-sdk
2828

2929
### Example
3030

31-
* `target` should be the address of the Diode service, e.g. `grpc://localhost:8080/diode` for insecure connection
32-
or `grpcs://example.com` for secure connection.
31+
* `target` should be the address of the Diode service.
32+
* Insecure connections: `grpc://localhost:8080/diode` or `http://localhost:8080/diode`
33+
* Secure connections: `grpcs://example.com` or `https://example.com`
3334

3435
```python
3536
from netboxlabs.diode.sdk import DiodeClient

netboxlabs/diode/sdk/client.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,18 @@ def parse_target(target: str) -> tuple[str, str, bool]:
6363
"""Parse the target into authority, path and tls_verify."""
6464
parsed_target = urlparse(target)
6565

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

69-
tls_verify = parsed_target.scheme == "grpcs"
69+
tls_verify = parsed_target.scheme in ["grpcs", "https"]
7070

7171
authority = parsed_target.netloc
7272

7373
if ":" not in authority:
74-
authority += ":443"
74+
if parsed_target.scheme in ["grpc", "http"]:
75+
authority += ":80"
76+
elif parsed_target.scheme in ["grpcs", "https"]:
77+
authority += ":443"
7578

7679
return authority, parsed_target.path, tls_verify
7780

netboxlabs/diode/sdk/diode/v1/ingester_pb2.py

Lines changed: 407 additions & 357 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netboxlabs/diode/sdk/diode/v1/ingester_pb2.pyi

Lines changed: 646 additions & 48 deletions
Large diffs are not rendered by default.

netboxlabs/diode/sdk/ingester.py

Lines changed: 849 additions & 3 deletions
Large diffs are not rendered by default.

tests/test_client.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,10 @@ def test_load_certs_returns_bytes():
104104
assert isinstance(_load_certs(), bytes)
105105

106106

107-
def test_parse_target_handles_http_prefix():
108-
"""Check that parse_target raises an error when the target contains http://."""
107+
def test_parse_target_handles_ftp_prefix():
108+
"""Check that parse_target raises an error when the target contains ftp://."""
109109
with pytest.raises(ValueError):
110-
parse_target("http://localhost:8081")
111-
112-
113-
def test_parse_target_handles_https_prefix():
114-
"""Check that parse_target raises an error when the target contains https://."""
115-
with pytest.raises(ValueError):
116-
parse_target("https://localhost:8081")
117-
110+
parse_target("ftp://localhost:8081")
118111

119112
def test_parse_target_parses_authority_correctly():
120113
"""Check that parse_target parses the authority correctly."""
@@ -127,6 +120,12 @@ def test_parse_target_parses_authority_correctly():
127120
def test_parse_target_adds_default_port_if_missing():
128121
"""Check that parse_target adds the default port if missing."""
129122
authority, _, _ = parse_target("grpc://localhost")
123+
assert authority == "localhost:80"
124+
authority, _, _ = parse_target("http://localhost")
125+
assert authority == "localhost:80"
126+
authority, _, _ = parse_target("grpcs://localhost")
127+
assert authority == "localhost:443"
128+
authority, _, _ = parse_target("https://localhost")
130129
assert authority == "localhost:443"
131130

132131

@@ -144,8 +143,14 @@ def test_parse_target_handles_no_path():
144143

145144
def test_parse_target_parses_tls_verify_correctly():
146145
"""Check that parse_target parses tls_verify correctly."""
146+
_, _, tls_verify = parse_target("grpc://localhost:8081")
147+
assert tls_verify is False
148+
_, _, tls_verify = parse_target("http://localhost:8081")
149+
assert tls_verify is False
147150
_, _, tls_verify = parse_target("grpcs://localhost:8081")
148151
assert tls_verify is True
152+
_, _, tls_verify = parse_target("https://localhost:8081")
153+
assert tls_verify is True
149154

150155

151156
def test_get_sentry_dsn_returns_env_var_when_no_input():

0 commit comments

Comments
 (0)