forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowing custom folder name for plugin installation (opensearch-proje…
…ct#848) Signed-off-by: Vacha Shah <vachshah@amazon.com>
- Loading branch information
Showing
15 changed files
with
269 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
distribution/tools/plugin-cli/src/main/java/org/opensearch/plugins/PluginHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.plugins; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* A helper class for the plugin-cli tasks. | ||
*/ | ||
public class PluginHelper { | ||
|
||
/** | ||
* Verify if a plugin exists with any folder name. | ||
* @param pluginPath the path for the plugins directory. | ||
* @param pluginName the name of the concerned plugin. | ||
* @return the path of the folder if the plugin exists. | ||
* @throws IOException if any I/O exception occurs while performing a file operation | ||
*/ | ||
public static Path verifyIfPluginExists(Path pluginPath, String pluginName) throws IOException { | ||
List<Path> pluginSubFolders = Files.walk(pluginPath, 1).filter(Files::isDirectory).collect(Collectors.toList()); | ||
for (Path customPluginFolderPath : pluginSubFolders) { | ||
if (customPluginFolderPath != pluginPath | ||
&& !((customPluginFolderPath.getFileName().toString()).contains(".installing")) | ||
&& !((customPluginFolderPath.getFileName().toString()).contains(".removing"))) { | ||
final PluginInfo info = PluginInfo.readFromProperties(customPluginFolderPath); | ||
if (info.getName().equals(pluginName)) { | ||
return customPluginFolderPath; | ||
} | ||
} | ||
} | ||
return pluginPath.resolve(pluginName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.