diff options
author | Vincent Ambo <mail@tazj.in> | 2022-02-18T08·36+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-02-18T11·52+0000 |
commit | ede837b6873a4f475b66bb6ee44e7190cd404012 (patch) | |
tree | 035cd699537de9e1dbf1eedf888f006e21bb373e /ops/journaldriver/src/main.rs | |
parent | 4ce2b49cd9e14f862f16326b925aadcc28b9fdb6 (diff) |
refactor(journaldriver): Use anyhow instead of failure r/3852
Apparently failure is not hip anymore, and crate updates are forcing the use of anyhow now. Whatever. The functionality basically stays the same, maybe error messages will look a little bit different now. Change-Id: I173d644688785339c16161ddeec47a534123710f Reviewed-on: https://cl.tvl.fyi/c/depot/+/5307 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: tazjin <tazjin@tvl.su>
Diffstat (limited to '')
-rw-r--r-- | ops/journaldriver/src/main.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/ops/journaldriver/src/main.rs b/ops/journaldriver/src/main.rs index 0c0e5cc23bff..1315d49eff49 100644 --- a/ops/journaldriver/src/main.rs +++ b/ops/journaldriver/src/main.rs @@ -32,7 +32,7 @@ //! `LOG_NAME` environment variables. #[macro_use] -extern crate failure; +extern crate anyhow; #[macro_use] extern crate log; #[macro_use] @@ -49,9 +49,9 @@ extern crate serde; extern crate systemd; extern crate ureq; +use anyhow::{Context, Result}; use chrono::offset::LocalResult; use chrono::prelude::{DateTime, TimeZone, Utc}; -use failure::ResultExt; use serde_json::{from_str, Value}; use std::fs::{self, rename, File}; use std::io::{self, ErrorKind, Read, Write}; @@ -72,9 +72,6 @@ const METADATA_ZONE_URL: &str = "http://metadata.google.internal/computeMetadata const METADATA_PROJECT_URL: &str = "http://metadata.google.internal/computeMetadata/v1/project/project-id"; -/// Convenience type alias for results using failure's `Error` type. -type Result<T> = std::result::Result<T, failure::Error>; - /// Representation of static service account credentials for GCP. #[derive(Debug, Deserialize)] struct Credentials { @@ -158,8 +155,7 @@ fn get_metadata(url: &str) -> Result<String> { /// Convenience helper for determining the project ID. fn get_project_id() -> String { env::var("GOOGLE_CLOUD_PROJECT") - .map_err(Into::into) - .or_else(|_: failure::Error| get_metadata(METADATA_PROJECT_URL)) + .or_else(|_| get_metadata(METADATA_PROJECT_URL)) .expect("Could not determine project ID") } |