diff --git a/README.md b/README.md index e2fc828..7856ecd 100644 --- a/README.md +++ b/README.md @@ -19,39 +19,41 @@ Beim Start der Anwendung können Parameter angegeben werden. Usage: mv64e-rest-to-kafka-gateway [OPTIONS] --token Options: - --bootstrap-server - Kafka Bootstrap-Server(s) [env: KAFKA_BOOTSTRAP_SERVERS=] [default: kafka:9094] - --topic - Kafka Topic [env: APP_KAFKA_TOPIC=] [default: etl-processor_input] - --token - bcrypt hashed Security Token [env: APP_SECURITY_TOKEN=] --listen - Address and port for HTTP requests [env: APP_LISTEN=] [default: [::]:3000] + Address and port for HTTP requests [env: LISTEN=] [default: [::]:3000] + --token + bcrypt hashed Security Token [env: SECURITY_TOKEN=] + --bootstrap-server + Kafka Bootstrap Server [env: KAFKA_BOOTSTRAP_SERVERS=] [default: kafka:9094] + --topic + Kafka Topic [env: KAFKA_TOPIC=] [default: etl-processor_input] --ssl-ca-file - CA file for SSL connection to Kafka [env: APP_SSL_CA_FILE=] + CA file for SSL connection to Kafka [env: KAFKA_SSL_CA_FILE=] --ssl-cert-file - Certificate file for SSL connection to Kafka [env: APP_SSL_CERT_FILE=] + Certificate file for SSL connection to Kafka [env: KAFKA_SSL_CERT_FILE=] --ssl-key-file - Key file for SSL connection to Kafka [env: APP_SSL_KEY_FILE=] + Key file for SSL connection to Kafka [env: KAFKA_SSL_KEY_FILE=] + --ssl-key-password + The SSL key password [env: KAFKA_SSL_KEY_PASSWORD=] ``` Die Anwendung lässt sich auch mit Umgebungsvariablen konfigurieren. -* `APP_KAFKA_SERVERS`: Zu verwendende Kafka-Bootstrap-Server als kommagetrennte Liste -* `APP_KAFKA_TOPIC`: Zu verwendendes Topic zum Warten auf neue Anfragen. Standardwert: `etl-processor_input` -* `APP_SECURITY_TOKEN`: Verpflichtende Angabe es Tokens als *bcrypt*-Hash -* `APP_LISTEN`: Adresse und Port für eingehende HTTP-Requests. Standardwert: `[::]:3000` - Port `3000` auf allen +* `LISTEN`: Adresse und Port für eingehende HTTP-Requests. Standardwert: `[::]:3000` - Port `3000` auf allen Adressen (IPv4 und IPv6) +* `SECURITY_TOKEN`: Verpflichtende Angabe es Tokens als *bcrypt*-Hash +* `KAFKA_BOOTSTRAP_SERVERS`: Zu verwendende Kafka-Bootstrap-Server als kommagetrennte Liste +* `KAFKA_TOPIC`: Zu verwendendes Topic zum Warten auf neue Anfragen. Standardwert: `etl-processor_input` Optionale Umgebungsvariablen - wenn angegeben wird eine SSL-Verbindung zu Kafka aufgebaut. -* `APP_KAFKA_SSL_CA_FILE`: CA für SSL-Verbindungen -* `APP_KAFKA_SSL_CERT_FILE`: SSL Certificate Datei -* `APP_KAFKA_SSL_KEY_FILE`: SSL Key Datei -* `APP_KAFKA_SSL_KEY_PASSWORD`: SSL KEY Passwort (wenn benötigt) +* `KAFKA_SSL_CA_FILE`: CA für SSL-Verbindungen +* `KAFKA_SSL_CERT_FILE`: SSL Certificate Datei +* `KAFKA_SSL_KEY_FILE`: SSL Key Datei +* `KAFKA_SSL_KEY_PASSWORD`: SSL KEY Passwort (wenn benötigt) Die Angabe eines Tokens ist verpflichtend und kann entweder über den Parameter `--token` erfolgen, oder über die -Umgebungsvariable `APP_SECURITY_TOKEN`. +Umgebungsvariable `SECURITY_TOKEN`. ## HTTP-Requests @@ -73,7 +75,7 @@ wird. Requests müssen einen HTTP-Header `authorization` für HTTP-Basic enthalten. Hier ist es erforderlich, dass der Benutzername `token` gewählt wird. -Es ist hierzu erforderlich, die erforderliche Umgebungsvariable `APP_SECURITY_TOKEN` zu setzen. Dies kann z.B. mit +Es ist hierzu erforderlich, die erforderliche Umgebungsvariable `SECURITY_TOKEN` zu setzen. Dies kann z.B. mit *htpasswd* erzeugt werden: ``` diff --git a/src/cli.rs b/src/cli.rs index 17c6c6b..6ee9308 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -4,10 +4,24 @@ use clap::Parser; #[command(author, version, about)] #[command(arg_required_else_help(true))] pub struct Cli { + #[arg( + long, + env = "LISTEN", + default_value = "[::]:3000", + help = "Address and port for HTTP requests" + )] + pub listen: String, + #[arg( + long, + alias = "security-token", + env = "SECURITY_TOKEN", + help = "bcrypt hashed Security Token" + )] + pub token: String, #[arg( long, alias = "kafka-servers", - env = "APP_KAFKA_SERVERS", + env = "KAFKA_BOOTSTRAP_SERVERS", default_value = "kafka:9094", help = "Kafka Bootstrap Server" )] @@ -15,47 +29,29 @@ pub struct Cli { #[arg( long, alias = "kafka-topic", - env = "APP_KAFKA_TOPIC", + env = "KAFKA_TOPIC", default_value = "etl-processor_input", help = "Kafka Topic" )] pub topic: String, #[arg( long, - alias = "security-token", - env = "APP_SECURITY_TOKEN", - help = "bcrypt hashed Security Token" - )] - pub token: String, - #[arg( - long, - env = "APP_LISTEN", - default_value = "[::]:3000", - help = "Address and port for HTTP requests" - )] - pub listen: String, - #[arg( - long, - env = "APP_KAFKA_SSL_CA_FILE", + env = "KAFKA_SSL_CA_FILE", help = "CA file for SSL connection to Kafka" )] pub ssl_ca_file: Option, #[arg( long, - env = "APP_KAFKA_SSL_CERT_FILE", + env = "KAFKA_SSL_CERT_FILE", help = "Certificate file for SSL connection to Kafka" )] pub ssl_cert_file: Option, #[arg( long, - env = "APP_KAFKA_SSL_KEY_FILE", + env = "KAFKA_SSL_KEY_FILE", help = "Key file for SSL connection to Kafka" )] pub ssl_key_file: Option, - #[arg( - long, - env = "APP_KAFKA_SSL_KEY_PASSWORD", - help = "The SSL key password" - )] + #[arg(long, env = "KAFKA_SSL_KEY_PASSWORD", help = "The SSL key password")] pub ssl_key_password: Option, }