github.com/bdwilliams/libcompose@v0.3.1-0.20160826154243-d81a9bdacff0/lookup/simple_env.go (about)

     1  package lookup
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/docker/libcompose/config"
     8  )
     9  
    10  // OsEnvLookup is a "bare" structure that implements the project.EnvironmentLookup interface
    11  type OsEnvLookup struct {
    12  }
    13  
    14  // Lookup creates a string slice of string containing a "docker-friendly" environment string
    15  // in the form of 'key=value'. It gets environment values using os.Getenv.
    16  // If the os environment variable does not exists, the slice is empty. serviceName and config
    17  // are not used at all in this implementation.
    18  func (o *OsEnvLookup) Lookup(key, serviceName string, config *config.ServiceConfig) []string {
    19  	ret := os.Getenv(key)
    20  	if ret == "" {
    21  		return []string{}
    22  	}
    23  	return []string{fmt.Sprintf("%s=%s", key, ret)}
    24  }