Crates.io | coreos-stream-metadata |
lib.rs | coreos-stream-metadata |
version | 0.1.0 |
source | src |
created_at | 2022-11-02 19:36:49.456765 |
updated_at | 2022-11-02 19:36:49.456765 |
description | Fetch and parse stream metadata for Fedora CoreOS and derivatives |
homepage | |
repository | https://github.com/coreos/stream-metadata-rust |
max_upload_size | |
id | 703698 |
size | 45,475 |
See the Fedora CoreOS documentation for basic information about streams.
This is a Rust library which defines standard structs that #[derive(Deserialize)]
for use with serde.
use anyhow::Result;
use coreos_stream_metadata::Stream;
#[tokio::main]
fn main() -> Result<()> {
let streamid = coreos_stream_metadata::fcos::StreamId::Stable;
let arch = "x86_64";
let region = "us-east-1";
let buf = reqwest::get(streamid.url())
.await?
.bytes()
.await?;
let stream: Stream = serde_json::from_slice(&buf)?;
let ami = stream.architectures.get(arch).unwrap().images.get("aws").unwrap().regions(region).unwrap();
println!("The AMI for FCOS {} {} is {} (version {})", streamid, region, ami.image, ami.release);
Ok(())
}