Skip to content

Commit

Permalink
modify taint
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevent-fei committed Dec 6, 2022
1 parent 40790e0 commit 9a0b28c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cmd/sealer/cmd/alpha/umount.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package alpha

import (
"fmt"
"io/fs"
"io/ioutil"
"os"
Expand Down Expand Up @@ -95,7 +96,10 @@ func NewUmountCmd() *cobra.Command {
}

for _, c := range containers {
id := getContainerID(images, args[0])
id, err := getContainerID(images, args[0])
if err != nil {
return err
}
if c.ImageID == id {
cid = c.ID
}
Expand Down Expand Up @@ -123,25 +127,22 @@ func NewUmountCmd() *cobra.Command {
return umountCmd
}

func getContainerID(images []storage.Image, imageName string) string {
var cid string
func getContainerID(images []storage.Image, imageName string) (string, error) {
for _, image := range images {
for _, n := range image.Names {
if n == imageName {
cid = image.ID
return image.ID, nil
}
}
}
return cid
return "", fmt.Errorf("failed to get container id")
}

func removeContainerDir(image storage.Image, file fs.FileInfo, imageName string) error {
for _, n := range image.Names {
if n == imageName {
if file.Name() == image.ID {
if err := os.RemoveAll(filepath.Join(common.DefaultLayerDir, file.Name())); err != nil {
return err
}
if n == imageName && file.Name() == image.ID {
if err := os.RemoveAll(filepath.Join(common.DefaultLayerDir, file.Name())); err != nil {
return err
}
}
}
Expand Down

0 comments on commit 9a0b28c

Please sign in to comment.