Unpack all image and not just the last layer
The go program we use to get binaries from a docker image was unpacking only the last layer. This is not required and it order to have a more generic approach and fewest requirement the program now unpack all the image Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
This commit is contained in:
parent
1672752d56
commit
f6b43ada0b
@ -98,14 +98,14 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
err = copyBinaryFromLastLayer(path.Join(imgsDir, imgDir), path.Join(releaseDir, imgDir), binaryToCopy)
|
err = untarLayers(path.Join(imgsDir, imgDir), path.Join(releaseDir, imgDir), binaryToCopy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyBinaryFromLastLayer(src, dest, binaryPath string) error {
|
func untarLayers(src, dest, binaryPath string) error {
|
||||||
b, err := ioutil.ReadFile(path.Join(src, "manifest.json"))
|
b, err := ioutil.ReadFile(path.Join(src, "manifest.json"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -114,8 +114,8 @@ func copyBinaryFromLastLayer(src, dest, binaryPath string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
last := man.LayerInfos()[len(man.LayerInfos())-1]
|
for _, l := range man.LayerInfos() {
|
||||||
layerTar, err := os.Open(path.Join(src, last.Digest.String()[7:]))
|
layerTar, err := os.Open(path.Join(src, l.Digest.String()[7:]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -123,6 +123,7 @@ func copyBinaryFromLastLayer(src, dest, binaryPath string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
input, err := ioutil.ReadFile(path.Join(src, binaryPath))
|
input, err := ioutil.ReadFile(path.Join(src, binaryPath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user