@@ -80,7 +80,7 @@ func ValidateContextDirectory(srcPath string, excludes []string) error {
8080 if err != nil && os .IsPermission (err ) {
8181 return errors .Errorf ("no permission to read from '%s'" , filePath )
8282 }
83- currentFile .Close ()
83+ _ = currentFile .Close ()
8484 }
8585 return nil
8686 })
@@ -97,10 +97,10 @@ func filepathMatches(matcher *patternmatcher.PatternMatcher, file string) (bool,
9797
9898// DetectArchiveReader detects whether the input stream is an archive or a
9999// Dockerfile and returns a buffered version of input, safe to consume in lieu
100- // of input. If an archive is detected, isArchive is set to true, and to false
100+ // of input. If an archive is detected, ok is set to true, and to false
101101// otherwise, in which case it is safe to assume input represents the contents
102102// of a Dockerfile.
103- func DetectArchiveReader (input io.ReadCloser ) (rc io.ReadCloser , isArchive bool , err error ) {
103+ func DetectArchiveReader (input io.ReadCloser ) (rc io.ReadCloser , ok bool , err error ) {
104104 buf := bufio .NewReader (input )
105105
106106 magic , err := buf .Peek (archiveHeaderSize * 2 )
@@ -141,12 +141,12 @@ func WriteTempDockerfile(rc io.ReadCloser) (dockerfileDir string, err error) {
141141// Dockerfile or tar archive. Returns a tar archive used as a context and a
142142// path to the Dockerfile inside the tar.
143143func GetContextFromReader (rc io.ReadCloser , dockerfileName string ) (out io.ReadCloser , relDockerfile string , err error ) {
144- rc , isArchive , err := DetectArchiveReader (rc )
144+ rc , ok , err := DetectArchiveReader (rc )
145145 if err != nil {
146146 return nil , "" , err
147147 }
148148
149- if isArchive {
149+ if ok {
150150 return rc , dockerfileName , nil
151151 }
152152
@@ -171,7 +171,7 @@ func GetContextFromReader(rc io.ReadCloser, dockerfileName string) (out io.ReadC
171171
172172 return newReadCloserWrapper (tarArchive , func () error {
173173 err := tarArchive .Close ()
174- os .RemoveAll (dockerfileDir )
174+ _ = os .RemoveAll (dockerfileDir )
175175 return err
176176 }), DefaultDockerfileName , nil
177177}
@@ -242,7 +242,7 @@ func getWithStatusError(url string) (resp *http.Response, err error) {
242242 }
243243 msg := fmt .Sprintf ("failed to GET %s with status %s" , url , resp .Status )
244244 body , err := io .ReadAll (resp .Body )
245- resp .Body .Close ()
245+ _ = resp .Body .Close ()
246246 if err != nil {
247247 return nil , errors .Wrapf (err , "%s: error reading body" , msg )
248248 }
@@ -374,7 +374,7 @@ func isUNC(path string) bool {
374374// the relative path to the dockerfile in the context.
375375func AddDockerfileToBuildContext (dockerfileCtx io.ReadCloser , buildCtx io.ReadCloser ) (io.ReadCloser , string , error ) {
376376 file , err := io .ReadAll (dockerfileCtx )
377- dockerfileCtx .Close ()
377+ _ = dockerfileCtx .Close ()
378378 if err != nil {
379379 return nil , "" , err
380380 }
@@ -438,17 +438,19 @@ func Compress(buildCtx io.ReadCloser) (io.ReadCloser, error) {
438438 go func () {
439439 compressWriter , err := compression .CompressStream (pipeWriter , archive .Gzip )
440440 if err != nil {
441- pipeWriter .CloseWithError (err )
441+ _ = pipeWriter .CloseWithError (err )
442442 }
443- defer buildCtx .Close ()
443+ defer func () {
444+ _ = buildCtx .Close ()
445+ }()
444446
445447 if _ , err := io .Copy (compressWriter , buildCtx ); err != nil {
446- pipeWriter .CloseWithError (errors .Wrap (err , "failed to compress context" ))
447- compressWriter .Close ()
448+ _ = pipeWriter .CloseWithError (errors .Wrap (err , "failed to compress context" ))
449+ _ = compressWriter .Close ()
448450 return
449451 }
450- compressWriter .Close ()
451- pipeWriter .Close ()
452+ _ = compressWriter .Close ()
453+ _ = pipeWriter .Close ()
452454 }()
453455
454456 return pipeReader , nil
0 commit comments