mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-04 15:58:39 +00:00
add ID and Hostname in docker info
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
@@ -505,6 +505,12 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||
if remoteInfo.Exists("MemTotal") {
|
||||
fmt.Fprintf(cli.out, "Total Memory: %s\n", units.BytesSize(float64(remoteInfo.GetInt64("MemTotal"))))
|
||||
}
|
||||
if remoteInfo.Exists("Hostname") {
|
||||
fmt.Fprintf(cli.out, "Hostname: %s\n", remoteInfo.Get("Hostname"))
|
||||
}
|
||||
if remoteInfo.Exists("ID") {
|
||||
fmt.Fprintf(cli.out, "ID: %s\n", remoteInfo.Get("ID"))
|
||||
}
|
||||
|
||||
if remoteInfo.GetBool("Debug") || os.Getenv("DEBUG") != "" {
|
||||
if remoteInfo.Exists("Debug") {
|
||||
|
||||
@@ -3,12 +3,15 @@ package api
|
||||
import (
|
||||
"fmt"
|
||||
"mime"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/engine"
|
||||
"github.com/docker/docker/pkg/parsers"
|
||||
"github.com/docker/docker/pkg/version"
|
||||
"github.com/docker/docker/vendor/src/github.com/docker/libtrust"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -47,3 +50,25 @@ func MatchesContentType(contentType, expectedType string) bool {
|
||||
}
|
||||
return err == nil && mimetype == expectedType
|
||||
}
|
||||
|
||||
// LoadOrCreateTrustKey attempts to load the libtrust key at the given path,
|
||||
// otherwise generates a new one
|
||||
func LoadOrCreateTrustKey(trustKeyPath string) (libtrust.PrivateKey, error) {
|
||||
err := os.MkdirAll(path.Dir(trustKeyPath), 0700)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
trustKey, err := libtrust.LoadKeyFile(trustKeyPath)
|
||||
if err == libtrust.ErrKeyFileDoesNotExist {
|
||||
trustKey, err = libtrust.GenerateECP256PrivateKey()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error generating key: %s", err)
|
||||
}
|
||||
if err := libtrust.SaveKey(trustKeyPath, trustKey); err != nil {
|
||||
return nil, fmt.Errorf("Error saving key file: %s", err)
|
||||
}
|
||||
} else if err != nil {
|
||||
log.Fatalf("Error loading key file: %s", err)
|
||||
}
|
||||
return trustKey, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user