Skip to content

Commit

Permalink
Support for environment variables substitution
Browse files Browse the repository at this point in the history
Now user can put environment variables in docker-compose
file and it will be read by kompose from environment

Fixes # 56
  • Loading branch information
surajssd committed Jul 26, 2016
1 parent 278a8af commit 934a3e1
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 81 deletions.
88 changes: 44 additions & 44 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions cli/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ import (
"fmt"
"math/rand"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/Sirupsen/logrus"
"github.com/urfave/cli"

"github.com/docker/docker/api/client/bundlefile"
"github.com/docker/libcompose/config"
"github.com/docker/libcompose/docker"
"github.com/docker/libcompose/lookup"
"github.com/docker/libcompose/project"

"encoding/json"
Expand Down Expand Up @@ -742,6 +745,25 @@ func loadComposeFile(file string, c *cli.Context) KomposeObject {
}
context.ComposeFiles = []string{file}

if context.ResourceLookup == nil {
context.ResourceLookup = &lookup.FileResourceLookup{}
}

if context.EnvironmentLookup == nil {
cwd, err := os.Getwd()
if err != nil {
return KomposeObject{}
}
context.EnvironmentLookup = &lookup.ComposableEnvLookup{
Lookups: []config.EnvironmentLookup{
&lookup.EnvfileLookup{
Path: filepath.Join(cwd, ".env"),
},
&lookup.OsEnvLookup{},
},
}
}

// load compose file into composeObject
composeObject := project.NewProject(&context.Context, nil, nil)
err := composeObject.Parse()
Expand Down
40 changes: 27 additions & 13 deletions vendor/github.com/docker/libcompose/config/merge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/docker/libcompose/docker/project.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/docker/libcompose/docker/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions vendor/github.com/docker/libcompose/lookup/file.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 934a3e1

Please sign in to comment.