Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 04c7253

Browse files
committedMar 10, 2025··
fixup! edgee: credentials: handle profiles
1 parent 8152637 commit 04c7253

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed
 

‎crates/api-client/src/auth.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,13 @@ impl Config {
8383
match profile {
8484
Some(profile) => self.profiles.get(profile).cloned(),
8585
None => match (self.api_token.clone(), self.url.clone()) {
86-
(Some(api_token), Some(url)) => Some(Credentials { api_token, url }),
86+
(Some(api_token), Some(url)) => Some(Credentials {
87+
api_token,
88+
url: Some(url),
89+
}),
8790
(Some(api_token), _) => Some(Credentials {
8891
api_token,
89-
url: "https://api.edgee.app".to_string(),
92+
url: Some("https://api.edgee.app".to_string()),
9093
}),
9194
_ => None,
9295
},
@@ -100,7 +103,7 @@ impl Config {
100103
}
101104
None => {
102105
self.api_token = Some(creds.api_token);
103-
self.url = Some(creds.url);
106+
self.url = creds.url;
104107
}
105108
}
106109
}
@@ -121,6 +124,7 @@ impl<S: State> ConnectBuilder<S> {
121124
{
122125
let api_token = creds.api_token.clone();
123126
let url = creds.url.clone();
124-
self.baseurl(url.clone().as_str()).api_token(api_token)
127+
self.baseurl(url.unwrap_or("https://api.edgee.app".to_string()))
128+
.api_token(api_token)
125129
}
126130
}

‎crates/cli/src/commands/auth/login.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ pub async fn run(opts: Options) -> Result<()> {
5252
}
5353
};
5454

55-
let creds = Credentials { api_token, url };
55+
let creds = Credentials {
56+
api_token,
57+
url: Some(url),
58+
};
5659

5760
let client = edgee_api_client::new().credentials(&creds).connect();
5861
let user = client

‎crates/cli/src/commands/auth/whoami.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ pub async fn run(opts: Options) -> anyhow::Result<()> {
3737
println!(" ID: {}", user.id);
3838
println!(" Name: {}", user.name);
3939
println!(" Email: {}", user.email);
40-
println!(" Url: {}", creds.url);
40+
if let Some(url) = &creds.url {
41+
println!(" Url: {}", url);
42+
}
4143
if let Some(profile) = opts.profile {
4244
println!(" Profile: {}", profile);
4345
}

0 commit comments

Comments
 (0)
Please sign in to comment.