Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/shp_build_upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ In case a source bundle image is defined, the bundling feature is used, which wi
source code into a bundle container and upload it to the specified container registry. Instead of
executing using Git in the source step, it will use the container registry to obtain the source code.

$ shp buildrun upload <build-name>
$ shp buildrun upload <build-name> /path/to/repository
$ shp build upload <build-name>
$ shp build upload <build-name> /path/to/repository


```
Expand Down
4 changes: 2 additions & 2 deletions pkg/shp/cmd/build/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ In case a source bundle image is defined, the bundling feature is used, which wi
source code into a bundle container and upload it to the specified container registry. Instead of
executing using Git in the source step, it will use the container registry to obtain the source code.

$ shp buildrun upload <build-name>
$ shp buildrun upload <build-name> /path/to/repository
$ shp build upload <build-name>
$ shp build upload <build-name> /path/to/repository
`

// targetBaseDir directory where data will be uploaded.
Expand Down
2 changes: 1 addition & 1 deletion pkg/shp/streamer/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Tar struct {

// skipPath inspect each path and makes sure it skips files the tar helper can't handle.
func (t *Tar) skipPath(fpath string, stat fs.FileInfo) bool {
if !stat.Mode().IsRegular() {
if !stat.Mode().IsRegular() && !(stat.Mode()&fs.ModeSymlink != 0) {
return true
}
if strings.HasPrefix(fpath, path.Join(t.src, ".git")) {
Expand Down
32 changes: 24 additions & 8 deletions pkg/shp/streamer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,33 @@ func writeFileToTar(tw *tar.Writer, src, fpath string, stat fs.FileInfo) error {
}

header.Name = trimPrefix(src, fpath)
if err := tw.WriteHeader(header); err != nil {
return err

// Symlink
if stat.Mode()&os.ModeSymlink != 0 {
target, err := os.Readlink(fpath)
if err != nil {
return err
}

header.Linkname = target
}

// #nosec G304 intentionally opening file from variable
f, err := os.Open(fpath)
if err != nil {
if err := tw.WriteHeader(header); err != nil {
return err
}
if _, err := io.Copy(tw, f); err != nil {
return err

// Copy regular file content
if stat.Mode().IsRegular() {
// #nosec G304 intentionally opening file from variable
f, err := os.Open(fpath)
if err != nil {
return err
}
if _, err := io.Copy(tw, f); err != nil {
return err
}
return f.Close()
}
return f.Close()

return nil
}