feat: 对接 docker compose SDK
This commit is contained in:

committed by
zhengkunwang223

parent
3de0ae1b0f
commit
bf9a37623a
@@ -2,8 +2,6 @@ package compose
|
||||
|
||||
import (
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
||||
"github.com/compose-spec/compose-go/loader"
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
)
|
||||
|
||||
func Up(filePath string) (string, error) {
|
||||
@@ -35,24 +33,3 @@ func Operate(filePath, operation string) (string, error) {
|
||||
stdout, err := cmd.Execf("docker-compose -f %s %s", filePath, operation)
|
||||
return stdout, err
|
||||
}
|
||||
|
||||
func GetComposeProject(yml []byte, env map[string]string) (*types.Project, error) {
|
||||
var configFiles []types.ConfigFile
|
||||
configFiles = append(configFiles, types.ConfigFile{
|
||||
Filename: "docker-compose.yml",
|
||||
Content: yml},
|
||||
)
|
||||
details := types.ConfigDetails{
|
||||
WorkingDir: "",
|
||||
ConfigFiles: configFiles,
|
||||
Environment: env,
|
||||
}
|
||||
|
||||
project, err := loader.Load(details, func(options *loader.Options) {
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return project, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user