https://github.com/realbucksavage/spring-config-client-go
Go client that consumes configuration from a Spring cloud config server
https://github.com/realbucksavage/spring-config-client-go
cloud-native cloud-native-go config-client go golang spring-cloud-config
Last synced: about 2 months ago
JSON representation
Go client that consumes configuration from a Spring cloud config server
- Host: GitHub
- URL: https://github.com/realbucksavage/spring-config-client-go
- Owner: realbucksavage
- License: mit
- Created: 2020-05-14T11:05:09.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-03T17:21:00.000Z (over 4 years ago)
- Last Synced: 2024-06-21T14:03:51.376Z (about 2 years ago)
- Topics: cloud-native, cloud-native-go, config-client, go, golang, spring-cloud-config
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spring-config-client-go
A simple package that facilitates fetching of configuration from a Spring Cloud Config Server
## Installation
```shell
go get github.com/realbucksavage/spring-config-client-go/v2
```
## Usage
```go
import (
"log"
"github.com/realbucksavage/spring-config-client-go/v2"
)
type applicationConfig struct {
Key1 Key1Type `json:"key1" yaml:"key1"`
// ...
}
func main() {
client, err := cloudconfig.NewClient(
"config:8888",
"someapp",
"production",
)
if err != nil {
panic(err)
}
// get a reader to configuration
rdr, err := client.Raw()
// or, decode configuration directly into a struct
var appConfig applicationConfig
err := client.Decode(&appConfig)
}
```
The client can also be customized with these options
### Basic Auth
```go
client, err := cloudconfig.NewClient(
server,
application,
profile,
cloudconfig.WithBasicAuth("username", "password"),
)
```
### Reading config as YAML instead of (default) JSON
```go
client, err := cloudconfig.NewClient(
server,
application,
profile,
cloudconfig.WithFormat(cloudconfig.YAMLFormat)),
)
```
### Using HTTPs (or, setting the scheme of config server's URL)
```go
client, err := cloudconfig.NewClient(
server,
application,
profile,
cloudconfig.WithScheme("https"),
)
```