Skip to content

Commit

Permalink
feat: Implement environment variable expansion in configuration parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
yarlson committed Oct 21, 2024
1 parent f2a9c60 commit 692728b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ storages:
image: postgres:16
- postgres_data:/var/lib/postgresql/data
env_vars:
- POSTGRES_PASSWORD=S3cret
- POSTGRES_USER=my-app
- POSTGRES_DB=my-app
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_DB=${POSTGRES_DB}

volumes:
- postgres_data
Expand Down
4 changes: 3 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ type Volume struct {
}

func ParseConfig(data []byte) (*Config, error) {
expandedData := os.ExpandEnv(string(data))

var config Config
if err := yaml.Unmarshal(data, &config); err != nil {
if err := yaml.Unmarshal([]byte(expandedData), &config); err != nil {
return nil, fmt.Errorf("error parsing YAML: %v", err)
}

Expand Down

0 comments on commit 692728b

Please sign in to comment.