Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove console from znet #420

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions pkg/znet/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
osexec "os/exec"
"path/filepath"
"runtime"
"sort"
"strings"
"syscall"
"time"
Expand All @@ -16,7 +15,6 @@ import (
"github.com/pkg/errors"

"github.com/CoreumFoundation/coreum-tools/pkg/libexec"
"github.com/CoreumFoundation/coreum-tools/pkg/logger"
"github.com/CoreumFoundation/coreum-tools/pkg/must"
"github.com/CoreumFoundation/coreum-tools/pkg/parallel"
"github.com/CoreumFoundation/coreum/v4/pkg/config/constant"
Expand All @@ -25,7 +23,6 @@ import (
"github.com/CoreumFoundation/crust/infra/apps/cored"
"github.com/CoreumFoundation/crust/infra/targets"
"github.com/CoreumFoundation/crust/infra/testing"
"github.com/CoreumFoundation/crust/pkg/znet/tmux"
)

var exe = must.String(filepath.EvalSymlinks(must.String(os.Executable())))
Expand Down Expand Up @@ -211,43 +208,6 @@ func Spec(spec *infra.Spec) error {
return nil
}

// Console starts tmux session on top of running environment.
func Console(ctx context.Context, configF *infra.ConfigFactory) error {
spec := infra.NewSpec(configF)
config := NewConfig(configF, spec)

if err := tmux.Kill(ctx, config.EnvName); err != nil {
return err
}

containers := map[string]string{}
for appName, app := range spec.Apps {
if app.Info().Status == infra.AppStatusRunning {
containers[appName] = app.Info().Container
}
}
if len(containers) == 0 {
logger.Get(ctx).Info("There are no running applications to show in tmux console")
return nil
}

appNames := make([]string, 0, len(containers))
for appName := range containers {
appNames = append(appNames, appName)
}
sort.Strings(appNames)

for _, appName := range appNames {
if err := tmux.ShowContainerLogs(ctx, config.EnvName, appName, containers[appName]); err != nil {
return err
}
}
if err := tmux.Attach(ctx, config.EnvName); err != nil {
return err
}
return tmux.Kill(ctx, config.EnvName)
}

// CoverageConvert converts & stores coverage from the first cored app we find.
func CoverageConvert(ctx context.Context, configF *infra.ConfigFactory) error {
spec := infra.NewSpec(configF)
Expand Down
11 changes: 0 additions & 11 deletions pkg/znet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func Main() {
rootCmd.AddCommand(removeCmd(ctx, configF, cmdF))
rootCmd.AddCommand(testCmd(ctx, configF, cmdF))
rootCmd.AddCommand(specCmd(configF, cmdF))
rootCmd.AddCommand(consoleCmd(ctx, configF, cmdF))
rootCmd.AddCommand(coverageConvertCmd(ctx, configF, cmdF))

return rootCmd.Execute()
Expand Down Expand Up @@ -131,16 +130,6 @@ func specCmd(configF *infra.ConfigFactory, cmdF *CmdFactory) *cobra.Command {
}
}

func consoleCmd(ctx context.Context, configF *infra.ConfigFactory, cmdF *CmdFactory) *cobra.Command {
return &cobra.Command{
Use: "console",
Short: "Starts tmux console on top of running environment",
RunE: cmdF.Cmd(func() error {
return Console(ctx, configF)
}),
}
}

func coverageConvertCmd(ctx context.Context, configF *infra.ConfigFactory, cmdF *CmdFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "coverage-convert",
Expand Down
60 changes: 0 additions & 60 deletions pkg/znet/tmux/tmux.go

This file was deleted.