Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updata: Update metadata generation tool #265

Merged
merged 10 commits into from
Nov 6, 2019
126 changes: 126 additions & 0 deletions workspaces/Cargo.lock

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

1 change: 1 addition & 0 deletions workspaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ members = [
"updater/signpost",
"updater/tough",
"updater/tough_schema",
"updater/update_metadata",
"updater/updog",

"tuftool",
Expand Down
3 changes: 3 additions & 0 deletions workspaces/api/data_store_version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ edition = "2018"
lazy_static = "1.2"
log = "0.4"
regex = "1.1"
serde = { version = "1.0", features = ["derive"] }
serde_plain = "0.3.0"

snafu = "0.5"

[build-dependencies]
Expand Down
14 changes: 14 additions & 0 deletions workspaces/api/data_store_version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ It is especially helpful during data store migrations, and is also used for data

#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_plain;

use lazy_static::lazy_static;
use regex::Regex;
use serde::{Serialize, Serializer};
use snafu::{OptionExt, ResultExt};
use std::path::Path;
use std::path::PathBuf;
Expand Down Expand Up @@ -92,12 +95,23 @@ impl FromStr for Version {
}
}

derive_deserialize_from_str!(Version, "Valid data-store version");

impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "v{}.{}", self.major, self.minor)
}
}

impl Serialize for Version {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&format!("{}.{}", self.major, self.minor))
}
}

impl Version {
#[allow(dead_code)]
pub fn new(major: VersionComponent, minor: VersionComponent) -> Self {
Expand Down
1 change: 1 addition & 0 deletions workspaces/deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ skip = [
{ name = "tough", licenses = [] },
{ name = "tough_schema", licenses = [] },
{ name = "tuftool", licenses = [] },
{ name = "update_metadata", licenses = [] },
{ name = "updog", licenses = [] },
{ name = "webpki-roots", licenses = [] },

Expand Down
21 changes: 21 additions & 0 deletions workspaces/updater/update_metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "update_metadata"
version = "0.1.0"
authors = ["Samuel Mendoza-Jonas <samjonas@amazon.com>"]
edition = "2018"
publish = false

[dependencies]
chrono = { version = "0.4.9", features = ["serde"] }
data_store_version = { path = "../../api/data_store_version" }
rand = "0.7.0"
regex = "1.1"
semver = { version = "0.9.0", features = ["serde"] }
serde = { version = "1.0.100", features = ["derive"] }
serde_json = "1.0.40"
serde_plain = "0.3.0"
snafu = "0.5.0"

[lib]
name = "update_metadata"
path = "src/lib.rs"
Loading