Skip to content

Commit 82ede4d

Browse files
authored
fix: populate env.json with valid Kafka bootstrap addresses (#188)
1 parent abe8131 commit 82ede4d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

components/Common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public void close() {
109109
export function EnvJson({ asyncapi, params }) {
110110
const server = asyncapi.allServers().get(params.server);
111111
const url = server.url();
112+
const hostname = server.host() || server.url();
112113
const protocol = server.protocol();
113114
let user = params.user;
114115
let password = params.password;
@@ -153,7 +154,7 @@ export function EnvJson({ asyncapi, params }) {
153154
return `
154155
{
155156
"KAFKA_ENDPOINTS": [{
156-
"BOOTSTRAP_ADDRESS": "${url}",
157+
"BOOTSTRAP_ADDRESS": "${hostname}",
157158
"APP_USER": "${user}",
158159
"APP_PASSWORD": "${password}"
159160
}]

test/Kafka.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ describe('kafka integration tests using the generator', () => {
4343
for (const expectedLine of expectedConnectionHelperLines) {
4444
expect(connectionHelper.includes(expectedLine)).toBe(true);
4545
}
46+
const connectionEnv = readFileSync(path.join(OUTPUT_DIR, 'env.json'), 'utf-8');
47+
const foundStreetlightsScram = connectionEnv.includes('"BOOTSTRAP_ADDRESS": "test.mykafkacluster.org:18092"');
48+
const foundStreetlightsMtls = connectionEnv.includes('"BOOTSTRAP_ADDRESS": "test.mykafkacluster.org:28092"');
49+
const foundRecordLabelKafka = connectionEnv.includes('"BOOTSTRAP_ADDRESS": "my-kafka-hostname:9092"');
50+
expect(foundStreetlightsScram || foundStreetlightsMtls || foundRecordLabelKafka).toBe(true);
4651

4752
return true;
4853
};

0 commit comments

Comments
 (0)