Skip to content

SimplifyNet/Etcd.Microsoft.Extensions.Configuration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

115 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Etcd.Microsoft.Extensions.Configuration

NuGet Version NuGet Download Build Package Libraries.io dependency status for latest release CodeFactor Grade Platform

Etcd-based configuration provider for Microsoft.Extensions.Configuration.

Keep in mind that starting from v2, it will work only under Windows 10 or Windows Server 2016 (or later) because the internal gRPC client uses the HTTP/2 protocol for communication (https://docs.microsoft.com/en-us/answers/questions/310032/2012-r2-net-core-http2.html).

Quick Start

HTTP

var config = new ConfigurationBuilder()
  .AddEtcd(
    new Credentials("MyEtcdUserName", "passw"),
    new EtcdSettings("http://serveraddress:2379"))
  .Build();

var mySection = config.GetSection("MySection");
var myKeyValue = mySection["MyKeyName"];

HTTPS

When using HTTPS, a *.crt CA certificate (provided by the etcd administrator) should be placed in a well-known system certificate store (depending on the OS).

  • For Windows, it is Trusted Root Certification Authority.
  • For Linux, at least for Arch/Manjaro Linux, it should be placed in /etc/ca-certificates/trust-source/anchors/, followed by the sudo trust extract-compat command.

HTTPS with Settings from a Local JSON File

appsettings.json

{
  "EtcdSettings": {
    "ConnectionString": "https://serveraddress:2379"
  }
}
var jsonConfig = new ConfigurationBuilder()
  .AddJsonFile("appsettings.json")
  .Build();

var config = new ConfigurationBuilder()
  .AddEtcd(
    new Credentials("MyEtcdUserName", "passw"),
    new ConfigurationBasedEtcdSettings(jsonConfig))
  .Build();

var mySection = config.GetSection("MySection");
var myKeyValue = mySection["MyKeyName"];

Settings can be mixed from different locations.

Testing

To setup an integration test environment, make sure you have an etcd instance running on the standard port, without ssl: http://localhost:2379

On ubuntu, simply run

sudo apt-get install etcd-server etcd-client

Create a root account and enable authentication

etcdctl --endpoints=http://localhost:2379 user add root
Password of root:

enable authentication:

etcdctl --endpoints=http://localhost:2379 auth enable

For your convenience, terraform files are included in the folder tests/terraform/

In the file tests/terraform/main.tf replace the password with the one you just used when creating the root user.

in the tests/terraform folder, init terraform:

terraform init

to see what changes will be made:

terraform plan

to execute the changes, and create the keys:

terraform apply

then run the tests from the src folder

Contributing

There are many ways in which you can participate in the project. Like most open-source software projects, contributing code is just one of many ways you can help improve. Some of the things you could help out with are:

  • Documentation (both code and features)
  • Bug reports
  • Bug fixes
  • Feature requests
  • Feature implementations
  • Test coverage
  • Code quality
  • Sample applications

License

Licensed under the GNU Lesser General Public License.

About

Etcd based configuration provider for Microsoft.Extensions.Configuration

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors