-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Allowing custom folder name for plugin installation #848
Allowing custom folder name for plugin installation #848
Conversation
✅ Gradle Wrapper Validation success 838229ded3c80bc2764a66935638cf71e7cfbf1b |
✅ DCO Check Passed 838229ded3c80bc2764a66935638cf71e7cfbf1b |
✅ Gradle Precommit success 838229ded3c80bc2764a66935638cf71e7cfbf1b |
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.
Good. Some should haves.
@@ -97,6 +98,9 @@ class PluginBuildPlugin implements Plugin<Project> { | |||
if (extension1.classname == null) { | |||
throw new InvalidUserDataException('classname is a required setting for opensearchplugin') | |||
} | |||
if (extension1.folderName == null) { |
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.
Why is folder defaulted to a empty string and not left alone as null
?
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.
The folder name property is added in plugin-descriptor.properties
so when copying these properties over, the logic needs some value of folder name, by default String gets converted to null and it is not able to read that. Other optional properties like extendedPlugins
also have a default added but it is a list so an empty list works for that. However, I have moved this default for folder name to PluginPropertiesExtension.java
so the check here would not be needed.
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.
You could fix this by assigning the value in the constructor. Then you don't even need a method that returns id
or folderName
depending on whether the latter is set.
@@ -864,16 +878,11 @@ private PluginInfo installPlugin(Terminal terminal, boolean isBatch, Path tmpRoo | |||
} | |||
PluginSecurity.confirmPolicyExceptions(terminal, permissions, isBatch); | |||
|
|||
final Path destination = env.pluginsFile().resolve(info.getName()); | |||
String folderName = (info.getFolderName() == null || info.getFolderName().isEmpty()) ? info.getName() : info.getFolderName(); |
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 be a method on info
, e.g. info.getTargetFolderName()
for example, and reused in a couple of places where we try to do this condition.
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.
Added a method getTargetFolderName()
for PluginInfo
.
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.
This is not a must have, but you could probably do what I am suggesting above, set the value of folderName
in the constructor and then you don't even need getTargetFolderName
- folderName
would have the correct value all the time, defaulting to id
.
"classname", | ||
"FakePlugin", | ||
"folderName", | ||
"customFolder" |
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.
Since it's a folder, let's change the example to custom-folder
, we don't want to encourage camelCase folder names.
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.
Thats true! Updated all the custom folder names to kebab-case.
} | ||
|
||
static void writePlugin(String name, boolean withCustomFolder, Path structure, String... additionalProps) throws IOException { | ||
if (withCustomFolder) { |
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.
Pass in the actual folder name (or null) instead of a boolean, and set it instead of doing this if
. Avoids duplicating this.
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.
Updated this.
838229d
to
fc944e6
Compare
✅ DCO Check Passed fc944e6d78281cd183c91826abd8467f00c728aa |
✅ Gradle Wrapper Validation success fc944e6d78281cd183c91826abd8467f00c728aa |
✅ Gradle Precommit success fc944e6d78281cd183c91826abd8467f00c728aa |
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.
Looks a lot cleaner, just some small stuff.
buildSrc/src/main/java/org/opensearch/gradle/plugin/PluginPropertiesExtension.java
Outdated
Show resolved
Hide resolved
), | ||
Arrays.stream(additionalProps) | ||
).toArray(String[]::new); | ||
if (folderName != null) { |
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.
Remove?
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.
Oh yes I missed this, removed it.
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'll hit approve, that empty if
needs to be removed but feel free to merge otherwise.
We'll need a corresponding doc change I believe for 1.1, cc: @aetter, maybe point @VachaShah where to make it? |
fc944e6
to
3f256cb
Compare
✅ Gradle Wrapper Validation success 3f256cbc83359f6f46866102859ecfc775f33b27 |
✅ DCO Check Passed 3f256cbc83359f6f46866102859ecfc775f33b27 |
✅ Gradle Precommit success 3f256cbc83359f6f46866102859ecfc775f33b27 |
start gradle check |
❌ Gradle Check failure 3f256cbc83359f6f46866102859ecfc775f33b27 |
@VachaShah not sure what's up with CI failures ^ |
I will look into these. |
I don't think changing the behavior of how |
We are not changing the behavior of the list or remove commands. They still work the same way as before, I added the behavior in the description just to show the behavior. This is just to provide the user a way to customize the folder name during installation. |
Got it - Just to confirm, if I install a plugin with a custom folder name, I can still remove it using the plugin name? And when I run 'opensearch-pugin list` it still lists the original plugin name? |
No the list command lists the folder name and the remove command uses the folder name to remove the plugin. |
Okay, that's what I was referring to as a change in behavior. I think, we need to make this change in a way that keeps the old behavior as it is and doesn't break it. |
@@ -116,6 +119,7 @@ public PluginInfo(final StreamInput in) throws IOException { | |||
javaVersion = "1.8"; | |||
} | |||
this.classname = in.readString(); | |||
this.folderName = in.readString(); |
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 think this needs to be scoped to a version e.g. if a version is after 1.0.0, then read it from the input stream otherwise use the default value for bwc.
Also, you need to add this field to the writeTo
method for writing to the output stream .
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 missed that in my CR, good call.
So we think users today think of adding/removing as using the ID not the folder. They just happen to be the same and the code uses folder. Sounds like you should be able to specify either. Rabi is right. |
Currently for this feature, the things that have been done are:
Other cases that would be required to maintain the backwards compatibility as mentioned by @adnapibar:
@adnapibar @dblock Any thoughts? |
Generally I think we need to fix everything that is broken by the change, so the entire list below.
Maybe we can add showing the plugin ID, name and folder to avoid confusion? I am not personally familiar with how this command works.
Agreed.
I think when removing a plugin scanning the list of all known folder names is a good idea. |
start gradle check |
Gradle check failing with the following errors:
|
start gradle check |
@VachaShah looks like this is labeled |
Sure will do. |
…ct#848) Signed-off-by: Vacha Shah <vachshah@amazon.com>
…ct#848) Signed-off-by: Vacha Shah <vachshah@amazon.com>
* @param extendedPlugins other plugins this plugin extends through SPI | ||
* @param hasNativeController whether or not the plugin has a native controller | ||
*/ | ||
public PluginInfo(String name, String description, String version, Version opensearchVersion, String javaVersion, | ||
String classname, List<String> extendedPlugins, boolean hasNativeController) { | ||
String classname, String customFolderName, List<String> extendedPlugins, boolean hasNativeController) { |
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.
Is it possible to keep the original constructor and add a new constructor to support customFolderName
? This change caused AD test case failed. Not a big problem, but we'd better make the change backward compatible.
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, we should have done that. Let's not break the interfaces like these :(
/cc: @VachaShah
@ylwu-amzn if you can PR this that'd be much appreciated, if not open an issue so we don't forget?
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.
@dblock busy with AD plugin feature development. Will open an issue to track this.
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.
Created an issue: #1190
Hi, |
I think we missed docs, I opened opensearch-project/documentation-website#756 (feel free to do the same for anything missing). |
…ype (opensearch-project#848) * Fixing cluster stats response for role types and adding search role type Signed-off-by: Vacha Shah <vachshah@amazon.com> * Add CHANGELOG Signed-off-by: Vacha Shah <vachshah@amazon.com> --------- Signed-off-by: Vacha Shah <vachshah@amazon.com>
Signed-off-by: Vacha Shah vachshah@amazon.com
Description
This PR allows the user to add a custom folder name for plugin cli installation. This custom folder name can be specified in the plugin properties file for the plugin, when this property is specified, the plugin would be installed with the custom folder name otherwise it will be installed with the name of the plugin. This feature would be available for versions after 1.0.0.
The feature includes:
install
plugin command will display the folder name where the plugin is being installed.list
plugin command will continue to display the plugin name to maintain backwards compatibility.remove
plugin command will continue to take in the plugin name to remove it even though the plugin is installed in a custom folder to maintain backwards compatibility.Testing
customFolderName
property inbuild.gradle
forjob-scheduler
plugin as follows:./opensearch-plugin install <path to build file>
, this resulted in the plugin being installed in folder:custom-folder
with an output message as follows:./opensearch-plugin list
, this resulted in the output:opensearch-job-scheduler
../opensearch-plugin remove opensearch-job-scheduler
.Issues Resolved
#686
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.