Skip to content

Consolidate path setting files entitlements to config #123649

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

Merged

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Feb 27, 2025

The setting based paths could be either absolute or relative, and they are always relative to the config dir. This commit removes the relative_path_setting property, and adds a mandatory basedir_if_relative property.

The setting based paths could be either absolute or relative, and they
are always relative to the config dir. This commit renames the
path_setting to make it clear it is related to config, and removes the
relative variant.
@rjernst rjernst added >refactoring auto-backport Automatically create backport pull requests when merged v8.18.1 v8.19.0 v9.0.1 v9.1.0 :Core/Infra/Entitlements Entitlements infrastructure labels Feb 27, 2025
@rjernst rjernst requested a review from a team as a code owner February 27, 2025 21:16
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Feb 27, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Contributor

@prdoyle prdoyle left a comment

Choose a reason for hiding this comment

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

LGTM

if (platform == platform()) {
return this;
Stream<String> result;
if (setting.contains("*")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering why we need this asterisk check. Does the settingGlobResolver path do the wrong thing if the setting contains no asterisk?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the setting glob resolver only knows how to deal with glob.

Copy link
Contributor

Choose a reason for hiding this comment

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

But a glob with no asterisks is still a glob right? Even if it's trivial.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just a way to understand if we want to call the "regular" Settings resolved (which maps to Settings#get) or the glob resolver (which maps to Settings#getGlobValues). The latter throws if you don't pass down something that contains a ".*."
Btw I think we should match that here, and look for ".*.", not just *.

mode: read
- relative_path_setting: foo.bar
relative_to: config
- config_path_setting: foo.bar
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. This is the first entitlement whose meaning is not immediately obvious to me. It could be particularly confusing if the path has nothing to do with the config dir (ie. if it's an absolute path). path_setting made sense to me, because it's a setting representing a path.

Anyway I don't feel strongly about it. If you think plugin authors will understand this, that's what matters. And assuming we want all three words "config", "path", and "setting" in the name, I think you've picked the best possible order. 😂

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I find it a bit awkward too. I also tend to think path_setting makes sense but it doesn't convey the implicit handling paths relative to config. But, to be honest, I'm not sure prefixing config to the name makes things much clearer.

This also keeps the door open to introducing other "path setting" entitlements in the future that have slightly different semantics.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure there's a need to convey that relative paths relate to config in the name of this field. That could be just how path_setting works, and mentioned in documentation. The first time someone says "huh, a relative path; I wonder what it's relative to?" the first place they'd look would be the docs for path_setting.

@rjernst rjernst enabled auto-merge (squash) February 28, 2025 00:55
@rjernst rjernst merged commit 71f72b9 into elastic:main Feb 28, 2025
17 checks passed
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Feb 28, 2025
The setting based paths could be either absolute or relative, and they
are always relative to the config dir. This commit renames the
path_setting to make it clear it is related to config, and removes the
relative variant.
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Feb 28, 2025
The setting based paths could be either absolute or relative, and they
are always relative to the config dir. This commit renames the
path_setting to make it clear it is related to config, and removes the
relative variant.
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Feb 28, 2025
The setting based paths could be either absolute or relative, and they
are always relative to the config dir. This commit renames the
path_setting to make it clear it is related to config, and removes the
relative variant.
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.18
8.x
9.0

elasticsearchmachine pushed a commit that referenced this pull request Feb 28, 2025
)

The setting based paths could be either absolute or relative, and they
are always relative to the config dir. This commit renames the
path_setting to make it clear it is related to config, and removes the
relative variant.
elasticsearchmachine pushed a commit that referenced this pull request Feb 28, 2025
)

The setting based paths could be either absolute or relative, and they
are always relative to the config dir. This commit renames the
path_setting to make it clear it is related to config, and removes the
relative variant.
elasticsearchmachine pushed a commit that referenced this pull request Feb 28, 2025
)

The setting based paths could be either absolute or relative, and they
are always relative to the config dir. This commit renames the
path_setting to make it clear it is related to config, and removes the
relative variant.
@ldematte
Copy link
Contributor

I see this has been already merged and I like it overall, but I agree that naming does not make it obvious.
What about path_from_setting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged :Core/Infra/Entitlements Entitlements infrastructure >refactoring Team:Core/Infra Meta label for core/infra team v8.18.1 v8.19.0 v9.0.1 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants