Created
December 17, 2019 08:01
-
-
Save alexeldeib/3b77fe2d54ebc37c904bd26ac7777271 to your computer and use it in GitHub Desktop.
imds sced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------------------ | |
# Cargo Build Stage | |
# ------------------------------------------------------------------------------ | |
FROM rust:latest as cargo-build | |
ARG APP=blah | |
ENV APP=$APP | |
ENV USER=root | |
WORKDIR /usr/src/blah | |
COPY . . | |
RUN cargo vendor | |
RUN cargo build --release | |
RUN cargo install --path . | |
# ------------------------------------------------------------------------------ | |
# Final Stage | |
# ------------------------------------------------------------------------------ | |
FROM gcr.io/distroless/cc | |
COPY --from=cargo-build /usr/src/blah/target/release/blah /usr/local/bin/blah | |
CMD ["/usr/local/bin/blah"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use serde::{Deserialize, Serialize}; | |
#[derive(Serialize, Deserialize, Debug)] | |
struct Metadata { | |
compute: Compute, | |
} | |
#[derive(Serialize, Deserialize, Debug)] | |
struct Compute { | |
name: String, | |
#[serde(rename = "azEnvironment")] | |
environment: String, | |
} | |
#[derive(Serialize, Deserialize, Debug)] | |
#[serde(rename_all = "PascalCase")] | |
struct ScheduledEventResponse { | |
document_incarnation: String, | |
events: Vec<Event>, | |
} | |
#[derive(Serialize, Deserialize, Debug)] | |
#[serde(rename_all = "PascalCase")] | |
struct Event { | |
event_id: String, | |
event_type: String, | |
resource_type: String, | |
resources: Vec<String>, | |
event_status: String, | |
not_before: String, | |
} | |
#[tokio::main] | |
async fn main() -> Result<(), Box<dyn std::error::Error>> { | |
let res = reqwest::Client::new() | |
.get("http://169.254.169.254/metadata/scheduledevents?api-version=2017-11-01") | |
.header("Metadata", "true") | |
.send() | |
.await? | |
.text() | |
.await?; | |
let data: ScheduledEventResponse = serde_json::from_str(&res[..]).unwrap(); | |
println!("{:#?}", data); | |
Ok(()) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment