diff --git a/cmd/command/log/logs.go b/cmd/command/log/logs.go deleted file mode 100644 index 03f12bdd6..000000000 --- a/cmd/command/log/logs.go +++ /dev/null @@ -1,66 +0,0 @@ -package log - -import ( - "github.com/pluralsh/plural-cli/pkg/client" - "github.com/pluralsh/plural-cli/pkg/common" - "github.com/pluralsh/plural-cli/pkg/config" - "github.com/pluralsh/plural-cli/pkg/logs" - "github.com/urfave/cli" -) - -type Plural struct { - client.Plural -} - -func Command(clients client.Plural) cli.Command { - p := Plural{ - Plural: clients, - } - return cli.Command{ - Name: "logs", - Usage: "Commands for tailing logs for specific apps", - Subcommands: p.logsCommands(), - Category: "Debugging", - } -} - -func (p *Plural) logsCommands() []cli.Command { - return []cli.Command{ - { - Name: "list", - Usage: "lists log tails for a repo", - ArgsUsage: "{repo}", - Action: common.LatestVersion(common.InitKubeconfig(common.RequireArgs(p.handleLogsList, []string{"{repo}"}))), - }, - { - Name: "tail", - Usage: "execs the specific logtail", - ArgsUsage: "{repo} {name}", - Action: common.LatestVersion(common.InitKubeconfig(common.RequireArgs(p.handleLogTail, []string{"{repo}", "{name}"}))), - }, - } -} - -func (p *Plural) handleLogsList(c *cli.Context) error { - repo := c.Args().Get(0) - conf := config.Read() - if err := p.InitKube(); err != nil { - return err - } - tails, err := logs.List(p.Kube, conf.Namespace(repo)) - if err != nil { - return err - } - - return logs.Print(tails) -} - -func (p *Plural) handleLogTail(c *cli.Context) error { - repo := c.Args().Get(0) - name := c.Args().Get(1) - conf := config.Read() - if err := p.InitKube(); err != nil { - return err - } - return logs.Tail(p.Kube, conf.Namespace(repo), name) -} diff --git a/cmd/command/log/logs_test.go b/cmd/command/log/logs_test.go deleted file mode 100644 index 4ef6cde22..000000000 --- a/cmd/command/log/logs_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package log_test - -import ( - "os" - "testing" - - pluralclient "github.com/pluralsh/plural-cli/pkg/client" - "github.com/pluralsh/plural-cli/pkg/common" - - "github.com/pluralsh/plural-cli/cmd/command/plural" - "github.com/pluralsh/plural-cli/pkg/test/mocks" - "github.com/pluralsh/plural-operator/apis/platform/v1alpha1" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" -) - -func TestLogsList(t *testing.T) { - tests := []struct { - name string - args []string - expectedError string - }{ - { - name: `test "logs list" without repo name`, - args: []string{plural.ApplicationName, "logs", "list"}, - expectedError: "Not enough arguments provided: needs {repo}. Try running --help to see usage.", - }, - { - name: `test "logs list" with repo name`, - args: []string{plural.ApplicationName, "logs", "list", "test"}, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - client := mocks.NewClient(t) - kube := mocks.NewKube(t) - if test.expectedError == "" { - kube.On("LogTailList", mock.AnythingOfType("string")).Return(&v1alpha1.LogTailList{Items: []v1alpha1.LogTail{}}, nil) - } - app := plural.CreateNewApp(&plural.Plural{ - Plural: pluralclient.Plural{ - Client: client, - Kube: kube, - }, - }) - app.HelpName = plural.ApplicationName - os.Args = test.args - _, err := common.CaptureStdout(app, os.Args) - if test.expectedError != "" { - assert.Equal(t, test.expectedError, err.Error()) - } else { - assert.NoError(t, err) - kube.AssertCalled(t, "LogTailList", mock.AnythingOfType("string")) - } - - }) - } -} diff --git a/cmd/command/plural/plural.go b/cmd/command/plural/plural.go index 0673fb4ad..ca6f63a0e 100644 --- a/cmd/command/plural/plural.go +++ b/cmd/command/plural/plural.go @@ -222,8 +222,6 @@ func CreateNewApp(plural *Plural) *cli.App { ops.Command(plural.Plural), profile.Command(), pr.Command(plural.Plural), - proxy.Command(plural.Plural), - log.Command(plural.Plural), cmdinit.Command(plural.Plural), up.Command(plural.Plural), workspace.Command(plural.Plural, plural.HelmConfiguration), diff --git a/cmd/command/proxy/proxy.go b/cmd/command/proxy/proxy.go deleted file mode 100644 index 9b03c7804..000000000 --- a/cmd/command/proxy/proxy.go +++ /dev/null @@ -1,66 +0,0 @@ -package proxy - -import ( - "github.com/pluralsh/plural-cli/pkg/client" - "github.com/pluralsh/plural-cli/pkg/common" - "github.com/pluralsh/plural-cli/pkg/config" - "github.com/pluralsh/plural-cli/pkg/proxy" - "github.com/urfave/cli" -) - -type Plural struct { - client.Plural -} - -func Command(clients client.Plural) cli.Command { - p := Plural{ - Plural: clients, - } - return cli.Command{ - Name: "proxy", - Usage: "proxies into running processes in your cluster", - Subcommands: p.proxyCommands(), - Category: "Debugging", - } -} - -func (p *Plural) proxyCommands() []cli.Command { - return []cli.Command{ - { - Name: "list", - Usage: "lists proxy plugins for a repo", - ArgsUsage: "{repo}", - Action: common.LatestVersion(common.InitKubeconfig(common.RequireArgs(p.handleProxyList, []string{"{repo}"}))), - }, - { - Name: "connect", - Usage: "connects to a named proxy for a repo", - ArgsUsage: "{repo} {name}", - Action: common.LatestVersion(common.InitKubeconfig(common.RequireArgs(p.handleProxyConnect, []string{"{repo}", "{name}"}))), - }, - } -} - -func (p *Plural) handleProxyList(c *cli.Context) error { - repo := c.Args().Get(0) - conf := config.Read() - if err := p.InitKube(); err != nil { - return err - } - proxies, err := proxy.List(p.Kube, conf.Namespace(repo)) - if err != nil { - return err - } - - return proxy.Print(proxies) -} - -func (p *Plural) handleProxyConnect(c *cli.Context) error { - repo := c.Args().Get(0) - name := c.Args().Get(1) - conf := config.Read() - if err := p.InitKube(); err != nil { - return err - } - return proxy.Exec(p.Kube, conf.Namespace(repo), name) -} diff --git a/cmd/command/proxy/proxy_test.go b/cmd/command/proxy/proxy_test.go deleted file mode 100644 index 1a10d7853..000000000 --- a/cmd/command/proxy/proxy_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package proxy_test - -import ( - "os" - "testing" - - clientcmd "github.com/pluralsh/plural-cli/pkg/client" - - "github.com/pluralsh/plural-cli/pkg/common" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/pluralsh/plural-operator/apis/platform/v1alpha1" - "github.com/stretchr/testify/mock" - - "github.com/pluralsh/plural-cli/cmd/command/plural" - "github.com/pluralsh/plural-cli/pkg/test/mocks" - "github.com/stretchr/testify/assert" -) - -func TestProxyList(t *testing.T) { - tests := []struct { - name string - args []string - proxyList *v1alpha1.ProxyList - expectedResponse string - }{ - { - name: `test "proxy list"`, - args: []string{plural.ApplicationName, "proxy", "list", "test"}, - proxyList: &v1alpha1.ProxyList{ - TypeMeta: metav1.TypeMeta{}, - Items: []v1alpha1.Proxy{ - { - ObjectMeta: metav1.ObjectMeta{Name: "proxy-1"}, - Spec: v1alpha1.ProxySpec{Type: v1alpha1.Sh, Target: "test-1"}, - }, - { - ObjectMeta: metav1.ObjectMeta{Name: "proxy-1"}, - Spec: v1alpha1.ProxySpec{Type: v1alpha1.Web, Target: "test-2"}, - }, - }, - }, - expectedResponse: `+---------+------+--------+ -| NAME | TYPE | TARGET | -+---------+------+--------+ -| proxy-1 | sh | test-1 | -| proxy-1 | web | test-2 | -+---------+------+--------+ -`, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - client := mocks.NewClient(t) - kube := mocks.NewKube(t) - kube.On("ProxyList", mock.AnythingOfType("string"), mock.AnythingOfType("string")).Return(test.proxyList, nil) - app := plural.CreateNewApp(&plural.Plural{ - Plural: clientcmd.Plural{ - Client: client, - Kube: kube, - }, - }) - app.HelpName = plural.ApplicationName - os.Args = test.args - res, err := common.CaptureStdout(app, os.Args) - assert.NoError(t, err) - - assert.Equal(t, test.expectedResponse, res) - }) - } -}