diff --git a/main.go b/main.go index 6b256b66..cf60b3f3 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ var ( configFlag = false debuggingFlag = false + dockerSwarm = false composeFiles []string ) @@ -44,6 +45,7 @@ func main() { flaggy.Bool(&configFlag, "c", "config", "Print the current default config") flaggy.Bool(&debuggingFlag, "d", "debug", "a boolean") flaggy.StringSlice(&composeFiles, "f", "file", "Specify alternate compose files") + flaggy.Bool(&dockerSwarm, "s", "swarm", "ue DOcker Swarm mode") flaggy.SetVersion(info) flaggy.Parse() @@ -64,7 +66,7 @@ func main() { 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 { log.Fatal(err.Error()) } diff --git a/pkg/app/app.go b/pkg/app/app.go index ffc73494..1327d90b 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -1,6 +1,7 @@ package app import ( + "fmt" "io" "strings" @@ -35,7 +36,7 @@ func NewApp(config *config.AppConfig) (*App, error) { var err error app.Log = log.NewLogger(config, "23432119147a4367abf7c0de2aa99a2d") 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 @@ -43,7 +44,11 @@ func NewApp(config *config.AppConfig) (*App, error) { if err != nil { 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 { return app, err } diff --git a/pkg/commands/docker.go b/pkg/commands/docker.go index edba4acf..d4d13d68 100644 --- a/pkg/commands/docker.go +++ b/pkg/commands/docker.go @@ -92,7 +92,7 @@ func NewDockerCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Translat err = osCommand.RunCommand(command) if err != nil { - //dockerCommand.InDockerComposeProject = false + dockerCommand.InDockerComposeProject = false log.Warn(err.Error()) } diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index afa91f1e..6b1d08ae 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -429,6 +429,7 @@ func GetDefaultConfig() UserConfig { // AppConfig contains the base configuration fields required for lazydocker. type AppConfig struct { Debug bool `long:"debug" env:"DEBUG" default:"false"` + DockerSwarm bool `long:"debug" default:"false` Version string `long:"version" env:"VERSION" default:"unversioned"` Commit string `long:"commit" env:"COMMIT"` BuildDate string `long:"build-date" env:"BUILD_DATE"` @@ -440,7 +441,7 @@ type AppConfig struct { } // 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) if err != nil { return nil, err @@ -462,6 +463,7 @@ func NewAppConfig(name, version, commit, date string, buildSource string, debugg Commit: commit, BuildDate: date, Debug: debuggingFlag || os.Getenv("DEBUG") == "TRUE", + DockerSwarm: dockerSwarm, BuildSource: buildSource, UserConfig: userConfig, ConfigDir: configDir, diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 1655420a..d4bfe27e 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -147,8 +147,12 @@ func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand SessionIndex: 0, } - cyclableViews := []string{"project", "containers", "images", "volumes"} + cyclableViews := []string{"project", "containers", "images"} + if config.DockerSwarm { + dockerCommand.InDockerComposeProject = true + } 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"} }