integrated hetzner client in repo + showcase of using scope for 'cleaner' scripts
This commit is contained in:
		
							
								
								
									
										25
									
								
								packages/clients/hetznerclient/src/config.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								packages/clients/hetznerclient/src/config.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| use std::env; | ||||
|  | ||||
| #[derive(Clone)] | ||||
| pub struct Config { | ||||
|     pub username: String, | ||||
|     pub password: String, | ||||
|     pub api_url: String, | ||||
| } | ||||
|  | ||||
| impl Config { | ||||
|     pub fn from_env() -> Result<Self, String> { | ||||
|         let username = env::var("HETZNER_USERNAME") | ||||
|             .map_err(|_| "HETZNER_USERNAME environment variable not set".to_string())?; | ||||
|         let password = env::var("HETZNER_PASSWORD") | ||||
|             .map_err(|_| "HETZNER_PASSWORD environment variable not set".to_string())?; | ||||
|         let api_url = env::var("HETZNER_API_URL") | ||||
|             .unwrap_or_else(|_| "https://robot-ws.your-server.de".to_string()); | ||||
|  | ||||
|         Ok(Config { | ||||
|             username, | ||||
|             password, | ||||
|             api_url, | ||||
|         }) | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user