Skip to content

Commit 0812b28

Browse files
committed
feat: remove fallback to "dev" namespace for operator-config.toml
1 parent 0317159 commit 0812b28

3 files changed

Lines changed: 6 additions & 38 deletions

File tree

doc/src/local-setup.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ In order to run Pharia Kernel, you need to provide a namespace configuration:
3333
mkdir skills
3434
```
3535

36-
All skills in this folder are exposed in the namespace "dev".
36+
All skills in this folder are exposed in the namespace "dev" with the environment variable `NAMESPACES__DEV__DIRECTORY`.
3737
Any changes in this folder will be picked up by the Pharia Kernel automatically. The `operator-config.toml` and `namespace.toml` should not be provided.
3838

3939
2. Start the container:
4040

4141
```shell
4242
podman run \
4343
-v ./skills:/app/skills \
44+
-e NAMESPACES__DEV__DIRECTORY = "/app/skills"
4445
-e PHARIA_AI_TOKEN=$PHARIA_AI_TOKEN \
4546
-e NAMESPACE_UPDATE_INTERVAL=1s \
4647
-e LOG_LEVEL="pharia_kernel=debug" \

src/config.rs

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use anyhow::anyhow;
2-
use config::ConfigError;
3-
use std::{env, io, net::SocketAddr, time::Duration};
2+
use std::{env, net::SocketAddr, time::Duration};
43

54
use crate::namespace_watcher::OperatorConfig;
65

@@ -72,40 +71,8 @@ impl AppConfig {
7271
.unwrap_or("10s")
7372
.parse()?;
7473

75-
let operator_config = match OperatorConfig::new("operator-config.toml") {
76-
Ok(operator_config) => operator_config,
77-
Err(config_error) => match config_error.downcast::<ConfigError>() {
78-
Ok(ConfigError::Foreign(foreign_error)) => {
79-
match foreign_error.downcast::<io::Error>() {
80-
Ok(io_error) if io_error.kind() == io::ErrorKind::NotFound => {
81-
// println! as the logger is not yet instantiated
82-
println!("Info: The 'operator-config.toml' is not found, fallback to the namespace 'dev' with the path 'skills' as the registry.");
83-
OperatorConfig::dev()
84-
}
85-
Ok(err) => {
86-
return Err(anyhow!(
87-
"The provided operator configuration must be valid: {err}"
88-
))
89-
}
90-
Err(err) => {
91-
return Err(anyhow!(
92-
"The provided operator configuration must be valid: {err}"
93-
))
94-
}
95-
}
96-
}
97-
Ok(err) => {
98-
return Err(anyhow!(
99-
"The provided operator configuration must be valid: {err}"
100-
))
101-
}
102-
Err(err) => {
103-
return Err(anyhow!(
104-
"The provided operator configuration must be valid: {err}"
105-
))
106-
}
107-
},
108-
};
74+
let operator_config = OperatorConfig::new("operator-config.toml")
75+
.map_err(|err| anyhow!("The provided operator configuration must be valid: {err}"))?;
10976

11077
let use_pooling_allocator = env::var("USE_POOLING_ALLOCATOR")
11178
.as_deref()

src/namespace_watcher/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl OperatorConfig {
4848
/// # Errors
4949
/// Cannot parse operator config from the provided file or the environment variables.
5050
pub fn new(config_file: &str) -> anyhow::Result<Self> {
51-
let file = File::with_name(config_file);
51+
let file = File::with_name(config_file).required(false);
5252
let env = Self::environment();
5353
Self::from_sources(file, env)
5454
}

0 commit comments

Comments
 (0)