Skip to content
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

Serialize Configuration Properties for Webhook #276

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "agent"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>", "<bfjelds@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion controller/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "controller"
version = "0.3.0"
version = "0.3.1"
authors = ["<bfjelds@microsoft.com>"]
edition = "2018"

Expand Down
4 changes: 2 additions & 2 deletions deployment/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "debug-echo-discovery-handler"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "onvif-discovery-handler"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opcua-discovery-handler"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "udev-discovery-handler"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/debug-echo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-debug-echo"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/onvif/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-onvif"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/opcua/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-opcua"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/udev/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-udev"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-discovery-utils"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion samples/brokers/udev-video-broker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "udev-video-broker"
version = "0.3.0"
version = "0.3.1"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>", "<bfjelds@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-shared"
version = "0.3.0"
version = "0.3.1"
authors = ["<bfjelds@microsoft.com>"]
edition = "2018"

Expand Down
11 changes: 5 additions & 6 deletions shared/src/akri/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<ServiceSpec>,

/// 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<String, String>,
}

Expand Down Expand Up @@ -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}"#;
let expected_deserialized = r#"{"discoveryHandler":{"name":"random","discoveryDetails":""},"capacity":4,"properties":{}}"#;
assert_eq!(expected_deserialized, serialized);
}

Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.3.1
2 changes: 1 addition & 1 deletion webhooks/validating/configuration/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "webhook-configuration"
version = "0.3.0"
version = "0.3.1"
authors = ["DazWilkin <daz.wilkin@gmail.com>"]
edition = "2018"

Expand Down
15 changes: 12 additions & 3 deletions webhooks/validating/configuration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ fn filter_configuration(mut v: Value) -> Value {

v
}

fn validate_configuration(rqst: &AdmissionRequest) -> AdmissionResponse {
println!("Validating Configuration");
match &rqst.object {
Expand All @@ -118,8 +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!(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additional logging for future debugging scenarios

"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) {
Expand Down Expand Up @@ -289,7 +297,7 @@ mod tests {
"spec": {
"discoveryHandler": {
"name": "debugEcho",
"discoveryDetails": "{\"descriptions\": [\"foo\",\"bar\"]}"
"discoveryDetails": "descriptions:\n- \"foo0\"\n- \"foo1\"\n"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is to ensure that validation succeeds regardless of the format of the discoveryDetails string, whether serialized json or yaml

},
"brokerPodSpec": {
"containers": [
Expand All @@ -309,7 +317,8 @@ mod tests {
}
]
},
"capacity": 1
"capacity": 1,
"properties": {}
}
},
"oldObject": null,
Expand Down