initial commit
This commit is contained in:
7
app/cmd/categories.go
Normal file
7
app/cmd/categories.go
Normal file
@ -0,0 +1,7 @@
|
||||
package cmd
|
||||
|
||||
var (
|
||||
catSetup = "SETUP"
|
||||
catEntities = "ENTITIES"
|
||||
catHelpers = "HELPERS"
|
||||
)
|
37
app/cmd/docker.go
Normal file
37
app/cmd/docker.go
Normal file
@ -0,0 +1,37 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"ledo/app/cmd/docker"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var CmdDocker = cli.Command{
|
||||
Name: "docker",
|
||||
Aliases: []string{"d"},
|
||||
Category: catHelpers,
|
||||
Usage: "docker helper",
|
||||
Description: `Manage docker-compose in project`,
|
||||
Action: runDockerDefault,
|
||||
Subcommands: []*cli.Command{
|
||||
&docker.CmdDockerPs,
|
||||
&docker.CmdDockerFqn,
|
||||
&docker.CmdDockerUp,
|
||||
&docker.CmdComposeBuild,
|
||||
&docker.CmdComposeDebug,
|
||||
&docker.CmdComposeDown,
|
||||
&docker.CmdComposeLogs,
|
||||
&docker.CmdComposeRestart,
|
||||
&docker.CmdComposeRun,
|
||||
&docker.CmdComposeShell,
|
||||
&docker.CmdComposeStart,
|
||||
&docker.CmdComposeUpOnce,
|
||||
&docker.CmdComposePull,
|
||||
&docker.CmdComposeStop,
|
||||
},
|
||||
}
|
||||
|
||||
func runDockerDefault(ctx *cli.Context) error {
|
||||
return docker.RunComposePs(ctx)
|
||||
}
|
||||
|
22
app/cmd/docker/build.go
Normal file
22
app/cmd/docker/build.go
Normal file
@ -0,0 +1,22 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeBuild = cli.Command{
|
||||
Name: "pull",
|
||||
Usage: "build docker image",
|
||||
Description: `Build all docker images`,
|
||||
Action: RunComposeBuild,
|
||||
}
|
||||
|
||||
func RunComposeBuild(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerBuild(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
21
app/cmd/docker/debug.go
Normal file
21
app/cmd/docker/debug.go
Normal file
@ -0,0 +1,21 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeDebug = cli.Command{
|
||||
Name: "debug",
|
||||
Usage: "debug main container",
|
||||
Description: `Run shell on main container without entrypoint execute`,
|
||||
Action: RunComposeDebug,
|
||||
}
|
||||
|
||||
func RunComposeDebug(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerDebug(ctx)
|
||||
return nil
|
||||
}
|
||||
|
21
app/cmd/docker/down.go
Normal file
21
app/cmd/docker/down.go
Normal file
@ -0,0 +1,21 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeDown = cli.Command{
|
||||
Name: "down",
|
||||
Usage: "down all containers",
|
||||
Description: `Down all containers defined in docker-compose`,
|
||||
Action: RunComposeDown,
|
||||
}
|
||||
|
||||
func RunComposeDown(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerDown(ctx)
|
||||
return nil
|
||||
}
|
||||
|
22
app/cmd/docker/fqn.go
Normal file
22
app/cmd/docker/fqn.go
Normal file
@ -0,0 +1,22 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdDockerFqn = cli.Command{
|
||||
Name: "fqn",
|
||||
Aliases: []string{"f"},
|
||||
Usage: "Docker image fqn",
|
||||
Description: `Get fqn docker image defined as main service in config file`,
|
||||
Action: RunDockerFqn,
|
||||
}
|
||||
|
||||
func RunDockerFqn(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
fmt.Printf("%v", compose.ShowDockerImageFQN(ctx))
|
||||
return nil
|
||||
}
|
22
app/cmd/docker/logs.go
Normal file
22
app/cmd/docker/logs.go
Normal file
@ -0,0 +1,22 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeLogs = cli.Command{
|
||||
Name: "logs",
|
||||
Aliases: []string{"l"},
|
||||
Usage: "logs from containers",
|
||||
Description: `Get fqn docker image defined as main service in config file`,
|
||||
Action: RunComposeLogs,
|
||||
}
|
||||
|
||||
func RunComposeLogs(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerLogs(ctx)
|
||||
return nil
|
||||
}
|
||||
|
21
app/cmd/docker/ps.go
Normal file
21
app/cmd/docker/ps.go
Normal file
@ -0,0 +1,21 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdDockerPs = cli.Command{
|
||||
Name: "ps",
|
||||
Aliases: []string{"p"},
|
||||
Usage: "list running containers",
|
||||
Description: `List all containers defined in docker-compose use in current mode`,
|
||||
Action: RunComposePs,
|
||||
}
|
||||
|
||||
func RunComposePs(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerPs(ctx)
|
||||
return nil
|
||||
}
|
21
app/cmd/docker/pull.go
Normal file
21
app/cmd/docker/pull.go
Normal file
@ -0,0 +1,21 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposePull = cli.Command{
|
||||
Name: "pull",
|
||||
Usage: "docker image pull",
|
||||
Description: `Pull docker image from registry server`,
|
||||
Action: RunComposePull,
|
||||
}
|
||||
|
||||
func RunComposePull(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerPull(ctx)
|
||||
return nil
|
||||
}
|
||||
|
21
app/cmd/docker/restart.go
Normal file
21
app/cmd/docker/restart.go
Normal file
@ -0,0 +1,21 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeRestart = cli.Command{
|
||||
Name: "restart",
|
||||
Usage: "Restart containers",
|
||||
Description: `Restart all containers defined in docker-compose`,
|
||||
Action: RunComposeRestart,
|
||||
}
|
||||
|
||||
func RunComposeRestart(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerRestart(ctx)
|
||||
return nil
|
||||
}
|
||||
|
21
app/cmd/docker/run.go
Normal file
21
app/cmd/docker/run.go
Normal file
@ -0,0 +1,21 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeRun = cli.Command{
|
||||
Name: "run",
|
||||
Usage: "run cmd in main container",
|
||||
Description: `Run command in main container`,
|
||||
Action: RunComposeRun,
|
||||
}
|
||||
|
||||
func RunComposeRun(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerRun(ctx)
|
||||
return nil
|
||||
}
|
||||
|
21
app/cmd/docker/shell.go
Normal file
21
app/cmd/docker/shell.go
Normal file
@ -0,0 +1,21 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeShell = cli.Command{
|
||||
Name: "shell",
|
||||
Usage: "run shell from main service",
|
||||
Description: `Execute shell cmd in main service`,
|
||||
Action: RunComposeShell,
|
||||
}
|
||||
|
||||
func RunComposeShell(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerShell(ctx)
|
||||
return nil
|
||||
}
|
||||
|
20
app/cmd/docker/start.go
Normal file
20
app/cmd/docker/start.go
Normal file
@ -0,0 +1,20 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeStart = cli.Command{
|
||||
Name: "start",
|
||||
Usage: "start containers",
|
||||
Description: `Start all containers defined in docker-compose stack run mode`,
|
||||
Action: RunComposeStart,
|
||||
}
|
||||
|
||||
func RunComposeStart(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerStart(ctx)
|
||||
return nil
|
||||
}
|
22
app/cmd/docker/stop.go
Normal file
22
app/cmd/docker/stop.go
Normal file
@ -0,0 +1,22 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeStop = cli.Command{
|
||||
Name: "stop",
|
||||
Usage: "stop containers",
|
||||
Description: `Stop all containers defined in docker-compose stack mode`,
|
||||
Action: RunComposePull,
|
||||
}
|
||||
|
||||
func RunComposeStop(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerStop(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
22
app/cmd/docker/up.go
Normal file
22
app/cmd/docker/up.go
Normal file
@ -0,0 +1,22 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdDockerUp = cli.Command{
|
||||
Name: "up",
|
||||
Aliases: []string{"u"},
|
||||
Usage: "up containers",
|
||||
Description: `Up all containers defined in docker-compose use in current mode`,
|
||||
Action: RunComposeUp,
|
||||
}
|
||||
|
||||
func RunComposeUp(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerUp(ctx)
|
||||
return nil
|
||||
}
|
||||
|
21
app/cmd/docker/uponce.go
Normal file
21
app/cmd/docker/uponce.go
Normal file
@ -0,0 +1,21 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdComposeUpOnce = cli.Command{
|
||||
Name: "uponce",
|
||||
Usage: "up one container",
|
||||
Description: `Up one container from docker compose stack`,
|
||||
Action: RunComposeUpOnce,
|
||||
}
|
||||
|
||||
func RunComposeUpOnce(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
compose.ExecComposerUpOnce(ctx)
|
||||
return nil
|
||||
}
|
||||
|
24
app/cmd/mode.go
Normal file
24
app/cmd/mode.go
Normal file
@ -0,0 +1,24 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/cmd/mode"
|
||||
)
|
||||
|
||||
var CmdMode = cli.Command{
|
||||
Name: "mode",
|
||||
Aliases: []string{"m"},
|
||||
Category: catSetup,
|
||||
Usage: "run mode management",
|
||||
Description: `Manage run mode`,
|
||||
Action: runModeDefault,
|
||||
Subcommands: []*cli.Command{
|
||||
&mode.CmdModeSelect,
|
||||
&mode.CmdModeList,
|
||||
},
|
||||
}
|
||||
|
||||
func runModeDefault(cmd *cli.Context) error {
|
||||
return mode.RunSelectMode(cmd)
|
||||
}
|
||||
|
22
app/cmd/mode/list.go
Normal file
22
app/cmd/mode/list.go
Normal file
@ -0,0 +1,22 @@
|
||||
package mode
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
var CmdModeList = cli.Command{
|
||||
Name: "list",
|
||||
Usage: "list run modes",
|
||||
Description: `List modes defined in project config file`,
|
||||
Action: RunModeList,
|
||||
}
|
||||
|
||||
func RunModeList(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
ctx.Mode.PrintListModes()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
27
app/cmd/mode/select.go
Normal file
27
app/cmd/mode/select.go
Normal file
@ -0,0 +1,27 @@
|
||||
package mode
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/context"
|
||||
"ledo/app/modules/interact"
|
||||
)
|
||||
|
||||
var CmdModeSelect = cli.Command{
|
||||
Name: "select",
|
||||
Usage: "select run mode",
|
||||
Description: `Select mode defined in project config file`,
|
||||
ArgsUsage: "[<mode>]",
|
||||
Action: RunSelectMode,
|
||||
}
|
||||
|
||||
func RunSelectMode(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
if cmd.Args().Len() == 1 {
|
||||
ctx.Mode.SetMode(cmd.Args().First())
|
||||
return nil
|
||||
}
|
||||
interact.SelectMode(ctx, "")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user