2 * ============LICENSE_START=======================================================
3 * dcaegen2-collectors-veshv
4 * ================================================================================
5 * Copyright (C) 2018-2019 NOKIA
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dcae.collectors.veshv.commandline
22 import org.apache.commons.cli.Option
25 enum class CommandLineOption(val option: Option, val required: Boolean = false) {
26 CONFIGURATION_FILE(required = true,
29 longOpt = "configuration-file"
30 desc = "Json file containing HV-VES configuration"
33 LISTEN_PORT(required = true,
36 longOpt = "listen-port"
40 VES_HV_PORT(required = true,
44 desc = "VesHvCollector port"
47 VES_HV_HOST(required = true,
51 desc = "VesHvCollector host"
54 KAFKA_SERVERS(required = true,
57 longOpt = "kafka-bootstrap-servers"
58 desc = "Comma-separated Kafka bootstrap servers in <host>:<port> format"
61 KAFKA_TOPICS(required = true,
64 longOpt = "kafka-topics"
65 desc = "Comma-separated Kafka topics"
68 HEALTH_CHECK_API_PORT(option {
70 longOpt = "health-check-api-port"
71 desc = "Health check rest api listen port"
76 longOpt = "ssl-disable"
77 desc = "Disable SSL encryption"
79 KEY_STORE_FILE(option {
82 desc = "Key store in PKCS12 format"
85 KEY_STORE_PASSWORD_FILE(option {
87 longOpt = "key-store-password-file"
88 desc = "File with key store password"
91 TRUST_STORE_FILE(option {
93 longOpt = "trust-store"
94 desc = "File with trusted certificate bundle in PKCS12 format"
97 TRUST_STORE_PASSWORD_FILE(option {
99 longOpt = "trust-store-password-file"
100 desc = "File with trust store password"
103 MAXIMUM_PAYLOAD_SIZE_BYTES(option {
105 longOpt = "max-payload-size"
106 desc = "Maximum supported payload size in bytes"
109 DISABLE_PROCESSING(option {
111 longOpt = "disable-processing"
112 desc = "Message queue consumer option. Indicates whether messages should be fully processed"
115 fun environmentVariableName(prefix: String = ""): String =
116 option.longOpt.toUpperCase().replace('-', '_').let { mainPart ->
117 if (prefix.isNotBlank()) {
118 "${prefix}_${mainPart}"
126 private class OptionDSL {
127 lateinit var shortOpt: String
128 lateinit var longOpt: String
129 lateinit var desc: String
130 var hasArgument: Boolean = false
133 private fun option(conf: OptionDSL.() -> Unit): Option {
134 val dsl = OptionDSL().apply(conf)
135 return Option.builder(dsl.shortOpt)
136 .longOpt(dsl.longOpt)
137 .hasArg(dsl.hasArgument)