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

Add json spec and spec puller #3

Merged
merged 1 commit into from
Sep 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
specification/*.json filter=lfs diff=lfs merge=lfs -text
src/specification/*.json filter=lfs diff=lfs merge=lfs -text
11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ name = "noctilucent"
version = "0.1.0"
edition = "2018"

[[bin]]
name = "specpull"
path = "src/specpull/bin/main.rs"

[[bin]]
name = "noctilucent"
path = "src/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "3.0.0-beta.2"
serde_json = "1.0.67"
nom = "7.0.0"
nom = "7.0.0"
reqwest = { version = "0.11", features = ["json", "gzip"] }
tokio = { version = "1", features = ["full"] }
3 changes: 3 additions & 0 deletions src/specification/spec.json
Git LFS file not shown
19 changes: 19 additions & 0 deletions src/specpull/bin/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// The purpose of this binary is to pull the cloudformation specification system.

use serde_json::Value;
use std::io::Write;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::builder().gzip(true).build().unwrap();
let resp = client.get("https://d1uauaxba7bl26.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json").send()
.await?;
let txt = resp.text().await.unwrap();
let mut file = std::fs::File::create("src/specification/spec.json")?;
file.write_all(txt.as_bytes())?;

if let Ok(x) = serde_json::from_str::<Value>(&txt) {
println!("{:#?}", x);
}
Ok(())
}