mirror of
https://github.com/dokku/dokku.git
synced 2026-02-24 04:00:36 +01:00
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. [1]: https://golang.org/doc/go1.16#ioutil Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
48 lines
842 B
Go
48 lines
842 B
Go
package builder
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"os"
|
|
"path"
|
|
"strings"
|
|
|
|
"github.com/dokku/dokku/plugins/common"
|
|
)
|
|
|
|
func listImagesByImageRepo(imageRepo string) ([]string, error) {
|
|
command := []string{
|
|
common.DockerBin(),
|
|
"image",
|
|
"ls",
|
|
"--quiet",
|
|
imageRepo,
|
|
}
|
|
|
|
var stderr bytes.Buffer
|
|
listCmd := common.NewShellCmd(strings.Join(command, " "))
|
|
listCmd.ShowOutput = false
|
|
listCmd.Command.Stderr = &stderr
|
|
b, err := listCmd.Output()
|
|
|
|
if err != nil {
|
|
return []string{}, errors.New(strings.TrimSpace(stderr.String()))
|
|
}
|
|
|
|
output := strings.Split(strings.TrimSpace(string(b[:])), "\n")
|
|
return output, nil
|
|
}
|
|
|
|
func removeAllContents(basePath string) error {
|
|
dir, err := os.ReadDir(basePath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, d := range dir {
|
|
os.RemoveAll(path.Join([]string{basePath, d.Name()}...))
|
|
}
|
|
|
|
return nil
|
|
}
|