Skip to content

Commit

Permalink
Containerd Logging and error handling (#7)
Browse files Browse the repository at this point in the history
Co-authored-by: Saurabh <saurabh.kumar@deepfence.io>
  • Loading branch information
saurabh2253 and Saurabh authored Dec 17, 2021
1 parent 120f432 commit c49ad43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ func (c Containerd) ExtractFileSystem(imageTarPath string, outputTarPath string,
fmt.Println("Error while Importing image")
return err
}
if len(imgs) == 0 {
fmt.Printf("No images imported, imageTarPath: %s, outputTarPath: %s, imageName: %s \n", imageTarPath, outputTarPath, imageName)
return errors.New("image not imported from: " + imageTarPath)
}
image, err := client.GetImage(ctx, imgs[0].Name)
if err != nil {
fmt.Println("Error while getting image from client")
Expand Down
2 changes: 1 addition & 1 deletion docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (d Docker) ExtractFileSystem(imageTarPath string, outputTarPath string, ima
for scanner.Scan() {
line := scanner.Text()
if strings.Contains(line, "Loaded image") {
splits := strings.SplitAfterN(line,":", 2)
splits := strings.SplitAfterN(line, ":", 2)
if len(splits) > 1 {
imageId = strings.TrimSpace(splits[1])
break
Expand Down

0 comments on commit c49ad43

Please sign in to comment.