1 unstable release
0.1.0 | Nov 2, 2022 |
---|
#15 in #fedora
31 downloads per month
Used in zincati
12KB
169 lines
Rust library for interacting with CoreOS Stream metadata
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.
Example usage
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(())
}
lib.rs
:
Library for interacting with CoreOS stream metadata, used by Fedora CoreOS and RHEL CoreOS.
Get the URL for FCOS stable stream:
use coreos_stream_metadata::fcos;
let url = fcos::StreamID::Stable.url();
Deserialize stream data and print URL for OpenStack image
use coreos_stream_metadata::Stream;
let stream: Stream = serde_json::from_reader(std::io::stdin())?;
let openstack = stream.query_thisarch_single("openstack").ok_or_else(|| anyhow::anyhow!("Missing openstack image"))?;
println!("OpenStack image URL: {}", openstack.location);
Dependencies
~1.3–1.8MB
~41K SLoC