sentry-options 0.0.6__tar.gz → 0.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sentry_options-0.0.6 → sentry_options-0.0.7}/Cargo.lock +5 -5
- {sentry_options-0.0.6 → sentry_options-0.0.7}/Cargo.toml +2 -2
- {sentry_options-0.0.6 → sentry_options-0.0.7}/PKG-INFO +1 -1
- {sentry_options-0.0.6 → sentry_options-0.0.7}/clients/python/tests/options_test.py +8 -8
- {sentry_options-0.0.6 → sentry_options-0.0.7}/clients/rust/src/lib.rs +1 -1
- {sentry_options-0.0.6 → sentry_options-0.0.7}/pyproject.toml +1 -1
- {sentry_options-0.0.6 → sentry_options-0.0.7}/sentry-options-validation/src/lib.rs +38 -15
- {sentry_options-0.0.6 → sentry_options-0.0.7}/clients/python/Cargo.toml +0 -0
- {sentry_options-0.0.6 → sentry_options-0.0.7}/clients/python/src/lib.rs +0 -0
- {sentry_options-0.0.6 → sentry_options-0.0.7}/clients/python/uv.lock +0 -0
- {sentry_options-0.0.6 → sentry_options-0.0.7}/clients/rust/Cargo.toml +0 -0
- {sentry_options-0.0.6 → sentry_options-0.0.7}/sentry-options-validation/Cargo.toml +0 -0
- {sentry_options-0.0.6 → sentry_options-0.0.7}/sentry-options-validation/src/namespace-schema.json +0 -0
|
@@ -276,7 +276,7 @@ dependencies = [
|
|
|
276
276
|
|
|
277
277
|
[[package]]
|
|
278
278
|
name = "example"
|
|
279
|
-
version = "0.0.
|
|
279
|
+
version = "0.0.7"
|
|
280
280
|
dependencies = [
|
|
281
281
|
"anyhow",
|
|
282
282
|
"sentry-options",
|
|
@@ -1177,7 +1177,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|
|
1177
1177
|
|
|
1178
1178
|
[[package]]
|
|
1179
1179
|
name = "sentry-options"
|
|
1180
|
-
version = "0.0.
|
|
1180
|
+
version = "0.0.7"
|
|
1181
1181
|
dependencies = [
|
|
1182
1182
|
"sentry-options-validation",
|
|
1183
1183
|
"serde_json",
|
|
@@ -1187,7 +1187,7 @@ dependencies = [
|
|
|
1187
1187
|
|
|
1188
1188
|
[[package]]
|
|
1189
1189
|
name = "sentry-options-cli"
|
|
1190
|
-
version = "0.0.
|
|
1190
|
+
version = "0.0.7"
|
|
1191
1191
|
dependencies = [
|
|
1192
1192
|
"chrono",
|
|
1193
1193
|
"clap",
|
|
@@ -1202,7 +1202,7 @@ dependencies = [
|
|
|
1202
1202
|
|
|
1203
1203
|
[[package]]
|
|
1204
1204
|
name = "sentry-options-python"
|
|
1205
|
-
version = "0.0.
|
|
1205
|
+
version = "0.0.7"
|
|
1206
1206
|
dependencies = [
|
|
1207
1207
|
"pyo3",
|
|
1208
1208
|
"sentry-options",
|
|
@@ -1211,7 +1211,7 @@ dependencies = [
|
|
|
1211
1211
|
|
|
1212
1212
|
[[package]]
|
|
1213
1213
|
name = "sentry-options-validation"
|
|
1214
|
-
version = "0.0.
|
|
1214
|
+
version = "0.0.7"
|
|
1215
1215
|
dependencies = [
|
|
1216
1216
|
"anyhow",
|
|
1217
1217
|
"jsonschema",
|
|
@@ -11,13 +11,13 @@ default-members = [
|
|
|
11
11
|
]
|
|
12
12
|
|
|
13
13
|
[workspace.package]
|
|
14
|
-
version = "0.0.
|
|
14
|
+
version = "0.0.7"
|
|
15
15
|
edition = "2024"
|
|
16
16
|
repository = "https://github.com/getsentry/sentry-options"
|
|
17
17
|
license = "Apache-2.0"
|
|
18
18
|
|
|
19
19
|
[workspace.dependencies]
|
|
20
|
-
sentry-options-validation = { path = "sentry-options-validation", version = "0.0.
|
|
20
|
+
sentry-options-validation = { path = "sentry-options-validation", version = "0.0.7" }
|
|
21
21
|
serde = { version = "1.0", features = ["derive"] }
|
|
22
22
|
serde_json = "1.0.145"
|
|
23
23
|
anyhow = "1.0.100"
|
|
@@ -19,7 +19,7 @@ def init_options(tmp_path_factory: pytest.TempPathFactory) -> None:
|
|
|
19
19
|
tmpdir = tmp_path_factory.mktemp('sentry_options')
|
|
20
20
|
|
|
21
21
|
# Create schema
|
|
22
|
-
schema_dir = tmpdir / 'schemas' / 'testing'
|
|
22
|
+
schema_dir = tmpdir / 'schemas' / 'sentry-options-testing'
|
|
23
23
|
schema_dir.mkdir(parents=True)
|
|
24
24
|
(schema_dir / 'schema.json').write_text(
|
|
25
25
|
json.dumps(
|
|
@@ -53,9 +53,9 @@ def init_options(tmp_path_factory: pytest.TempPathFactory) -> None:
|
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
# Create values (override str-opt)
|
|
56
|
-
values_dir = tmpdir / 'values' / 'testing'
|
|
56
|
+
values_dir = tmpdir / 'values' / 'sentry-options-testing'
|
|
57
57
|
values_dir.mkdir(parents=True)
|
|
58
|
-
values = {'str-opt': 'custom-value'}
|
|
58
|
+
values = {'options': {'str-opt': 'custom-value'}}
|
|
59
59
|
(values_dir / 'values.json').write_text(json.dumps(values))
|
|
60
60
|
|
|
61
61
|
# Set env var and initialize
|
|
@@ -74,25 +74,25 @@ def init_options(tmp_path_factory: pytest.TempPathFactory) -> None:
|
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
def test_get_string_from_values() -> None:
|
|
77
|
-
value = options('testing').get('str-opt')
|
|
77
|
+
value = options('sentry-options-testing').get('str-opt')
|
|
78
78
|
assert value == 'custom-value'
|
|
79
79
|
assert isinstance(value, str)
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
def test_get_int_default() -> None:
|
|
83
|
-
value = options('testing').get('int-opt')
|
|
83
|
+
value = options('sentry-options-testing').get('int-opt')
|
|
84
84
|
assert value == 42
|
|
85
85
|
assert isinstance(value, int)
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
def test_get_float_default() -> None:
|
|
89
|
-
value = options('testing').get('float-opt')
|
|
89
|
+
value = options('sentry-options-testing').get('float-opt')
|
|
90
90
|
assert value == 3.14
|
|
91
91
|
assert isinstance(value, float)
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
def test_get_bool_default() -> None:
|
|
95
|
-
value = options('testing').get('bool-opt')
|
|
95
|
+
value = options('sentry-options-testing').get('bool-opt')
|
|
96
96
|
assert value is True
|
|
97
97
|
assert isinstance(value, bool)
|
|
98
98
|
|
|
@@ -104,7 +104,7 @@ def test_unknown_namespace() -> None:
|
|
|
104
104
|
|
|
105
105
|
def test_unknown_option() -> None:
|
|
106
106
|
with pytest.raises(UnknownOptionError, match='bad-key'):
|
|
107
|
-
options('testing').get('bad-key')
|
|
107
|
+
options('sentry-options-testing').get('bad-key')
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
def test_double_init() -> None:
|
|
@@ -171,7 +171,7 @@ mod tests {
|
|
|
171
171
|
}
|
|
172
172
|
}"#,
|
|
173
173
|
);
|
|
174
|
-
create_values(&values, "test", r#"{"enabled": true}"#);
|
|
174
|
+
create_values(&values, "test", r#"{"options": {"enabled": true}}"#);
|
|
175
175
|
|
|
176
176
|
let options = Options::from_directory(temp.path()).unwrap();
|
|
177
177
|
assert_eq!(options.get("test", "enabled").unwrap(), json!(true));
|
|
@@ -365,6 +365,7 @@ impl SchemaRegistry {
|
|
|
365
365
|
|
|
366
366
|
/// Load and validate JSON values from a directory.
|
|
367
367
|
/// Expects structure: `{values_dir}/{namespace}/values.json`
|
|
368
|
+
/// Values file must have format: `{"options": {"key": value, ...}}`
|
|
368
369
|
/// Skips namespaces without a values.json file.
|
|
369
370
|
pub fn load_values_json(&self, values_dir: &Path) -> ValidationResult<ValuesByNamespace> {
|
|
370
371
|
let mut all_values = HashMap::new();
|
|
@@ -376,10 +377,18 @@ impl SchemaRegistry {
|
|
|
376
377
|
continue;
|
|
377
378
|
}
|
|
378
379
|
|
|
379
|
-
let
|
|
380
|
-
self.validate_values(namespace, &values)?;
|
|
380
|
+
let parsed: Value = serde_json::from_reader(fs::File::open(&values_file)?)?;
|
|
381
381
|
|
|
382
|
-
|
|
382
|
+
let values = parsed
|
|
383
|
+
.get("options")
|
|
384
|
+
.ok_or_else(|| ValidationError::ValueError {
|
|
385
|
+
namespace: namespace.clone(),
|
|
386
|
+
errors: "values.json must have an 'options' key".to_string(),
|
|
387
|
+
})?;
|
|
388
|
+
|
|
389
|
+
self.validate_values(namespace, values)?;
|
|
390
|
+
|
|
391
|
+
if let Value::Object(obj) = values.clone() {
|
|
383
392
|
let ns_values: HashMap<String, Value> = obj.into_iter().collect();
|
|
384
393
|
all_values.insert(namespace.clone(), ns_values);
|
|
385
394
|
}
|
|
@@ -979,10 +988,12 @@ Error: \"version\" is a required property"
|
|
|
979
988
|
fs::write(
|
|
980
989
|
test_values_dir.join("values.json"),
|
|
981
990
|
r#"{
|
|
982
|
-
"
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
991
|
+
"options": {
|
|
992
|
+
"enabled": true,
|
|
993
|
+
"name": "test-name",
|
|
994
|
+
"count": 42,
|
|
995
|
+
"rate": 0.75
|
|
996
|
+
}
|
|
986
997
|
}"#,
|
|
987
998
|
)
|
|
988
999
|
.unwrap();
|
|
@@ -1053,7 +1064,11 @@ Error: \"version\" is a required property"
|
|
|
1053
1064
|
// Only create values for one namespace
|
|
1054
1065
|
let with_values_dir = values_dir.join("with-values");
|
|
1055
1066
|
fs::create_dir_all(&with_values_dir).unwrap();
|
|
1056
|
-
fs::write(
|
|
1067
|
+
fs::write(
|
|
1068
|
+
with_values_dir.join("values.json"),
|
|
1069
|
+
r#"{"options": {"opt": "y"}}"#,
|
|
1070
|
+
)
|
|
1071
|
+
.unwrap();
|
|
1057
1072
|
|
|
1058
1073
|
let registry = SchemaRegistry::from_directory(&schemas_dir).unwrap();
|
|
1059
1074
|
let values = registry.load_values_json(&values_dir).unwrap();
|
|
@@ -1087,7 +1102,7 @@ Error: \"version\" is a required property"
|
|
|
1087
1102
|
fs::create_dir_all(&test_values_dir).unwrap();
|
|
1088
1103
|
fs::write(
|
|
1089
1104
|
test_values_dir.join("values.json"),
|
|
1090
|
-
r#"{"count": "not-a-number"}"#,
|
|
1105
|
+
r#"{"options": {"count": "not-a-number"}}"#,
|
|
1091
1106
|
)
|
|
1092
1107
|
.unwrap();
|
|
1093
1108
|
|
|
@@ -1123,7 +1138,11 @@ Error: \"version\" is a required property"
|
|
|
1123
1138
|
|
|
1124
1139
|
let ns1_values = values_dir.join("ns1");
|
|
1125
1140
|
fs::create_dir_all(&ns1_values).unwrap();
|
|
1126
|
-
fs::write(
|
|
1141
|
+
fs::write(
|
|
1142
|
+
ns1_values.join("values.json"),
|
|
1143
|
+
r#"{"options": {"enabled": true}}"#,
|
|
1144
|
+
)
|
|
1145
|
+
.unwrap();
|
|
1127
1146
|
|
|
1128
1147
|
let ns2_schema = schemas_dir.join("ns2");
|
|
1129
1148
|
fs::create_dir_all(&ns2_schema).unwrap();
|
|
@@ -1141,7 +1160,11 @@ Error: \"version\" is a required property"
|
|
|
1141
1160
|
|
|
1142
1161
|
let ns2_values = values_dir.join("ns2");
|
|
1143
1162
|
fs::create_dir_all(&ns2_values).unwrap();
|
|
1144
|
-
fs::write(
|
|
1163
|
+
fs::write(
|
|
1164
|
+
ns2_values.join("values.json"),
|
|
1165
|
+
r#"{"options": {"count": 42}}"#,
|
|
1166
|
+
)
|
|
1167
|
+
.unwrap();
|
|
1145
1168
|
|
|
1146
1169
|
(temp_dir, schemas_dir, values_dir)
|
|
1147
1170
|
}
|
|
@@ -1158,7 +1181,7 @@ Error: \"version\" is a required property"
|
|
|
1158
1181
|
thread::sleep(std::time::Duration::from_millis(10));
|
|
1159
1182
|
fs::write(
|
|
1160
1183
|
values_dir.join("ns1").join("values.json"),
|
|
1161
|
-
r#"{"enabled": false}"#,
|
|
1184
|
+
r#"{"options": {"enabled": false}}"#,
|
|
1162
1185
|
)
|
|
1163
1186
|
.unwrap();
|
|
1164
1187
|
|
|
@@ -1195,12 +1218,12 @@ Error: \"version\" is a required property"
|
|
|
1195
1218
|
// modify
|
|
1196
1219
|
fs::write(
|
|
1197
1220
|
values_dir.join("ns1").join("values.json"),
|
|
1198
|
-
r#"{"enabled": false}"#,
|
|
1221
|
+
r#"{"options": {"enabled": false}}"#,
|
|
1199
1222
|
)
|
|
1200
1223
|
.unwrap();
|
|
1201
1224
|
fs::write(
|
|
1202
1225
|
values_dir.join("ns2").join("values.json"),
|
|
1203
|
-
r#"{"count": 100}"#,
|
|
1226
|
+
r#"{"options": {"count": 100}}"#,
|
|
1204
1227
|
)
|
|
1205
1228
|
.unwrap();
|
|
1206
1229
|
|
|
@@ -1231,7 +1254,7 @@ Error: \"version\" is a required property"
|
|
|
1231
1254
|
// won't pass validation
|
|
1232
1255
|
fs::write(
|
|
1233
1256
|
values_dir.join("ns1").join("values.json"),
|
|
1234
|
-
r#"{"enabled": "not-a-boolean"}"#,
|
|
1257
|
+
r#"{"options": {"enabled": "not-a-boolean"}}"#,
|
|
1235
1258
|
)
|
|
1236
1259
|
.unwrap();
|
|
1237
1260
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sentry_options-0.0.6 → sentry_options-0.0.7}/sentry-options-validation/src/namespace-schema.json
RENAMED
|
File without changes
|