From 553c2cd68015026158e058d2b63a42c1128b96db Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Fri, 12 Mar 2021 10:49:24 -0800 Subject: [PATCH 1/3] don't skip serializing configuration properties --- shared/src/akri/configuration.rs | 10 +++++----- webhooks/validating/configuration/src/main.rs | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/shared/src/akri/configuration.rs b/shared/src/akri/configuration.rs index 2fe033d01..32f5037e1 100644 --- a/shared/src/akri/configuration.rs +++ b/shared/src/akri/configuration.rs @@ -43,7 +43,7 @@ pub struct Configuration { /// discover the capability and any information needed by the `DiscoveryHandler`. pub discovery_handler: DiscoveryHandlerInfo, - /// This defines the number of nodes that can schedule worloads for + /// This defines the number of nodes that can schedule workloads for /// any given capability that is found #[serde(default = "default_capacity")] pub capacity: i32, @@ -64,14 +64,14 @@ pub struct Configuration { /// This defines a service that should be created to access /// all of the capabilities found that are described by this - /// configuration. For each Configurataion, there is at most + /// configuration. For each Configuration, there is at most /// 1 device capability service. #[serde(default, skip_serializing_if = "Option::is_none")] pub configuration_service_spec: Option, - /// This defines some properties that will be propogated to + /// This defines some properties that will be propagated to /// any Instance - #[serde(default, skip_serializing_if = "HashMap::is_empty")] + #[serde(default)] pub properties: HashMap, } @@ -241,7 +241,7 @@ mod crd_serialization_tests { let serialized = serde_json::to_string(&deserialized).unwrap(); let expected_deserialized = - r#"{"discoveryHandler":{"name":"random","discoveryDetails":""},"capacity":4}"#; + r#"{"discoveryHandler":{"name":"random","discoveryDetails":""},"capacity":4,"properties":{}}"#; assert_eq!(expected_deserialized, serialized); } diff --git a/webhooks/validating/configuration/src/main.rs b/webhooks/validating/configuration/src/main.rs index 36f1d7942..d751d345d 100644 --- a/webhooks/validating/configuration/src/main.rs +++ b/webhooks/validating/configuration/src/main.rs @@ -107,6 +107,7 @@ fn filter_configuration(mut v: Value) -> Value { v } + fn validate_configuration(rqst: &AdmissionRequest) -> AdmissionResponse { println!("Validating Configuration"); match &rqst.object { @@ -118,8 +119,9 @@ fn validate_configuration(rqst: &AdmissionRequest) -> AdmissionResponse { serde_json::from_str(y.as_str()).expect("Could not parse as Akri Configuration"); let reserialized = serde_json::to_string(&config).unwrap(); let deserialized: Value = serde_json::from_str(&reserialized).expect("untyped JSON"); - + println!("validate_configuration - deserialized Configuration: {:?}", deserialized); let val: Value = filter_configuration(raw.clone()); + println!("validate_configuration - expected deserialized format: {:?}", val); // Do they match? match check(&val, &deserialized) { @@ -289,7 +291,7 @@ mod tests { "spec": { "discoveryHandler": { "name": "debugEcho", - "discoveryDetails": "{\"descriptions\": [\"foo\",\"bar\"]}" + "discoveryDetails": "descriptions:\n- \"foo0\"\n- \"foo1\"\n" }, "brokerPodSpec": { "containers": [ @@ -309,7 +311,8 @@ mod tests { } ] }, - "capacity": 1 + "capacity": 1, + "properties": {} } }, "oldObject": null, From 76acb88907cfc93066d4773d8c66b547235c5808 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Fri, 12 Mar 2021 10:49:46 -0800 Subject: [PATCH 2/3] increase version --- Cargo.lock | 28 +++++++++---------- agent/Cargo.toml | 2 +- controller/Cargo.toml | 2 +- deployment/helm/Chart.yaml | 4 +-- .../debug-echo-discovery-handler/Cargo.toml | 2 +- .../onvif-discovery-handler/Cargo.toml | 2 +- .../opcua-discovery-handler/Cargo.toml | 2 +- .../udev-discovery-handler/Cargo.toml | 2 +- discovery-handlers/debug-echo/Cargo.toml | 2 +- discovery-handlers/onvif/Cargo.toml | 2 +- discovery-handlers/opcua/Cargo.toml | 2 +- discovery-handlers/udev/Cargo.toml | 2 +- discovery-utils/Cargo.toml | 2 +- samples/brokers/udev-video-broker/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- version.txt | 2 +- webhooks/validating/configuration/Cargo.toml | 2 +- 17 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02d9eb0f2..99c9e8603 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -320,7 +320,7 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "agent" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-debug-echo", "akri-discovery-utils", @@ -385,7 +385,7 @@ dependencies = [ [[package]] name = "akri-debug-echo" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-discovery-utils", "akri-shared", @@ -404,7 +404,7 @@ dependencies = [ [[package]] name = "akri-discovery-utils" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-shared", "anyhow", @@ -424,7 +424,7 @@ dependencies = [ [[package]] name = "akri-onvif" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-discovery-utils", "akri-shared", @@ -452,7 +452,7 @@ dependencies = [ [[package]] name = "akri-opcua" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-discovery-utils", "akri-shared", @@ -475,7 +475,7 @@ dependencies = [ [[package]] name = "akri-shared" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "async-trait", @@ -504,7 +504,7 @@ dependencies = [ [[package]] name = "akri-udev" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-discovery-utils", "anyhow", @@ -1059,7 +1059,7 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "controller" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-shared", "anyhow", @@ -1220,7 +1220,7 @@ dependencies = [ [[package]] name = "debug-echo-discovery-handler" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-debug-echo", "akri-discovery-utils", @@ -2410,7 +2410,7 @@ checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "onvif-discovery-handler" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-discovery-utils", "akri-onvif", @@ -2476,7 +2476,7 @@ dependencies = [ [[package]] name = "opcua-discovery-handler" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-discovery-utils", "akri-opcua", @@ -4551,7 +4551,7 @@ dependencies = [ [[package]] name = "udev-discovery-handler" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-discovery-utils", "akri-udev", @@ -4562,7 +4562,7 @@ dependencies = [ [[package]] name = "udev-video-broker" -version = "0.3.0" +version = "0.3.1" dependencies = [ "akri-shared", "env_logger", @@ -4856,7 +4856,7 @@ dependencies = [ [[package]] name = "webhook-configuration" -version = "0.3.0" +version = "0.3.1" dependencies = [ "actix", "actix-rt", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index f8d1bf29f..c534b80ad 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "agent" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring ", ""] edition = "2018" diff --git a/controller/Cargo.toml b/controller/Cargo.toml index ce37805a6..60a7801d5 100644 --- a/controller/Cargo.toml +++ b/controller/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "controller" -version = "0.3.0" +version = "0.3.1" authors = [""] edition = "2018" diff --git a/deployment/helm/Chart.yaml b/deployment/helm/Chart.yaml index 7e695b387..0774b4ecd 100644 --- a/deployment/helm/Chart.yaml +++ b/deployment/helm/Chart.yaml @@ -15,9 +15,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.3.0 +version: 0.3.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 0.3.0 +appVersion: 0.3.1 diff --git a/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml b/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml index 138f861d6..6fe23207b 100644 --- a/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "debug-echo-discovery-handler" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handler-modules/onvif-discovery-handler/Cargo.toml b/discovery-handler-modules/onvif-discovery-handler/Cargo.toml index afd4e85c6..1fe870a80 100644 --- a/discovery-handler-modules/onvif-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/onvif-discovery-handler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "onvif-discovery-handler" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handler-modules/opcua-discovery-handler/Cargo.toml b/discovery-handler-modules/opcua-discovery-handler/Cargo.toml index d4e7883ae..9559f8c08 100644 --- a/discovery-handler-modules/opcua-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/opcua-discovery-handler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opcua-discovery-handler" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handler-modules/udev-discovery-handler/Cargo.toml b/discovery-handler-modules/udev-discovery-handler/Cargo.toml index 253650f94..365369efa 100644 --- a/discovery-handler-modules/udev-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/udev-discovery-handler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "udev-discovery-handler" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handlers/debug-echo/Cargo.toml b/discovery-handlers/debug-echo/Cargo.toml index 1bd3799a7..04b3192a9 100644 --- a/discovery-handlers/debug-echo/Cargo.toml +++ b/discovery-handlers/debug-echo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-debug-echo" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handlers/onvif/Cargo.toml b/discovery-handlers/onvif/Cargo.toml index c34862072..6d605bc42 100644 --- a/discovery-handlers/onvif/Cargo.toml +++ b/discovery-handlers/onvif/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-onvif" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handlers/opcua/Cargo.toml b/discovery-handlers/opcua/Cargo.toml index a8f6ed546..17f88913a 100644 --- a/discovery-handlers/opcua/Cargo.toml +++ b/discovery-handlers/opcua/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-opcua" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handlers/udev/Cargo.toml b/discovery-handlers/udev/Cargo.toml index 83a1f53a7..1fa621452 100644 --- a/discovery-handlers/udev/Cargo.toml +++ b/discovery-handlers/udev/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-udev" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-utils/Cargo.toml b/discovery-utils/Cargo.toml index 23a5325d8..db7c8b58b 100644 --- a/discovery-utils/Cargo.toml +++ b/discovery-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-discovery-utils" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring "] edition = "2018" diff --git a/samples/brokers/udev-video-broker/Cargo.toml b/samples/brokers/udev-video-broker/Cargo.toml index 195614751..7961728b0 100644 --- a/samples/brokers/udev-video-broker/Cargo.toml +++ b/samples/brokers/udev-video-broker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "udev-video-broker" -version = "0.3.0" +version = "0.3.1" authors = ["Kate Goldenring ", ""] edition = "2018" diff --git a/shared/Cargo.toml b/shared/Cargo.toml index f524d05a7..35a1f9a76 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-shared" -version = "0.3.0" +version = "0.3.1" authors = [""] edition = "2018" diff --git a/version.txt b/version.txt index 0d91a54c7..9e11b32fc 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.3.0 +0.3.1 diff --git a/webhooks/validating/configuration/Cargo.toml b/webhooks/validating/configuration/Cargo.toml index c61b584bc..cdd12234c 100644 --- a/webhooks/validating/configuration/Cargo.toml +++ b/webhooks/validating/configuration/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "webhook-configuration" -version = "0.3.0" +version = "0.3.1" authors = ["DazWilkin "] edition = "2018" From 61ed7142481c2adb88c7a522dd6ccbf0bb88583b Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Fri, 12 Mar 2021 11:08:26 -0800 Subject: [PATCH 3/3] rust fmt fixes --- shared/src/akri/configuration.rs | 3 +-- webhooks/validating/configuration/src/main.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/shared/src/akri/configuration.rs b/shared/src/akri/configuration.rs index 32f5037e1..a0eb2aae1 100644 --- a/shared/src/akri/configuration.rs +++ b/shared/src/akri/configuration.rs @@ -240,8 +240,7 @@ mod crd_serialization_tests { assert_eq!(0, deserialized.properties.len()); let serialized = serde_json::to_string(&deserialized).unwrap(); - let expected_deserialized = - r#"{"discoveryHandler":{"name":"random","discoveryDetails":""},"capacity":4,"properties":{}}"#; + let expected_deserialized = r#"{"discoveryHandler":{"name":"random","discoveryDetails":""},"capacity":4,"properties":{}}"#; assert_eq!(expected_deserialized, serialized); } diff --git a/webhooks/validating/configuration/src/main.rs b/webhooks/validating/configuration/src/main.rs index d751d345d..0c2772dc2 100644 --- a/webhooks/validating/configuration/src/main.rs +++ b/webhooks/validating/configuration/src/main.rs @@ -119,9 +119,15 @@ fn validate_configuration(rqst: &AdmissionRequest) -> AdmissionResponse { serde_json::from_str(y.as_str()).expect("Could not parse as Akri Configuration"); let reserialized = serde_json::to_string(&config).unwrap(); let deserialized: Value = serde_json::from_str(&reserialized).expect("untyped JSON"); - println!("validate_configuration - deserialized Configuration: {:?}", deserialized); + println!( + "validate_configuration - deserialized Configuration: {:?}", + deserialized + ); let val: Value = filter_configuration(raw.clone()); - println!("validate_configuration - expected deserialized format: {:?}", val); + println!( + "validate_configuration - expected deserialized format: {:?}", + val + ); // Do they match? match check(&val, &deserialized) {