-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Refactor file path resolution for entitlements #127040
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
Changes from 8 commits
60fc0ff
01a2ec0
7be175e
1e3bf01
a69c72e
d7ac08f
48e1e62
e037e9c
aebfe8b
5fddb31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,29 @@ | |
| package org.elasticsearch.entitlement.runtime.policy; | ||
|
|
||
| import java.nio.file.Path; | ||
| import java.util.function.Function; | ||
| import java.util.stream.Stream; | ||
|
|
||
| public record PathLookup( | ||
| Path homeDir, | ||
| Path configDir, | ||
| Path[] dataDirs, | ||
| Path[] sharedRepoDirs, | ||
| Path tempDir, | ||
| Function<String, Stream<String>> settingResolver | ||
| ) {} | ||
| /** | ||
| * Resolves paths for known directories checked by entitlements. | ||
| */ | ||
| public interface PathLookup { | ||
| enum BaseDir { | ||
| HOME, | ||
|
||
| CONFIG, | ||
| DATA, | ||
| SHARED_REPO, | ||
| LIB, | ||
| MODULES, | ||
| PLUGINS, | ||
| LOGS, | ||
| TEMP | ||
| } | ||
|
|
||
| Path getPIDFile(); | ||
|
||
|
|
||
| Stream<Path> getBaseDirPaths(BaseDir baseDir); | ||
|
|
||
| Stream<Path> resolveRelativePaths(BaseDir baseDir, Path relativePath); | ||
|
|
||
| Stream<Path> resolveSettingPaths(BaseDir baseDir, String settingName); | ||
| } | ||
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.
nit: maybe have a helper method to get a dir we expect, so that there can be a clear assertion (there should be exactly one of these in the stream, never 0 or 2+).
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.
I made this handle the streams properly instead of assuming there's only 1.