Pull in serde with the appropriate features to get my derive macro working

This commit is contained in:
R Tyler Croy 2020-02-02 13:48:10 -08:00
parent dcfcff4874
commit 236cb09577
No known key found for this signature in database
GPG Key ID: E5C92681BEF6CEA2
4 changed files with 104 additions and 0 deletions

16
Cargo.lock generated
View File

@ -184,6 +184,8 @@ dependencies = [
"config 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
"surf 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tide 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1115,6 +1117,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "serde"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde-hjson"
@ -1128,6 +1133,16 @@ dependencies = [
"serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_derive"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_json"
version = "1.0.45"
@ -1790,6 +1805,7 @@ dependencies = [
"checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8"
"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
"checksum serde-hjson 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8"
"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
"checksum serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b"
"checksum serde_qs 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d43eef44996bbe16e99ac720e1577eefa16f7b76b5172165c98ced20ae9903e1"
"checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5"

View File

@ -22,3 +22,6 @@ config = { version = "~0.10.1", features = ["yaml"] }
# Used for making http requests to the upstream docker registry
surf = "~1.0.3"
serde = { version = "~1.0.104", features = ["derive"] }
serde_json = "~1.0.0"

View File

@ -4,6 +4,10 @@
extern crate config;
extern crate pretty_env_logger;
#[macro_use]
extern crate serde;
#[macro_use]
extern crate serde_json;
extern crate surf;
extern crate tide;
@ -11,6 +15,10 @@ use async_std::task;
use log::*;
use tide::{Request, Response};
use std::path::Path;
mod models;
/**
* Load the settings based on the hierarchy.
*

77
src/models.rs Normal file
View File

@ -0,0 +1,77 @@
/**
* The models module contains all the serde structs for the Docker registry
* requests and responses that we care about
*/
extern crate serde;
extern crate serde_json;
use serde::{Deserialize, Serialize};
use serde_json::Result;
/**
* Manifest format, retrieved from: /v2/alpine/manifests/latest
{
"schemaVersion": 1,
"name": "alpine",
"tag": "latest",
"architecture": "amd64",
"fsLayers": [
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:6c40cc604d8e4c121adcb6b0bfe8bb038815c350980090e74aa5a6423f8f82c0"
}
],
"history": [
{
"v1Compatibility": "{\"architecture\":\"amd64\",\"config\":{\"Hostname\":\"\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":[\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"],\"Cmd\":[\"/bin/sh\"],\"ArgsEscaped\":true,\"Image\":\"sha256:ce244ca5cf823254a1dff4ea35589dcdbe540266820f401a86b7b8dc9eda8f19\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"container\":\"35bf94cc91dd11f6bd36502cefc82fd4515b20e0181b49e7c316bd78ff7c75d6\",\"container_config\":{\"Hostname\":\"35bf94cc91dd\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":[\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"],\"Cmd\":[\"/bin/sh\",\"-c\",\"#(nop) \",\"CMD [\\\"/bin/sh\\\"]\"],\"ArgsEscaped\":true,\"Image\":\"sha256:ce244ca5cf823254a1dff4ea35589dcdbe540266820f401a86b7b8dc9eda8f19\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":{}},\"created\":\"2019-01-30T22:19:52.734509838Z\",\"docker_version\":\"18.06.1-ce\",\"id\":\"02f7a7ef96f88a71b565eae4fd329ae31942b036f9deec4489c53540c2a18b6d\",\"os\":\"linux\",\"parent\":\"92bdbc97504bab151c3cf7451f2664797538d1fbe2fa0c8b92a218a97cc079df\",\"throwaway\":true}"
},
{
"v1Compatibility": "{\"id\":\"92bdbc97504bab151c3cf7451f2664797538d1fbe2fa0c8b92a218a97cc079df\",\"created\":\"2019-01-30T22:19:52.585366638Z\",\"container_config\":{\"Cmd\":[\"/bin/sh -c #(nop) ADD file:2a1fc9351afe35698918545b2d466d9805c2e8afcec52f916785ee65bbafeced in / \"]}}"
}
],
"signatures": [
{
"header": {
"jwk": {
"crv": "P-256",
"kid": "GNNE:U4EY:Q2RK:62PO:3FIP:TAHB:XHLQ:IMOC:LYHD:HRH3:QJ2I:VJVZ",
"kty": "EC",
"x": "8q3mDSgd7V3wjnwTlGpsuS4f7XVGRwcWJBGkfTj5C2g",
"y": "E2wP8yAe8iLLuVF3_QbGndah-9_O9FkhXOE1nuzvAPE"
},
"alg": "ES256"
},
"signature": "ZZdKYM_K9PWoMZ1EZQwiRg7J1dYWPNYmy7gxIX37eDErZ-8E6gfvibcxVIzsvTpV6a2v-kKOLwl_qmAAif-_FA",
"protected": "eyJmb3JtYXRMZW5ndGgiOjIxMzMsImZvcm1hdFRhaWwiOiJDbjAiLCJ0aW1lIjoiMjAyMC0wMi0wMVQxNjozODo1OFoifQ"
}
]
}
*/
#[derive(Serialize, Deserialize)]
struct Manifest {
#[serde(rename = "schemaVersion")]
schema_version: u16,
name: String,
tag: String,
architecture: String,
#[serde(rename = "fsLayers")]
fs_layers: Vec<Layer>,
signatures: Vec<Signature>,
}
#[derive(Serialize, Deserialize)]
struct Layer {
#[serde(rename = "blobSum")]
blob_sum: String,
}
#[derive(Serialize, Deserialize)]
struct Signature {
signature: String,
protected: String,
}