Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect BIGML_DOMAIN when setting dashboard url #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bigml/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion bigml/src/resource/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,7 +32,9 @@ impl<R: Resource> Id<R> {

/// 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")
}
Expand Down