docker / libcompose

*Unmaintained/Deprecated* An experimental go library providing Compose-like functionality
https://godoc.org/github.com/docker/libcompose
Apache License 2.0
586 stars 191 forks source link

Issue with env_file population. #488

Closed cdrage closed 7 years ago

cdrage commented 7 years ago

Using this an example:

version: '2'

services:
  redis:
    image: 'bitnami/redis:latest'
    environment:
      - ALLOW_EMPTY_PASSWORD=no
    env_file:
      - foo.env
      - bar.env
    ports:
      - '6379:6379'

It seems that env_file isn't being properly populated to the ServiceConfig.

It's hard to explain without showing code, but essentially we use libcompose to parse a Docker Compose file and env_file within ServiceConfig is blank.

Yes, it goes through the file and grabs the environment variables correctly, but within the libcompose code, env_file isn't being shown within ServiceConfig (appears as a blank string).

I'll try to pull up an example later :+1:

jritsema commented 7 years ago

I just hit this as well. Was expecting the serviceConfig.EnvFile field to be populated but it's empty even though the contents of the env files end up in serviceConfig.Environment. Curious what the design intent was on this? I'd like to be able to determine which file a particular env var came from.

// ServiceConfig holds version 2 of libcompose service configuration
type ServiceConfig struct {
  EnvFile        yaml.Stringorslice   `yaml:"env_file,omitempty"`
  Environment    yaml.MaporEqualSlice `yaml:"environment,omitempty"`
jritsema commented 7 years ago

Looks like the culprit is here. @vdemeester do you know if we would break anyone if we simply removed this line? Any thoughts?