-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add the ability to access file_path in FileOpener #8484
Conversation
Thanks for the PR! This will not work correctly as the |
Thanks for the review. I'm not so sure where/how we could get and then set the file_path (in this case, glob_pattern) in |
I'm not a big fan of this solution as I can see this becoming tricky w.r.t. memory management of the multiple openers as you are returning a raw pointer and not an owning pointer - I think a cleaner solution would be to expand |
virtual ~FileOpener() {}; | ||
|
||
virtual bool TryGetCurrentSetting(const string &key, Value &result) = 0; | ||
virtual bool TryGetCurrentSetting(const string &key, Value &result, FileOpenerInfo &info) = 0; |
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.
Can make new argument an optional_ptr and default it to a nullptr for most subclasses.
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.
Looking at usage again. It might be cleaner to have two virtual TryGetCurrentSetting
methods one with the FileOpenerInfo
and one without. This way users can only provide FileOpenerInfo when it makes sense, and avoids potentially confusing nullptrs
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.
Okay makes sense!
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.
Can default this method to disregard FileOpenerInfo
to make life easier on library writer (though I am personally inclined towards forcing libraries to be explicit).
} | ||
|
||
bool FileOpener::TryGetCurrentSetting(const string &key, Value &result, FileOpenerInfo &info) { | ||
return false; |
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.
Should this default to calling the none FileOpenerInfo method i.e.
bool FileOpener::TryGetCurrentSetting(const string &key, Value &result, FileOpenerInfo &info) {
return this->TryGetCurrentSetting(key, value);
}
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.
Yes. Corrected.
Thanks for the pointer. I made another attempt. Please let me know if this makes sense. |
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.
Thanks for the fixes! LGTM. Could you just have a look at the failing CI?
Thanks! LGTM |
This allows us to support multiple secrets and do path matching, etc.