diff --git a/workflow/executor/executor.go b/workflow/executor/executor.go index 1eff992a7292..36967f5d5375 100644 --- a/workflow/executor/executor.go +++ b/workflow/executor/executor.go @@ -892,6 +892,11 @@ func untar(tarPath string, destPath string) error { return err } switch header.Typeflag { + case tar.TypeSymlink: + err := os.Symlink(header.Linkname, target) + if err != nil { + return err + } case tar.TypeReg: f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode)) if err != nil { diff --git a/workflow/executor/executor_test.go b/workflow/executor/executor_test.go index 5eeb216f2368..53964281239d 100644 --- a/workflow/executor/executor_test.go +++ b/workflow/executor/executor_test.go @@ -277,18 +277,30 @@ func TestUnzip(t *testing.T) { func TestUntar(t *testing.T) { tarPath := "testdata/file.tar.gz" - destPath := "testdata/untarredFile" + destPath := "testdata/untarredDir" + filePath := "testdata/untarredDir/file" + linkPath := "testdata/untarredDir/link" // test err := untar(tarPath, destPath) assert.NoError(t, err) - // check untarred file + // check untarred contents fileInfo, err := os.Stat(destPath) assert.NoError(t, err) + assert.True(t, fileInfo.Mode().IsDir()) + fileInfo, err = os.Stat(filePath) + assert.NoError(t, err) + assert.True(t, fileInfo.Mode().IsRegular()) + fileInfo, err = os.Stat(linkPath) + assert.NoError(t, err) assert.True(t, fileInfo.Mode().IsRegular()) // cleanup + err = os.Remove(linkPath) + assert.NoError(t, err) + err = os.Remove(filePath) + assert.NoError(t, err) err = os.Remove(destPath) assert.NoError(t, err) } diff --git a/workflow/executor/testdata/file.tar.gz b/workflow/executor/testdata/file.tar.gz index 1cefc6b53e0a..1e9a92907913 100644 Binary files a/workflow/executor/testdata/file.tar.gz and b/workflow/executor/testdata/file.tar.gz differ diff --git a/workflow/executor/testdata/link b/workflow/executor/testdata/link new file mode 120000 index 000000000000..1a010b1c0f08 --- /dev/null +++ b/workflow/executor/testdata/link @@ -0,0 +1 @@ +file \ No newline at end of file