Custom detekt rule for logger usage check
[dcaegen2/collectors/hv-ves.git] / sources / hv-collector-utils / src / main / kotlin / org / onap / dcae / collectors / veshv / utils / commandline / CommandLineOption.kt
1 /*
2  * ============LICENSE_START=======================================================
3  * dcaegen2-collectors-veshv
4  * ================================================================================
5  * Copyright (C) 2018 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.onap.dcae.collectors.veshv.utils.commandline
21
22 import org.apache.commons.cli.Option
23
24
25 enum class CommandLineOption(val option: Option, val required: Boolean = false) {
26     HEALTH_CHECK_API_PORT(Option.builder("H")
27             .longOpt("health-check-api-port")
28             .hasArg()
29             .desc("Health check rest api listen port")
30             .build()
31     ),
32     LISTEN_PORT(Option.builder("p")
33             .longOpt("listen-port")
34             .hasArg()
35             .desc("Listen port")
36             .build(),
37             required = true
38     ),
39     CONSUL_CONFIG_URL(Option.builder("c")
40             .longOpt("config-url")
41             .hasArg()
42             .desc("URL of ves configuration on consul")
43             .build(),
44             required = true
45     ),
46     CONSUL_FIRST_REQUEST_DELAY(Option.builder("d")
47             .longOpt("first-request-delay")
48             .hasArg()
49             .desc("Delay of first request to consul in seconds")
50             .build()
51     ),
52     CONSUL_REQUEST_INTERVAL(Option.builder("I")
53             .longOpt("request-interval")
54             .hasArg()
55             .desc("Interval of consul configuration requests in seconds")
56             .build()
57     ),
58     VES_HV_PORT(Option.builder("v")
59             .longOpt("ves-port")
60             .hasArg()
61             .desc("VesHvCollector port")
62             .build(),
63             required = true
64     ),
65     VES_HV_HOST(Option.builder("h")
66             .longOpt("ves-host")
67             .hasArg()
68             .desc("VesHvCollector host")
69             .build(),
70             required = true
71     ),
72     KAFKA_SERVERS(Option.builder("s")
73             .longOpt("kafka-bootstrap-servers")
74             .hasArg()
75             .desc("Comma-separated Kafka bootstrap servers in <host>:<port> format")
76             .build(),
77             required = true
78     ),
79     KAFKA_TOPICS(Option.builder("f")
80             .longOpt("kafka-topics")
81             .hasArg()
82             .desc("Comma-separated Kafka topics")
83             .build(),
84             required = true
85     ),
86     SSL_DISABLE(Option.builder("l")
87             .longOpt("ssl-disable")
88             .desc("Disable SSL encryption")
89             .build()
90     ),
91     KEY_STORE_FILE(Option.builder("k")
92             .longOpt("key-store")
93             .hasArg()
94             .desc("Key store in PKCS12 format")
95             .build()
96     ),
97     KEY_STORE_PASSWORD(Option.builder("kp")
98             .longOpt("key-store-password")
99             .hasArg()
100             .desc("Key store password")
101             .build()
102     ),
103     TRUST_STORE_FILE(Option.builder("t")
104             .longOpt("trust-store")
105             .hasArg()
106             .desc("File with trusted certificate bundle in PKCS12 format")
107             .build()
108     ),
109     TRUST_STORE_PASSWORD(Option.builder("tp")
110             .longOpt("trust-store-password")
111             .hasArg()
112             .desc("Trust store password")
113             .build()
114     ),
115     IDLE_TIMEOUT_SEC(Option.builder("i")
116             .longOpt("idle-timeout-sec")
117             .hasArg()
118             .desc("""Idle timeout for remote hosts. After given time without any data exchange the
119                 |connection might be closed.""".trimMargin())
120             .build()
121     ),
122     MAXIMUM_PAYLOAD_SIZE_BYTES(Option.builder("m")
123             .longOpt("max-payload-size")
124             .hasArg()
125             .desc("Maximum supported payload size in bytes")
126             .build()
127     ),
128     DUMMY_MODE(Option.builder("u")
129             .longOpt("dummy")
130             .desc("If present will start in dummy mode (dummy external services)")
131             .build()
132     );
133
134     fun environmentVariableName(prefix: String = DEFAULT_ENV_PREFIX): String =
135             option.longOpt.toUpperCase().replace('-', '_').let { mainPart ->
136                 "${prefix}_${mainPart}"
137             }
138
139     companion object {
140         private const val DEFAULT_ENV_PREFIX = "VESHV"
141     }
142 }