From f90a5eba229c8b02a2ec6ab4672aaa73c8346fb0 Mon Sep 17 00:00:00 2001 From: Seamus Abshere Date: Wed, 13 May 2020 12:01:32 -0400 Subject: [PATCH] respect BIGML_DOMAIN when setting dashboard url --- bigml/src/errors.rs | 1 + bigml/src/resource/id.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bigml/src/errors.rs b/bigml/src/errors.rs index 8803be0..236365f 100644 --- a/bigml/src/errors.rs +++ b/bigml/src/errors.rs @@ -79,6 +79,7 @@ pub enum Error { /// We tried to create a BigML resource, but we failed. Display a dashboard /// URL to make it easy to look up the actual error. + /// FIXME we need to use BIGML_DOMAIN here #[fail(display = "https://bigml.com/dashboard/{} failed ({})", id, message)] WaitFailed { /// The ID of the resource that we were waiting on. diff --git a/bigml/src/resource/id.rs b/bigml/src/resource/id.rs index 0cf7a4d..28b93cc 100644 --- a/bigml/src/resource/id.rs +++ b/bigml/src/resource/id.rs @@ -2,12 +2,14 @@ use serde::de::Unexpected; use serde::{self, Deserialize, Deserializer, Serialize, Serializer}; +use std::env; use std::fmt; use std::marker::PhantomData; use std::str::FromStr; use url::Url; use super::Resource; +use crate::client::DEFAULT_BIGML_DOMAIN; use crate::errors::*; /// A strongly-typed "resource ID" used to identify many different kinds of @@ -30,7 +32,9 @@ impl Id { /// Get a URL pointing at the human-readable version of this resource. pub fn dashboard_url(&self) -> Url { - Url::parse(&format!("https://bigml.com/dashboard/{}", self)) + let domain = env::var("BIGML_DOMAIN") + .unwrap_or_else(|_| DEFAULT_BIGML_DOMAIN.to_owned()); + Url::parse(&format!("https://{}/dashboard/{}", domain, self)) // This should never fail to parse. .expect("dashboard URL unexpectedly failed to parse") }