From c8baae58513f2152692da706304a4cdfa0ca2418 Mon Sep 17 00:00:00 2001 From: Jonathan Bunde-Pedersen Date: Thu, 6 Jul 2017 13:57:22 +0200 Subject: [PATCH] Using subject as key in list handler --- daemon/daemon.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index fd3eeed..97a4f66 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -73,8 +73,8 @@ func Spawn(token *jwt.Token, name, image string, options Options) (*Info, error) for { t0 := time.Now().UnixNano() select { - case <-time.After(1000 * time.Millisecond): - ms := (time.Now().UnixNano() - t0) / 1e6 + case <-time.After(time.Second): + ms := (time.Now().UnixNano() - t0) / 1e9 if err := options.Meter.Record(int(ms)); err != nil { log.WithError(err).Warn("Could not record time spent - kill and exit") if err := container.Kill(uname, false, false); err != nil { @@ -93,7 +93,11 @@ func Spawn(token *jwt.Token, name, image string, options Options) (*Info, error) // List the daemons running on this token. func List(token *jwt.Token) ([]docker.APIContainers, error) { - return container.List(nil, container.WithLabel("token", token.Raw)) + claims, ok := token.Claims.(jwt.MapClaims) + if !ok { + return nil, fmt.Errorf("Could extract claims from token") + } + return container.List(nil, container.WithLabel("subject", claims["sub"].(string))) } // SpawnHandler handles spawn requests