1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/uuid.go
Justin Cormack 98fc09128b Remove the rest of v1 manifest support
As people are using the UUID in `docker info` that was based on the v1 manifest signing key, replace
with a UUID instead.

Remove deprecated `--disable-legacy-registry` option that was scheduled to be removed in 18.03.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2019-03-02 10:46:37 -08:00

28 lines
669 B
Go

package daemon // import "github.com/docker/docker/daemon"
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/docker/docker/pkg/ioutils"
"github.com/pborman/uuid"
)
func loadOrCreateUUID(path string) (string, error) {
err := os.MkdirAll(filepath.Dir(path), 0755)
if err != nil {
return "", err
}
id, err := ioutil.ReadFile(path)
if os.IsNotExist(err) {
id = []byte(uuid.New())
if err := ioutils.AtomicWriteFile(path, id, os.FileMode(0600)); err != nil {
return "", fmt.Errorf("Error saving uuid file: %s", err)
}
} else if err != nil {
return "", fmt.Errorf("Error loading uuid file %s: %s", path, err)
}
return string(id), nil
}