Skip to content

Conversation

Mice7R
Copy link
Contributor

@Mice7R Mice7R commented Mar 25, 2025

This sets the file format to be yaml instead of let the config to figure it out by extension. The problem is that it guesses file format by extension and some tools - eg ansible - create tempfiles without extension to validate the config changes before applying them, that makes the validation always fail.

This PR changes how the config file is loaded so that it doesn't guess file type.

@@ -11,7 +11,7 @@ use warpgate_common::{WarpgateConfig, WarpgateConfigStore};

pub fn load_config(path: &Path, secure: bool) -> Result<WarpgateConfig> {
let mut store: serde_yaml::Value = Config::builder()
.add_source(File::from(path))
.add_source(File::new(path.to_str().unwrap_or(""), FileFormat::Yaml))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should fail instead of defaulting to ""

Copy link
Contributor Author

@Mice7R Mice7R Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know enough rust to know how to make it fail with an error thats why I added the default. The default should fail anyway because it doesnt exists.

If you show me how to make it fail, I make the commit

@Mice7R
Copy link
Contributor Author

Mice7R commented Mar 27, 2025

I've changed the code to generate an error instead of defaulting to empty string

@Eugeny Eugeny merged commit 5d3a8ac into warp-tech:main Mar 27, 2025
5 of 8 checks passed
@Eugeny
Copy link
Member

Eugeny commented Mar 27, 2025

Thank you!

@all-contributors please add @Mice7R for code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants