Skip to content

Commit

Permalink
use vfs instead of filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarf committed Feb 23, 2024
1 parent 0ff3aa0 commit 5141e5b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions cmds/ocm/commands/ocmcmds/common/inputs/utils.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package inputs

import (
"fmt"
"os"

"github.com/mandelsoft/filepath/pkg/filepath"
"github.com/mandelsoft/vfs/pkg/vfs"

"github.com/open-component-model/ocm/pkg/contexts/clictx"
"github.com/open-component-model/ocm/pkg/errors"
)
Expand Down Expand Up @@ -40,7 +36,7 @@ func GetBaseDir(fs vfs.FileSystem, filePath string) (string, error) {
return "", fmt.Errorf("unable to read current working directory: %w", err)
}
} else {
wd = filepath.Dir(filePath)
wd = vfs.Dir(fs, filePath)
}
return wd, nil
}
Expand All @@ -50,14 +46,14 @@ func GetPath(ctx clictx.Context, path string, inputFilePath string) (string, err
if path == "" {
return "", fmt.Errorf("path attribute required")
}
if filepath.IsAbs(path) {
if vfs.IsAbs(fs, path) {
return path, nil
} else {
wd, err := GetBaseDir(fs, inputFilePath)
if err != nil {
return "", err
}

return filepath.Join(wd, path), nil
return vfs.Join(fs, wd, path), nil
}
}

0 comments on commit 5141e5b

Please sign in to comment.