Skip to content

Commit

Permalink
abord build if mergeConfig returns an error and fix duplicate error m…
Browse files Browse the repository at this point in the history
…essage
  • Loading branch information
vieux committed Sep 20, 2013
1 parent a813937 commit 5bd0437
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 1 addition & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,7 @@ func postBuild(srv *Server, version float64, w http.ResponseWriter, r *http.Requ
b := NewBuildFile(srv, utils.NewWriteFlusher(w), !suppressOutput, !noCache, rm)
id, err := b.Build(context)
if err != nil {
fmt.Fprintf(w, "Error build: %s\n", err)
return err
return fmt.Errorf("Error build: %s", err)
}
if repoName != "" {
srv.runtime.repositories.Set(repoName, tag, id, false)
Expand Down
4 changes: 3 additions & 1 deletion runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ func (runtime *Runtime) Create(config *Config) (*Container, error) {
}

if img.Config != nil {
MergeConfig(config, img.Config)
if err := MergeConfig(config, img.Config); err != nil {
return nil, err
}
}

if len(config.Entrypoint) != 0 && config.Cmd == nil {
Expand Down
8 changes: 6 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func CompareConfig(a, b *Config) bool {
return true
}

func MergeConfig(userConf, imageConf *Config) {
func MergeConfig(userConf, imageConf *Config) error {
if userConf.User == "" {
userConf.User = imageConf.User
}
Expand All @@ -85,7 +85,10 @@ func MergeConfig(userConf, imageConf *Config) {
found := false
imageNat, _ := parseNat(imagePortSpec)
for _, userPortSpec := range userConf.PortSpecs {
userNat, _ := parseNat(userPortSpec)
userNat, err := parseNat(userPortSpec)
if err != nil {
return err
}
if imageNat.Proto == userNat.Proto && imageNat.Backend == userNat.Backend {
found = true
}
Expand Down Expand Up @@ -146,6 +149,7 @@ func MergeConfig(userConf, imageConf *Config) {
userConf.Volumes[k] = v
}
}
return nil
}

func parseLxcConfOpts(opts ListOpts) ([]KeyValuePair, error) {
Expand Down

0 comments on commit 5bd0437

Please sign in to comment.