mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-23 23:51:03 +00:00
Merge pull request #328 from jesseduffield/no-more-unversioned
This commit is contained in:
commit
dc2e0ffa54
20 changed files with 76 additions and 51 deletions
3
go.mod
3
go.mod
|
|
@ -7,7 +7,6 @@ require (
|
||||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
|
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
|
||||||
github.com/boz/go-throttle v0.0.0-20160922054636-fdc4eab740c1
|
github.com/boz/go-throttle v0.0.0-20160922054636-fdc4eab740c1
|
||||||
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
|
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
|
||||||
github.com/davecgh/go-spew v1.1.1
|
|
||||||
github.com/docker/docker v0.7.3-0.20190307005417-54dddadc7d5d
|
github.com/docker/docker v0.7.3-0.20190307005417-54dddadc7d5d
|
||||||
github.com/fatih/color v1.7.0
|
github.com/fatih/color v1.7.0
|
||||||
github.com/go-errors/errors v1.0.1
|
github.com/go-errors/errors v1.0.1
|
||||||
|
|
@ -29,6 +28,7 @@ require (
|
||||||
require (
|
require (
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
|
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
|
||||||
github.com/Microsoft/go-winio v0.4.14 // indirect
|
github.com/Microsoft/go-winio v0.4.14 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/docker/distribution v2.7.1+incompatible // indirect
|
github.com/docker/distribution v2.7.1+incompatible // indirect
|
||||||
github.com/docker/go-connections v0.4.0 // indirect
|
github.com/docker/go-connections v0.4.0 // indirect
|
||||||
github.com/docker/go-units v0.4.0 // indirect
|
github.com/docker/go-units v0.4.0 // indirect
|
||||||
|
|
@ -50,6 +50,7 @@ require (
|
||||||
golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect
|
golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect
|
||||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
|
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
|
||||||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
|
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
|
||||||
|
golang.org/x/text v0.3.7 // indirect
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
|
||||||
google.golang.org/grpc v1.22.0 // indirect
|
google.golang.org/grpc v1.22.0 // indirect
|
||||||
gopkg.in/yaml.v2 v2.2.2 // indirect
|
gopkg.in/yaml.v2 v2.2.2 // indirect
|
||||||
|
|
|
||||||
3
go.sum
3
go.sum
|
|
@ -123,8 +123,9 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60=
|
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60=
|
||||||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
|
|
||||||
35
main.go
35
main.go
|
|
@ -6,18 +6,23 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/integrii/flaggy"
|
"github.com/integrii/flaggy"
|
||||||
"github.com/jesseduffield/lazydocker/pkg/app"
|
"github.com/jesseduffield/lazydocker/pkg/app"
|
||||||
"github.com/jesseduffield/lazydocker/pkg/config"
|
"github.com/jesseduffield/lazydocker/pkg/config"
|
||||||
|
"github.com/jesseduffield/lazydocker/pkg/utils"
|
||||||
"github.com/jesseduffield/yaml"
|
"github.com/jesseduffield/yaml"
|
||||||
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const DEFAULT_VERSION = "unversioned"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
commit string
|
commit string
|
||||||
version = "unversioned"
|
version = DEFAULT_VERSION
|
||||||
date string
|
date string
|
||||||
buildSource = "unknown"
|
buildSource = "unknown"
|
||||||
|
|
||||||
|
|
@ -27,6 +32,8 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
updateBuildInfo()
|
||||||
|
|
||||||
info := fmt.Sprintf(
|
info := fmt.Sprintf(
|
||||||
"%s\nDate: %s\nBuildSource: %s\nCommit: %s\nOS: %s\nArch: %s",
|
"%s\nDate: %s\nBuildSource: %s\nCommit: %s\nOS: %s\nArch: %s",
|
||||||
version,
|
version,
|
||||||
|
|
@ -90,6 +97,30 @@ func main() {
|
||||||
stackTrace := newErr.ErrorStack()
|
stackTrace := newErr.ErrorStack()
|
||||||
app.Log.Error(stackTrace)
|
app.Log.Error(stackTrace)
|
||||||
|
|
||||||
log.Fatal(fmt.Sprintf("%s\n\n%s", app.Tr.ErrorOccurred, stackTrace))
|
log.Fatalf("%s\n\n%s", app.Tr.ErrorOccurred, stackTrace)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateBuildInfo() {
|
||||||
|
if version == DEFAULT_VERSION {
|
||||||
|
if buildInfo, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
revision, ok := lo.Find(buildInfo.Settings, func(setting debug.BuildSetting) bool {
|
||||||
|
return setting.Key == "vcs.revision"
|
||||||
|
})
|
||||||
|
if ok {
|
||||||
|
commit = revision.Value
|
||||||
|
// if lazydocker was built from source we'll show the version as the
|
||||||
|
// abbreviated commit hash
|
||||||
|
version = utils.SafeTruncate(revision.Value, 7)
|
||||||
|
}
|
||||||
|
|
||||||
|
// if version hasn't been set we assume that neither has the date
|
||||||
|
time, ok := lo.Find(buildInfo.Settings, func(setting debug.BuildSetting) bool {
|
||||||
|
return setting.Key == "vcs.time"
|
||||||
|
})
|
||||||
|
if ok {
|
||||||
|
date = time.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,6 @@ func (gui *Gui) renderContainerLogsAux(container *commands.Container, stop, noti
|
||||||
gui.Log.Warn(err)
|
gui.Log.Warn(err)
|
||||||
}
|
}
|
||||||
gui.Log.Info("killed container logs process")
|
gui.Log.Info("killed container logs process")
|
||||||
return
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
_ = cmd.Wait()
|
_ = cmd.Wait()
|
||||||
|
|
@ -411,7 +410,6 @@ type removeContainerOption struct {
|
||||||
description string
|
description string
|
||||||
command string
|
command string
|
||||||
configOptions types.ContainerRemoveOptions
|
configOptions types.ContainerRemoveOptions
|
||||||
runCommand bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDisplayStrings is a function.
|
// GetDisplayStrings is a function.
|
||||||
|
|
|
||||||
|
|
@ -360,7 +360,7 @@ func (gui *Gui) handleDonate(g *gocui.Gui, v *gocui.View) error {
|
||||||
if cx > len(gui.Tr.Donate) {
|
if cx > len(gui.Tr.Donate) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return gui.OSCommand.OpenLink("https://donorbox.org/lazydocker")
|
return gui.OSCommand.OpenLink("https://github.com/sponsors/jesseduffield")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) editFile(filename string) error {
|
func (gui *Gui) editFile(filename string) error {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||||
g.Highlight = true
|
g.Highlight = true
|
||||||
width, height := g.Size()
|
width, height := g.Size()
|
||||||
|
|
||||||
information := "lazydocker " + gui.Config.Version
|
information := gui.Config.Version
|
||||||
if gui.g.Mouse {
|
if gui.g.Mouse {
|
||||||
donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.Donate)
|
donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.Donate)
|
||||||
information = donate + " " + information
|
information = donate + " " + information
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
|
|
@ -73,5 +71,5 @@ func (gui *Gui) handleCreateOptionsMenu(g *gocui.Gui, v *gocui.View) error {
|
||||||
return bindings[index].Handler(g, v)
|
return bindings[index].Handler(g, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.createMenu(strings.Title(gui.Tr.Menu), bindings, len(bindings), handleMenuPress)
|
return gui.createMenu(gui.Tr.MenuTitle, bindings, len(bindings), handleMenuPress)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,11 +126,6 @@ func (gui *Gui) renderServiceTop(service *commands.Service) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) renderServiceLogs(service *commands.Service) error {
|
func (gui *Gui) renderServiceLogs(service *commands.Service) error {
|
||||||
service, err := gui.getSelectedService()
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if service.Container == nil {
|
if service.Container == nil {
|
||||||
return gui.T.NewTask(func(stop chan struct{}) {
|
return gui.T.NewTask(func(stop chan struct{}) {
|
||||||
gui.clearMainView()
|
gui.clearMainView()
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,6 @@ func (gui *Gui) focusPoint(selectedX int, selectedY int, lineCount int, v *gocui
|
||||||
if originalCy != cy {
|
if originalCy != cy {
|
||||||
_ = v.SetCursor(cx, selectedY-oy)
|
_ = v.SetCursor(cx, selectedY-oy)
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) cleanString(s string) string {
|
func (gui *Gui) cleanString(s string) string {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ func dutchSet() TranslationSet {
|
||||||
Execute: "voer uit",
|
Execute: "voer uit",
|
||||||
Close: "sluit",
|
Close: "sluit",
|
||||||
Menu: "menu",
|
Menu: "menu",
|
||||||
|
MenuTitle: "Menu",
|
||||||
Scroll: "scroll",
|
Scroll: "scroll",
|
||||||
OpenConfig: "open de lazydocker configuratie",
|
OpenConfig: "open de lazydocker configuratie",
|
||||||
EditConfig: "verander de lazydocker configuratie",
|
EditConfig: "verander de lazydocker configuratie",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ type TranslationSet struct {
|
||||||
GlobalTitle string
|
GlobalTitle string
|
||||||
Navigate string
|
Navigate string
|
||||||
Menu string
|
Menu string
|
||||||
|
MenuTitle string
|
||||||
Execute string
|
Execute string
|
||||||
Scroll string
|
Scroll string
|
||||||
Close string
|
Close string
|
||||||
|
|
@ -127,6 +128,7 @@ func englishSet() TranslationSet {
|
||||||
Execute: "execute",
|
Execute: "execute",
|
||||||
Close: "close",
|
Close: "close",
|
||||||
Menu: "menu",
|
Menu: "menu",
|
||||||
|
MenuTitle: "Menu",
|
||||||
Scroll: "scroll",
|
Scroll: "scroll",
|
||||||
OpenConfig: "open lazydocker config",
|
OpenConfig: "open lazydocker config",
|
||||||
EditConfig: "edit lazydocker config",
|
EditConfig: "edit lazydocker config",
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ func germanSet() TranslationSet {
|
||||||
Navigate: "navigieren",
|
Navigate: "navigieren",
|
||||||
Execute: "ausführen",
|
Execute: "ausführen",
|
||||||
Close: "schließen",
|
Close: "schließen",
|
||||||
Menu: "Menü",
|
Menu: "menü",
|
||||||
|
MenuTitle: "Menü",
|
||||||
Scroll: "scrollen",
|
Scroll: "scrollen",
|
||||||
OpenConfig: "öffne lazydocker Konfiguration",
|
OpenConfig: "öffne lazydocker Konfiguration",
|
||||||
EditConfig: "bearbeite lazydocker Konfiguration",
|
EditConfig: "bearbeite lazydocker Konfiguration",
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,8 @@ import (
|
||||||
|
|
||||||
// Localizer will translate a message into the user's language
|
// Localizer will translate a message into the user's language
|
||||||
type Localizer struct {
|
type Localizer struct {
|
||||||
language string
|
Log *logrus.Entry
|
||||||
Log *logrus.Entry
|
S TranslationSet
|
||||||
S TranslationSet
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTranslationSetFromConfig(log *logrus.Entry, configLanguage string) (*TranslationSet, error) {
|
func NewTranslationSetFromConfig(log *logrus.Entry, configLanguage string) (*TranslationSet, error) {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ func polishSet() TranslationSet {
|
||||||
Execute: "wykonaj",
|
Execute: "wykonaj",
|
||||||
Close: "zamknij",
|
Close: "zamknij",
|
||||||
Menu: "menu",
|
Menu: "menu",
|
||||||
|
MenuTitle: "Menu",
|
||||||
Scroll: "przewiń",
|
Scroll: "przewiń",
|
||||||
OpenConfig: "otwórz konfigurację",
|
OpenConfig: "otwórz konfigurację",
|
||||||
EditConfig: "edytuj konfigurację",
|
EditConfig: "edytuj konfigurację",
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ func turkishSet() TranslationSet {
|
||||||
Execute: "çalıştır",
|
Execute: "çalıştır",
|
||||||
Close: "kapat",
|
Close: "kapat",
|
||||||
Menu: "menü",
|
Menu: "menü",
|
||||||
|
MenuTitle: "Menü",
|
||||||
Scroll: "kaydır",
|
Scroll: "kaydır",
|
||||||
OpenConfig: "lazydocker ayarlarını aç",
|
OpenConfig: "lazydocker ayarlarını aç",
|
||||||
EditConfig: "lazzydocker ayarlarını düzenle",
|
EditConfig: "lazzydocker ayarlarını düzenle",
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type TaskManager struct {
|
type TaskManager struct {
|
||||||
waitingTask *Task
|
currentTask *Task
|
||||||
currentTask *Task
|
waitingMutex sync.Mutex
|
||||||
waitingMutex sync.Mutex
|
taskIDMutex sync.Mutex
|
||||||
taskIDMutex sync.Mutex
|
Log *logrus.Entry
|
||||||
Log *logrus.Entry
|
Tr *i18n.TranslationSet
|
||||||
Tr *i18n.TranslationSet
|
newTaskId int
|
||||||
waitingTaskAlerts chan struct{}
|
|
||||||
newTaskId int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Task struct {
|
type Task struct {
|
||||||
|
|
@ -104,7 +102,6 @@ func (t *Task) Stop() {
|
||||||
<-t.notifyStopped
|
<-t.notifyStopped
|
||||||
t.Log.Info("received notifystopped message")
|
t.Log.Info("received notifystopped message")
|
||||||
t.stopped = true
|
t.stopped = true
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTickerTask is a convenience function for making a new task that repeats some action once per e.g. second
|
// NewTickerTask is a convenience function for making a new task that repeats some action once per e.g. second
|
||||||
|
|
|
||||||
|
|
@ -379,3 +379,11 @@ func CloseMany(closers []io.Closer) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SafeTruncate(str string, limit int) string {
|
||||||
|
if len(str) > limit {
|
||||||
|
return str[0:limit]
|
||||||
|
} else {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import "log"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
c := make(chan struct{})
|
|
||||||
|
|
||||||
close(c)
|
|
||||||
|
|
||||||
close(c)
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-c:
|
|
||||||
log.Println("hmm")
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-c:
|
|
||||||
log.Println("okay")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
11
vendor/github.com/docker/go-units/circle.yml
generated
vendored
Normal file
11
vendor/github.com/docker/go-units/circle.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
dependencies:
|
||||||
|
post:
|
||||||
|
# install golint
|
||||||
|
- go get golang.org/x/lint/golint
|
||||||
|
|
||||||
|
test:
|
||||||
|
pre:
|
||||||
|
# run analysis before tests
|
||||||
|
- go vet ./...
|
||||||
|
- test -z "$(golint ./... | tee /dev/stderr)"
|
||||||
|
- test -z "$(gofmt -s -l . | tee /dev/stderr)"
|
||||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
|
@ -146,6 +146,8 @@ golang.org/x/net/proxy
|
||||||
golang.org/x/sys/internal/unsafeheader
|
golang.org/x/sys/internal/unsafeheader
|
||||||
golang.org/x/sys/unix
|
golang.org/x/sys/unix
|
||||||
golang.org/x/sys/windows
|
golang.org/x/sys/windows
|
||||||
|
# golang.org/x/text v0.3.7
|
||||||
|
## explicit; go 1.17
|
||||||
# golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
|
# golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
|
||||||
## explicit
|
## explicit
|
||||||
# golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
|
# golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue