From b778dd5339c09d70f2c816fc5609bf907553a0c0 Mon Sep 17 00:00:00 2001 From: David Bernard Date: Sun, 24 Mar 2024 15:27:51 +0100 Subject: [PATCH] feat!: add support for mulitple version of cdevents' specifications (#19) - refactor: move spec into a subfolder and add link to `main` branch of spec - feat!: add support for multiple version of specification of cdevents - link as git submodule several versions of cdevents specs - add version into module name of subject's content - generate a module per specs with alias to the versionned subejct's content module - generate a module `latest` with alias to the latest version of each subject's content module - ignore subject'content with modifier in their version - update tests to load every json schema and test it (selection based on `context.type` - refactor: apply linter's advices - docs: use `spec_0_3_0` in README.md instead of `latest` FIX #16 --------- Signed-off-by: David Bernard --- .gitmodules | 7 +- Makefile | 2 +- README.md | 2 +- cdevents-sdk/Cargo.toml | 1 + cdevents-sdk/examples/pipelinerun_finished.rs | 2 +- cdevents-sdk/src/cloudevents.rs | 2 +- ...packaged.rs => artifact_packaged_0_1_1.rs} | 0 ...blished.rs => artifact_published_0_1_1.rs} | 0 ...act_signed.rs => artifact_signed_0_1_0.rs} | 2 +- ...nch_created.rs => branch_created_0_1_2.rs} | 0 ...nch_deleted.rs => branch_deleted_0_1_2.rs} | 0 ...ld_finished.rs => build_finished_0_1_1.rs} | 0 ...{build_queued.rs => build_queued_0_1_1.rs} | 0 ...uild_started.rs => build_started_0_1_1.rs} | 0 ...abandoned.rs => change_abandoned_0_1_2.rs} | 0 ...nge_created.rs => change_created_0_1_2.rs} | 0 .../src/generated/change_created_0_2_0.rs | 41 + ...hange_merged.rs => change_merged_0_1_2.rs} | 0 ...e_reviewed.rs => change_reviewed_0_1_2.rs} | 0 ...nge_updated.rs => change_updated_0_1_2.rs} | 0 ...reated.rs => environment_created_0_1_1.rs} | 0 ...eleted.rs => environment_deleted_0_1_1.rs} | 0 ...ified.rs => environment_modified_0_1_1.rs} | 0 ...detected.rs => incident_detected_0_1_0.rs} | 0 ...reported.rs => incident_reported_0_1_0.rs} | 0 ...resolved.rs => incident_resolved_0_1_0.rs} | 0 cdevents-sdk/src/generated/mod.rs | 1235 +++++++++-------- ...ished.rs => pipelinerun_finished_0_1_1.rs} | 0 ..._queued.rs => pipelinerun_queued_0_1_1.rs} | 0 ...tarted.rs => pipelinerun_started_0_1_1.rs} | 0 ...created.rs => repository_created_0_1_1.rs} | 2 +- ...deleted.rs => repository_deleted_0_1_1.rs} | 0 ...dified.rs => repository_modified_0_1_1.rs} | 0 ..._deployed.rs => service_deployed_0_1_1.rs} | 0 ...ublished.rs => service_published_0_1_1.rs} | 0 ...ce_removed.rs => service_removed_0_1_1.rs} | 0 ...ledback.rs => service_rolledback_0_1_1.rs} | 0 ..._upgraded.rs => service_upgraded_0_1_1.rs} | 0 ..._finished.rs => taskrun_finished_0_1_1.rs} | 0 ...un_started.rs => taskrun_started_0_1_1.rs} | 0 ...ished.rs => testcaserun_finished_0_1_0.rs} | 0 ..._queued.rs => testcaserun_queued_0_1_0.rs} | 0 ...tarted.rs => testcaserun_started_0_1_0.rs} | 0 ...ished.rs => testoutput_published_0_1_0.rs} | 0 ...shed.rs => testsuiterun_finished_0_1_0.rs} | 0 ...queued.rs => testsuiterun_queued_0_1_0.rs} | 0 ...arted.rs => testsuiterun_started_0_1_0.rs} | 0 cdevents-sdk/src/uri.rs | 6 +- cdevents-sdk/src/uri_reference.rs | 6 +- cdevents-sdk/tests/specs.rs | 80 +- cdevents-specs/main | 1 + cdevents-spec => cdevents-specs/spec-v0.3 | 0 generator/Cargo.toml | 2 + generator/README.md | 4 +- generator/src/main.rs | 182 ++- generator/src/version.rs | 31 + generator/templates/mod.hbs | 14 +- 57 files changed, 996 insertions(+), 626 deletions(-) rename cdevents-sdk/src/generated/{artifact_packaged.rs => artifact_packaged_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{artifact_published.rs => artifact_published_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{artifact_signed.rs => artifact_signed_0_1_0.rs} (94%) rename cdevents-sdk/src/generated/{branch_created.rs => branch_created_0_1_2.rs} (100%) rename cdevents-sdk/src/generated/{branch_deleted.rs => branch_deleted_0_1_2.rs} (100%) rename cdevents-sdk/src/generated/{build_finished.rs => build_finished_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{build_queued.rs => build_queued_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{build_started.rs => build_started_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{change_abandoned.rs => change_abandoned_0_1_2.rs} (100%) rename cdevents-sdk/src/generated/{change_created.rs => change_created_0_1_2.rs} (100%) create mode 100644 cdevents-sdk/src/generated/change_created_0_2_0.rs rename cdevents-sdk/src/generated/{change_merged.rs => change_merged_0_1_2.rs} (100%) rename cdevents-sdk/src/generated/{change_reviewed.rs => change_reviewed_0_1_2.rs} (100%) rename cdevents-sdk/src/generated/{change_updated.rs => change_updated_0_1_2.rs} (100%) rename cdevents-sdk/src/generated/{environment_created.rs => environment_created_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{environment_deleted.rs => environment_deleted_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{environment_modified.rs => environment_modified_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{incident_detected.rs => incident_detected_0_1_0.rs} (100%) rename cdevents-sdk/src/generated/{incident_reported.rs => incident_reported_0_1_0.rs} (100%) rename cdevents-sdk/src/generated/{incident_resolved.rs => incident_resolved_0_1_0.rs} (100%) rename cdevents-sdk/src/generated/{pipelinerun_finished.rs => pipelinerun_finished_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{pipelinerun_queued.rs => pipelinerun_queued_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{pipelinerun_started.rs => pipelinerun_started_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{repository_created.rs => repository_created_0_1_1.rs} (97%) rename cdevents-sdk/src/generated/{repository_deleted.rs => repository_deleted_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{repository_modified.rs => repository_modified_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{service_deployed.rs => service_deployed_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{service_published.rs => service_published_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{service_removed.rs => service_removed_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{service_rolledback.rs => service_rolledback_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{service_upgraded.rs => service_upgraded_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{taskrun_finished.rs => taskrun_finished_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{taskrun_started.rs => taskrun_started_0_1_1.rs} (100%) rename cdevents-sdk/src/generated/{testcaserun_finished.rs => testcaserun_finished_0_1_0.rs} (100%) rename cdevents-sdk/src/generated/{testcaserun_queued.rs => testcaserun_queued_0_1_0.rs} (100%) rename cdevents-sdk/src/generated/{testcaserun_started.rs => testcaserun_started_0_1_0.rs} (100%) rename cdevents-sdk/src/generated/{testoutput_published.rs => testoutput_published_0_1_0.rs} (100%) rename cdevents-sdk/src/generated/{testsuiterun_finished.rs => testsuiterun_finished_0_1_0.rs} (100%) rename cdevents-sdk/src/generated/{testsuiterun_queued.rs => testsuiterun_queued_0_1_0.rs} (100%) rename cdevents-sdk/src/generated/{testsuiterun_started.rs => testsuiterun_started_0_1_0.rs} (100%) create mode 160000 cdevents-specs/main rename cdevents-spec => cdevents-specs/spec-v0.3 (100%) create mode 100644 generator/src/version.rs diff --git a/.gitmodules b/.gitmodules index 72bdf71..a76a335 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,7 @@ -[submodule "cdevents-spec"] - path = cdevents-spec +[submodule "cdevents-specs/spec-v0.3"] + path = cdevents-specs/spec-v0.3 url = https://github.com/cdevents/spec.git branch = spec-v0.3 +[submodule "cdevents-specs/main"] + path = cdevents-specs/main + url = https://github.com/cdevents/spec.git diff --git a/Makefile b/Makefile index f32eed0..275e96b 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ clean: cargo clean generate: - cargo run -p generator -- --templates-dir "generator/templates" --jsonschema-dir "cdevents-spec/schemas" --dest "cdevents-sdk/src/generated" + cargo run -p generator -- --templates-dir "generator/templates" --jsonschemas "cdevents-specs/*/schemas/*.json" --dest "cdevents-sdk/src/generated" test: cargo nextest run --all-features diff --git a/README.md b/README.md index fe53265..269eb78 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ To send a CDEvent as CloudEvent: // from examples/pipelinerun_finished.rs use std::error::Error; -use cdevents_sdk::{CDEvent, Subject, pipelinerun_finished, Content}; +use cdevents_sdk::{CDEvent, Subject, spec_0_3_0::pipelinerun_finished, Content}; use cloudevents::{Event, AttributesReader}; fn main() -> Result<(), Box> { diff --git a/cdevents-sdk/Cargo.toml b/cdevents-sdk/Cargo.toml index f38f150..2d77bde 100644 --- a/cdevents-sdk/Cargo.toml +++ b/cdevents-sdk/Cargo.toml @@ -22,6 +22,7 @@ time = { version = "0.3", features = ["serde-human-readable"] } [dev-dependencies] assert-json-diff = "2.0" boon = "0.5" +glob = "0.3" proptest = "1" rstest = "0.18" diff --git a/cdevents-sdk/examples/pipelinerun_finished.rs b/cdevents-sdk/examples/pipelinerun_finished.rs index 12a5c07..b4c2671 100644 --- a/cdevents-sdk/examples/pipelinerun_finished.rs +++ b/cdevents-sdk/examples/pipelinerun_finished.rs @@ -1,6 +1,6 @@ use std::error::Error; -use cdevents_sdk::{CDEvent, Subject, pipelinerun_finished}; +use cdevents_sdk::{CDEvent, Subject, latest::pipelinerun_finished}; use cloudevents::{Event, AttributesReader}; fn main() -> Result<(), Box> { diff --git a/cdevents-sdk/src/cloudevents.rs b/cdevents-sdk/src/cloudevents.rs index 0c674be..41254a4 100644 --- a/cdevents-sdk/src/cloudevents.rs +++ b/cdevents-sdk/src/cloudevents.rs @@ -67,7 +67,7 @@ mod tests { #[test] fn test_into_cloudevent() -> Result<(), Box> { let cdevent = CDEvent::from( - Subject::from(build_queued::Content{}) + Subject::from(latest::build_queued::Content{}) .with_id("subject123".try_into()?) .with_source("/event/source/123".try_into()?) ) diff --git a/cdevents-sdk/src/generated/artifact_packaged.rs b/cdevents-sdk/src/generated/artifact_packaged_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/artifact_packaged.rs rename to cdevents-sdk/src/generated/artifact_packaged_0_1_1.rs diff --git a/cdevents-sdk/src/generated/artifact_published.rs b/cdevents-sdk/src/generated/artifact_published_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/artifact_published.rs rename to cdevents-sdk/src/generated/artifact_published_0_1_1.rs diff --git a/cdevents-sdk/src/generated/artifact_signed.rs b/cdevents-sdk/src/generated/artifact_signed_0_1_0.rs similarity index 94% rename from cdevents-sdk/src/generated/artifact_signed.rs rename to cdevents-sdk/src/generated/artifact_signed_0_1_0.rs index b7b700e..099735f 100644 --- a/cdevents-sdk/src/generated/artifact_signed.rs +++ b/cdevents-sdk/src/generated/artifact_signed_0_1_0.rs @@ -9,7 +9,7 @@ use serde::{Serialize, Deserialize}; #[serde(deny_unknown_fields)] pub struct Content { #[serde(rename = "signature",)] - pub signature: String, + pub signature: crate::NonEmptyString, } #[cfg(test)] diff --git a/cdevents-sdk/src/generated/branch_created.rs b/cdevents-sdk/src/generated/branch_created_0_1_2.rs similarity index 100% rename from cdevents-sdk/src/generated/branch_created.rs rename to cdevents-sdk/src/generated/branch_created_0_1_2.rs diff --git a/cdevents-sdk/src/generated/branch_deleted.rs b/cdevents-sdk/src/generated/branch_deleted_0_1_2.rs similarity index 100% rename from cdevents-sdk/src/generated/branch_deleted.rs rename to cdevents-sdk/src/generated/branch_deleted_0_1_2.rs diff --git a/cdevents-sdk/src/generated/build_finished.rs b/cdevents-sdk/src/generated/build_finished_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/build_finished.rs rename to cdevents-sdk/src/generated/build_finished_0_1_1.rs diff --git a/cdevents-sdk/src/generated/build_queued.rs b/cdevents-sdk/src/generated/build_queued_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/build_queued.rs rename to cdevents-sdk/src/generated/build_queued_0_1_1.rs diff --git a/cdevents-sdk/src/generated/build_started.rs b/cdevents-sdk/src/generated/build_started_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/build_started.rs rename to cdevents-sdk/src/generated/build_started_0_1_1.rs diff --git a/cdevents-sdk/src/generated/change_abandoned.rs b/cdevents-sdk/src/generated/change_abandoned_0_1_2.rs similarity index 100% rename from cdevents-sdk/src/generated/change_abandoned.rs rename to cdevents-sdk/src/generated/change_abandoned_0_1_2.rs diff --git a/cdevents-sdk/src/generated/change_created.rs b/cdevents-sdk/src/generated/change_created_0_1_2.rs similarity index 100% rename from cdevents-sdk/src/generated/change_created.rs rename to cdevents-sdk/src/generated/change_created_0_1_2.rs diff --git a/cdevents-sdk/src/generated/change_created_0_2_0.rs b/cdevents-sdk/src/generated/change_created_0_2_0.rs new file mode 100644 index 0000000..f4500e7 --- /dev/null +++ b/cdevents-sdk/src/generated/change_created_0_2_0.rs @@ -0,0 +1,41 @@ +// @generated +// by cdevents/sdk-rust/generator (subject.hbs) + +#[cfg(feature = "testkit")] use proptest_derive::Arbitrary; +use serde::{Serialize, Deserialize}; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[cfg_attr(feature = "testkit", derive(Arbitrary))] +#[serde(deny_unknown_fields)] +pub struct Content { + #[serde(rename = "description", default, skip_serializing_if = "Option::is_none",)] + pub description: Option, + #[serde(rename = "repository", default, skip_serializing_if = "Option::is_none",)] + pub repository: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[cfg_attr(feature = "testkit", derive(Arbitrary))] +#[serde(deny_unknown_fields)] +pub struct ContentRepository { + #[serde(rename = "id",)] + pub id: crate::Id, + #[serde(rename = "source", default, skip_serializing_if = "Option::is_none",)] + pub source: Option, +} + +#[cfg(test)] +mod tests { + use proptest::prelude::*; + use super::*; + + proptest! { + #[test] + #[cfg(feature = "testkit")] + fn arbitraries_are_json_valid(s in any::()) { + let json_str = serde_json::to_string(&s).unwrap(); + let actual = serde_json::from_str::(&json_str).unwrap(); + assert_eq!(s, actual); + } + } +} diff --git a/cdevents-sdk/src/generated/change_merged.rs b/cdevents-sdk/src/generated/change_merged_0_1_2.rs similarity index 100% rename from cdevents-sdk/src/generated/change_merged.rs rename to cdevents-sdk/src/generated/change_merged_0_1_2.rs diff --git a/cdevents-sdk/src/generated/change_reviewed.rs b/cdevents-sdk/src/generated/change_reviewed_0_1_2.rs similarity index 100% rename from cdevents-sdk/src/generated/change_reviewed.rs rename to cdevents-sdk/src/generated/change_reviewed_0_1_2.rs diff --git a/cdevents-sdk/src/generated/change_updated.rs b/cdevents-sdk/src/generated/change_updated_0_1_2.rs similarity index 100% rename from cdevents-sdk/src/generated/change_updated.rs rename to cdevents-sdk/src/generated/change_updated_0_1_2.rs diff --git a/cdevents-sdk/src/generated/environment_created.rs b/cdevents-sdk/src/generated/environment_created_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/environment_created.rs rename to cdevents-sdk/src/generated/environment_created_0_1_1.rs diff --git a/cdevents-sdk/src/generated/environment_deleted.rs b/cdevents-sdk/src/generated/environment_deleted_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/environment_deleted.rs rename to cdevents-sdk/src/generated/environment_deleted_0_1_1.rs diff --git a/cdevents-sdk/src/generated/environment_modified.rs b/cdevents-sdk/src/generated/environment_modified_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/environment_modified.rs rename to cdevents-sdk/src/generated/environment_modified_0_1_1.rs diff --git a/cdevents-sdk/src/generated/incident_detected.rs b/cdevents-sdk/src/generated/incident_detected_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/incident_detected.rs rename to cdevents-sdk/src/generated/incident_detected_0_1_0.rs diff --git a/cdevents-sdk/src/generated/incident_reported.rs b/cdevents-sdk/src/generated/incident_reported_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/incident_reported.rs rename to cdevents-sdk/src/generated/incident_reported_0_1_0.rs diff --git a/cdevents-sdk/src/generated/incident_resolved.rs b/cdevents-sdk/src/generated/incident_resolved_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/incident_resolved.rs rename to cdevents-sdk/src/generated/incident_resolved_0_1_0.rs diff --git a/cdevents-sdk/src/generated/mod.rs b/cdevents-sdk/src/generated/mod.rs index 47f92f2..06430cb 100644 --- a/cdevents-sdk/src/generated/mod.rs +++ b/cdevents-sdk/src/generated/mod.rs @@ -1,291 +1,418 @@ // @generated // by cdevents/sdk-rust/generator (mod.hbs) -use serde::de::Error; +use serde::{Serialize, Deserialize, de::Error}; -pub mod artifact_packaged; -pub mod artifact_published; -pub mod artifact_signed; -pub mod branch_created; -pub mod branch_deleted; -pub mod build_finished; -pub mod build_queued; -pub mod build_started; -pub mod change_abandoned; -pub mod change_created; -pub mod change_merged; -pub mod change_reviewed; -pub mod change_updated; -pub mod environment_created; -pub mod environment_deleted; -pub mod environment_modified; -pub mod incident_detected; -pub mod incident_reported; -pub mod incident_resolved; -pub mod pipelinerun_finished; -pub mod pipelinerun_queued; -pub mod pipelinerun_started; -pub mod repository_created; -pub mod repository_deleted; -pub mod repository_modified; -pub mod service_deployed; -pub mod service_published; -pub mod service_removed; -pub mod service_rolledback; -pub mod service_upgraded; -pub mod taskrun_finished; -pub mod taskrun_started; -pub mod testcaserun_finished; -pub mod testcaserun_queued; -pub mod testcaserun_started; -pub mod testoutput_published; -pub mod testsuiterun_finished; -pub mod testsuiterun_queued; -pub mod testsuiterun_started; +pub mod artifact_packaged_0_1_1; +pub mod artifact_published_0_1_1; +pub mod artifact_signed_0_1_0; +pub mod branch_created_0_1_2; +pub mod branch_deleted_0_1_2; +pub mod build_finished_0_1_1; +pub mod build_queued_0_1_1; +pub mod build_started_0_1_1; +pub mod change_abandoned_0_1_2; +pub mod change_created_0_2_0; +pub mod change_created_0_1_2; +pub mod change_merged_0_1_2; +pub mod change_reviewed_0_1_2; +pub mod change_updated_0_1_2; +pub mod environment_created_0_1_1; +pub mod environment_deleted_0_1_1; +pub mod environment_modified_0_1_1; +pub mod incident_detected_0_1_0; +pub mod incident_reported_0_1_0; +pub mod incident_resolved_0_1_0; +pub mod pipelinerun_finished_0_1_1; +pub mod pipelinerun_queued_0_1_1; +pub mod pipelinerun_started_0_1_1; +pub mod repository_created_0_1_1; +pub mod repository_deleted_0_1_1; +pub mod repository_modified_0_1_1; +pub mod service_deployed_0_1_1; +pub mod service_published_0_1_1; +pub mod service_removed_0_1_1; +pub mod service_rolledback_0_1_1; +pub mod service_upgraded_0_1_1; +pub mod taskrun_finished_0_1_1; +pub mod taskrun_started_0_1_1; +pub mod testcaserun_finished_0_1_0; +pub mod testcaserun_queued_0_1_0; +pub mod testcaserun_started_0_1_0; +pub mod testoutput_published_0_1_0; +pub mod testsuiterun_finished_0_1_0; +pub mod testsuiterun_queued_0_1_0; +pub mod testsuiterun_started_0_1_0; -use serde::{Serialize, Deserialize}; +pub mod latest { + pub use super::artifact_packaged_0_1_1 as artifact_packaged; + pub use super::artifact_published_0_1_1 as artifact_published; + pub use super::artifact_signed_0_1_0 as artifact_signed; + pub use super::branch_created_0_1_2 as branch_created; + pub use super::branch_deleted_0_1_2 as branch_deleted; + pub use super::build_finished_0_1_1 as build_finished; + pub use super::build_queued_0_1_1 as build_queued; + pub use super::build_started_0_1_1 as build_started; + pub use super::change_abandoned_0_1_2 as change_abandoned; + pub use super::change_created_0_2_0 as change_created; + pub use super::change_merged_0_1_2 as change_merged; + pub use super::change_reviewed_0_1_2 as change_reviewed; + pub use super::change_updated_0_1_2 as change_updated; + pub use super::environment_created_0_1_1 as environment_created; + pub use super::environment_deleted_0_1_1 as environment_deleted; + pub use super::environment_modified_0_1_1 as environment_modified; + pub use super::incident_detected_0_1_0 as incident_detected; + pub use super::incident_reported_0_1_0 as incident_reported; + pub use super::incident_resolved_0_1_0 as incident_resolved; + pub use super::pipelinerun_finished_0_1_1 as pipelinerun_finished; + pub use super::pipelinerun_queued_0_1_1 as pipelinerun_queued; + pub use super::pipelinerun_started_0_1_1 as pipelinerun_started; + pub use super::repository_created_0_1_1 as repository_created; + pub use super::repository_deleted_0_1_1 as repository_deleted; + pub use super::repository_modified_0_1_1 as repository_modified; + pub use super::service_deployed_0_1_1 as service_deployed; + pub use super::service_published_0_1_1 as service_published; + pub use super::service_removed_0_1_1 as service_removed; + pub use super::service_rolledback_0_1_1 as service_rolledback; + pub use super::service_upgraded_0_1_1 as service_upgraded; + pub use super::taskrun_finished_0_1_1 as taskrun_finished; + pub use super::taskrun_started_0_1_1 as taskrun_started; + pub use super::testcaserun_finished_0_1_0 as testcaserun_finished; + pub use super::testcaserun_queued_0_1_0 as testcaserun_queued; + pub use super::testcaserun_started_0_1_0 as testcaserun_started; + pub use super::testoutput_published_0_1_0 as testoutput_published; + pub use super::testsuiterun_finished_0_1_0 as testsuiterun_finished; + pub use super::testsuiterun_queued_0_1_0 as testsuiterun_queued; + pub use super::testsuiterun_started_0_1_0 as testsuiterun_started; +} +pub mod spec_0_3_0 { + pub use super::artifact_packaged_0_1_1 as artifact_packaged; + pub use super::artifact_published_0_1_1 as artifact_published; + pub use super::artifact_signed_0_1_0 as artifact_signed; + pub use super::branch_created_0_1_2 as branch_created; + pub use super::branch_deleted_0_1_2 as branch_deleted; + pub use super::build_finished_0_1_1 as build_finished; + pub use super::build_queued_0_1_1 as build_queued; + pub use super::build_started_0_1_1 as build_started; + pub use super::change_abandoned_0_1_2 as change_abandoned; + pub use super::change_created_0_1_2 as change_created; + pub use super::change_merged_0_1_2 as change_merged; + pub use super::change_reviewed_0_1_2 as change_reviewed; + pub use super::change_updated_0_1_2 as change_updated; + pub use super::environment_created_0_1_1 as environment_created; + pub use super::environment_deleted_0_1_1 as environment_deleted; + pub use super::environment_modified_0_1_1 as environment_modified; + pub use super::incident_detected_0_1_0 as incident_detected; + pub use super::incident_reported_0_1_0 as incident_reported; + pub use super::incident_resolved_0_1_0 as incident_resolved; + pub use super::pipelinerun_finished_0_1_1 as pipelinerun_finished; + pub use super::pipelinerun_queued_0_1_1 as pipelinerun_queued; + pub use super::pipelinerun_started_0_1_1 as pipelinerun_started; + pub use super::repository_created_0_1_1 as repository_created; + pub use super::repository_deleted_0_1_1 as repository_deleted; + pub use super::repository_modified_0_1_1 as repository_modified; + pub use super::service_deployed_0_1_1 as service_deployed; + pub use super::service_published_0_1_1 as service_published; + pub use super::service_removed_0_1_1 as service_removed; + pub use super::service_rolledback_0_1_1 as service_rolledback; + pub use super::service_upgraded_0_1_1 as service_upgraded; + pub use super::taskrun_finished_0_1_1 as taskrun_finished; + pub use super::taskrun_started_0_1_1 as taskrun_started; + pub use super::testcaserun_finished_0_1_0 as testcaserun_finished; + pub use super::testcaserun_queued_0_1_0 as testcaserun_queued; + pub use super::testcaserun_started_0_1_0 as testcaserun_started; + pub use super::testoutput_published_0_1_0 as testoutput_published; + pub use super::testsuiterun_finished_0_1_0 as testsuiterun_finished; + pub use super::testsuiterun_queued_0_1_0 as testsuiterun_queued; + pub use super::testsuiterun_started_0_1_0 as testsuiterun_started; +} +pub mod spec_0_4_0_draft { + pub use super::artifact_signed_0_1_0 as artifact_signed; + pub use super::branch_created_0_1_2 as branch_created; + pub use super::branch_deleted_0_1_2 as branch_deleted; + pub use super::build_finished_0_1_1 as build_finished; + pub use super::build_queued_0_1_1 as build_queued; + pub use super::build_started_0_1_1 as build_started; + pub use super::change_abandoned_0_1_2 as change_abandoned; + pub use super::change_created_0_2_0 as change_created; + pub use super::change_merged_0_1_2 as change_merged; + pub use super::change_reviewed_0_1_2 as change_reviewed; + pub use super::change_updated_0_1_2 as change_updated; + pub use super::environment_created_0_1_1 as environment_created; + pub use super::environment_deleted_0_1_1 as environment_deleted; + pub use super::environment_modified_0_1_1 as environment_modified; + pub use super::incident_detected_0_1_0 as incident_detected; + pub use super::incident_reported_0_1_0 as incident_reported; + pub use super::incident_resolved_0_1_0 as incident_resolved; + pub use super::pipelinerun_finished_0_1_1 as pipelinerun_finished; + pub use super::pipelinerun_queued_0_1_1 as pipelinerun_queued; + pub use super::pipelinerun_started_0_1_1 as pipelinerun_started; + pub use super::repository_created_0_1_1 as repository_created; + pub use super::repository_deleted_0_1_1 as repository_deleted; + pub use super::repository_modified_0_1_1 as repository_modified; + pub use super::service_deployed_0_1_1 as service_deployed; + pub use super::service_published_0_1_1 as service_published; + pub use super::service_removed_0_1_1 as service_removed; + pub use super::service_rolledback_0_1_1 as service_rolledback; + pub use super::service_upgraded_0_1_1 as service_upgraded; + pub use super::taskrun_finished_0_1_1 as taskrun_finished; + pub use super::taskrun_started_0_1_1 as taskrun_started; + pub use super::testcaserun_finished_0_1_0 as testcaserun_finished; + pub use super::testcaserun_queued_0_1_0 as testcaserun_queued; + pub use super::testcaserun_started_0_1_0 as testcaserun_started; + pub use super::testoutput_published_0_1_0 as testoutput_published; + pub use super::testsuiterun_finished_0_1_0 as testsuiterun_finished; + pub use super::testsuiterun_queued_0_1_0 as testsuiterun_queued; + pub use super::testsuiterun_started_0_1_0 as testsuiterun_started; +} -pub const ARTIFACT_PACKAGED: &str = "dev.cdevents.artifact.packaged.0.1.1"; -pub const ARTIFACT_PUBLISHED: &str = "dev.cdevents.artifact.published.0.1.1"; -pub const ARTIFACT_SIGNED: &str = "dev.cdevents.artifact.signed.0.1.0"; -pub const BRANCH_CREATED: &str = "dev.cdevents.branch.created.0.1.2"; -pub const BRANCH_DELETED: &str = "dev.cdevents.branch.deleted.0.1.2"; -pub const BUILD_FINISHED: &str = "dev.cdevents.build.finished.0.1.1"; -pub const BUILD_QUEUED: &str = "dev.cdevents.build.queued.0.1.1"; -pub const BUILD_STARTED: &str = "dev.cdevents.build.started.0.1.1"; -pub const CHANGE_ABANDONED: &str = "dev.cdevents.change.abandoned.0.1.2"; -pub const CHANGE_CREATED: &str = "dev.cdevents.change.created.0.1.2"; -pub const CHANGE_MERGED: &str = "dev.cdevents.change.merged.0.1.2"; -pub const CHANGE_REVIEWED: &str = "dev.cdevents.change.reviewed.0.1.2"; -pub const CHANGE_UPDATED: &str = "dev.cdevents.change.updated.0.1.2"; -pub const ENVIRONMENT_CREATED: &str = "dev.cdevents.environment.created.0.1.1"; -pub const ENVIRONMENT_DELETED: &str = "dev.cdevents.environment.deleted.0.1.1"; -pub const ENVIRONMENT_MODIFIED: &str = "dev.cdevents.environment.modified.0.1.1"; -pub const INCIDENT_DETECTED: &str = "dev.cdevents.incident.detected.0.1.0"; -pub const INCIDENT_REPORTED: &str = "dev.cdevents.incident.reported.0.1.0"; -pub const INCIDENT_RESOLVED: &str = "dev.cdevents.incident.resolved.0.1.0"; -pub const PIPELINERUN_FINISHED: &str = "dev.cdevents.pipelinerun.finished.0.1.1"; -pub const PIPELINERUN_QUEUED: &str = "dev.cdevents.pipelinerun.queued.0.1.1"; -pub const PIPELINERUN_STARTED: &str = "dev.cdevents.pipelinerun.started.0.1.1"; -pub const REPOSITORY_CREATED: &str = "dev.cdevents.repository.created.0.1.1"; -pub const REPOSITORY_DELETED: &str = "dev.cdevents.repository.deleted.0.1.1"; -pub const REPOSITORY_MODIFIED: &str = "dev.cdevents.repository.modified.0.1.1"; -pub const SERVICE_DEPLOYED: &str = "dev.cdevents.service.deployed.0.1.1"; -pub const SERVICE_PUBLISHED: &str = "dev.cdevents.service.published.0.1.1"; -pub const SERVICE_REMOVED: &str = "dev.cdevents.service.removed.0.1.1"; -pub const SERVICE_ROLLEDBACK: &str = "dev.cdevents.service.rolledback.0.1.1"; -pub const SERVICE_UPGRADED: &str = "dev.cdevents.service.upgraded.0.1.1"; -pub const TASKRUN_FINISHED: &str = "dev.cdevents.taskrun.finished.0.1.1"; -pub const TASKRUN_STARTED: &str = "dev.cdevents.taskrun.started.0.1.1"; -pub const TESTCASERUN_FINISHED: &str = "dev.cdevents.testcaserun.finished.0.1.0"; -pub const TESTCASERUN_QUEUED: &str = "dev.cdevents.testcaserun.queued.0.1.0"; -pub const TESTCASERUN_STARTED: &str = "dev.cdevents.testcaserun.started.0.1.0"; -pub const TESTOUTPUT_PUBLISHED: &str = "dev.cdevents.testoutput.published.0.1.0"; -pub const TESTSUITERUN_FINISHED: &str = "dev.cdevents.testsuiterun.finished.0.1.0"; -pub const TESTSUITERUN_QUEUED: &str = "dev.cdevents.testsuiterun.queued.0.1.0"; -pub const TESTSUITERUN_STARTED: &str = "dev.cdevents.testsuiterun.started.0.1.0"; +pub const ARTIFACT_PACKAGED_0_1_1: &str = "dev.cdevents.artifact.packaged.0.1.1"; +pub const ARTIFACT_PUBLISHED_0_1_1: &str = "dev.cdevents.artifact.published.0.1.1"; +pub const ARTIFACT_SIGNED_0_1_0: &str = "dev.cdevents.artifact.signed.0.1.0"; +pub const BRANCH_CREATED_0_1_2: &str = "dev.cdevents.branch.created.0.1.2"; +pub const BRANCH_DELETED_0_1_2: &str = "dev.cdevents.branch.deleted.0.1.2"; +pub const BUILD_FINISHED_0_1_1: &str = "dev.cdevents.build.finished.0.1.1"; +pub const BUILD_QUEUED_0_1_1: &str = "dev.cdevents.build.queued.0.1.1"; +pub const BUILD_STARTED_0_1_1: &str = "dev.cdevents.build.started.0.1.1"; +pub const CHANGE_ABANDONED_0_1_2: &str = "dev.cdevents.change.abandoned.0.1.2"; +pub const CHANGE_CREATED_0_2_0: &str = "dev.cdevents.change.created.0.2.0"; +pub const CHANGE_CREATED_0_1_2: &str = "dev.cdevents.change.created.0.1.2"; +pub const CHANGE_MERGED_0_1_2: &str = "dev.cdevents.change.merged.0.1.2"; +pub const CHANGE_REVIEWED_0_1_2: &str = "dev.cdevents.change.reviewed.0.1.2"; +pub const CHANGE_UPDATED_0_1_2: &str = "dev.cdevents.change.updated.0.1.2"; +pub const ENVIRONMENT_CREATED_0_1_1: &str = "dev.cdevents.environment.created.0.1.1"; +pub const ENVIRONMENT_DELETED_0_1_1: &str = "dev.cdevents.environment.deleted.0.1.1"; +pub const ENVIRONMENT_MODIFIED_0_1_1: &str = "dev.cdevents.environment.modified.0.1.1"; +pub const INCIDENT_DETECTED_0_1_0: &str = "dev.cdevents.incident.detected.0.1.0"; +pub const INCIDENT_REPORTED_0_1_0: &str = "dev.cdevents.incident.reported.0.1.0"; +pub const INCIDENT_RESOLVED_0_1_0: &str = "dev.cdevents.incident.resolved.0.1.0"; +pub const PIPELINERUN_FINISHED_0_1_1: &str = "dev.cdevents.pipelinerun.finished.0.1.1"; +pub const PIPELINERUN_QUEUED_0_1_1: &str = "dev.cdevents.pipelinerun.queued.0.1.1"; +pub const PIPELINERUN_STARTED_0_1_1: &str = "dev.cdevents.pipelinerun.started.0.1.1"; +pub const REPOSITORY_CREATED_0_1_1: &str = "dev.cdevents.repository.created.0.1.1"; +pub const REPOSITORY_DELETED_0_1_1: &str = "dev.cdevents.repository.deleted.0.1.1"; +pub const REPOSITORY_MODIFIED_0_1_1: &str = "dev.cdevents.repository.modified.0.1.1"; +pub const SERVICE_DEPLOYED_0_1_1: &str = "dev.cdevents.service.deployed.0.1.1"; +pub const SERVICE_PUBLISHED_0_1_1: &str = "dev.cdevents.service.published.0.1.1"; +pub const SERVICE_REMOVED_0_1_1: &str = "dev.cdevents.service.removed.0.1.1"; +pub const SERVICE_ROLLEDBACK_0_1_1: &str = "dev.cdevents.service.rolledback.0.1.1"; +pub const SERVICE_UPGRADED_0_1_1: &str = "dev.cdevents.service.upgraded.0.1.1"; +pub const TASKRUN_FINISHED_0_1_1: &str = "dev.cdevents.taskrun.finished.0.1.1"; +pub const TASKRUN_STARTED_0_1_1: &str = "dev.cdevents.taskrun.started.0.1.1"; +pub const TESTCASERUN_FINISHED_0_1_0: &str = "dev.cdevents.testcaserun.finished.0.1.0"; +pub const TESTCASERUN_QUEUED_0_1_0: &str = "dev.cdevents.testcaserun.queued.0.1.0"; +pub const TESTCASERUN_STARTED_0_1_0: &str = "dev.cdevents.testcaserun.started.0.1.0"; +pub const TESTOUTPUT_PUBLISHED_0_1_0: &str = "dev.cdevents.testoutput.published.0.1.0"; +pub const TESTSUITERUN_FINISHED_0_1_0: &str = "dev.cdevents.testsuiterun.finished.0.1.0"; +pub const TESTSUITERUN_QUEUED_0_1_0: &str = "dev.cdevents.testsuiterun.queued.0.1.0"; +pub const TESTSUITERUN_STARTED_0_1_0: &str = "dev.cdevents.testsuiterun.started.0.1.0"; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[serde(untagged)] // TODO how to use content of context.type as discriminator ? pub enum Content { - ArtifactPackaged(artifact_packaged::Content), - ArtifactPublished(artifact_published::Content), - ArtifactSigned(artifact_signed::Content), - BranchCreated(branch_created::Content), - BranchDeleted(branch_deleted::Content), - BuildFinished(build_finished::Content), - BuildQueued(build_queued::Content), - BuildStarted(build_started::Content), - ChangeAbandoned(change_abandoned::Content), - ChangeCreated(change_created::Content), - ChangeMerged(change_merged::Content), - ChangeReviewed(change_reviewed::Content), - ChangeUpdated(change_updated::Content), - EnvironmentCreated(environment_created::Content), - EnvironmentDeleted(environment_deleted::Content), - EnvironmentModified(environment_modified::Content), - IncidentDetected(incident_detected::Content), - IncidentReported(incident_reported::Content), - IncidentResolved(incident_resolved::Content), - PipelinerunFinished(pipelinerun_finished::Content), - PipelinerunQueued(pipelinerun_queued::Content), - PipelinerunStarted(pipelinerun_started::Content), - RepositoryCreated(repository_created::Content), - RepositoryDeleted(repository_deleted::Content), - RepositoryModified(repository_modified::Content), - ServiceDeployed(service_deployed::Content), - ServicePublished(service_published::Content), - ServiceRemoved(service_removed::Content), - ServiceRolledback(service_rolledback::Content), - ServiceUpgraded(service_upgraded::Content), - TaskrunFinished(taskrun_finished::Content), - TaskrunStarted(taskrun_started::Content), - TestcaserunFinished(testcaserun_finished::Content), - TestcaserunQueued(testcaserun_queued::Content), - TestcaserunStarted(testcaserun_started::Content), - TestoutputPublished(testoutput_published::Content), - TestsuiterunFinished(testsuiterun_finished::Content), - TestsuiterunQueued(testsuiterun_queued::Content), - TestsuiterunStarted(testsuiterun_started::Content), + ArtifactPackaged011(artifact_packaged_0_1_1::Content), + ArtifactPublished011(artifact_published_0_1_1::Content), + ArtifactSigned010(artifact_signed_0_1_0::Content), + BranchCreated012(branch_created_0_1_2::Content), + BranchDeleted012(branch_deleted_0_1_2::Content), + BuildFinished011(build_finished_0_1_1::Content), + BuildQueued011(build_queued_0_1_1::Content), + BuildStarted011(build_started_0_1_1::Content), + ChangeAbandoned012(change_abandoned_0_1_2::Content), + ChangeCreated020(change_created_0_2_0::Content), + ChangeCreated012(change_created_0_1_2::Content), + ChangeMerged012(change_merged_0_1_2::Content), + ChangeReviewed012(change_reviewed_0_1_2::Content), + ChangeUpdated012(change_updated_0_1_2::Content), + EnvironmentCreated011(environment_created_0_1_1::Content), + EnvironmentDeleted011(environment_deleted_0_1_1::Content), + EnvironmentModified011(environment_modified_0_1_1::Content), + IncidentDetected010(incident_detected_0_1_0::Content), + IncidentReported010(incident_reported_0_1_0::Content), + IncidentResolved010(incident_resolved_0_1_0::Content), + PipelinerunFinished011(pipelinerun_finished_0_1_1::Content), + PipelinerunQueued011(pipelinerun_queued_0_1_1::Content), + PipelinerunStarted011(pipelinerun_started_0_1_1::Content), + RepositoryCreated011(repository_created_0_1_1::Content), + RepositoryDeleted011(repository_deleted_0_1_1::Content), + RepositoryModified011(repository_modified_0_1_1::Content), + ServiceDeployed011(service_deployed_0_1_1::Content), + ServicePublished011(service_published_0_1_1::Content), + ServiceRemoved011(service_removed_0_1_1::Content), + ServiceRolledback011(service_rolledback_0_1_1::Content), + ServiceUpgraded011(service_upgraded_0_1_1::Content), + TaskrunFinished011(taskrun_finished_0_1_1::Content), + TaskrunStarted011(taskrun_started_0_1_1::Content), + TestcaserunFinished010(testcaserun_finished_0_1_0::Content), + TestcaserunQueued010(testcaserun_queued_0_1_0::Content), + TestcaserunStarted010(testcaserun_started_0_1_0::Content), + TestoutputPublished010(testoutput_published_0_1_0::Content), + TestsuiterunFinished010(testsuiterun_finished_0_1_0::Content), + TestsuiterunQueued010(testsuiterun_queued_0_1_0::Content), + TestsuiterunStarted010(testsuiterun_started_0_1_0::Content), } impl Content { pub fn from_json(ty: &str, json: serde_json::Value) -> Result{ match ty { - ARTIFACT_PACKAGED => { - let variant: artifact_packaged::Content = serde_json::from_value(json)?; + ARTIFACT_PACKAGED_0_1_1 => { + let variant: artifact_packaged_0_1_1::Content = serde_json::from_value(json)?; + Ok(variant.into()) + }, + ARTIFACT_PUBLISHED_0_1_1 => { + let variant: artifact_published_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - ARTIFACT_PUBLISHED => { - let variant: artifact_published::Content = serde_json::from_value(json)?; + ARTIFACT_SIGNED_0_1_0 => { + let variant: artifact_signed_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - ARTIFACT_SIGNED => { - let variant: artifact_signed::Content = serde_json::from_value(json)?; + BRANCH_CREATED_0_1_2 => { + let variant: branch_created_0_1_2::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - BRANCH_CREATED => { - let variant: branch_created::Content = serde_json::from_value(json)?; + BRANCH_DELETED_0_1_2 => { + let variant: branch_deleted_0_1_2::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - BRANCH_DELETED => { - let variant: branch_deleted::Content = serde_json::from_value(json)?; + BUILD_FINISHED_0_1_1 => { + let variant: build_finished_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - BUILD_FINISHED => { - let variant: build_finished::Content = serde_json::from_value(json)?; + BUILD_QUEUED_0_1_1 => { + let variant: build_queued_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - BUILD_QUEUED => { - let variant: build_queued::Content = serde_json::from_value(json)?; + BUILD_STARTED_0_1_1 => { + let variant: build_started_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - BUILD_STARTED => { - let variant: build_started::Content = serde_json::from_value(json)?; + CHANGE_ABANDONED_0_1_2 => { + let variant: change_abandoned_0_1_2::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - CHANGE_ABANDONED => { - let variant: change_abandoned::Content = serde_json::from_value(json)?; + CHANGE_CREATED_0_2_0 => { + let variant: change_created_0_2_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - CHANGE_CREATED => { - let variant: change_created::Content = serde_json::from_value(json)?; + CHANGE_CREATED_0_1_2 => { + let variant: change_created_0_1_2::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - CHANGE_MERGED => { - let variant: change_merged::Content = serde_json::from_value(json)?; + CHANGE_MERGED_0_1_2 => { + let variant: change_merged_0_1_2::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - CHANGE_REVIEWED => { - let variant: change_reviewed::Content = serde_json::from_value(json)?; + CHANGE_REVIEWED_0_1_2 => { + let variant: change_reviewed_0_1_2::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - CHANGE_UPDATED => { - let variant: change_updated::Content = serde_json::from_value(json)?; + CHANGE_UPDATED_0_1_2 => { + let variant: change_updated_0_1_2::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - ENVIRONMENT_CREATED => { - let variant: environment_created::Content = serde_json::from_value(json)?; + ENVIRONMENT_CREATED_0_1_1 => { + let variant: environment_created_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - ENVIRONMENT_DELETED => { - let variant: environment_deleted::Content = serde_json::from_value(json)?; + ENVIRONMENT_DELETED_0_1_1 => { + let variant: environment_deleted_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - ENVIRONMENT_MODIFIED => { - let variant: environment_modified::Content = serde_json::from_value(json)?; + ENVIRONMENT_MODIFIED_0_1_1 => { + let variant: environment_modified_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - INCIDENT_DETECTED => { - let variant: incident_detected::Content = serde_json::from_value(json)?; + INCIDENT_DETECTED_0_1_0 => { + let variant: incident_detected_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - INCIDENT_REPORTED => { - let variant: incident_reported::Content = serde_json::from_value(json)?; + INCIDENT_REPORTED_0_1_0 => { + let variant: incident_reported_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - INCIDENT_RESOLVED => { - let variant: incident_resolved::Content = serde_json::from_value(json)?; + INCIDENT_RESOLVED_0_1_0 => { + let variant: incident_resolved_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - PIPELINERUN_FINISHED => { - let variant: pipelinerun_finished::Content = serde_json::from_value(json)?; + PIPELINERUN_FINISHED_0_1_1 => { + let variant: pipelinerun_finished_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - PIPELINERUN_QUEUED => { - let variant: pipelinerun_queued::Content = serde_json::from_value(json)?; + PIPELINERUN_QUEUED_0_1_1 => { + let variant: pipelinerun_queued_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - PIPELINERUN_STARTED => { - let variant: pipelinerun_started::Content = serde_json::from_value(json)?; + PIPELINERUN_STARTED_0_1_1 => { + let variant: pipelinerun_started_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - REPOSITORY_CREATED => { - let variant: repository_created::Content = serde_json::from_value(json)?; + REPOSITORY_CREATED_0_1_1 => { + let variant: repository_created_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - REPOSITORY_DELETED => { - let variant: repository_deleted::Content = serde_json::from_value(json)?; + REPOSITORY_DELETED_0_1_1 => { + let variant: repository_deleted_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - REPOSITORY_MODIFIED => { - let variant: repository_modified::Content = serde_json::from_value(json)?; + REPOSITORY_MODIFIED_0_1_1 => { + let variant: repository_modified_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - SERVICE_DEPLOYED => { - let variant: service_deployed::Content = serde_json::from_value(json)?; + SERVICE_DEPLOYED_0_1_1 => { + let variant: service_deployed_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - SERVICE_PUBLISHED => { - let variant: service_published::Content = serde_json::from_value(json)?; + SERVICE_PUBLISHED_0_1_1 => { + let variant: service_published_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - SERVICE_REMOVED => { - let variant: service_removed::Content = serde_json::from_value(json)?; + SERVICE_REMOVED_0_1_1 => { + let variant: service_removed_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - SERVICE_ROLLEDBACK => { - let variant: service_rolledback::Content = serde_json::from_value(json)?; + SERVICE_ROLLEDBACK_0_1_1 => { + let variant: service_rolledback_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - SERVICE_UPGRADED => { - let variant: service_upgraded::Content = serde_json::from_value(json)?; + SERVICE_UPGRADED_0_1_1 => { + let variant: service_upgraded_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - TASKRUN_FINISHED => { - let variant: taskrun_finished::Content = serde_json::from_value(json)?; + TASKRUN_FINISHED_0_1_1 => { + let variant: taskrun_finished_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - TASKRUN_STARTED => { - let variant: taskrun_started::Content = serde_json::from_value(json)?; + TASKRUN_STARTED_0_1_1 => { + let variant: taskrun_started_0_1_1::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - TESTCASERUN_FINISHED => { - let variant: testcaserun_finished::Content = serde_json::from_value(json)?; + TESTCASERUN_FINISHED_0_1_0 => { + let variant: testcaserun_finished_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - TESTCASERUN_QUEUED => { - let variant: testcaserun_queued::Content = serde_json::from_value(json)?; + TESTCASERUN_QUEUED_0_1_0 => { + let variant: testcaserun_queued_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - TESTCASERUN_STARTED => { - let variant: testcaserun_started::Content = serde_json::from_value(json)?; + TESTCASERUN_STARTED_0_1_0 => { + let variant: testcaserun_started_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - TESTOUTPUT_PUBLISHED => { - let variant: testoutput_published::Content = serde_json::from_value(json)?; + TESTOUTPUT_PUBLISHED_0_1_0 => { + let variant: testoutput_published_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - TESTSUITERUN_FINISHED => { - let variant: testsuiterun_finished::Content = serde_json::from_value(json)?; + TESTSUITERUN_FINISHED_0_1_0 => { + let variant: testsuiterun_finished_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - TESTSUITERUN_QUEUED => { - let variant: testsuiterun_queued::Content = serde_json::from_value(json)?; + TESTSUITERUN_QUEUED_0_1_0 => { + let variant: testsuiterun_queued_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, - TESTSUITERUN_STARTED => { - let variant: testsuiterun_started::Content = serde_json::from_value(json)?; + TESTSUITERUN_STARTED_0_1_0 => { + let variant: testsuiterun_started_0_1_0::Content = serde_json::from_value(json)?; Ok(variant.into()) }, variant => Err(serde_json::Error::custom(format_args!( @@ -297,133 +424,136 @@ impl Content { pub fn ty(&self) -> &'static str { match self { - Self::ArtifactPackaged(_) => ARTIFACT_PACKAGED, - Self::ArtifactPublished(_) => ARTIFACT_PUBLISHED, - Self::ArtifactSigned(_) => ARTIFACT_SIGNED, - Self::BranchCreated(_) => BRANCH_CREATED, - Self::BranchDeleted(_) => BRANCH_DELETED, - Self::BuildFinished(_) => BUILD_FINISHED, - Self::BuildQueued(_) => BUILD_QUEUED, - Self::BuildStarted(_) => BUILD_STARTED, - Self::ChangeAbandoned(_) => CHANGE_ABANDONED, - Self::ChangeCreated(_) => CHANGE_CREATED, - Self::ChangeMerged(_) => CHANGE_MERGED, - Self::ChangeReviewed(_) => CHANGE_REVIEWED, - Self::ChangeUpdated(_) => CHANGE_UPDATED, - Self::EnvironmentCreated(_) => ENVIRONMENT_CREATED, - Self::EnvironmentDeleted(_) => ENVIRONMENT_DELETED, - Self::EnvironmentModified(_) => ENVIRONMENT_MODIFIED, - Self::IncidentDetected(_) => INCIDENT_DETECTED, - Self::IncidentReported(_) => INCIDENT_REPORTED, - Self::IncidentResolved(_) => INCIDENT_RESOLVED, - Self::PipelinerunFinished(_) => PIPELINERUN_FINISHED, - Self::PipelinerunQueued(_) => PIPELINERUN_QUEUED, - Self::PipelinerunStarted(_) => PIPELINERUN_STARTED, - Self::RepositoryCreated(_) => REPOSITORY_CREATED, - Self::RepositoryDeleted(_) => REPOSITORY_DELETED, - Self::RepositoryModified(_) => REPOSITORY_MODIFIED, - Self::ServiceDeployed(_) => SERVICE_DEPLOYED, - Self::ServicePublished(_) => SERVICE_PUBLISHED, - Self::ServiceRemoved(_) => SERVICE_REMOVED, - Self::ServiceRolledback(_) => SERVICE_ROLLEDBACK, - Self::ServiceUpgraded(_) => SERVICE_UPGRADED, - Self::TaskrunFinished(_) => TASKRUN_FINISHED, - Self::TaskrunStarted(_) => TASKRUN_STARTED, - Self::TestcaserunFinished(_) => TESTCASERUN_FINISHED, - Self::TestcaserunQueued(_) => TESTCASERUN_QUEUED, - Self::TestcaserunStarted(_) => TESTCASERUN_STARTED, - Self::TestoutputPublished(_) => TESTOUTPUT_PUBLISHED, - Self::TestsuiterunFinished(_) => TESTSUITERUN_FINISHED, - Self::TestsuiterunQueued(_) => TESTSUITERUN_QUEUED, - Self::TestsuiterunStarted(_) => TESTSUITERUN_STARTED, + Self::ArtifactPackaged011(_) => ARTIFACT_PACKAGED_0_1_1, + Self::ArtifactPublished011(_) => ARTIFACT_PUBLISHED_0_1_1, + Self::ArtifactSigned010(_) => ARTIFACT_SIGNED_0_1_0, + Self::BranchCreated012(_) => BRANCH_CREATED_0_1_2, + Self::BranchDeleted012(_) => BRANCH_DELETED_0_1_2, + Self::BuildFinished011(_) => BUILD_FINISHED_0_1_1, + Self::BuildQueued011(_) => BUILD_QUEUED_0_1_1, + Self::BuildStarted011(_) => BUILD_STARTED_0_1_1, + Self::ChangeAbandoned012(_) => CHANGE_ABANDONED_0_1_2, + Self::ChangeCreated020(_) => CHANGE_CREATED_0_2_0, + Self::ChangeCreated012(_) => CHANGE_CREATED_0_1_2, + Self::ChangeMerged012(_) => CHANGE_MERGED_0_1_2, + Self::ChangeReviewed012(_) => CHANGE_REVIEWED_0_1_2, + Self::ChangeUpdated012(_) => CHANGE_UPDATED_0_1_2, + Self::EnvironmentCreated011(_) => ENVIRONMENT_CREATED_0_1_1, + Self::EnvironmentDeleted011(_) => ENVIRONMENT_DELETED_0_1_1, + Self::EnvironmentModified011(_) => ENVIRONMENT_MODIFIED_0_1_1, + Self::IncidentDetected010(_) => INCIDENT_DETECTED_0_1_0, + Self::IncidentReported010(_) => INCIDENT_REPORTED_0_1_0, + Self::IncidentResolved010(_) => INCIDENT_RESOLVED_0_1_0, + Self::PipelinerunFinished011(_) => PIPELINERUN_FINISHED_0_1_1, + Self::PipelinerunQueued011(_) => PIPELINERUN_QUEUED_0_1_1, + Self::PipelinerunStarted011(_) => PIPELINERUN_STARTED_0_1_1, + Self::RepositoryCreated011(_) => REPOSITORY_CREATED_0_1_1, + Self::RepositoryDeleted011(_) => REPOSITORY_DELETED_0_1_1, + Self::RepositoryModified011(_) => REPOSITORY_MODIFIED_0_1_1, + Self::ServiceDeployed011(_) => SERVICE_DEPLOYED_0_1_1, + Self::ServicePublished011(_) => SERVICE_PUBLISHED_0_1_1, + Self::ServiceRemoved011(_) => SERVICE_REMOVED_0_1_1, + Self::ServiceRolledback011(_) => SERVICE_ROLLEDBACK_0_1_1, + Self::ServiceUpgraded011(_) => SERVICE_UPGRADED_0_1_1, + Self::TaskrunFinished011(_) => TASKRUN_FINISHED_0_1_1, + Self::TaskrunStarted011(_) => TASKRUN_STARTED_0_1_1, + Self::TestcaserunFinished010(_) => TESTCASERUN_FINISHED_0_1_0, + Self::TestcaserunQueued010(_) => TESTCASERUN_QUEUED_0_1_0, + Self::TestcaserunStarted010(_) => TESTCASERUN_STARTED_0_1_0, + Self::TestoutputPublished010(_) => TESTOUTPUT_PUBLISHED_0_1_0, + Self::TestsuiterunFinished010(_) => TESTSUITERUN_FINISHED_0_1_0, + Self::TestsuiterunQueued010(_) => TESTSUITERUN_QUEUED_0_1_0, + Self::TestsuiterunStarted010(_) => TESTSUITERUN_STARTED_0_1_0, } } pub fn subject(&self) -> &'static str { match self { - Self::ArtifactPackaged(_) => "artifact", - Self::ArtifactPublished(_) => "artifact", - Self::ArtifactSigned(_) => "artifact", - Self::BranchCreated(_) => "branch", - Self::BranchDeleted(_) => "branch", - Self::BuildFinished(_) => "build", - Self::BuildQueued(_) => "build", - Self::BuildStarted(_) => "build", - Self::ChangeAbandoned(_) => "change", - Self::ChangeCreated(_) => "change", - Self::ChangeMerged(_) => "change", - Self::ChangeReviewed(_) => "change", - Self::ChangeUpdated(_) => "change", - Self::EnvironmentCreated(_) => "environment", - Self::EnvironmentDeleted(_) => "environment", - Self::EnvironmentModified(_) => "environment", - Self::IncidentDetected(_) => "incident", - Self::IncidentReported(_) => "incident", - Self::IncidentResolved(_) => "incident", - Self::PipelinerunFinished(_) => "pipelineRun", - Self::PipelinerunQueued(_) => "pipelineRun", - Self::PipelinerunStarted(_) => "pipelineRun", - Self::RepositoryCreated(_) => "repository", - Self::RepositoryDeleted(_) => "repository", - Self::RepositoryModified(_) => "repository", - Self::ServiceDeployed(_) => "service", - Self::ServicePublished(_) => "service", - Self::ServiceRemoved(_) => "service", - Self::ServiceRolledback(_) => "service", - Self::ServiceUpgraded(_) => "service", - Self::TaskrunFinished(_) => "taskRun", - Self::TaskrunStarted(_) => "taskRun", - Self::TestcaserunFinished(_) => "testCaseRun", - Self::TestcaserunQueued(_) => "testCaseRun", - Self::TestcaserunStarted(_) => "testCaseRun", - Self::TestoutputPublished(_) => "testOutput", - Self::TestsuiterunFinished(_) => "testSuiteRun", - Self::TestsuiterunQueued(_) => "testSuiteRun", - Self::TestsuiterunStarted(_) => "testSuiteRun", + Self::ArtifactPackaged011(_) => "artifact", + Self::ArtifactPublished011(_) => "artifact", + Self::ArtifactSigned010(_) => "artifact", + Self::BranchCreated012(_) => "branch", + Self::BranchDeleted012(_) => "branch", + Self::BuildFinished011(_) => "build", + Self::BuildQueued011(_) => "build", + Self::BuildStarted011(_) => "build", + Self::ChangeAbandoned012(_) => "change", + Self::ChangeCreated020(_) => "change", + Self::ChangeCreated012(_) => "change", + Self::ChangeMerged012(_) => "change", + Self::ChangeReviewed012(_) => "change", + Self::ChangeUpdated012(_) => "change", + Self::EnvironmentCreated011(_) => "environment", + Self::EnvironmentDeleted011(_) => "environment", + Self::EnvironmentModified011(_) => "environment", + Self::IncidentDetected010(_) => "incident", + Self::IncidentReported010(_) => "incident", + Self::IncidentResolved010(_) => "incident", + Self::PipelinerunFinished011(_) => "pipelineRun", + Self::PipelinerunQueued011(_) => "pipelineRun", + Self::PipelinerunStarted011(_) => "pipelineRun", + Self::RepositoryCreated011(_) => "repository", + Self::RepositoryDeleted011(_) => "repository", + Self::RepositoryModified011(_) => "repository", + Self::ServiceDeployed011(_) => "service", + Self::ServicePublished011(_) => "service", + Self::ServiceRemoved011(_) => "service", + Self::ServiceRolledback011(_) => "service", + Self::ServiceUpgraded011(_) => "service", + Self::TaskrunFinished011(_) => "taskRun", + Self::TaskrunStarted011(_) => "taskRun", + Self::TestcaserunFinished010(_) => "testCaseRun", + Self::TestcaserunQueued010(_) => "testCaseRun", + Self::TestcaserunStarted010(_) => "testCaseRun", + Self::TestoutputPublished010(_) => "testOutput", + Self::TestsuiterunFinished010(_) => "testSuiteRun", + Self::TestsuiterunQueued010(_) => "testSuiteRun", + Self::TestsuiterunStarted010(_) => "testSuiteRun", } } pub fn predicate(&self) -> &'static str { match self { - Self::ArtifactPackaged(_) => "packaged", - Self::ArtifactPublished(_) => "published", - Self::ArtifactSigned(_) => "signed", - Self::BranchCreated(_) => "created", - Self::BranchDeleted(_) => "deleted", - Self::BuildFinished(_) => "finished", - Self::BuildQueued(_) => "queued", - Self::BuildStarted(_) => "started", - Self::ChangeAbandoned(_) => "abandoned", - Self::ChangeCreated(_) => "created", - Self::ChangeMerged(_) => "merged", - Self::ChangeReviewed(_) => "reviewed", - Self::ChangeUpdated(_) => "updated", - Self::EnvironmentCreated(_) => "created", - Self::EnvironmentDeleted(_) => "deleted", - Self::EnvironmentModified(_) => "modified", - Self::IncidentDetected(_) => "detected", - Self::IncidentReported(_) => "reported", - Self::IncidentResolved(_) => "resolved", - Self::PipelinerunFinished(_) => "finished", - Self::PipelinerunQueued(_) => "queued", - Self::PipelinerunStarted(_) => "started", - Self::RepositoryCreated(_) => "created", - Self::RepositoryDeleted(_) => "deleted", - Self::RepositoryModified(_) => "modified", - Self::ServiceDeployed(_) => "deployed", - Self::ServicePublished(_) => "published", - Self::ServiceRemoved(_) => "removed", - Self::ServiceRolledback(_) => "rolledback", - Self::ServiceUpgraded(_) => "upgraded", - Self::TaskrunFinished(_) => "finished", - Self::TaskrunStarted(_) => "started", - Self::TestcaserunFinished(_) => "finished", - Self::TestcaserunQueued(_) => "queued", - Self::TestcaserunStarted(_) => "started", - Self::TestoutputPublished(_) => "published", - Self::TestsuiterunFinished(_) => "finished", - Self::TestsuiterunQueued(_) => "queued", - Self::TestsuiterunStarted(_) => "started", + Self::ArtifactPackaged011(_) => "packaged", + Self::ArtifactPublished011(_) => "published", + Self::ArtifactSigned010(_) => "signed", + Self::BranchCreated012(_) => "created", + Self::BranchDeleted012(_) => "deleted", + Self::BuildFinished011(_) => "finished", + Self::BuildQueued011(_) => "queued", + Self::BuildStarted011(_) => "started", + Self::ChangeAbandoned012(_) => "abandoned", + Self::ChangeCreated020(_) => "created", + Self::ChangeCreated012(_) => "created", + Self::ChangeMerged012(_) => "merged", + Self::ChangeReviewed012(_) => "reviewed", + Self::ChangeUpdated012(_) => "updated", + Self::EnvironmentCreated011(_) => "created", + Self::EnvironmentDeleted011(_) => "deleted", + Self::EnvironmentModified011(_) => "modified", + Self::IncidentDetected010(_) => "detected", + Self::IncidentReported010(_) => "reported", + Self::IncidentResolved010(_) => "resolved", + Self::PipelinerunFinished011(_) => "finished", + Self::PipelinerunQueued011(_) => "queued", + Self::PipelinerunStarted011(_) => "started", + Self::RepositoryCreated011(_) => "created", + Self::RepositoryDeleted011(_) => "deleted", + Self::RepositoryModified011(_) => "modified", + Self::ServiceDeployed011(_) => "deployed", + Self::ServicePublished011(_) => "published", + Self::ServiceRemoved011(_) => "removed", + Self::ServiceRolledback011(_) => "rolledback", + Self::ServiceUpgraded011(_) => "upgraded", + Self::TaskrunFinished011(_) => "finished", + Self::TaskrunStarted011(_) => "started", + Self::TestcaserunFinished010(_) => "finished", + Self::TestcaserunQueued010(_) => "queued", + Self::TestcaserunStarted010(_) => "started", + Self::TestoutputPublished010(_) => "published", + Self::TestsuiterunFinished010(_) => "finished", + Self::TestsuiterunQueued010(_) => "queued", + Self::TestsuiterunStarted010(_) => "started", } } } @@ -432,242 +562,248 @@ impl Content { pub fn extract_subject_predicate(ty: &str) -> Option<(&str, &str)>{ // let mut split = ty.split('.'); match ty { - ARTIFACT_PACKAGED => Some(("artifact", "packaged")), - ARTIFACT_PUBLISHED => Some(("artifact", "published")), - ARTIFACT_SIGNED => Some(("artifact", "signed")), - BRANCH_CREATED => Some(("branch", "created")), - BRANCH_DELETED => Some(("branch", "deleted")), - BUILD_FINISHED => Some(("build", "finished")), - BUILD_QUEUED => Some(("build", "queued")), - BUILD_STARTED => Some(("build", "started")), - CHANGE_ABANDONED => Some(("change", "abandoned")), - CHANGE_CREATED => Some(("change", "created")), - CHANGE_MERGED => Some(("change", "merged")), - CHANGE_REVIEWED => Some(("change", "reviewed")), - CHANGE_UPDATED => Some(("change", "updated")), - ENVIRONMENT_CREATED => Some(("environment", "created")), - ENVIRONMENT_DELETED => Some(("environment", "deleted")), - ENVIRONMENT_MODIFIED => Some(("environment", "modified")), - INCIDENT_DETECTED => Some(("incident", "detected")), - INCIDENT_REPORTED => Some(("incident", "reported")), - INCIDENT_RESOLVED => Some(("incident", "resolved")), - PIPELINERUN_FINISHED => Some(("pipelineRun", "finished")), - PIPELINERUN_QUEUED => Some(("pipelineRun", "queued")), - PIPELINERUN_STARTED => Some(("pipelineRun", "started")), - REPOSITORY_CREATED => Some(("repository", "created")), - REPOSITORY_DELETED => Some(("repository", "deleted")), - REPOSITORY_MODIFIED => Some(("repository", "modified")), - SERVICE_DEPLOYED => Some(("service", "deployed")), - SERVICE_PUBLISHED => Some(("service", "published")), - SERVICE_REMOVED => Some(("service", "removed")), - SERVICE_ROLLEDBACK => Some(("service", "rolledback")), - SERVICE_UPGRADED => Some(("service", "upgraded")), - TASKRUN_FINISHED => Some(("taskRun", "finished")), - TASKRUN_STARTED => Some(("taskRun", "started")), - TESTCASERUN_FINISHED => Some(("testCaseRun", "finished")), - TESTCASERUN_QUEUED => Some(("testCaseRun", "queued")), - TESTCASERUN_STARTED => Some(("testCaseRun", "started")), - TESTOUTPUT_PUBLISHED => Some(("testOutput", "published")), - TESTSUITERUN_FINISHED => Some(("testSuiteRun", "finished")), - TESTSUITERUN_QUEUED => Some(("testSuiteRun", "queued")), - TESTSUITERUN_STARTED => Some(("testSuiteRun", "started")), + ARTIFACT_PACKAGED_0_1_1 => Some(("artifact", "packaged")), + ARTIFACT_PUBLISHED_0_1_1 => Some(("artifact", "published")), + ARTIFACT_SIGNED_0_1_0 => Some(("artifact", "signed")), + BRANCH_CREATED_0_1_2 => Some(("branch", "created")), + BRANCH_DELETED_0_1_2 => Some(("branch", "deleted")), + BUILD_FINISHED_0_1_1 => Some(("build", "finished")), + BUILD_QUEUED_0_1_1 => Some(("build", "queued")), + BUILD_STARTED_0_1_1 => Some(("build", "started")), + CHANGE_ABANDONED_0_1_2 => Some(("change", "abandoned")), + CHANGE_CREATED_0_2_0 => Some(("change", "created")), + CHANGE_CREATED_0_1_2 => Some(("change", "created")), + CHANGE_MERGED_0_1_2 => Some(("change", "merged")), + CHANGE_REVIEWED_0_1_2 => Some(("change", "reviewed")), + CHANGE_UPDATED_0_1_2 => Some(("change", "updated")), + ENVIRONMENT_CREATED_0_1_1 => Some(("environment", "created")), + ENVIRONMENT_DELETED_0_1_1 => Some(("environment", "deleted")), + ENVIRONMENT_MODIFIED_0_1_1 => Some(("environment", "modified")), + INCIDENT_DETECTED_0_1_0 => Some(("incident", "detected")), + INCIDENT_REPORTED_0_1_0 => Some(("incident", "reported")), + INCIDENT_RESOLVED_0_1_0 => Some(("incident", "resolved")), + PIPELINERUN_FINISHED_0_1_1 => Some(("pipelineRun", "finished")), + PIPELINERUN_QUEUED_0_1_1 => Some(("pipelineRun", "queued")), + PIPELINERUN_STARTED_0_1_1 => Some(("pipelineRun", "started")), + REPOSITORY_CREATED_0_1_1 => Some(("repository", "created")), + REPOSITORY_DELETED_0_1_1 => Some(("repository", "deleted")), + REPOSITORY_MODIFIED_0_1_1 => Some(("repository", "modified")), + SERVICE_DEPLOYED_0_1_1 => Some(("service", "deployed")), + SERVICE_PUBLISHED_0_1_1 => Some(("service", "published")), + SERVICE_REMOVED_0_1_1 => Some(("service", "removed")), + SERVICE_ROLLEDBACK_0_1_1 => Some(("service", "rolledback")), + SERVICE_UPGRADED_0_1_1 => Some(("service", "upgraded")), + TASKRUN_FINISHED_0_1_1 => Some(("taskRun", "finished")), + TASKRUN_STARTED_0_1_1 => Some(("taskRun", "started")), + TESTCASERUN_FINISHED_0_1_0 => Some(("testCaseRun", "finished")), + TESTCASERUN_QUEUED_0_1_0 => Some(("testCaseRun", "queued")), + TESTCASERUN_STARTED_0_1_0 => Some(("testCaseRun", "started")), + TESTOUTPUT_PUBLISHED_0_1_0 => Some(("testOutput", "published")), + TESTSUITERUN_FINISHED_0_1_0 => Some(("testSuiteRun", "finished")), + TESTSUITERUN_QUEUED_0_1_0 => Some(("testSuiteRun", "queued")), + TESTSUITERUN_STARTED_0_1_0 => Some(("testSuiteRun", "started")), _ => None, } } -impl From for Content { - fn from(value: artifact_packaged::Content) -> Self { - Self::ArtifactPackaged(value) +impl From for Content { + fn from(value: artifact_packaged_0_1_1::Content) -> Self { + Self::ArtifactPackaged011(value) } } -impl From for Content { - fn from(value: artifact_published::Content) -> Self { - Self::ArtifactPublished(value) +impl From for Content { + fn from(value: artifact_published_0_1_1::Content) -> Self { + Self::ArtifactPublished011(value) } } -impl From for Content { - fn from(value: artifact_signed::Content) -> Self { - Self::ArtifactSigned(value) +impl From for Content { + fn from(value: artifact_signed_0_1_0::Content) -> Self { + Self::ArtifactSigned010(value) } } -impl From for Content { - fn from(value: branch_created::Content) -> Self { - Self::BranchCreated(value) +impl From for Content { + fn from(value: branch_created_0_1_2::Content) -> Self { + Self::BranchCreated012(value) } } -impl From for Content { - fn from(value: branch_deleted::Content) -> Self { - Self::BranchDeleted(value) +impl From for Content { + fn from(value: branch_deleted_0_1_2::Content) -> Self { + Self::BranchDeleted012(value) } } -impl From for Content { - fn from(value: build_finished::Content) -> Self { - Self::BuildFinished(value) +impl From for Content { + fn from(value: build_finished_0_1_1::Content) -> Self { + Self::BuildFinished011(value) } } -impl From for Content { - fn from(value: build_queued::Content) -> Self { - Self::BuildQueued(value) +impl From for Content { + fn from(value: build_queued_0_1_1::Content) -> Self { + Self::BuildQueued011(value) } } -impl From for Content { - fn from(value: build_started::Content) -> Self { - Self::BuildStarted(value) +impl From for Content { + fn from(value: build_started_0_1_1::Content) -> Self { + Self::BuildStarted011(value) } } -impl From for Content { - fn from(value: change_abandoned::Content) -> Self { - Self::ChangeAbandoned(value) +impl From for Content { + fn from(value: change_abandoned_0_1_2::Content) -> Self { + Self::ChangeAbandoned012(value) } } -impl From for Content { - fn from(value: change_created::Content) -> Self { - Self::ChangeCreated(value) +impl From for Content { + fn from(value: change_created_0_2_0::Content) -> Self { + Self::ChangeCreated020(value) } } -impl From for Content { - fn from(value: change_merged::Content) -> Self { - Self::ChangeMerged(value) +impl From for Content { + fn from(value: change_created_0_1_2::Content) -> Self { + Self::ChangeCreated012(value) } } -impl From for Content { - fn from(value: change_reviewed::Content) -> Self { - Self::ChangeReviewed(value) +impl From for Content { + fn from(value: change_merged_0_1_2::Content) -> Self { + Self::ChangeMerged012(value) } } -impl From for Content { - fn from(value: change_updated::Content) -> Self { - Self::ChangeUpdated(value) +impl From for Content { + fn from(value: change_reviewed_0_1_2::Content) -> Self { + Self::ChangeReviewed012(value) } } -impl From for Content { - fn from(value: environment_created::Content) -> Self { - Self::EnvironmentCreated(value) +impl From for Content { + fn from(value: change_updated_0_1_2::Content) -> Self { + Self::ChangeUpdated012(value) } } -impl From for Content { - fn from(value: environment_deleted::Content) -> Self { - Self::EnvironmentDeleted(value) +impl From for Content { + fn from(value: environment_created_0_1_1::Content) -> Self { + Self::EnvironmentCreated011(value) } } -impl From for Content { - fn from(value: environment_modified::Content) -> Self { - Self::EnvironmentModified(value) +impl From for Content { + fn from(value: environment_deleted_0_1_1::Content) -> Self { + Self::EnvironmentDeleted011(value) } } -impl From for Content { - fn from(value: incident_detected::Content) -> Self { - Self::IncidentDetected(value) +impl From for Content { + fn from(value: environment_modified_0_1_1::Content) -> Self { + Self::EnvironmentModified011(value) } } -impl From for Content { - fn from(value: incident_reported::Content) -> Self { - Self::IncidentReported(value) +impl From for Content { + fn from(value: incident_detected_0_1_0::Content) -> Self { + Self::IncidentDetected010(value) } } -impl From for Content { - fn from(value: incident_resolved::Content) -> Self { - Self::IncidentResolved(value) +impl From for Content { + fn from(value: incident_reported_0_1_0::Content) -> Self { + Self::IncidentReported010(value) } } -impl From for Content { - fn from(value: pipelinerun_finished::Content) -> Self { - Self::PipelinerunFinished(value) +impl From for Content { + fn from(value: incident_resolved_0_1_0::Content) -> Self { + Self::IncidentResolved010(value) } } -impl From for Content { - fn from(value: pipelinerun_queued::Content) -> Self { - Self::PipelinerunQueued(value) +impl From for Content { + fn from(value: pipelinerun_finished_0_1_1::Content) -> Self { + Self::PipelinerunFinished011(value) } } -impl From for Content { - fn from(value: pipelinerun_started::Content) -> Self { - Self::PipelinerunStarted(value) +impl From for Content { + fn from(value: pipelinerun_queued_0_1_1::Content) -> Self { + Self::PipelinerunQueued011(value) } } -impl From for Content { - fn from(value: repository_created::Content) -> Self { - Self::RepositoryCreated(value) +impl From for Content { + fn from(value: pipelinerun_started_0_1_1::Content) -> Self { + Self::PipelinerunStarted011(value) } } -impl From for Content { - fn from(value: repository_deleted::Content) -> Self { - Self::RepositoryDeleted(value) +impl From for Content { + fn from(value: repository_created_0_1_1::Content) -> Self { + Self::RepositoryCreated011(value) } } -impl From for Content { - fn from(value: repository_modified::Content) -> Self { - Self::RepositoryModified(value) +impl From for Content { + fn from(value: repository_deleted_0_1_1::Content) -> Self { + Self::RepositoryDeleted011(value) } } -impl From for Content { - fn from(value: service_deployed::Content) -> Self { - Self::ServiceDeployed(value) +impl From for Content { + fn from(value: repository_modified_0_1_1::Content) -> Self { + Self::RepositoryModified011(value) } } -impl From for Content { - fn from(value: service_published::Content) -> Self { - Self::ServicePublished(value) +impl From for Content { + fn from(value: service_deployed_0_1_1::Content) -> Self { + Self::ServiceDeployed011(value) } } -impl From for Content { - fn from(value: service_removed::Content) -> Self { - Self::ServiceRemoved(value) +impl From for Content { + fn from(value: service_published_0_1_1::Content) -> Self { + Self::ServicePublished011(value) } } -impl From for Content { - fn from(value: service_rolledback::Content) -> Self { - Self::ServiceRolledback(value) +impl From for Content { + fn from(value: service_removed_0_1_1::Content) -> Self { + Self::ServiceRemoved011(value) } } -impl From for Content { - fn from(value: service_upgraded::Content) -> Self { - Self::ServiceUpgraded(value) +impl From for Content { + fn from(value: service_rolledback_0_1_1::Content) -> Self { + Self::ServiceRolledback011(value) } } -impl From for Content { - fn from(value: taskrun_finished::Content) -> Self { - Self::TaskrunFinished(value) +impl From for Content { + fn from(value: service_upgraded_0_1_1::Content) -> Self { + Self::ServiceUpgraded011(value) } } -impl From for Content { - fn from(value: taskrun_started::Content) -> Self { - Self::TaskrunStarted(value) +impl From for Content { + fn from(value: taskrun_finished_0_1_1::Content) -> Self { + Self::TaskrunFinished011(value) } } -impl From for Content { - fn from(value: testcaserun_finished::Content) -> Self { - Self::TestcaserunFinished(value) +impl From for Content { + fn from(value: taskrun_started_0_1_1::Content) -> Self { + Self::TaskrunStarted011(value) } } -impl From for Content { - fn from(value: testcaserun_queued::Content) -> Self { - Self::TestcaserunQueued(value) +impl From for Content { + fn from(value: testcaserun_finished_0_1_0::Content) -> Self { + Self::TestcaserunFinished010(value) } } -impl From for Content { - fn from(value: testcaserun_started::Content) -> Self { - Self::TestcaserunStarted(value) +impl From for Content { + fn from(value: testcaserun_queued_0_1_0::Content) -> Self { + Self::TestcaserunQueued010(value) } } -impl From for Content { - fn from(value: testoutput_published::Content) -> Self { - Self::TestoutputPublished(value) +impl From for Content { + fn from(value: testcaserun_started_0_1_0::Content) -> Self { + Self::TestcaserunStarted010(value) } } -impl From for Content { - fn from(value: testsuiterun_finished::Content) -> Self { - Self::TestsuiterunFinished(value) +impl From for Content { + fn from(value: testoutput_published_0_1_0::Content) -> Self { + Self::TestoutputPublished010(value) } } -impl From for Content { - fn from(value: testsuiterun_queued::Content) -> Self { - Self::TestsuiterunQueued(value) +impl From for Content { + fn from(value: testsuiterun_finished_0_1_0::Content) -> Self { + Self::TestsuiterunFinished010(value) } } -impl From for Content { - fn from(value: testsuiterun_started::Content) -> Self { - Self::TestsuiterunStarted(value) +impl From for Content { + fn from(value: testsuiterun_queued_0_1_0::Content) -> Self { + Self::TestsuiterunQueued010(value) + } +} +impl From for Content { + fn from(value: testsuiterun_started_0_1_0::Content) -> Self { + Self::TestsuiterunStarted010(value) } } @@ -679,45 +815,46 @@ impl<> proptest::arbitrary::Arbitrary for Content { fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { use proptest::prelude::*; prop_oneof![ - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), - any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), + any::().prop_map(Content::from), ].boxed() } } @@ -729,83 +866,85 @@ impl<> proptest::arbitrary::Arbitrary for Content { // #[test] // fn test_true() { // -// assert_eq!(extract_subject_predicate(ARTIFACT_PACKAGED), Some(("artifact","packaged"))); +// assert_eq!(extract_subject_predicate(ARTIFACT_PACKAGED_0_1_1), Some(("artifact","packaged"))); +// +// assert_eq!(extract_subject_predicate(ARTIFACT_PUBLISHED_0_1_1), Some(("artifact","published"))); // -// assert_eq!(extract_subject_predicate(ARTIFACT_PUBLISHED), Some(("artifact","published"))); +// assert_eq!(extract_subject_predicate(ARTIFACT_SIGNED_0_1_0), Some(("artifact","signed"))); // -// assert_eq!(extract_subject_predicate(ARTIFACT_SIGNED), Some(("artifact","signed"))); +// assert_eq!(extract_subject_predicate(BRANCH_CREATED_0_1_2), Some(("branch","created"))); // -// assert_eq!(extract_subject_predicate(BRANCH_CREATED), Some(("branch","created"))); +// assert_eq!(extract_subject_predicate(BRANCH_DELETED_0_1_2), Some(("branch","deleted"))); // -// assert_eq!(extract_subject_predicate(BRANCH_DELETED), Some(("branch","deleted"))); +// assert_eq!(extract_subject_predicate(BUILD_FINISHED_0_1_1), Some(("build","finished"))); // -// assert_eq!(extract_subject_predicate(BUILD_FINISHED), Some(("build","finished"))); +// assert_eq!(extract_subject_predicate(BUILD_QUEUED_0_1_1), Some(("build","queued"))); // -// assert_eq!(extract_subject_predicate(BUILD_QUEUED), Some(("build","queued"))); +// assert_eq!(extract_subject_predicate(BUILD_STARTED_0_1_1), Some(("build","started"))); // -// assert_eq!(extract_subject_predicate(BUILD_STARTED), Some(("build","started"))); +// assert_eq!(extract_subject_predicate(CHANGE_ABANDONED_0_1_2), Some(("change","abandoned"))); // -// assert_eq!(extract_subject_predicate(CHANGE_ABANDONED), Some(("change","abandoned"))); +// assert_eq!(extract_subject_predicate(CHANGE_CREATED_0_2_0), Some(("change","created"))); // -// assert_eq!(extract_subject_predicate(CHANGE_CREATED), Some(("change","created"))); +// assert_eq!(extract_subject_predicate(CHANGE_CREATED_0_1_2), Some(("change","created"))); // -// assert_eq!(extract_subject_predicate(CHANGE_MERGED), Some(("change","merged"))); +// assert_eq!(extract_subject_predicate(CHANGE_MERGED_0_1_2), Some(("change","merged"))); // -// assert_eq!(extract_subject_predicate(CHANGE_REVIEWED), Some(("change","reviewed"))); +// assert_eq!(extract_subject_predicate(CHANGE_REVIEWED_0_1_2), Some(("change","reviewed"))); // -// assert_eq!(extract_subject_predicate(CHANGE_UPDATED), Some(("change","updated"))); +// assert_eq!(extract_subject_predicate(CHANGE_UPDATED_0_1_2), Some(("change","updated"))); // -// assert_eq!(extract_subject_predicate(ENVIRONMENT_CREATED), Some(("environment","created"))); +// assert_eq!(extract_subject_predicate(ENVIRONMENT_CREATED_0_1_1), Some(("environment","created"))); // -// assert_eq!(extract_subject_predicate(ENVIRONMENT_DELETED), Some(("environment","deleted"))); +// assert_eq!(extract_subject_predicate(ENVIRONMENT_DELETED_0_1_1), Some(("environment","deleted"))); // -// assert_eq!(extract_subject_predicate(ENVIRONMENT_MODIFIED), Some(("environment","modified"))); +// assert_eq!(extract_subject_predicate(ENVIRONMENT_MODIFIED_0_1_1), Some(("environment","modified"))); // -// assert_eq!(extract_subject_predicate(INCIDENT_DETECTED), Some(("incident","detected"))); +// assert_eq!(extract_subject_predicate(INCIDENT_DETECTED_0_1_0), Some(("incident","detected"))); // -// assert_eq!(extract_subject_predicate(INCIDENT_REPORTED), Some(("incident","reported"))); +// assert_eq!(extract_subject_predicate(INCIDENT_REPORTED_0_1_0), Some(("incident","reported"))); // -// assert_eq!(extract_subject_predicate(INCIDENT_RESOLVED), Some(("incident","resolved"))); +// assert_eq!(extract_subject_predicate(INCIDENT_RESOLVED_0_1_0), Some(("incident","resolved"))); // -// assert_eq!(extract_subject_predicate(PIPELINERUN_FINISHED), Some(("pipelineRun","finished"))); +// assert_eq!(extract_subject_predicate(PIPELINERUN_FINISHED_0_1_1), Some(("pipelinerun","finished"))); // -// assert_eq!(extract_subject_predicate(PIPELINERUN_QUEUED), Some(("pipelineRun","queued"))); +// assert_eq!(extract_subject_predicate(PIPELINERUN_QUEUED_0_1_1), Some(("pipelinerun","queued"))); // -// assert_eq!(extract_subject_predicate(PIPELINERUN_STARTED), Some(("pipelineRun","started"))); +// assert_eq!(extract_subject_predicate(PIPELINERUN_STARTED_0_1_1), Some(("pipelinerun","started"))); // -// assert_eq!(extract_subject_predicate(REPOSITORY_CREATED), Some(("repository","created"))); +// assert_eq!(extract_subject_predicate(REPOSITORY_CREATED_0_1_1), Some(("repository","created"))); // -// assert_eq!(extract_subject_predicate(REPOSITORY_DELETED), Some(("repository","deleted"))); +// assert_eq!(extract_subject_predicate(REPOSITORY_DELETED_0_1_1), Some(("repository","deleted"))); // -// assert_eq!(extract_subject_predicate(REPOSITORY_MODIFIED), Some(("repository","modified"))); +// assert_eq!(extract_subject_predicate(REPOSITORY_MODIFIED_0_1_1), Some(("repository","modified"))); // -// assert_eq!(extract_subject_predicate(SERVICE_DEPLOYED), Some(("service","deployed"))); +// assert_eq!(extract_subject_predicate(SERVICE_DEPLOYED_0_1_1), Some(("service","deployed"))); // -// assert_eq!(extract_subject_predicate(SERVICE_PUBLISHED), Some(("service","published"))); +// assert_eq!(extract_subject_predicate(SERVICE_PUBLISHED_0_1_1), Some(("service","published"))); // -// assert_eq!(extract_subject_predicate(SERVICE_REMOVED), Some(("service","removed"))); +// assert_eq!(extract_subject_predicate(SERVICE_REMOVED_0_1_1), Some(("service","removed"))); // -// assert_eq!(extract_subject_predicate(SERVICE_ROLLEDBACK), Some(("service","rolledback"))); +// assert_eq!(extract_subject_predicate(SERVICE_ROLLEDBACK_0_1_1), Some(("service","rolledback"))); // -// assert_eq!(extract_subject_predicate(SERVICE_UPGRADED), Some(("service","upgraded"))); +// assert_eq!(extract_subject_predicate(SERVICE_UPGRADED_0_1_1), Some(("service","upgraded"))); // -// assert_eq!(extract_subject_predicate(TASKRUN_FINISHED), Some(("taskRun","finished"))); +// assert_eq!(extract_subject_predicate(TASKRUN_FINISHED_0_1_1), Some(("taskrun","finished"))); // -// assert_eq!(extract_subject_predicate(TASKRUN_STARTED), Some(("taskRun","started"))); +// assert_eq!(extract_subject_predicate(TASKRUN_STARTED_0_1_1), Some(("taskrun","started"))); // -// assert_eq!(extract_subject_predicate(TESTCASERUN_FINISHED), Some(("testCaseRun","finished"))); +// assert_eq!(extract_subject_predicate(TESTCASERUN_FINISHED_0_1_0), Some(("testcaserun","finished"))); // -// assert_eq!(extract_subject_predicate(TESTCASERUN_QUEUED), Some(("testCaseRun","queued"))); +// assert_eq!(extract_subject_predicate(TESTCASERUN_QUEUED_0_1_0), Some(("testcaserun","queued"))); // -// assert_eq!(extract_subject_predicate(TESTCASERUN_STARTED), Some(("testCaseRun","started"))); +// assert_eq!(extract_subject_predicate(TESTCASERUN_STARTED_0_1_0), Some(("testcaserun","started"))); // -// assert_eq!(extract_subject_predicate(TESTOUTPUT_PUBLISHED), Some(("testOutput","published"))); +// assert_eq!(extract_subject_predicate(TESTOUTPUT_PUBLISHED_0_1_0), Some(("testoutput","published"))); // -// assert_eq!(extract_subject_predicate(TESTSUITERUN_FINISHED), Some(("testSuiteRun","finished"))); +// assert_eq!(extract_subject_predicate(TESTSUITERUN_FINISHED_0_1_0), Some(("testsuiterun","finished"))); // -// assert_eq!(extract_subject_predicate(TESTSUITERUN_QUEUED), Some(("testSuiteRun","queued"))); +// assert_eq!(extract_subject_predicate(TESTSUITERUN_QUEUED_0_1_0), Some(("testsuiterun","queued"))); // -// assert_eq!(extract_subject_predicate(TESTSUITERUN_STARTED), Some(("testSuiteRun","started"))); +// assert_eq!(extract_subject_predicate(TESTSUITERUN_STARTED_0_1_0), Some(("testsuiterun","started"))); // // } // } \ No newline at end of file diff --git a/cdevents-sdk/src/generated/pipelinerun_finished.rs b/cdevents-sdk/src/generated/pipelinerun_finished_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/pipelinerun_finished.rs rename to cdevents-sdk/src/generated/pipelinerun_finished_0_1_1.rs diff --git a/cdevents-sdk/src/generated/pipelinerun_queued.rs b/cdevents-sdk/src/generated/pipelinerun_queued_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/pipelinerun_queued.rs rename to cdevents-sdk/src/generated/pipelinerun_queued_0_1_1.rs diff --git a/cdevents-sdk/src/generated/pipelinerun_started.rs b/cdevents-sdk/src/generated/pipelinerun_started_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/pipelinerun_started.rs rename to cdevents-sdk/src/generated/pipelinerun_started_0_1_1.rs diff --git a/cdevents-sdk/src/generated/repository_created.rs b/cdevents-sdk/src/generated/repository_created_0_1_1.rs similarity index 97% rename from cdevents-sdk/src/generated/repository_created.rs rename to cdevents-sdk/src/generated/repository_created_0_1_1.rs index b2d8e60..2c294b8 100644 --- a/cdevents-sdk/src/generated/repository_created.rs +++ b/cdevents-sdk/src/generated/repository_created_0_1_1.rs @@ -13,7 +13,7 @@ pub struct Content { #[serde(rename = "owner", default, skip_serializing_if = "Option::is_none",)] pub owner: Option, #[serde(rename = "url",)] - pub url: String, + pub url: crate::Uri, #[serde(rename = "viewUrl", default, skip_serializing_if = "Option::is_none",)] pub view_url: Option, } diff --git a/cdevents-sdk/src/generated/repository_deleted.rs b/cdevents-sdk/src/generated/repository_deleted_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/repository_deleted.rs rename to cdevents-sdk/src/generated/repository_deleted_0_1_1.rs diff --git a/cdevents-sdk/src/generated/repository_modified.rs b/cdevents-sdk/src/generated/repository_modified_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/repository_modified.rs rename to cdevents-sdk/src/generated/repository_modified_0_1_1.rs diff --git a/cdevents-sdk/src/generated/service_deployed.rs b/cdevents-sdk/src/generated/service_deployed_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/service_deployed.rs rename to cdevents-sdk/src/generated/service_deployed_0_1_1.rs diff --git a/cdevents-sdk/src/generated/service_published.rs b/cdevents-sdk/src/generated/service_published_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/service_published.rs rename to cdevents-sdk/src/generated/service_published_0_1_1.rs diff --git a/cdevents-sdk/src/generated/service_removed.rs b/cdevents-sdk/src/generated/service_removed_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/service_removed.rs rename to cdevents-sdk/src/generated/service_removed_0_1_1.rs diff --git a/cdevents-sdk/src/generated/service_rolledback.rs b/cdevents-sdk/src/generated/service_rolledback_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/service_rolledback.rs rename to cdevents-sdk/src/generated/service_rolledback_0_1_1.rs diff --git a/cdevents-sdk/src/generated/service_upgraded.rs b/cdevents-sdk/src/generated/service_upgraded_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/service_upgraded.rs rename to cdevents-sdk/src/generated/service_upgraded_0_1_1.rs diff --git a/cdevents-sdk/src/generated/taskrun_finished.rs b/cdevents-sdk/src/generated/taskrun_finished_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/taskrun_finished.rs rename to cdevents-sdk/src/generated/taskrun_finished_0_1_1.rs diff --git a/cdevents-sdk/src/generated/taskrun_started.rs b/cdevents-sdk/src/generated/taskrun_started_0_1_1.rs similarity index 100% rename from cdevents-sdk/src/generated/taskrun_started.rs rename to cdevents-sdk/src/generated/taskrun_started_0_1_1.rs diff --git a/cdevents-sdk/src/generated/testcaserun_finished.rs b/cdevents-sdk/src/generated/testcaserun_finished_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/testcaserun_finished.rs rename to cdevents-sdk/src/generated/testcaserun_finished_0_1_0.rs diff --git a/cdevents-sdk/src/generated/testcaserun_queued.rs b/cdevents-sdk/src/generated/testcaserun_queued_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/testcaserun_queued.rs rename to cdevents-sdk/src/generated/testcaserun_queued_0_1_0.rs diff --git a/cdevents-sdk/src/generated/testcaserun_started.rs b/cdevents-sdk/src/generated/testcaserun_started_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/testcaserun_started.rs rename to cdevents-sdk/src/generated/testcaserun_started_0_1_0.rs diff --git a/cdevents-sdk/src/generated/testoutput_published.rs b/cdevents-sdk/src/generated/testoutput_published_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/testoutput_published.rs rename to cdevents-sdk/src/generated/testoutput_published_0_1_0.rs diff --git a/cdevents-sdk/src/generated/testsuiterun_finished.rs b/cdevents-sdk/src/generated/testsuiterun_finished_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/testsuiterun_finished.rs rename to cdevents-sdk/src/generated/testsuiterun_finished_0_1_0.rs diff --git a/cdevents-sdk/src/generated/testsuiterun_queued.rs b/cdevents-sdk/src/generated/testsuiterun_queued_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/testsuiterun_queued.rs rename to cdevents-sdk/src/generated/testsuiterun_queued_0_1_0.rs diff --git a/cdevents-sdk/src/generated/testsuiterun_started.rs b/cdevents-sdk/src/generated/testsuiterun_started_0_1_0.rs similarity index 100% rename from cdevents-sdk/src/generated/testsuiterun_started.rs rename to cdevents-sdk/src/generated/testsuiterun_started_0_1_0.rs diff --git a/cdevents-sdk/src/uri.rs b/cdevents-sdk/src/uri.rs index 73cad0a..d3914ea 100644 --- a/cdevents-sdk/src/uri.rs +++ b/cdevents-sdk/src/uri.rs @@ -60,9 +60,9 @@ impl TryFrom for Uri { } } -impl ToString for Uri { - fn to_string(&self) -> String { - self.0.as_str().to_owned()//into_string() +impl std::fmt::Display for Uri { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.as_str().fmt(f) } } diff --git a/cdevents-sdk/src/uri_reference.rs b/cdevents-sdk/src/uri_reference.rs index 11385ce..edd3d2a 100644 --- a/cdevents-sdk/src/uri_reference.rs +++ b/cdevents-sdk/src/uri_reference.rs @@ -49,9 +49,9 @@ impl TryFrom for UriReference { } } -impl ToString for UriReference { - fn to_string(&self) -> String { - self.0.as_str().to_owned()//into_string() +impl std::fmt::Display for UriReference { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.as_str().fmt(f) } } diff --git a/cdevents-sdk/tests/specs.rs b/cdevents-sdk/tests/specs.rs index 06cc5ec..c380cc3 100644 --- a/cdevents-sdk/tests/specs.rs +++ b/cdevents-sdk/tests/specs.rs @@ -1,13 +1,60 @@ use assert_json_diff::assert_json_eq; use cdevents_sdk::CDEvent; -use rstest::rstest; -use std::fs; +use rstest::*; +use std::{collections::HashMap, fs}; use std::path::PathBuf; use proptest::prelude::*; -use boon::{Schemas, Compiler}; +use boon::{Schemas, Compiler, SchemaIndex}; +use glob::glob; +use std::sync::OnceLock; + +struct EventsSchemas { + schemas: Schemas, + mapping: HashMap, +} + +impl EventsSchemas { + fn load() -> Self { + let mut schemas = Schemas::new(); + let mut compiler = Compiler::new(); + let mut mapping = HashMap::new(); + for entry in glob("../cdevents-specs/*/schemas/*.json").expect("Failed to read glob pattern") { + let schemapath = entry.unwrap(); + //TODO avoid to read the schema twice (as json, then as jsonschema) + let jsonschema: serde_json::Value = serde_json::from_str(&std::fs::read_to_string(&schemapath).unwrap()).unwrap(); + let ty = jsonschema["properties"]["context"]["properties"]["type"]["default"].as_str() + .unwrap_or_default() + .to_string(); + mapping.entry(ty).or_insert_with(|| { + let sch_index = compiler.compile(&schemapath.to_string_lossy(), &mut schemas); + if let Err(err) = sch_index { + panic!("{err:#}"); //like a assert(false,...) + } + sch_index.unwrap() + }); + } + Self { + schemas, mapping + } + } + + fn check_against_schema(&self, json: &serde_json::Value, ty: &str) { + let sch_index = self.mapping.get(ty).unwrap_or_else(|| panic!("to have schema for {ty}")); + let result = self.schemas.validate(json, *sch_index); + if let Err(err) = result { + panic!("{err}"); + } + } +} + +static EVENTS_SCHEMA_CELL: OnceLock = OnceLock::new(); + +fn events_schemas() -> &'static EventsSchemas { + EVENTS_SCHEMA_CELL.get_or_init(EventsSchemas::load) +} #[rstest] -fn for_each_example(#[files("../cdevents-spec/examples/*.json")] path: PathBuf) { +fn for_each_example(#[files("../cdevents-specs/spec-v0.3/examples/*.json")] path: PathBuf) { let example_txt = fs::read_to_string(path).expect("to read file as string"); //HACK uri are stored ad http::Uri, they are "normalized" when serialized, so prenormalization to avoid failure like // json atoms at path ".subject.content.repository.source" are not equal: @@ -30,37 +77,22 @@ fn for_each_example(#[files("../cdevents-spec/examples/*.json")] path: PathBuf) assert_json_eq!(example_json, cdevent_json); } -fn check_against_schema(json: &serde_json::Value, ty: &str) { - let (subject, predicate) = cdevents_sdk::extract_subject_predicate(ty).expect("valid type: {ty}"); - let schemapath = format!("../cdevents-spec/schemas/{subject}{predicate}.json").to_lowercase(); - //TODO optimize to not recompile a previously read schema - let mut schemas = Schemas::new(); - let mut compiler = Compiler::new(); - let sch_index = compiler.compile(&schemapath, &mut schemas); - if let Err(err) = sch_index { - panic!("{err:#}"); //like a assert(false,...) - } - let sch_index = sch_index.unwrap(); - let result = schemas.validate(json, sch_index); - if let Err(err) = result { - panic!("{err}"); - } -} - #[rstest] -fn validate_example_against_schema(#[files("../cdevents-spec/examples/*.json")] path: PathBuf) { +fn validate_example_against_schema(#[files("../cdevents-specs/spec-v0.3/examples/*.json")] path: PathBuf) { + let events_schemas = events_schemas(); let example_txt = fs::read_to_string(path).expect("to read file as string"); let example_json: serde_json::Value = serde_json::from_str(&example_txt).expect("to parse as json"); let ty = example_json["context"]["type"].as_str().expect("valid context.type in json"); - check_against_schema(&example_json, ty); + events_schemas.check_against_schema(&example_json, ty); } proptest! { #[test] #[cfg(feature = "testkit")] fn arbitraries_check_jsonschema(s in any::()) { + let events_schemas = events_schemas(); let json = serde_json::to_value(&s).unwrap(); - check_against_schema(&json, s.ty()); + events_schemas.check_against_schema(&json, s.ty()); } } diff --git a/cdevents-specs/main b/cdevents-specs/main new file mode 160000 index 0000000..d6b6f88 --- /dev/null +++ b/cdevents-specs/main @@ -0,0 +1 @@ +Subproject commit d6b6f88c1981d90adf1f8ffa0a3d3eb1bc9aad13 diff --git a/cdevents-spec b/cdevents-specs/spec-v0.3 similarity index 100% rename from cdevents-spec rename to cdevents-specs/spec-v0.3 diff --git a/generator/Cargo.toml b/generator/Cargo.toml index fee5803..1950e31 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -13,11 +13,13 @@ description = "generate cdevents type from json schema on cdevents-spec" anyhow = "1.0" clap = { version = "4", features = ["derive"] } cruet = "0.14" +glob = "0.3" handlebars = { version = "5", features = ["dir_source"] } handlebars_misc_helpers = { version = "0.15", default-features = false, features = [ "string", "json", ] } +indexmap = "2.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" url = "2.5" diff --git a/generator/README.md b/generator/README.md index fe1efa0..95f0529 100644 --- a/generator/README.md +++ b/generator/README.md @@ -13,9 +13,9 @@ Goals: generate rust code for cdevents from jsonschema provided as part of cdeve ## Run -To generate the `subjects` into sibling crate `cdevents/src/generated` from content of `cdevents-spec/schemas`, from root workspace +To generate the `subjects` into sibling crate `cdevents/src/generated` from content of `cdevents-specs/spec-v0.3/schemas`, from root workspace ```sh cargo run -p generator -- --help -cargo run -p generator -- --templates-dir "generator/templates" --jsonschema-dir "cdevents-spec/schemas" --dest "cdevents-sdk/src/generated" +cargo run -p generator -- --templates-dir "generator/templates" --jsonschema-dir "cdevents-specs/spec-v0.3/schemas" --dest "cdevents-sdk/src/generated" ``` diff --git a/generator/src/main.rs b/generator/src/main.rs index 85e50fb..6fd563a 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -1,10 +1,15 @@ +mod version; + use anyhow::{Context, Result}; use clap::Parser; use cruet::Inflector; +use glob::glob; use handlebars::{DirectorySourceOptions, Handlebars}; +use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; -use std::{fs, path::PathBuf}; +use std::{collections::HashMap, fs, path::PathBuf}; +use version::Version; /// generator of part of the rust code of cdevents from spec #[derive(Parser, Debug)] @@ -13,9 +18,9 @@ struct Settings { #[arg(long, default_value = "templates")] templates_dir: PathBuf, - /// directory with json schemas of events to generate - #[arg(long, default_value = "../cdevents-spec/schemas")] - jsonschema_dir: PathBuf, + /// glob pattern to find files with json schemas of events to generate + #[arg(long, default_value = "../cdevents-specs/*/schemas/*.json")] + jsonschemas: String, /// destination directory where to generate code #[arg(long, default_value = "../cdevents-sdk/src/generated")] @@ -37,30 +42,37 @@ fn main() -> Result<()> { } fs::create_dir_all(&settings.dest)?; - let mut variants = vec![]; - let mut jsonfiles = - std::fs::read_dir(settings.jsonschema_dir)?.collect::, _>>()?; - jsonfiles.sort_by_key(|v| v.file_name()); - for entry in jsonfiles { - let path = entry.path(); - if let Some(extension) = path.extension() { - if extension == "json" { - let json: Value = serde_json::from_str(&std::fs::read_to_string(&path)?)?; - let (variant_info, code) = generate_variant(&hbs, json) - .with_context(|| format!("failed to generate variant on {:?}", &path))?; + let mut variants = IndexMap::new(); + let mut variants_per_specs = VariantPerSpecs::new(); + + let mut jsonfiles = glob(&settings.jsonschemas)?.collect::, _>>()?; + jsonfiles.sort_by(|a, b| a.file_name().cmp(&b.file_name())); + for path in jsonfiles { + let json: Value = serde_json::from_str(&std::fs::read_to_string(&path)?)?; + let (variant_info, code) = generate_variant(&hbs, json) + .with_context(|| format!("failed to generate variant on {:?}", &path))?; + if let Some(code) = code { + variants_per_specs.register(&variant_info); + + if !variants.contains_key(&variant_info.context_type) { + // generate code for variant let file = settings .dest .join(cruet::to_snake_case(&variant_info.rust_module)) .with_extension("rs"); //TODO use a formatter like https://crates.io/crates/prettyplease? fs::write(file, code)?; - variants.push(variant_info); + variants.insert(variant_info.context_type.to_owned(), variant_info); } } } - let (module_name, code) = - generate_module(&hbs, &variants).with_context(|| "failed to generate module")?; + let (module_name, code) = generate_module( + &hbs, + &variants.into_values().collect::>(), + &variants_per_specs, + ) + .with_context(|| "failed to generate module")?; let file = settings.dest.join(module_name).with_extension("rs"); //TODO use a formatter like https://crates.io/crates/prettyplease? fs::write(file, code)?; @@ -68,17 +80,30 @@ fn main() -> Result<()> { Ok(()) } -fn generate_variant(hbs: &Handlebars, jsonschema: Value) -> Result<(VariantInfo, String)> { - // let id = jsonschema["$id"] - // .as_str() - // .ok_or(anyhow!("$id not found or not a string")) - // .and_then(|s| url::Url::parse(s).with_context(|| format!("failed to parse: {}", s)))?; - // let module_name = id - // .path_segments() - // .and_then(|v| v.last()) - // .map(cruet::to_snake_case) - // .ok_or(anyhow!("no path in $id"))? - // .replace("_event", ""); +fn to_rust_module(subject: &str, predicate: &str, version: Option<&Version>) -> String { + //HACK: ignore module for version with modifier (draft, beta, ...) + if let Some(version) = version { + format!( + "{}_{}_{}_{}_{}", + subject, predicate, version.major, version.minor, version.patch + ) + .to_snake_case() + } else { + format!("{}_{}", subject, predicate).to_snake_case() + } +} + +fn generate_variant(hbs: &Handlebars, jsonschema: Value) -> Result<(VariantInfo, Option)> { + //e.g. "$id": "https://cdevents.dev/0.3.0/schema/branch-created-event" + let spec_version = jsonschema["$id"] + .as_str() + .ok_or(anyhow::anyhow!("$id not found or not a string")) + .and_then(|s| url::Url::parse(s).with_context(|| format!("failed to parse: {}", s)))? + .path_segments() + .ok_or(anyhow::anyhow!("$id not an url with a path"))? + .next() + .unwrap_or("0.0.0") + .to_owned(); // extract module's name from `context.type` (and not from `$id`) let context_type = jsonschema["properties"]["context"]["properties"]["type"]["default"] @@ -87,28 +112,52 @@ fn generate_variant(hbs: &Handlebars, jsonschema: Value) -> Result<(VariantInfo, .to_string(); let fragments = context_type.split('.').collect::>(); - let rust_module = format!("{}_{}", fragments[2], fragments[3]).to_snake_case(); + let subject = fragments[2].to_owned(); let predicate = fragments[3].to_owned(); + let version_modifiers = fragments[6].split('-').collect::>(); + + let version = Version { + major: fragments[4].parse::()?, + minor: fragments[5].parse::()?, + patch: version_modifiers[0].parse::()?, + modifier: version_modifiers + .get(1) + .map(|s| s.to_string()) + .unwrap_or_default(), + }; + let rust_module = to_rust_module(&subject, &predicate, Some(&version)); // due to inconstency in case/format the subject could be not be extracted from the context.type (ty), jsonshema $id, spec filename (shema, examples) - let subject = jsonschema["properties"]["subject"]["properties"]["type"]["default"] + let subject_type = jsonschema["properties"]["subject"]["properties"]["type"]["default"] .as_str() .unwrap_or_default() .to_string(); let data = build_data_for_variants(jsonschema); - let code = hbs.render("variant", &data)?; + let code = if version.modifier.is_empty() { + Some(hbs.render("variant", &data)?) + } else { + None + }; let variant_info = VariantInfo { context_type, rust_module, subject, + subject_type, predicate, + version, + spec_version, }; Ok((variant_info, code)) } -fn generate_module(hbs: &Handlebars, variants: &[VariantInfo]) -> Result<(String, String)> { +fn generate_module( + hbs: &Handlebars, + variants: &[VariantInfo], + variants_per_specs: &VariantPerSpecs, +) -> Result<(String, String)> { let data = json!({ - "variants": variants + "variants": variants, + "variants_per_specs": variants_per_specs.generate_mapping(), }); let code = hbs.render("mod", &data)?; Ok(("mod".to_string(), code)) @@ -143,7 +192,10 @@ struct VariantInfo { context_type: String, rust_module: String, subject: String, + subject_type: String, predicate: String, + version: Version, + spec_version: String, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -196,8 +248,10 @@ fn collect_structs( match (field_names.last(), json_definition["minLength"].as_i64()) { (Some(&"id"), _) => "crate::Id", (Some(&"name"), Some(1)) => "crate::Name", + (Some(&"url"), Some(1)) => "crate::Uri", // workaround for wrongly typed in jsonschema (Some(x), Some(1)) if x.ends_with("Id") => "crate::Id", (Some(x), Some(1)) if x.ends_with("Name") => "crate::Name", + (Some(_), Some(1)) => "crate::NonEmptyString", _ => "String", } .to_string(); @@ -282,3 +336,63 @@ fn collect_structs( fn to_type_name(fied_names: &[&str]) -> String { fied_names.join("_").to_class_case() } + +struct VariantPerSpecs { + specs: HashMap>, +} + +impl VariantPerSpecs { + fn new() -> Self { + let mut specs = HashMap::new(); + specs.insert("latest".to_owned(), IndexMap::new()); + Self { specs } + } + + fn register(&mut self, variant_info: &VariantInfo) { + let key_version = (variant_info.subject.clone(), variant_info.predicate.clone()); + match self.specs.get_mut(&variant_info.spec_version) { + Some(l) => { + l.insert(key_version.clone(), variant_info.version.clone()); + } + None => { + let mut l = IndexMap::new(); + l.insert(key_version.clone(), variant_info.version.clone()); + self.specs.insert(variant_info.spec_version.clone(), l); + } + } + + if let Some(variants_latest) = self.specs.get_mut("latest") { + // update variant_version + match variants_latest.get(&key_version) { + Some(v) if v < &variant_info.version => { + variants_latest.insert(key_version, variant_info.version.clone()); + } + None => { + variants_latest.insert(key_version, variant_info.version.clone()); + } + _ => (), + } + } + } + + fn generate_mapping(&self) -> HashMap> { + self.specs.iter().fold(HashMap::new(), |mut acc, (k, v)| { + let mapping = v + .iter() + .map(|(k, v)| { + ( + to_rust_module(&k.0, &k.1, Some(v)), + to_rust_module(&k.0, &k.1, None), + ) + }) + .collect::>(); + let mod_name = if k == "latest" { + k.to_owned() + } else { + format!("spec_{}", k).to_snake_case() + }; + acc.insert(mod_name, mapping); + acc + }) + } +} diff --git a/generator/src/version.rs b/generator/src/version.rs new file mode 100644 index 0000000..cb7ec7a --- /dev/null +++ b/generator/src/version.rs @@ -0,0 +1,31 @@ +use std::cmp::Ordering; + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub(crate) struct Version { + pub(crate) major: u8, + pub(crate) minor: u8, + pub(crate) patch: u8, + pub(crate) modifier: String, +} + +impl PartialOrd for Version { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Version { + fn cmp(&self, other: &Self) -> Ordering { + let mut r = self.major.cmp(&other.major); + if r.is_eq() { + r = self.minor.cmp(&other.minor); + } + if r.is_eq() { + r = self.patch.cmp(&other.patch); + } + //TODO compare modifier with semantic ("snapshot", "draft", "alpha", "beta", "rc", "ga", "") + r + } +} diff --git a/generator/templates/mod.hbs b/generator/templates/mod.hbs index 51f4665..17f7010 100644 --- a/generator/templates/mod.hbs +++ b/generator/templates/mod.hbs @@ -1,13 +1,19 @@ // @generated // by cdevents/sdk-rust/generator (mod.hbs) -use serde::de::Error; +use serde::{Serialize, Deserialize, de::Error}; {{#each variants }} pub mod {{this.rust_module}}; {{/each}} -use serde::{Serialize, Deserialize}; +{{#each variants_per_specs }} +pub mod {{@key}} { + {{#each this }} + pub use super::{{this.0}} as {{this.1}}; + {{/each}} +} +{{/each}} {{#each variants }} pub const {{to_screaming_snake_case this.rust_module}}: &str = "{{ this.context_type }}"; @@ -48,7 +54,7 @@ impl Content { pub fn subject(&self) -> &'static str { match self { {{#each variants }} - Self::{{to_class_case this.rust_module}}(_) => "{{ this.subject }}", + Self::{{to_class_case this.rust_module}}(_) => "{{ this.subject_type }}", {{/each}} } } @@ -67,7 +73,7 @@ pub fn extract_subject_predicate(ty: &str) -> Option<(&str, &str)>{ // let mut split = ty.split('.'); match ty { {{#each variants }} - {{to_screaming_snake_case this.rust_module}} => Some(("{{ this.subject }}", "{{ this.predicate }}")), + {{to_screaming_snake_case this.rust_module}} => Some(("{{ this.subject_type }}", "{{ this.predicate }}")), {{/each}} _ => None, }