From 0881b382243dcfba8980bf644cd93a47765afb24 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 9 May 2021 15:23:02 +0200 Subject: [PATCH] kafka: refactor setting "calocation" to "ca" --- etc/examples/nodes/kafka.conf | 94 +++++++++++++++++----------------- include/villas/nodes/kafka.hpp | 4 +- lib/nodes/kafka.cpp | 14 ++--- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/etc/examples/nodes/kafka.conf b/etc/examples/nodes/kafka.conf index 7726a0708..1ff98c5cd 100644 --- a/etc/examples/nodes/kafka.conf +++ b/etc/examples/nodes/kafka.conf @@ -1,47 +1,47 @@ -nodes = { - kafka_consumer_node = { - type = "kafka", - - format = "villas.human", - - server = "localhost:9094", - protocol = "SASL_SSL", - client_id = "villas-node", - - in = { - consume = "test-topic", - group_id = "villas-node" - }, - - ssl = { - calocation = "/etc/ssl/certs/ca.pem", - }, - sals = { - mechanisms = "SCRAM-SHA-512", - username = "scram-sha-512-usr", - password = "scram-sha-512-pwd" - } - } - kafka_producer_node = { - type = "kafka", - - format = "villas.human", - - server = "localhost:9094", - protocol = "SASL_SSL", - client_id = "villas-node", - - out = { - produce = "test-topic" - }, - - ssl = { - calocation = "/etc/ssl/certs/ca.pem", - }, - sals = { - mechanisms = "SCRAM-SHA-512", - username = "scram-sha-512-usr", - password = "scram-sha-512-pwd" - } - } -} +nodes = { + kafka_consumer_node = { + type = "kafka", + + format = "villas.human", + + server = "localhost:9094", + protocol = "SASL_SSL", + client_id = "villas-node", + + in = { + consume = "test-topic", + group_id = "villas-node" + }, + + ssl = { + ca = "/etc/ssl/certs/ca.pem", + }, + sals = { + mechanisms = "SCRAM-SHA-512", + username = "scram-sha-512-usr", + password = "scram-sha-512-pwd" + } + } + kafka_producer_node = { + type = "kafka", + + format = "villas.human", + + server = "localhost:9094", + protocol = "SASL_SSL", + client_id = "villas-node", + + out = { + produce = "test-topic" + }, + + ssl = { + ca = "/etc/ssl/certs/ca.pem", + }, + sals = { + mechanisms = "SCRAM-SHA-512", + username = "scram-sha-512-usr", + password = "scram-sha-512-pwd" + } + } +} diff --git a/include/villas/nodes/kafka.hpp b/include/villas/nodes/kafka.hpp index f888cfa2a..09893b0a8 100644 --- a/include/villas/nodes/kafka.hpp +++ b/include/villas/nodes/kafka.hpp @@ -49,7 +49,7 @@ struct kafka { char *protocol; /**< Security protocol. */ char *produce; /**< Producer topic. */ char *consume; /**< Consumer topic. */ - char *client_id; /**< Client id. */ + char *client_id; /**< Client ID. */ struct { rd_kafka_t *client; @@ -62,7 +62,7 @@ struct kafka { } consumer; struct { - char *calocation; /**< SSL CA file. */ + char *ca; /**< SSL CA file. */ } ssl; struct { diff --git a/lib/nodes/kafka.cpp b/lib/nodes/kafka.cpp index 6628f16a0..7a671e257 100644 --- a/lib/nodes/kafka.cpp +++ b/lib/nodes/kafka.cpp @@ -129,7 +129,7 @@ int kafka_init(struct vnode *n) k->sasl.username = nullptr; k->sasl.password = nullptr; - k->ssl.calocation = nullptr; + k->ssl.ca = nullptr; ret = 0; @@ -182,18 +182,18 @@ int kafka_parse(struct vnode *n, json_t *json) if (json_ssl) { - const char *calocation = nullptr; + const char *ca = nullptr; ret = json_unpack_ex(json_ssl, &err, 0, "{ s?: s }", - "calocation", &calocation + "ca", &ca ); if (ret) throw ConfigError(json_ssl, err, "node-config-node-kafka-ssl", "Failed to parse SSL configuration of node {}", node_name(n)); - if (!calocation) - throw ConfigError(json_ssl, "node-config-node-kafka-ssl", "'calocation' settings must be set for node {}.", node_name(n)); + if (!ca) + throw ConfigError(json_ssl, "node-config-node-kafka-ssl", "'ca' settings must be set for node {}.", node_name(n)); - k->ssl.calocation = calocation ? strdup(calocation) : nullptr; + k->ssl.ca = ca ? strdup(ca) : nullptr; } if (json_sasl) { @@ -324,7 +324,7 @@ int kafka_start(struct vnode *n) ret = 1; if (!strcmp(k->protocol, "SASL_SSL") || !strcmp(k->protocol, "SSL")) { - if (rd_kafka_conf_set(rdkconf, "ssl.ca.location", k->ssl.calocation, errstr, sizeof(errstr)) != RD_KAFKA_CONF_OK) + if (rd_kafka_conf_set(rdkconf, "ssl.ca.location", k->ssl.ca, errstr, sizeof(errstr)) != RD_KAFKA_CONF_OK) ret = 1; }