Skip to content

Commit

Permalink
lint refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
PeepoFrog committed Mar 5, 2024
1 parent 0eda8fd commit ed6b30d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/core/orchestration/docker/fileSending.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,26 @@ func (dm *DockerOrchestrator) GetFileFromContainer(ctx context.Context, folderPa
// Todo: this func has to be deprecated, use volume folder instead
// readTarArchive reads a file from the TAR archive stream
// and returns the file content as a byte slice.
func readTarArchive(tr *tar.Reader, fileName string) ([]byte, error) {
func readTarArchive(tarReader *tar.Reader, fileName string) ([]byte, error) {
for {
hdr, err := tr.Next()
hdr, err := tarReader.Next()
if err == io.EOF {
break
}

if err != nil {
return nil, err
return nil, fmt.Errorf("error when advancing to next tar archive entry: %w", err)
}

if hdr.Name == fileName {
b, err := io.ReadAll(tr)
b, err := io.ReadAll(tarReader) //nolint: govet
if err != nil {
return nil, err
return nil, fmt.Errorf("error when reading tar file, error: %w", err)
}

return b, nil
}
}

return nil, fmt.Errorf("%w: %s", ErrFileNotFoundInTarBase, fileName)
}

0 comments on commit ed6b30d

Please sign in to comment.