Files
play-with-docker/pwd/check_swarm_status_task.go
Jonathan Leibiusky @xetorthio e9911abf94 Storage has now it's own package.
Remove global `sessions` map and use configured storage.
Add a `types` package so both `pwd` and `storage` can access without
circular dependencies.
Now the session is prepared when requested and not on load.
2017-06-15 16:09:41 -03:00

29 lines
593 B
Go

package pwd
import (
"log"
"github.com/docker/docker/api/types/swarm"
"github.com/play-with-docker/play-with-docker/pwd/types"
)
type checkSwarmStatusTask struct {
}
func (c checkSwarmStatusTask) Run(i *types.Instance) error {
if i.Docker == nil {
return nil
}
if info, err := i.Docker.GetDaemonInfo(); err == nil {
if info.Swarm.LocalNodeState != swarm.LocalNodeStateInactive && info.Swarm.LocalNodeState != swarm.LocalNodeStateLocked {
i.IsManager = &info.Swarm.ControlAvailable
} else {
i.IsManager = nil
}
} else {
log.Println(err)
return err
}
return nil
}