Code Monkey home page Code Monkey logo

senv's Introduction

Senv

License Go Report Card Build Status Coverage Status

A fast Spring cloud-config-client written in Go.

It fetches properties from a Spring cloud-config-server and make them available via system environment variables For more information on spring cloud config take a look here.

Install

You can get the latest binary using Go:

> go get -u github.com/jamowei/senv/senv

or download released binary from here.

Example

Your spring config server is running on http://127.0.0.1:8888/.

your application.yml file in config repo is:

# general
description: Spring Config Server
user: admin
workdir: /var/work
---
# test environment
spring:
  profiles:
    active: dev
db:
  user: ${user}
  password: test123
---
# production environment
spring:
  profiles:
    active: prod
db:
  user: ${user}
  password: prod123

your own application file myapp.yml in config repo:

file:
  input: ${workdir}/input.txt
  output: ${workdir}/output.txt

and you have a static file "conf.xml" with variables:

<configuration>
  <user>${db.user}</user>
  <pass>${db.password}</pass>
</configuration>

then you can start your application myapp like the following:

  • with development settings:
    > senv env -n myapp -p dev \n
      Fetching config from server at: http://127.0.0.1:8888/myapp/dev/master
      Located environment: name="myapp", profiles=[dev], label="master", version=29374923859338549, state=""
    > echo "$DB_USER:$DB_PASSWORD"             // prints: admin:test123
    > myapp -user $DB_USER -pass $DB_PASSWORD -in $FILE_INPUT -out $FILE_OUTPUT
      ...
    
  • with production settings:
    > senv env -n myapp -p prod \n
      Fetching config from server at: http://127.0.0.1:8888/myapp/prod/master
      Located environment: name="myapp", profiles=[prod], label="master", version=29374923859338549, state=""
    > echo "$DB_USER:$DB_PASSWORD"             // prints: admin:prod123
    > myapp -user $DB_USER -pass $DB_PASSWORD -in $FILE_INPUT -out $FILE_OUTPUT
      ...
    
  • getting the "conf.xml":
    > senv file -n myapp -p prod conf.xml \n
      Fetching file "conf.xml" from server at: http://127.0.0.1:8888/myapp/prod/master/conf.xml
    > cat conf.xml                          //prints: <configuration>
                                                        <user>admin</user>
                                                        <pass>prod123</pass>
                                                      </configuration>
    > myapp -conf conf.xml
      ...
    

Help

  > senv --help 
    Senv is a fast native config-client for a
    spring-cloud-config-server written in Go
    
    Usage:
      senv [command]
    
    Available Commands:
      env         Fetches properties and sets them as environment variables
      file        Receives static file(s)
      help        Help about any command
    
    Flags:
      -h, --help               help for senv
          --host string        configserver host (default "127.0.0.1")
      -l, --label string       config-repo label to be used (default "master")
      -n, --name string        spring.application.name (default "application")
          --port string        configserver port (default "8888")
      -p, --profiles strings   spring.active.profiles (default [default])
          --version            version for senv
    
    Use "senv [command] --help" for more information about a command.

ToDo's

  • https support with own ca
  • customizable http header for vault and basic auth
  • 100% code coverage
  • ...

Contributing

  1. Fork it
  2. Download your fork to your PC (git clone https://github.com/your_username/cobra && cd cobra)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Make changes and add them (git add .)
  5. Commit your changes (git commit -m 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new pull request

License

Senv is released under the MIT license. See LICENSE

senv's People

Contributors

jamowei avatar

Stargazers

TheMiken16 avatar Juan David Correa avatar Kenny Chen avatar hulucc avatar 浮生 avatar  avatar ik5 avatar Fred van Staden avatar  avatar Jeff Parulan avatar Martin Wind avatar JY Li avatar iceman avatar Sergio Kovtunenko avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.