Skip to content

Commit a99e91c

Browse files
thaJeztahaustinvazquez
authored andcommitted
cli/command/image/build: deprecate DetectArchiveReader util
It was only used internal in the package. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit c52fa07) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 579b72a commit a99e91c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

cli/command/image/build/context.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.
108110
func 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.
148159
func 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
}

cli/command/image/build/context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ func TestDetectArchiveReader(t *testing.T) {
326326
_ = content.Close()
327327
}()
328328

329-
_, isArchive, err := DetectArchiveReader(content)
329+
_, isArchive, err := detectArchiveReader(content)
330330
assert.NilError(t, err)
331331
assert.Check(t, is.Equal(tc.expected, isArchive), tc.file)
332332
})

0 commit comments

Comments
 (0)