Skip to content

Commit 02b606e

Browse files
tensorworkerndeloof
authored andcommitted
use go-compose instead Signed-off-by: tensorworker <tensorworker@proton.me>
Signed-off-by: tensorworker <tensorworker@proton.me>
1 parent 9856802 commit 02b606e

File tree

3 files changed

+2
-110
lines changed

3 files changed

+2
-110
lines changed

cmd/compose/compose.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/compose-spec/compose-go/v2/cli"
3333
"github.com/compose-spec/compose-go/v2/dotenv"
3434
"github.com/compose-spec/compose-go/v2/loader"
35+
composepaths "github.com/compose-spec/compose-go/v2/paths"
3536
"github.com/compose-spec/compose-go/v2/types"
3637
composegoutils "github.com/compose-spec/compose-go/v2/utils"
3738
"github.com/docker/buildx/util/logutil"
@@ -46,7 +47,6 @@ import (
4647

4748
"github.com/docker/compose/v5/cmd/display"
4849
"github.com/docker/compose/v5/cmd/formatter"
49-
"github.com/docker/compose/v5/internal/paths"
5050
"github.com/docker/compose/v5/internal/tracing"
5151
"github.com/docker/compose/v5/pkg/api"
5252
"github.com/docker/compose/v5/pkg/compose"
@@ -551,7 +551,7 @@ func RootCommand(dockerCli command.Cli, backendOptions *BackendOptions) *cobra.C
551551
fmt.Fprint(os.Stderr, aec.Apply("option '--workdir' is DEPRECATED at root level! Please use '--project-directory' instead.\n", aec.RedF))
552552
}
553553
for i, file := range opts.EnvFiles {
554-
file = paths.ExpandUser(file)
554+
file = composepaths.ExpandUser(file)
555555
if !filepath.IsAbs(file) {
556556
file, err := filepath.Abs(file)
557557
if err != nil {

internal/paths/paths.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,6 @@ import (
2222
"strings"
2323
)
2424

25-
// ExpandUser expands a leading tilde (~) in a path to the user's home directory.
26-
// If the path doesn't start with ~, it is returned unchanged.
27-
// If the home directory cannot be determined, the original path is returned.
28-
func ExpandUser(path string) string {
29-
if path == "" {
30-
return path
31-
}
32-
if path[0] != '~' {
33-
return path
34-
}
35-
if len(path) > 1 && path[1] != '/' && path[1] != filepath.Separator {
36-
// ~otheruser/... syntax is not supported
37-
return path
38-
}
39-
home, err := os.UserHomeDir()
40-
if err != nil {
41-
return path
42-
}
43-
if len(path) == 1 {
44-
return home
45-
}
46-
return filepath.Join(home, path[2:])
47-
}
48-
4925
func IsChild(dir string, file string) bool {
5026
if dir == "" {
5127
return false

internal/paths/paths_test.go

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)