-
Notifications
You must be signed in to change notification settings - Fork 28
Fix broken state file path resolution #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken state file path resolution #295
Conversation
Not sure how I feel about it. For me it looks messier than ability to set |
|
The weirdness comes at the point that we decide to append cw-orch path without any additional input. What if we use something like
@Kayanski thoughts |
We chose to use ~/.cw-orchestrator by default to make sure that people don't need to be in a specific folder to run their scripts. With Now, we need to decide what to do for paths. Using $VARIABLE inside env files is very error-prone no ? Even if shellexpand covers it |
Buckram123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how ../ would be handled. Agree it's much cleaner!
cw-orch-daemon/src/state.rs
Outdated
| if env_file_path | ||
| .components() | ||
| .map(|comp| comp.as_os_str().to_owned().into_string().unwrap()) | ||
| .next() | ||
| == Some(".".to_string()) | ||
| { | ||
| let current_dir = std::env::current_dir()?; | ||
| let actual_relative_path = env_file_path.strip_prefix("./")?; | ||
| current_dir.join(actual_relative_path) | ||
| } else { | ||
| let state_folder = default_state_folder()?; | ||
|
|
||
| // We need to create the default state folder if it doesn't exist | ||
| std::fs::create_dir_all(state_folder.clone())?; | ||
|
|
||
| state_folder.join(env_file_path) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder how it would handle ../
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
|
This PR aims at resolving state file path resolution
Closes ORC-46
Discussion
Today we have 2 variables to set the state file path :
This is too much. I propose to remove the first one and keep only the latter and follow the rules :
folder/file.jsonis.cw-orchestrator/folder/file.json./folder/file.jsoniscall_dir/folder/file.json/usr/var/file.jsonis/usr/var/file.json