diff --git a/cli/command/image/build/context.go b/cli/command/image/build/context.go index 3dfeed674c..a2cb5e9978 100644 --- a/cli/command/image/build/context.go +++ b/cli/command/image/build/context.go @@ -108,7 +108,7 @@ func DetectArchiveReader(input io.ReadCloser) (rc io.ReadCloser, ok bool, err er return nil, false, fmt.Errorf("failed to peek context header from STDIN: %w", err) } - return newReadCloserWrapper(buf, func() error { return input.Close() }), IsArchive(magic), nil + return newReadCloserWrapper(buf, func() error { return input.Close() }), isArchive(magic), nil } // WriteTempDockerfile writes a Dockerfile stream to a temporary file with a @@ -178,7 +178,15 @@ func GetContextFromReader(rc io.ReadCloser, dockerfileName string) (out io.ReadC // IsArchive checks for the magic bytes of a tar or any supported compression // algorithm. +// +// Deprecated: this utility was used internally and will be removed in the next release. func IsArchive(header []byte) bool { + return isArchive(header) +} + +// isArchive checks for the magic bytes of a tar or any supported compression +// algorithm. +func isArchive(header []byte) bool { if compression.Detect(header) != compression.None { return true } diff --git a/cli/command/image/build/context_test.go b/cli/command/image/build/context_test.go index f7ebce2413..8630d81146 100644 --- a/cli/command/image/build/context_test.go +++ b/cli/command/image/build/context_test.go @@ -291,7 +291,7 @@ func TestIsArchive(t *testing.T) { } for _, tc := range tests { t.Run(tc.doc, func(t *testing.T) { - assert.Check(t, is.Equal(tc.expected, IsArchive(tc.header)), tc.doc) + assert.Check(t, is.Equal(tc.expected, isArchive(tc.header)), tc.doc) }) } }