[ https://issues.apache.org/jira/browse/KNOX-3002?focusedWorklogId=901875&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-901875 ]
ASF GitHub Bot logged work on KNOX-3002: ---------------------------------------- Author: ASF GitHub Bot Created on: 26/Jan/24 08:11 Start Date: 26/Jan/24 08:11 Worklog Time Spent: 10m Work Description: 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 :) Issue Time Tracking ------------------- Worklog Id: (was: 901875) Time Spent: 0.5h (was: 20m) > KnoxCLI command for generating descriptor for a role type from a list of hosts > ------------------------------------------------------------------------------ > > Key: KNOX-3002 > URL: https://issues.apache.org/jira/browse/KNOX-3002 > Project: Apache Knox > Issue Type: New Feature > Components: KnoxCLI > Reporter: Attila Magyar > Assignee: Attila Magyar > Priority: Major > Time Spent: 0.5h > Remaining Estimate: 0h > -- This message was sent by Atlassian Jira (v8.20.10#820010)