mirror of
https://github.com/zix99/traefik-lazyload.git
synced 2026-01-02 10:57:22 +01:00
Some docs and cleanup
This commit is contained in:
@@ -74,7 +74,6 @@ func (s *Core) StartHost(hostname string) (*StartResult, error) {
|
||||
}
|
||||
|
||||
if ets, exists := s.active[ct.ID]; exists {
|
||||
// TODO: Handle case we think it's active, but not? (eg. crash? slow boot?)
|
||||
logrus.Debugf("Asked to start host, but we already think it's started: %s", ets.name)
|
||||
return &StartResult{
|
||||
WaitForCode: ets.waitForCode,
|
||||
@@ -265,6 +264,7 @@ func (s *Core) findAllLazyloadContainers(ctx context.Context, includeStopped boo
|
||||
})
|
||||
}
|
||||
|
||||
// Returns all actively managed containers
|
||||
func (s *Core) ActiveContainers() []*ContainerState {
|
||||
s.mux.Lock()
|
||||
defer s.mux.Unlock()
|
||||
@@ -279,8 +279,9 @@ func (s *Core) ActiveContainers() []*ContainerState {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *Core) QualifyingContainers() []string {
|
||||
ct, err := s.findAllLazyloadContainers(context.Background(), true)
|
||||
// Return all containers that qualify to be load-managed (eg. have the tag)
|
||||
func (s *Core) QualifyingContainers(ctx context.Context) []string {
|
||||
ct, err := s.findAllLazyloadContainers(ctx, true)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"traefik-lazyload/pkg/config"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
@@ -22,7 +23,7 @@ func labelOrDefault(ct *types.Container, sublabel, dflt string) (string, bool) {
|
||||
return dflt, false
|
||||
}
|
||||
|
||||
func short(id string) string {
|
||||
func shortId(id string) string {
|
||||
const SLEN = 8
|
||||
if len(id) <= SLEN {
|
||||
return id
|
||||
@@ -33,11 +34,18 @@ func short(id string) string {
|
||||
func containerShort(c *types.Container) string {
|
||||
var name string
|
||||
if len(c.Names) > 0 {
|
||||
name = c.Names[0]
|
||||
name = trimRootPath(c.Names[0])
|
||||
} else {
|
||||
name = c.Image
|
||||
}
|
||||
return fmt.Sprintf("%s(%s)", name, short(c.ID))
|
||||
return fmt.Sprintf("%s(%s)", name, shortId(c.ID))
|
||||
}
|
||||
|
||||
func trimRootPath(s string) string {
|
||||
if strings.HasPrefix(s, "/") {
|
||||
return s[1:]
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func isRunning(c *types.Container) bool {
|
||||
|
||||
Reference in New Issue
Block a user