Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions packages/orchestrator/cmd/copy-build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,25 @@ func NewHeaderFromPath(ctx context.Context, from, headerPath string) (*header.He
return h, nil
}

func getReferencedData(h *header.Header, objectType storage.ObjectType) []string {
builds := make(map[string]struct{})
func getReferencedData(h *header.Header, dataFileName string) []string {
builds := make(map[uuid.UUID]struct{})

for _, mapping := range h.Mapping {
builds[mapping.BuildId.String()] = struct{}{}
builds[mapping.BuildId] = struct{}{}
}

delete(builds, uuid.Nil.String())
delete(builds, uuid.Nil)

var dataReferences []string

for build := range builds {
paths := storage.Paths{
BuildID: build,
BuildID: build.String(),
}

switch objectType {
case storage.MemfileHeaderObjectType:
dataReferences = append(dataReferences, paths.Memfile())
case storage.RootFSHeaderObjectType:
dataReferences = append(dataReferences, paths.Rootfs())
}
ct := h.GetBuildFrameData(build).CompressionType()
Comment thread
arkamar marked this conversation as resolved.

dataReferences = append(dataReferences, paths.DataFile(dataFileName, ct))
}

return dataReferences
Expand Down Expand Up @@ -246,7 +243,7 @@ func main() {
memfileHeader = h
}

dataReferences := getReferencedData(memfileHeader, storage.MemfileHeaderObjectType)
dataReferences := getReferencedData(memfileHeader, storage.MemfileName)

filesToCopy = append(filesToCopy, buildMemfileHeaderPath)
filesToCopy = append(filesToCopy, dataReferences...)
Expand All @@ -272,7 +269,7 @@ func main() {
rootfsHeader = h
}

dataReferences = getReferencedData(rootfsHeader, storage.RootFSHeaderObjectType)
dataReferences = getReferencedData(rootfsHeader, storage.RootfsName)

filesToCopy = append(filesToCopy, buildRootfsHeaderPath)
filesToCopy = append(filesToCopy, dataReferences...)
Expand Down
Loading