This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/plan/task/util.go
Helder Correia 770acd3ce2
Expand user home dir in client filesystem
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
2022-03-25 20:25:36 -01:00

29 lines
664 B
Go

package task
import (
"fmt"
"path/filepath"
"github.com/mitchellh/go-homedir"
"github.com/moby/buildkit/client/llb"
"go.dagger.io/dagger/compiler"
)
func vertexNamef(v *compiler.Value, format string, a ...interface{}) string {
prefix := fmt.Sprintf("@%s@", v.Path().String())
name := fmt.Sprintf(format, a...)
return prefix + " " + name
}
func withCustomName(v *compiler.Value, format string, a ...interface{}) llb.ConstraintsOpt {
return llb.WithCustomName(vertexNamef(v, format, a...))
}
func clientFilePath(path string) (string, error) {
expanded, err := homedir.Expand(path)
if err != nil {
return "", err
}
return filepath.Abs(expanded)
}