adevinta / zoe

The Kafka CLI for humans
https://adevinta.github.io/zoe
MIT License
287 stars 21 forks source link

add ability to do environment variables substitution #14

Closed wlezzar closed 4 years ago

wlezzar commented 4 years ago

This PR adds the ability to use environment variables inside zoe's configuration file:

clusters:
   my-cluster:
    props:
      bootstrap.servers: ${BOOTSTRAP_SERVER}
      key.deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value.deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
    registry: ${SCHEMA_REGISTRY:-localhost:8081}
 runners:
    default: local

You can the variable substitution with above config file using the following command:

BOOTSTRAP_SERVER=localhost:9092 zoe -o table config clusters list
┌────────────┬────────────────┬────────────────┬────────┬────────┐
│ cluster    │ brokers        │ registry       │ topics │ groups │
├────────────┼────────────────┼────────────────┼────────┼────────┤
│ my-cluster │ localhost:9092 │ localhost:8081 │        │        │
└────────────┴────────────────┴────────────────┴────────┴────────┘
rsaltrelli commented 4 years ago

This looks great! A nice convenience feature would be to be able to store those env vars in a .env file, but that's not super important.

wlezzar commented 4 years ago

Thanks @rsaltrelli. For the .env file, did you check https://github.com/direnv/direnv ? I think this would help exactly in this.