Skip to content

Commit

Permalink
Change symlink fields to oldpath and newpath
Browse files Browse the repository at this point in the history
Also run `make generated-files`

Signed-off-by: Peter Engelbert <[email protected]>
  • Loading branch information
pmengelbert committed Nov 20, 2024
1 parent e343181 commit 952a185
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 121 deletions.
22 changes: 11 additions & 11 deletions client/llb/fileop.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func (fa *FileAction) Mkfile(p string, m os.FileMode, dt []byte, opt ...MkfileOp
return a
}

func (fa *FileAction) Symlink(target, src string, opt ...SymlinkOption) *FileAction {
a := Symlink(target, src, opt...)
func (fa *FileAction) Symlink(oldpath, newpath string, opt ...SymlinkOption) *FileAction {
a := Symlink(oldpath, newpath, opt...)
a.prev = fa
return a
}
Expand Down Expand Up @@ -360,32 +360,32 @@ type SymlinkOption interface {
SetSymlinkOption(*SymlinkInfo)
}

func Symlink(target, src string, opts ...SymlinkOption) *FileAction {
func Symlink(oldpath, newpath string, opts ...SymlinkOption) *FileAction {
var si SymlinkInfo
for _, o := range opts {
o.SetSymlinkOption(&si)
}

return &FileAction{
action: &fileActionSymlink{
target: target,
src: src,
info: si,
oldpath: oldpath,
newpath: newpath,
info: si,
},
}
}

type fileActionSymlink struct {
target string
src string
info SymlinkInfo
oldpath string
newpath string
info SymlinkInfo
}

func (f *fileActionSymlink) toProtoAction(_ context.Context, _ string, base pb.InputIndex) (pb.IsFileAction, error) {
return &pb.FileAction_Symlink{
Symlink: &pb.FileActionSymlink{
Target: f.target,
Src: f.src,
Oldpath: f.oldpath,
Newpath: f.newpath,
Owner: f.info.ChownOpt.marshal(base),
Timestamp: marshalTime(f.info.CreatedTime),
},
Expand Down
4 changes: 2 additions & 2 deletions client/llb/fileop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ func TestFileSymlink(t *testing.T) {

symlink := action.Action.(*pb.FileAction_Symlink).Symlink

require.Equal(t, "foo", symlink.Target)
require.Equal(t, "/bar", symlink.Src)
require.Equal(t, "foo", symlink.Oldpath)
require.Equal(t, "/bar", symlink.Newpath)
}

func TestFileRm(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/buildctl/debug/dumpllb.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func attr(dgst digest.Digest, op *pb.Op) (string, string) {
case *pb.FileAction_Rm:
name = fmt.Sprintf("rm{path=%s}", act.Rm.Path)
case *pb.FileAction_Symlink:
name = fmt.Sprintf("symlink{target=%s, src=%s}", act.Symlink.Target, act.Symlink.Src)
name = fmt.Sprintf("symlink{oldpath=%s, newpath=%s}", act.Symlink.Oldpath, act.Symlink.Newpath)
}

names = append(names, name)
Expand Down
8 changes: 4 additions & 4 deletions solver/llbsolver/file/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func symlink(d string, action *pb.FileActionSymlink, user *copy.User, idmap *idt
}
}()

src, err := fs.RootPath(d, filepath.Join("/", action.Src))
newpath, err := fs.RootPath(d, filepath.Join("/", action.Newpath))
if err != nil {
return errors.WithStack(err)
}
Expand All @@ -86,15 +86,15 @@ func symlink(d string, action *pb.FileActionSymlink, user *copy.User, idmap *idt
return err
}

if err := os.Symlink(action.Target, src); err != nil {
if err := os.Symlink(action.Oldpath, newpath); err != nil {
return errors.WithStack(err)
}

if err := copy.Chown(src, nil, ch); err != nil {
if err := copy.Chown(newpath, nil, ch); err != nil {
return errors.WithStack(err)
}

if err := copy.Utimes(src, timestampToTime(action.Timestamp)); err != nil {
if err := copy.Utimes(newpath, timestampToTime(action.Timestamp)); err != nil {
return errors.WithStack(err)
}

Expand Down
2 changes: 1 addition & 1 deletion solver/llbsolver/vertex.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func fileOpName(actions []*pb.FileAction) string {
case *pb.FileAction_Mkfile:
names = append(names, fmt.Sprintf("mkfile %s", a.Mkfile.Path))
case *pb.FileAction_Symlink:
names = append(names, fmt.Sprintf("symlink %s -> %s", a.Symlink.Src, a.Symlink.Target))
names = append(names, fmt.Sprintf("symlink %s -> %s", a.Symlink.Newpath, a.Symlink.Oldpath))
case *pb.FileAction_Rm:
names = append(names, fmt.Sprintf("rm %s", a.Rm.Path))
case *pb.FileAction_Copy:
Expand Down
164 changes: 82 additions & 82 deletions solver/pb/ops.pb.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions solver/pb/ops.proto
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ message FileActionMkFile {

message FileActionSymlink {
// destination path for the new file representing the link
string target = 1;
string oldpath = 1;
// source path for the link
string src = 2;
string newpath = 2;
// optional owner for the new file
ChownOpt owner = 3;
// optional created time override
Expand Down
36 changes: 18 additions & 18 deletions solver/pb/ops_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 952a185

Please sign in to comment.