Skip to content

Commit

Permalink
Logs and simple docker example
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Jul 11, 2024
1 parent b745cb9 commit a14f8a6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/simple-api-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["[email protected]"]
edition = "2021"

[dependencies]
gcloud-sdk = { path = "./../../gcloud-sdk", default-features = false, features = ["google-logging-v2"] }
gcloud-sdk = { version = "0.25.0", git = "https://github.com/abdolence/gcloud-sdk-rs.git", branch = "hyper-1", default-features = false, features = ["tls-webpki-roots","google-logging-v2"] }
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version ="0.3", features = ["env-filter"] }
24 changes: 24 additions & 0 deletions examples/simple-api-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM rust:1 as builder

WORKDIR /opt/sources

COPY src src
COPY Cargo.toml ./

RUN cargo build --release --bin simple-api-client-example


FROM gcr.io/distroless/cc-debian12

COPY --from=builder /usr/lib/x86_64-linux-gnu/libcbor.* /usr/lib/x86_64-linux-gnu/
COPY --from=builder /usr/lib/x86_64-linux-gnu/libcrypt* /usr/lib/x86_64-linux-gnu/
COPY --from=builder /usr/lib/x86_64-linux-gnu/libgmp* /usr/lib/x86_64-linux-gnu/
COPY --from=builder /usr/lib/x86_64-linux-gnu/libgnutls* /usr/lib/x86_64-linux-gnu/
COPY --from=builder /usr/lib/x86_64-linux-gnu/libicu* /usr/lib/x86_64-linux-gnu/
COPY --from=builder /usr/lib/x86_64-linux-gnu/libssl* /usr/lib/x86_64-linux-gnu/

COPY --from=builder /opt/sources/target/release/simple-api-client-example /opt/service/simple-api-client-example

WORKDIR /opt/service

CMD ["./simple-api-client-example"]
11 changes: 8 additions & 3 deletions gcloud-sdk/src/token_source/gce/gce_metadata_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::error::ErrorKind;
use hyper::http::uri::PathAndQuery;
use std::env;
use tracing::debug;

#[derive(Debug)]
pub struct GceMetadataClient {
Expand All @@ -14,6 +15,7 @@ impl GceMetadataClient {
pub fn new() -> Self {
match env::var(GCE_METADATA_HOST_ENV).ok() {
Some(metadata_server_host) => {
debug!("Detected metadata server host: {}", metadata_server_host);
let mut default_headers = reqwest::header::HeaderMap::new();
default_headers.append(
"Metadata-Flavor",
Expand All @@ -38,9 +40,12 @@ impl GceMetadataClient {
metadata_server_host,
}
}
None => Self {
metadata_client: None,
metadata_server_host: "metadata_server_host".into(),
None => {
debug!("No metadata server detected");
Self {
metadata_client: None,
metadata_server_host: "metadata_server_host".into(),
}
},
}
}
Expand Down

0 comments on commit a14f8a6

Please sign in to comment.