Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify the schema registry url to the CLI in local mode. #545

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/quickstart/quickstart-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Proceed to [starting KSQL](#start-ksql).
1. From the host machine, start KSQL CLI on the container.

```bash
$ docker-compose exec ksql-cli ksql-cli local --bootstrap-server kafka:29092
$ docker-compose exec ksql-cli ksql-cli local --bootstrap-server kafka:29092 --schema-registry-url schema-registry:8081
```

2. Return to the [main KSQL quick start](README.md#create-a-stream-and-table) to start querying the data in the Kafka cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public class Local extends AbstractCliCommands {
private static final String COMMAND_TOPIC_SUFFIX_OPTION_NAME = "--command-topic-suffix";
private static final String COMMAND_TOPIC_SUFFIX_OPTION_DEFAULT = "commands";

private static final String SCHEMA_REGISTRY_URL_OPTION_NAME = "--schema-registry-url";
private static final String SCHEMA_REGISTRY_URL_OPTION_DEFAULT = "http://localhost:8081";

@Port(acceptablePorts = PortType.ANY)
@Option(
name = PORT_NUMBER_OPTION_NAME,
Expand Down Expand Up @@ -98,6 +101,15 @@ public class Local extends AbstractCliCommands {
)
String propertiesFile;

@Option(
name = SCHEMA_REGISTRY_URL_OPTION_NAME,
description = "The url of the schema registry server to be used. It defaults to " +
SCHEMA_REGISTRY_URL_OPTION_DEFAULT + ". Avro support requires a functioning"
+ " schema registry which the KSQL instance can connect to. Setting this will"
+ " override the schema registry url in the properties file, if set."
)
String schemaRegistryUrl;

@Override
public LocalCli getCli() throws Exception {
Properties serverProperties;
Expand Down Expand Up @@ -145,6 +157,7 @@ private void addDefaultProperties(Properties properties) {
COMMAND_TOPIC_SUFFIX_OPTION_DEFAULT
);
properties.put(StreamsConfig.APPLICATION_ID_CONFIG, KsqlConfig.KSQL_SERVICE_ID_DEFAULT);
properties.put(KsqlConfig.SCHEMA_REGISTRY_URL_PROPERTY, SCHEMA_REGISTRY_URL_OPTION_DEFAULT);
}

private void addFileProperties(Properties properties) throws IOException {
Expand Down Expand Up @@ -174,5 +187,9 @@ private void addFlagProperties(Properties properties) {
if (commandTopicSuffix != null) {
properties.put(KsqlRestConfig.COMMAND_TOPIC_SUFFIX_CONFIG, commandTopicSuffix);
}

if (schemaRegistryUrl != null) {
properties.put(KsqlConfig.SCHEMA_REGISTRY_URL_PROPERTY, schemaRegistryUrl);
}
}
}