@@ -43,6 +43,7 @@ pub struct PublicNet {
4343 pub ipv4 : Ipv4 ,
4444}
4545
46+ #[ allow( dead_code) ]
4647#[ derive( Debug , Serialize , Deserialize ) ]
4748pub struct IpAddress {
4849 pub ip : String ,
@@ -87,13 +88,22 @@ struct CreateServerRequest {
8788#[ derive( Debug , Deserialize ) ]
8889struct CreateServerResponse {
8990 server : Server ,
91+ root_password : Option < String > ,
9092}
9193
94+ /// Result of creating a server, includes the server info and root password
95+ pub struct CreateServerResult {
96+ pub server : Server ,
97+ pub root_password : Option < String > ,
98+ }
99+
100+ #[ allow( dead_code) ]
92101#[ derive( Debug , Deserialize ) ]
93102struct ErrorResponse {
94103 error : ErrorDetail ,
95104}
96105
106+ #[ allow( dead_code) ]
97107#[ derive( Debug , Deserialize ) ]
98108struct ErrorDetail {
99109 message : String ,
@@ -112,7 +122,7 @@ impl HetznerClient {
112122 }
113123 }
114124
115- pub async fn create_server ( & self , config : & ServerConfig ) -> Result < Server > {
125+ pub async fn create_server ( & self , config : & ServerConfig ) -> Result < CreateServerResult > {
116126 let url = format ! ( "{}/servers" , HETZNER_API_BASE ) ;
117127
118128 let labels = if config. labels . is_empty ( ) {
@@ -183,7 +193,10 @@ impl HetznerClient {
183193 result. server. name, result. server. id, result. server. public_net. ipv4. ip
184194 ) ;
185195
186- Ok ( result. server )
196+ Ok ( CreateServerResult {
197+ server : result. server ,
198+ root_password : result. root_password ,
199+ } )
187200 }
188201
189202 pub async fn delete_server ( & self , id : u64 ) -> Result < ( ) > {
@@ -338,7 +351,9 @@ impl HetznerClient {
338351 #[ derive( Debug , Deserialize ) ]
339352 struct ServerTypesAvailable {
340353 available : Vec < u64 > ,
354+ #[ allow( dead_code) ]
341355 available_for_migration : Vec < u64 > ,
356+ #[ allow( dead_code) ]
342357 supported : Vec < u64 > ,
343358 }
344359
@@ -370,6 +385,7 @@ impl HetznerClient {
370385 . collect ( ) )
371386 }
372387
388+ #[ allow( dead_code) ]
373389 pub async fn get_server ( & self , id : u64 ) -> Result < Server > {
374390 let url = format ! ( "{}/servers/{}" , HETZNER_API_BASE , id) ;
375391
@@ -448,6 +464,7 @@ final_message: "FFmpeg worker is ready!"
448464}
449465
450466/// Cloud-init config with SSH key access
467+ #[ allow( dead_code) ]
451468pub fn worker_cloud_init_with_ssh (
452469 queue_url : & str ,
453470 binary_url : & str ,
@@ -496,13 +513,19 @@ final_message: "FFmpeg worker is ready!"
496513 )
497514}
498515
516+ /// Result of provisioning a worker
517+ pub struct ProvisionResult {
518+ pub ip : String ,
519+ pub root_password : Option < String > ,
520+ }
521+
499522pub async fn provision_worker (
500523 hetzner_token : & str ,
501524 queue_url : & str ,
502525 binary_url : & str ,
503526 bg_image_url : & str ,
504527 name : Option < String > ,
505- ) -> Result < String > {
528+ ) -> Result < ProvisionResult > {
506529 let client = HetznerClient :: new ( hetzner_token. to_string ( ) ) ;
507530
508531 let name = name. unwrap_or_else ( || {
@@ -520,6 +543,9 @@ pub async fn provision_worker(
520543 ..Default :: default ( )
521544 } ;
522545
523- let server = client. create_server ( & config) . await ?;
524- Ok ( server. public_net . ipv4 . ip )
546+ let result = client. create_server ( & config) . await ?;
547+ Ok ( ProvisionResult {
548+ ip : result. server . public_net . ipv4 . ip ,
549+ root_password : result. root_password ,
550+ } )
525551}
0 commit comments