smolnar82 commented on code in PR #835:
URL: https://github.com/apache/knox/pull/835#discussion_r1467334234
##########
gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java:
##########
@@ -2392,6 +2413,55 @@ public String getUsage() {
}
+ public class GenerateDescriptorCommand extends Command {
+
+ public static final String USAGE =
+ "generate-descriptor --service-urls-file \"path/to/urls.txt\"
--service-name SERVICE_NAME \n" +
+ "--provider-name my-provider.json --descriptor-name
my-descriptor.json \n" +
+ "[--output-dir /path/to/output_dir] \n" +
+ "[--force] \n";
+ public static final String DESC =
+ "Create Knox topology descriptor file for one service\n"
+ + "Options are as follows: \n"
+ + "--service-urls-file (required) path to a text file
containing service urls \n"
+ + "--service-name (required) the name of the service, such
as WEBHDFS, IMPALAUI or HIVE \n"
+ + "--descriptor-name (required) name of descriptor to be
created \n"
+ + "--provider-name (required) name of the referenced
shared provider \n"
+ + "--output-dir (optional) output directory to save the
descriptor file \n"
+ + "--force (optional) force rewriting of existing files,
if not used, command will fail when the configs files with same name already
exist. \n";
+
+ @Override
+ public void execute() throws Exception {
+ if (StringUtils.isBlank(FilenameUtils.getExtension(providerName))
+ ||
StringUtils.isBlank(FilenameUtils.getExtension(descriptorName))) {
+ throw new IllegalArgumentException("JSON extension is required for
provider and descriptor file names");
+ }
+ if (StringUtils.isBlank(urlsFilePath) ) {
+ throw new IllegalArgumentException("Missing --service-urls-file");
+ }
+ if (!new File(urlsFilePath).isFile()) {
+ throw new IllegalArgumentException(urlsFilePath + " does not exist");
+ }
+ if (StringUtils.isBlank(serviceName)) {
+ throw new IllegalArgumentException("Missing --service-name");
+ }
+ File outputDir = StringUtils.isBlank(KnoxCLI.this.outputDir) ? new
File(".") : new File(KnoxCLI.this.outputDir);
+
+ DescriptorGenerator generator =
+ new DescriptorGenerator(descriptorName, providerName,
serviceName, ServiceUrls.fromFile(new File(urlsFilePath)));
+ generator.saveDescriptor(
Review Comment:
I meant the `generator.saveDescriptor(...)` call, just be make it clear :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]