Skip to content

Commit

Permalink
Add more information
Browse files Browse the repository at this point in the history
  • Loading branch information
manabu committed Aug 16, 2016
1 parent 2718e5a commit 41784f3
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions dockerlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func main() {
var createdByHistoryList = []string{}
// layer ID -> json
var jsonMap = map[string]string{}
var allJsonMap = map[string]string{}
var layerTarMap = map[string][]*tar.Header{}
var first = false
for _, history := range historyList {
Expand Down Expand Up @@ -71,7 +72,7 @@ func main() {
if strings.HasSuffix(header.Name, "/json") {
var jsonstring = buf2.String()
//var imagestring = ""

allJsonMap[layerID] = jsonstring
if strings.Index(jsonstring, "\"Image\":\"\"") != -1 || !first {
jsonMap[layerID] = jsonstring
}
Expand Down Expand Up @@ -178,15 +179,30 @@ func main() {
// for _, createdBy := range createdByHistoryList {
// fmt.Println(createdBy)
// }
var createdByListMap = map[string][]string{}
var currentLayerID = ""
var currentLayerIndex = 0
for _, createdBy := range createdByHistoryList {
if strings.Index(createdBy, "#(nop)") != -1 && strings.Index(createdBy, "ADD") == -1 && strings.Index(createdBy, "COPY") == -1 {
//fmt.Println(strings.Repeat("-", 12) + " " + createdBy)
} else {
currentLayerID = layerHistoryList[currentLayerIndex]
currentLayerIndex++
}
createdByListMap[currentLayerID] = append(createdByListMap[currentLayerID], createdBy)
}
//
var layerIndex = 0
fmt.Println("---- id and createdBy")

for _, createdBy := range createdByHistoryList {
if strings.Index(createdBy, "#(nop)") != -1 && strings.Index(createdBy, "ADD") == -1 && strings.Index(createdBy, "COPY") == -1 {
fmt.Println("--------" + createdBy)
//fmt.Println(strings.Repeat("-", 12) + " " + createdBy)
} else {
var layerID = layerHistoryList[layerIndex]
fmt.Println(layerID + " " + createdBy)
for _, savedCreatedBy := range createdByListMap[layerID] {
fmt.Println(layerID[:12] + " " + savedCreatedBy)
}
//fmt.Println(allJsonMap[layerID])

for _, layerTarHeader := range layerTarMap[layerID] {
var filename = layerTarHeader.Name
Expand Down Expand Up @@ -230,7 +246,7 @@ func main() {
}
// calc size

fmt.Println(status + " " + filename + " " + strconv.FormatInt(fileSize, 10))
fmt.Println(status + " " + filename + " " + strconv.FormatInt(fileSize, 10) + " " + strconv.Itoa(layerTarHeader.Uid) + "(" + layerTarHeader.Uname + ")" + ":" + strconv.Itoa(layerTarHeader.Gid) + "(" + layerTarHeader.Gname + ")" + " " + strconv.FormatInt(layerTarHeader.Mode, 8))
}

layerIndex++
Expand Down

0 comments on commit 41784f3

Please sign in to comment.