| ... | ... |
@@ -579,6 +579,14 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
| 579 | 579 |
if remoteInfo.Exists("NGoroutines") {
|
| 580 | 580 |
fmt.Fprintf(cli.out, "Goroutines: %d\n", remoteInfo.GetInt("NGoroutines"))
|
| 581 | 581 |
} |
| 582 |
+ if remoteInfo.Exists("SystemTime") {
|
|
| 583 |
+ t, err := remoteInfo.GetTime("SystemTime")
|
|
| 584 |
+ if err != nil {
|
|
| 585 |
+ log.Errorf("Error reading system time: %v", err)
|
|
| 586 |
+ } else {
|
|
| 587 |
+ fmt.Fprintf(cli.out, "System Time: %s\n", t.Format(time.UnixDate)) |
|
| 588 |
+ } |
|
| 589 |
+ } |
|
| 582 | 590 |
if remoteInfo.Exists("NEventsListener") {
|
| 583 | 591 |
fmt.Fprintf(cli.out, "EventsListeners: %d\n", remoteInfo.GetInt("NEventsListener"))
|
| 584 | 592 |
} |
| ... | ... |
@@ -3,6 +3,7 @@ package daemon |
| 3 | 3 |
import ( |
| 4 | 4 |
"os" |
| 5 | 5 |
"runtime" |
| 6 |
+ "time" |
|
| 6 | 7 |
|
| 7 | 8 |
log "github.com/Sirupsen/logrus" |
| 8 | 9 |
"github.com/docker/docker/autogen/dockerversion" |
| ... | ... |
@@ -76,6 +77,7 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
|
| 76 | 76 |
v.SetBool("Debug", os.Getenv("DEBUG") != "")
|
| 77 | 77 |
v.SetInt("NFd", utils.GetTotalUsedFds())
|
| 78 | 78 |
v.SetInt("NGoroutines", runtime.NumGoroutine())
|
| 79 |
+ v.Set("SystemTime", time.Now().Format(time.RFC3339Nano))
|
|
| 79 | 80 |
v.Set("ExecutionDriver", daemon.ExecutionDriver().Name())
|
| 80 | 81 |
v.SetInt("NEventsListener", env.GetInt("count"))
|
| 81 | 82 |
v.Set("KernelVersion", kernelVersion)
|
| ... | ... |
@@ -57,10 +57,10 @@ This endpoint now returns `Os`, `Arch` and `KernelVersion`. |
| 57 | 57 |
**New!** |
| 58 | 58 |
You can set ulimit settings to be used within the container. |
| 59 | 59 |
|
| 60 |
-`Get /info` |
|
| 60 |
+`GET /info` |
|
| 61 | 61 |
|
| 62 | 62 |
**New!** |
| 63 |
-Add return value `HttpProxy`,`HttpsProxy` and `NoProxy` to this entrypoint. |
|
| 63 |
+This endpoint now returns `SystemTime`, `HttpProxy`,`HttpsProxy` and `NoProxy`. |
|
| 64 | 64 |
|
| 65 | 65 |
|
| 66 | 66 |
## v1.17 |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"io" |
| 8 | 8 |
"strconv" |
| 9 | 9 |
"strings" |
| 10 |
+ "time" |
|
| 10 | 11 |
|
| 11 | 12 |
"github.com/docker/docker/utils" |
| 12 | 13 |
) |
| ... | ... |
@@ -69,6 +70,15 @@ func (env *Env) SetBool(key string, value bool) {
|
| 69 | 69 |
} |
| 70 | 70 |
} |
| 71 | 71 |
|
| 72 |
+func (env *Env) GetTime(key string) (time.Time, error) {
|
|
| 73 |
+ t, err := time.Parse(time.RFC3339Nano, env.Get(key)) |
|
| 74 |
+ return t, err |
|
| 75 |
+} |
|
| 76 |
+ |
|
| 77 |
+func (env *Env) SetTime(key string, t time.Time) {
|
|
| 78 |
+ env.Set(key, t.Format(time.RFC3339Nano)) |
|
| 79 |
+} |
|
| 80 |
+ |
|
| 72 | 81 |
func (env *Env) GetInt(key string) int {
|
| 73 | 82 |
return int(env.GetInt64(key)) |
| 74 | 83 |
} |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"bytes" |
| 5 | 5 |
"encoding/json" |
| 6 | 6 |
"testing" |
| 7 |
+ "time" |
|
| 7 | 8 |
|
| 8 | 9 |
"github.com/docker/docker/pkg/testutils" |
| 9 | 10 |
) |
| ... | ... |
@@ -94,6 +95,27 @@ func TestSetenvBool(t *testing.T) {
|
| 94 | 94 |
} |
| 95 | 95 |
} |
| 96 | 96 |
|
| 97 |
+func TestSetenvTime(t *testing.T) {
|
|
| 98 |
+ job := mkJob(t, "dummy") |
|
| 99 |
+ |
|
| 100 |
+ now := time.Now() |
|
| 101 |
+ job.SetenvTime("foo", now)
|
|
| 102 |
+ if val, err := job.GetenvTime("foo"); err != nil {
|
|
| 103 |
+ t.Fatalf("GetenvTime failed to parse: %v", err)
|
|
| 104 |
+ } else {
|
|
| 105 |
+ nowStr := now.Format(time.RFC3339) |
|
| 106 |
+ valStr := val.Format(time.RFC3339) |
|
| 107 |
+ if nowStr != valStr {
|
|
| 108 |
+ t.Fatalf("GetenvTime returns incorrect value: %s, Expected: %s", valStr, nowStr)
|
|
| 109 |
+ } |
|
| 110 |
+ } |
|
| 111 |
+ |
|
| 112 |
+ job.Setenv("bar", "Obviously I'm not a date")
|
|
| 113 |
+ if val, err := job.GetenvTime("bar"); err == nil {
|
|
| 114 |
+ t.Fatalf("GetenvTime was supposed to fail, instead returned: %s", val)
|
|
| 115 |
+ } |
|
| 116 |
+} |
|
| 117 |
+ |
|
| 97 | 118 |
func TestSetenvInt(t *testing.T) {
|
| 98 | 119 |
job := mkJob(t, "dummy") |
| 99 | 120 |
|
| ... | ... |
@@ -145,6 +145,14 @@ func (job *Job) SetenvBool(key string, value bool) {
|
| 145 | 145 |
job.env.SetBool(key, value) |
| 146 | 146 |
} |
| 147 | 147 |
|
| 148 |
+func (job *Job) GetenvTime(key string) (value time.Time, err error) {
|
|
| 149 |
+ return job.env.GetTime(key) |
|
| 150 |
+} |
|
| 151 |
+ |
|
| 152 |
+func (job *Job) SetenvTime(key string, value time.Time) {
|
|
| 153 |
+ job.env.SetTime(key, value) |
|
| 154 |
+} |
|
| 155 |
+ |
|
| 148 | 156 |
func (job *Job) GetenvSubEnv(key string) *Env {
|
| 149 | 157 |
return job.env.GetSubEnv(key) |
| 150 | 158 |
} |