Skip to content

Commit

Permalink
fix: setting up self config in workers
Browse files Browse the repository at this point in the history
  • Loading branch information
woutersl committed Nov 6, 2024
1 parent da86ffe commit 9bf99af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/model/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,20 @@ impl Configuration {
token: self.self_service_token.clone(),
}
}

/// Sets the self configuration from a external registry spec
pub fn set_self_from_external(&mut self, external_config: ExternalRegistry) {
self.self_local_name = external_config.name;
self.web_public_uri = if external_config.protocol == ExternalRegistryProtocol::Sparse {
external_config.index[..(external_config.index.len() - 1)].to_string()
} else {
external_config.index
};
self.index.allow_protocol_sparse = external_config.protocol == ExternalRegistryProtocol::Sparse;
self.index.allow_protocol_git = external_config.protocol == ExternalRegistryProtocol::Git;
self.self_service_login = external_config.login;
self.self_service_token = external_config.token;
}
}

/// Gets the rustc version
Expand Down
2 changes: 1 addition & 1 deletion src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn main_loop(
));
};
let external_config = serde_json::from_str::<ExternalRegistry>(&message)?;
config.external_registries.push(external_config);
config.set_self_from_external(external_config);
config.write_auth_config().await?;
let config = &config;

Expand Down

0 comments on commit 9bf99af

Please sign in to comment.