mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
add a --swarm flag, so its possible to merge
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
parent
3a9152d681
commit
ec76d0ed6f
5 changed files with 19 additions and 6 deletions
4
main.go
4
main.go
|
|
@ -23,6 +23,7 @@ var (
|
||||||
|
|
||||||
configFlag = false
|
configFlag = false
|
||||||
debuggingFlag = false
|
debuggingFlag = false
|
||||||
|
dockerSwarm = false
|
||||||
composeFiles []string
|
composeFiles []string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -44,6 +45,7 @@ func main() {
|
||||||
flaggy.Bool(&configFlag, "c", "config", "Print the current default config")
|
flaggy.Bool(&configFlag, "c", "config", "Print the current default config")
|
||||||
flaggy.Bool(&debuggingFlag, "d", "debug", "a boolean")
|
flaggy.Bool(&debuggingFlag, "d", "debug", "a boolean")
|
||||||
flaggy.StringSlice(&composeFiles, "f", "file", "Specify alternate compose files")
|
flaggy.StringSlice(&composeFiles, "f", "file", "Specify alternate compose files")
|
||||||
|
flaggy.Bool(&dockerSwarm, "s", "swarm", "ue DOcker Swarm mode")
|
||||||
flaggy.SetVersion(info)
|
flaggy.SetVersion(info)
|
||||||
|
|
||||||
flaggy.Parse()
|
flaggy.Parse()
|
||||||
|
|
@ -64,7 +66,7 @@ func main() {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
appConfig, err := config.NewAppConfig("lazydocker", version, commit, date, buildSource, debuggingFlag, composeFiles, projectDir)
|
appConfig, err := config.NewAppConfig("lazydocker", version, commit, date, buildSource, debuggingFlag, dockerSwarm, composeFiles, projectDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -35,7 +36,7 @@ func NewApp(config *config.AppConfig) (*App, error) {
|
||||||
var err error
|
var err error
|
||||||
app.Log = log.NewLogger(config, "23432119147a4367abf7c0de2aa99a2d")
|
app.Log = log.NewLogger(config, "23432119147a4367abf7c0de2aa99a2d")
|
||||||
app.Tr = i18n.NewTranslationSet(app.Log)
|
app.Tr = i18n.NewTranslationSet(app.Log)
|
||||||
app.OSCommand = commands.NewOSCommand(app.Log, config)
|
app.OSCommand = commands.NewOSCommand(app.Log, app.Config)
|
||||||
|
|
||||||
// here is the place to make use of the docker-compose.yml file in the current directory
|
// here is the place to make use of the docker-compose.yml file in the current directory
|
||||||
|
|
||||||
|
|
@ -43,7 +44,11 @@ func NewApp(config *config.AppConfig) (*App, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return app, err
|
return app, err
|
||||||
}
|
}
|
||||||
app.Gui, err = gui.NewGui(app.Log, app.DockerCommand, app.OSCommand, app.Tr, config, app.ErrorChan)
|
|
||||||
|
// TODO: detect if swarm mode is on..
|
||||||
|
fmt.Printf("SWARM: %s\n", app.Config.DockerSwarm)
|
||||||
|
|
||||||
|
app.Gui, err = gui.NewGui(app.Log, app.DockerCommand, app.OSCommand, app.Tr, app.Config, app.ErrorChan)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return app, err
|
return app, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ func NewDockerCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Translat
|
||||||
|
|
||||||
err = osCommand.RunCommand(command)
|
err = osCommand.RunCommand(command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//dockerCommand.InDockerComposeProject = false
|
dockerCommand.InDockerComposeProject = false
|
||||||
log.Warn(err.Error())
|
log.Warn(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -429,6 +429,7 @@ func GetDefaultConfig() UserConfig {
|
||||||
// AppConfig contains the base configuration fields required for lazydocker.
|
// AppConfig contains the base configuration fields required for lazydocker.
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
Debug bool `long:"debug" env:"DEBUG" default:"false"`
|
Debug bool `long:"debug" env:"DEBUG" default:"false"`
|
||||||
|
DockerSwarm bool `long:"debug" default:"false`
|
||||||
Version string `long:"version" env:"VERSION" default:"unversioned"`
|
Version string `long:"version" env:"VERSION" default:"unversioned"`
|
||||||
Commit string `long:"commit" env:"COMMIT"`
|
Commit string `long:"commit" env:"COMMIT"`
|
||||||
BuildDate string `long:"build-date" env:"BUILD_DATE"`
|
BuildDate string `long:"build-date" env:"BUILD_DATE"`
|
||||||
|
|
@ -440,7 +441,7 @@ type AppConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAppConfig makes a new app config
|
// NewAppConfig makes a new app config
|
||||||
func NewAppConfig(name, version, commit, date string, buildSource string, debuggingFlag bool, composeFiles []string, projectDir string) (*AppConfig, error) {
|
func NewAppConfig(name, version, commit, date string, buildSource string, debuggingFlag, dockerSwarm bool, composeFiles []string, projectDir string) (*AppConfig, error) {
|
||||||
configDir, err := findOrCreateConfigDir(name)
|
configDir, err := findOrCreateConfigDir(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -462,6 +463,7 @@ func NewAppConfig(name, version, commit, date string, buildSource string, debugg
|
||||||
Commit: commit,
|
Commit: commit,
|
||||||
BuildDate: date,
|
BuildDate: date,
|
||||||
Debug: debuggingFlag || os.Getenv("DEBUG") == "TRUE",
|
Debug: debuggingFlag || os.Getenv("DEBUG") == "TRUE",
|
||||||
|
DockerSwarm: dockerSwarm,
|
||||||
BuildSource: buildSource,
|
BuildSource: buildSource,
|
||||||
UserConfig: userConfig,
|
UserConfig: userConfig,
|
||||||
ConfigDir: configDir,
|
ConfigDir: configDir,
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,12 @@ func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand
|
||||||
SessionIndex: 0,
|
SessionIndex: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
cyclableViews := []string{"project", "containers", "images", "volumes"}
|
cyclableViews := []string{"project", "containers", "images"}
|
||||||
|
if config.DockerSwarm {
|
||||||
|
dockerCommand.InDockerComposeProject = true
|
||||||
|
}
|
||||||
if dockerCommand.InDockerComposeProject {
|
if dockerCommand.InDockerComposeProject {
|
||||||
|
// Frustratingly, this is not actually the driver for what views are shown - the InDOckerComposeProject var is used inside the gui code
|
||||||
cyclableViews = []string{"project", "services", "containers", "images", "volumes"}
|
cyclableViews = []string{"project", "services", "containers", "images", "volumes"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue