Do not require instances to exist during optional config load ()

* Do not require instances to exist during optional config load

We were incorrectly requiring every config file to have the named
instance be present during configuration loading. This led to a
situation where if /etc/kanidm/config didn't have a user configured
instance from their ~/.config/kanidm, that the cli would fail to
load.

* CLIPS FOR THE CLIP GODS
This commit is contained in:
Firstyear 2025-05-02 14:40:23 +10:00 committed by GitHub
parent f2d4f65bc6
commit b27fd2f3de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -375,12 +375,15 @@ impl KanidmClientBuilder {
if let Some(instance_config) = config.instances.remove(instance_name) {
self.apply_config_options(instance_config)
} else {
let emsg = format!(
"instance {} does not exist in config file {:?}",
instance_name, config_path
info!(
"instance {} does not exist in config file {}",
instance_name,
config_path.as_ref().display()
);
error!(%emsg);
Err(ClientError::ConfigParseIssue(emsg))
// It's not an error if the instance isn't present, the build step
// will fail if there is insufficent information to proceed.
Ok(self)
}
} else {
self.apply_config_options(config.default)