https://github.com/shiv3/configmapper
Golang Config Parser for Kubernetes Configmap with Toml and merge Deployment env
https://github.com/shiv3/configmapper
configmap golang toml toml-config
Last synced: 5 months ago
JSON representation
Golang Config Parser for Kubernetes Configmap with Toml and merge Deployment env
- Host: GitHub
- URL: https://github.com/shiv3/configmapper
- Owner: shiv3
- Created: 2021-07-13T05:42:04.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-13T06:23:13.000Z (almost 5 years ago)
- Last Synced: 2025-10-12T10:45:59.141Z (9 months ago)
- Topics: configmap, golang, toml, toml-config
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# configmapper
Golang Config Parser for Kubernetes Configmap with Toml
## Usage
Defines a config struct
```go
type Config struct {
EnvConfig EnvConfig `mapstructure:"env"`
}
type EnvConfig struct {
Env string `validate:"required"`
ServiceName string `mapstructure:"service_name" validate:"required"`
ProjectID string `mapstructure:"project_id" validate:"required"`
LogLevel string `mapstructure:"log_level" validate:"required"`
}
```
Create a configmap file
`manifests/configmap.yaml`
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: test-configmap
labels:
app: test
data:
config.toml: |-
[env]
env = "1"
service_name = "2"
project_id = "3"
log_level = "4"
```
Initialize config from struct
`main.go`
```go
c, err := configmapper.Initialize(Config{})
if err != nil {
panic(err) // error handling
}
config := c.(Config)
// use config
...
```
if run local, run golang with LOCAL=1
```sh
LOCAL=1 go run main.go
```