feat(image): support tar.gz image (fanal#40)

This commit is contained in:
Teppei Fukuda
2019-10-15 11:48:52 +03:00
committed by GitHub
parent 83f0e2b08b
commit 9e8f0bb4f0
9 changed files with 57 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package utils
import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
@@ -37,3 +38,13 @@ func IsCommandAvailable(name string) bool {
}
return true
}
func IsGzip(f *os.File) bool {
buf := make([]byte, 3)
n, _ := f.Read(buf)
defer f.Seek(0, io.SeekStart)
if n < 3 {
return false
}
return buf[0] == 0x1F && buf[1] == 0x8B && buf[2] == 0x8
}