mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 01:53:42 +08:00 
			
		
		
		
	Merge pull request #117 from tonistiigi/compose-env
bake: replace env in compose files
This commit is contained in:
		@@ -2,7 +2,9 @@ package bake
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/docker/cli/cli/compose/loader"
 | 
						"github.com/docker/cli/cli/compose/loader"
 | 
				
			||||||
	composetypes "github.com/docker/cli/cli/compose/types"
 | 
						composetypes "github.com/docker/cli/cli/compose/types"
 | 
				
			||||||
@@ -19,9 +21,22 @@ func parseCompose(dt []byte) (*composetypes.Config, error) {
 | 
				
			|||||||
				Config: parsed,
 | 
									Config: parsed,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							Environment: envMap(os.Environ()),
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func envMap(env []string) map[string]string {
 | 
				
			||||||
 | 
						result := make(map[string]string, len(env))
 | 
				
			||||||
 | 
						for _, s := range env {
 | 
				
			||||||
 | 
							kv := strings.SplitN(s, "=", 2)
 | 
				
			||||||
 | 
							if len(kv) != 2 {
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							result[kv[0]] = kv[1]
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return result
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func ParseCompose(dt []byte) (*Config, error) {
 | 
					func ParseCompose(dt []byte) (*Config, error) {
 | 
				
			||||||
	cfg, err := parseCompose(dt)
 | 
						cfg, err := parseCompose(dt)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user