@@ -105,7 +105,18 @@ func filepathMatches(matcher *patternmatcher.PatternMatcher, file string) (bool,
105105// of input. If an archive is detected, ok is set to true, and to false
106106// otherwise, in which case it is safe to assume input represents the contents
107107// of a Dockerfile.
108+ //
109+ // Deprecated: this utility was only used internally, and will be removed in the next release.
108110func DetectArchiveReader (input io.ReadCloser ) (rc io.ReadCloser , ok bool , err error ) {
111+ return detectArchiveReader (input )
112+ }
113+
114+ // detectArchiveReader detects whether the input stream is an archive or a
115+ // Dockerfile and returns a buffered version of input, safe to consume in lieu
116+ // of input. If an archive is detected, ok is set to true, and to false
117+ // otherwise, in which case it is safe to assume input represents the contents
118+ // of a Dockerfile.
119+ func detectArchiveReader (input io.ReadCloser ) (rc io.ReadCloser , ok bool , err error ) {
109120 buf := bufio .NewReader (input )
110121
111122 magic , err := buf .Peek (archiveHeaderSize * 2 )
@@ -146,7 +157,7 @@ func WriteTempDockerfile(rc io.ReadCloser) (dockerfileDir string, err error) {
146157// Dockerfile or tar archive. Returns a tar archive used as a context and a
147158// path to the Dockerfile inside the tar.
148159func GetContextFromReader (rc io.ReadCloser , dockerfileName string ) (out io.ReadCloser , relDockerfile string , err error ) {
149- rc , ok , err := DetectArchiveReader (rc )
160+ rc , ok , err := detectArchiveReader (rc )
150161 if err != nil {
151162 return nil , "" , err
152163 }
0 commit comments