forked from docker/buildx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: support more variations on context and dockerfile + iidfile
Signed-off-by: Tibor Vass <[email protected]>
- Loading branch information
Tibor Vass
committed
Apr 17, 2019
1 parent
037af0e
commit dc07613
Showing
13 changed files
with
894 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package build | ||
|
||
import ( | ||
"archive/tar" | ||
"bytes" | ||
"os" | ||
) | ||
|
||
// archiveHeaderSize is the number of bytes in an archive header | ||
const archiveHeaderSize = 512 | ||
|
||
func isLocalDir(c string) bool { | ||
st, err := os.Stat(c) | ||
return err == nil && st.IsDir() | ||
} | ||
|
||
func isArchive(header []byte) bool { | ||
for _, m := range [][]byte{ | ||
{0x42, 0x5A, 0x68}, // bzip2 | ||
{0x1F, 0x8B, 0x08}, // gzip | ||
{0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00}, // xz | ||
} { | ||
if len(header) < len(m) { | ||
continue | ||
} | ||
if bytes.Equal(m, header[:len(m)]) { | ||
return true | ||
} | ||
} | ||
|
||
r := tar.NewReader(bytes.NewBuffer(header)) | ||
_, err := r.Next() | ||
return err == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.