mirror of
https://github.com/wahyd4/kt-connect.git
synced 2026-08-09 05:16:02 +10:00
test: add test case for inbound
This commit is contained in:
@@ -12,6 +12,9 @@ generate-mock:
|
||||
mockgen -source=pkg/kt/command/types.go -destination=pkg/mockd/mock/action_mock.go -package=mock
|
||||
mockgen -source=pkg/kt/cluster/types.go -destination=pkg/mockd/mock/kubernetes_mock.go -package=mock
|
||||
mockgen -source=pkg/kt/connect/types.go -destination=pkg/mockd/mock/connect_mock.go -package=mock
|
||||
mockgen -source=pkg/kt/exec/kubectl/types.go -destination=pkg/mockd/mock/kubectl_mock.go -package=mock
|
||||
mockgen -source=pkg/kt/exec/ssh/types.go -destination=pkg/mockd/mock/ssh_mock.go -package=mock
|
||||
mockgen -source=pkg/kt/exec/sshuttle/types.go -destination=pkg/mockd/mock/sshuttle_mock.go -package=mock
|
||||
|
||||
# run unit test
|
||||
unit-test:
|
||||
|
||||
@@ -34,8 +34,14 @@ func NewCheckCommand(options *options.DaemonOptions, action ActionInterface) cli
|
||||
func (action *Action) Check(options *options.DaemonOptions) (err error) {
|
||||
log.Info().Msgf("system info %s-%s", runtime.GOOS, runtime.GOARCH)
|
||||
|
||||
sshCli := ssh.SshCli{}
|
||||
kubernetesCli := kubectl.Kubectl{
|
||||
KubeConfig: options.KubeConfig,
|
||||
}
|
||||
uttle := sshuttle.SSHUttle{}
|
||||
|
||||
err = runCommandWithMsg(
|
||||
ssh.Version(),
|
||||
sshCli.Version(),
|
||||
"checking ssh version", "ssh is missing, please make sure command ssh is work right at your local first",
|
||||
)
|
||||
|
||||
@@ -44,7 +50,7 @@ func (action *Action) Check(options *options.DaemonOptions) (err error) {
|
||||
}
|
||||
|
||||
err = runCommandWithMsg(
|
||||
kubectl.Version(options.KubeConfig),
|
||||
kubernetesCli.Version(),
|
||||
"checking kubectl version", "kubectl is missing, please make sure kubectl is working right at your local first",
|
||||
)
|
||||
|
||||
@@ -53,7 +59,7 @@ func (action *Action) Check(options *options.DaemonOptions) (err error) {
|
||||
}
|
||||
|
||||
err = runCommandWithMsg(
|
||||
sshuttle.Version(),
|
||||
uttle.Version(),
|
||||
"checking sshuttle version", "sshuttle is missing, you can only use 'ktctl connect --method socks5' with Socks5 proxy mode",
|
||||
)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func newDashboardCommand(options *options.DaemonOptions, action ActionInterface)
|
||||
if options.Debug {
|
||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||
}
|
||||
return action.ApplyDashboard()
|
||||
return action.ApplyDashboard(options)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -49,8 +49,9 @@ func newDashboardCommand(options *options.DaemonOptions, action ActionInterface)
|
||||
}
|
||||
|
||||
// ApplyDashboard ...
|
||||
func (action *Action) ApplyDashboard() (err error) {
|
||||
command := kubectl.ApplyDashboardToCluster()
|
||||
func (action *Action) ApplyDashboard(options *options.DaemonOptions) (err error) {
|
||||
kubernetesCli := kubectl.Kubectl{KubeConfig: options.KubeConfig}
|
||||
command := kubernetesCli.ApplyDashboardToCluster()
|
||||
log.Info().Msg("Install/Upgrade Dashboard to cluster")
|
||||
err = exec.RunAndWait(command, "apply kt dashboard", true)
|
||||
if err != nil {
|
||||
@@ -63,7 +64,10 @@ func (action *Action) ApplyDashboard() (err error) {
|
||||
// OpenDashboard ...
|
||||
func (action *Action) OpenDashboard(options *options.DaemonOptions) (err error) {
|
||||
ch := SetUpWaitingChannel()
|
||||
command := kubectl.PortForwardDashboardToLocal(options.DashboardOptions.Port)
|
||||
kubernetesCli := kubectl.Kubectl{
|
||||
KubeConfig: options.KubeConfig,
|
||||
}
|
||||
command := kubernetesCli.PortForwardDashboardToLocal(options.DashboardOptions.Port)
|
||||
err = exec.BackgroundRun(command, "forward dashboard to localhost", true)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -12,7 +12,7 @@ type ActionInterface interface {
|
||||
Run(service string, options *options.DaemonOptions) error
|
||||
Exchange(service string, options *options.DaemonOptions) error
|
||||
Mesh(service string, options *options.DaemonOptions) error
|
||||
ApplyDashboard() error
|
||||
ApplyDashboard(options *options.DaemonOptions) error
|
||||
}
|
||||
|
||||
// Action cmd action
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/alibaba/kt-connect/pkg/kt/options"
|
||||
|
||||
"github.com/alibaba/kt-connect/pkg/kt/exec"
|
||||
"github.com/alibaba/kt-connect/pkg/kt/exec/kubectl"
|
||||
"github.com/alibaba/kt-connect/pkg/kt/exec/ssh"
|
||||
@@ -15,9 +17,22 @@ import (
|
||||
|
||||
// Inbound mapping local port from cluster
|
||||
func (s *Shadow) Inbound(exposePort, podName, remoteIP string, credential *util.SSHCredential) (err error) {
|
||||
debug := s.Options.Debug
|
||||
kubeConfig := s.Options.KubeConfig
|
||||
namespace := s.Options.Namespace
|
||||
kubernetesCli := &kubectl.Cli{
|
||||
KubeConfig: s.Options.KubeConfig,
|
||||
}
|
||||
sshCli := &ssh.Cli{}
|
||||
return inbound(exposePort, podName, remoteIP, credential, s.Options, kubernetesCli, sshCli)
|
||||
}
|
||||
|
||||
func inbound(
|
||||
exposePort, podName, remoteIP string, credential *util.SSHCredential,
|
||||
options *options.DaemonOptions,
|
||||
kubernetesCli kubectl.CliInterface,
|
||||
sshCli ssh.CliInterface,
|
||||
) (err error) {
|
||||
debug := options.Debug
|
||||
namespace := options.Namespace
|
||||
|
||||
log.Info().Msgf("remote %s forward to local %s", remoteIP, exposePort)
|
||||
localSSHPort, err := strconv.Atoi(util.GetRandomSSHPort(remoteIP))
|
||||
if err != nil {
|
||||
@@ -26,7 +41,7 @@ func (s *Shadow) Inbound(exposePort, podName, remoteIP string, credential *util.
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func(wg *sync.WaitGroup) {
|
||||
portforward := kubectl.PortForward(kubeConfig, namespace, podName, localSSHPort)
|
||||
portforward := kubernetesCli.PortForward(namespace, podName, localSSHPort)
|
||||
err = exec.BackgroundRun(portforward, "exchange port forward to local", debug)
|
||||
// make sure port-forward already success
|
||||
time.Sleep(time.Duration(2) * time.Second)
|
||||
@@ -44,6 +59,6 @@ func (s *Shadow) Inbound(exposePort, podName, remoteIP string, credential *util.
|
||||
localPort = ports[1]
|
||||
remotePort = ports[0]
|
||||
}
|
||||
cmd := ssh.ForwardRemoteRequestToLocal(localPort, credential.RemoteHost, remotePort, credential.PrivateKeyPath, localSSHPort)
|
||||
cmd := sshCli.ForwardRemoteRequestToLocal(localPort, credential.RemoteHost, remotePort, credential.PrivateKeyPath, localSSHPort)
|
||||
return exec.BackgroundRun(cmd, "ssh remote port-forward", debug)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package connect
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"github.com/alibaba/kt-connect/pkg/mockd/mock"
|
||||
"github.com/golang/mock/gomock"
|
||||
|
||||
"github.com/alibaba/kt-connect/pkg/kt/options"
|
||||
"github.com/alibaba/kt-connect/pkg/kt/util"
|
||||
)
|
||||
|
||||
func Test_inbound(t *testing.T) {
|
||||
|
||||
ctl := gomock.NewController(t)
|
||||
|
||||
type args struct {
|
||||
exposePort string
|
||||
podName string
|
||||
remoteIP string
|
||||
credential *util.SSHCredential
|
||||
options *options.DaemonOptions
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "shouldRedirectRequestToLocalHost",
|
||||
args: args{
|
||||
exposePort: "8080",
|
||||
podName: "podName",
|
||||
remoteIP: "127.0.0.1",
|
||||
credential: &util.SSHCredential{},
|
||||
options: options.NewDaemonOptions(),
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
kubectl := mock.NewMockKubernetesCliInterface(ctl)
|
||||
ssh := mock.NewMockSshClIInterface(ctl)
|
||||
|
||||
kubectl.EXPECT().PortForward(gomock.Any(), gomock.Any(), gomock.Any()).Return(exec.Command("ls", "-al"))
|
||||
ssh.EXPECT().ForwardRemoteRequestToLocal(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(exec.Command("ls", "-al"))
|
||||
|
||||
if err := inbound(tt.args.exposePort, tt.args.podName, tt.args.remoteIP, tt.args.credential, tt.args.options, kubectl, ssh); (err != nil) != tt.wantErr {
|
||||
t.Errorf("inbound() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,16 @@ import (
|
||||
// Outbound start vpn connection
|
||||
func (s *Shadow) Outbound(name, podIP string, credential *util.SSHCredential, cidrs []string) (err error) {
|
||||
options := s.Options
|
||||
|
||||
kubernetesCli := kubectl.Cli{
|
||||
KubeConfig: options.KubeConfig,
|
||||
}
|
||||
|
||||
sshCli := ssh.Cli{}
|
||||
uttle := sshuttle.Cli{}
|
||||
|
||||
err = exec.BackgroundRun(
|
||||
kubectl.PortForward(
|
||||
options.KubeConfig,
|
||||
kubernetesCli.PortForward(
|
||||
options.Namespace,
|
||||
name,
|
||||
options.ConnectOptions.SSHPort),
|
||||
@@ -33,9 +40,9 @@ func (s *Shadow) Outbound(name, podIP string, credential *util.SSHCredential, ci
|
||||
log.Info().Msgf("Start SOCKS5 Proxy: export http_proxy=socks5://127.0.0.1:%d", options.ConnectOptions.Socke5Proxy)
|
||||
log.Info().Msgf("==============================================================")
|
||||
_ = ioutil.WriteFile(".jvmrc", []byte(fmt.Sprintf("-DsocksProxyHost=127.0.0.1\n-DsocksProxyPort=%d", options.ConnectOptions.Socke5Proxy)), 0644)
|
||||
err = exec.BackgroundRun(ssh.DynamicForwardLocalRequestToRemote(credential.RemoteHost, credential.PrivateKeyPath, options.ConnectOptions.SSHPort, options.ConnectOptions.Socke5Proxy), "vpn(ssh)", options.Debug)
|
||||
err = exec.BackgroundRun(sshCli.DynamicForwardLocalRequestToRemote(credential.RemoteHost, credential.PrivateKeyPath, options.ConnectOptions.SSHPort, options.ConnectOptions.Socke5Proxy), "vpn(ssh)", options.Debug)
|
||||
} else {
|
||||
err = exec.BackgroundRun(sshuttle.SSHUttle(credential.RemoteHost, credential.PrivateKeyPath, options.ConnectOptions.SSHPort, podIP, options.ConnectOptions.DisableDNS, cidrs, options.Debug), "vpn(sshuttle)", options.Debug)
|
||||
err = exec.BackgroundRun(uttle.Connect(credential.RemoteHost, credential.PrivateKeyPath, options.ConnectOptions.SSHPort, podIP, options.ConnectOptions.DisableDNS, cidrs, options.Debug), "vpn(sshuttle)", options.Debug)
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -5,15 +5,16 @@ import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// Version kubectl version
|
||||
func Version(kubeConifg string) *exec.Cmd {
|
||||
return exec.Command("kubectl", "--kubeconfig="+kubeConifg, "version", "--short", "port-forward")
|
||||
// Version ...
|
||||
func (k *Cli) Version() *exec.Cmd {
|
||||
return exec.Command("kubectl", "--kubeconfig="+k.KubeConfig, "version", "--short", "port-forward")
|
||||
}
|
||||
|
||||
// ApplyDashboardToCluster Apply Dashboard to cluster
|
||||
func ApplyDashboardToCluster() *exec.Cmd {
|
||||
// ApplyDashboardToCluster ...
|
||||
func (k *Cli) ApplyDashboardToCluster() *exec.Cmd {
|
||||
return exec.Command(
|
||||
"kubectl",
|
||||
"--kubeconfig="+k.KubeConfig,
|
||||
"-n",
|
||||
"kube-system",
|
||||
"apply",
|
||||
@@ -21,10 +22,11 @@ func ApplyDashboardToCluster() *exec.Cmd {
|
||||
"https://raw.githubusercontent.com/alibaba/kt-connect/master/docs/deploy/manifest/all-in-one.yaml")
|
||||
}
|
||||
|
||||
//PortForwardDashboardToLocal forward dashboardto local
|
||||
func PortForwardDashboardToLocal(port string) *exec.Cmd {
|
||||
// PortForwardDashboardToLocal ...
|
||||
func (k *Cli) PortForwardDashboardToLocal(port string) *exec.Cmd {
|
||||
return exec.Command(
|
||||
"kubectl",
|
||||
"--kubeconfig="+k.KubeConfig,
|
||||
"-n",
|
||||
"kube-system",
|
||||
"port-forward",
|
||||
@@ -33,7 +35,7 @@ func PortForwardDashboardToLocal(port string) *exec.Cmd {
|
||||
)
|
||||
}
|
||||
|
||||
// PortForward kubectl port forward
|
||||
func PortForward(kubeConifg, namespace, resource string, remotePort int) *exec.Cmd {
|
||||
return exec.Command("kubectl", "--kubeconfig="+kubeConifg, "-n", namespace, "port-forward", resource, fmt.Sprintf("%d", remotePort)+":22")
|
||||
// PortForward ...
|
||||
func (k *Cli) PortForward(namespace, resource string, remotePort int) *exec.Cmd {
|
||||
return exec.Command("kubectl", "--kubeconfig="+k.KubeConfig, "-n", namespace, "port-forward", resource, fmt.Sprintf("%d", remotePort)+":22")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package kubectl
|
||||
|
||||
import "os/exec"
|
||||
|
||||
// CliInterface ...
|
||||
type CliInterface interface {
|
||||
Version() *exec.Cmd
|
||||
ApplyDashboardToCluster() *exec.Cmd
|
||||
PortForwardDashboardToLocal(port string) *exec.Cmd
|
||||
PortForward(namespace, resource string, remotePort int) *exec.Cmd
|
||||
}
|
||||
|
||||
// Cli ...
|
||||
type Cli struct {
|
||||
KubeConfig string
|
||||
}
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
)
|
||||
|
||||
// Version check sshuttle version
|
||||
func Version() *exec.Cmd {
|
||||
func (s *Cli) Version() *exec.Cmd {
|
||||
return exec.Command("ssh", "-V")
|
||||
}
|
||||
|
||||
// ForwardRemoteRequestToLocal ssh remote port forward
|
||||
func ForwardRemoteRequestToLocal(localPort, remoteHost, remotePort, privateKeyPath string, remoteSSHPort int) *exec.Cmd {
|
||||
func (s *Cli) ForwardRemoteRequestToLocal(localPort, remoteHost, remotePort, privateKeyPath string, remoteSSHPort int) *exec.Cmd {
|
||||
return exec.Command("ssh",
|
||||
"-oStrictHostKeyChecking=no",
|
||||
"-oUserKnownHostsFile=/dev/null",
|
||||
@@ -23,7 +23,7 @@ func ForwardRemoteRequestToLocal(localPort, remoteHost, remotePort, privateKeyPa
|
||||
}
|
||||
|
||||
// DynamicForwardLocalRequestToRemote ssh remote port forward
|
||||
func DynamicForwardLocalRequestToRemote(remoteHost, privateKeyPath string, remoteSSHPort int, proxyPort int) *exec.Cmd {
|
||||
func (s *Cli) DynamicForwardLocalRequestToRemote(remoteHost, privateKeyPath string, remoteSSHPort int, proxyPort int) *exec.Cmd {
|
||||
return exec.Command("ssh",
|
||||
"-oStrictHostKeyChecking=no",
|
||||
"-oUserKnownHostsFile=/dev/null",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package ssh
|
||||
|
||||
import "os/exec"
|
||||
|
||||
// CliInterface ...
|
||||
type CliInterface interface {
|
||||
Version() *exec.Cmd
|
||||
ForwardRemoteRequestToLocal(localPort, remoteHost, remotePort, privateKeyPath string, remoteSSHPort int) *exec.Cmd
|
||||
DynamicForwardLocalRequestToRemote(remoteHost, privateKeyPath string, remoteSSHPort int, proxyPort int) *exec.Cmd
|
||||
}
|
||||
|
||||
// Cli ...
|
||||
type Cli struct{}
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
)
|
||||
|
||||
// Version check sshuttle version
|
||||
func Version() *exec.Cmd {
|
||||
func (s *Cli) Version() *exec.Cmd {
|
||||
return exec.Command("sshuttle", "--version")
|
||||
}
|
||||
|
||||
// SSHUttle ssh-baed vpn connect
|
||||
func SSHUttle(remoteHost, privateKeyPath string, remotePort int, DNSServer string, disableDNS bool, cidrs []string, debug bool) *exec.Cmd {
|
||||
// Connect ssh-baed vpn connect
|
||||
func (s *Cli) Connect(remoteHost, privateKeyPath string, remotePort int, DNSServer string, disableDNS bool, cidrs []string, debug bool) *exec.Cmd {
|
||||
args := []string{}
|
||||
if !disableDNS {
|
||||
args = append(args, "--dns", "--to-ns", DNSServer)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package sshuttle
|
||||
|
||||
import "os/exec"
|
||||
|
||||
// CliInterface ...
|
||||
type CliInterface interface {
|
||||
Version() *exec.Cmd
|
||||
Connect(remoteHost, privateKeyPath string, remotePort int, DNSServer string, disableDNS bool, cidrs []string, debug bool) *exec.Cmd
|
||||
}
|
||||
|
||||
// Cli ...
|
||||
type Cli struct{}
|
||||
@@ -119,15 +119,15 @@ func (mr *MockActionInterfaceMockRecorder) Mesh(service, options interface{}) *g
|
||||
}
|
||||
|
||||
// ApplyDashboard mocks base method
|
||||
func (m *MockActionInterface) ApplyDashboard() error {
|
||||
func (m *MockActionInterface) ApplyDashboard(options *options.DaemonOptions) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ApplyDashboard")
|
||||
ret := m.ctrl.Call(m, "ApplyDashboard", options)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ApplyDashboard indicates an expected call of ApplyDashboard
|
||||
func (mr *MockActionInterfaceMockRecorder) ApplyDashboard() *gomock.Call {
|
||||
func (mr *MockActionInterfaceMockRecorder) ApplyDashboard(options interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplyDashboard", reflect.TypeOf((*MockActionInterface)(nil).ApplyDashboard))
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplyDashboard", reflect.TypeOf((*MockActionInterface)(nil).ApplyDashboard), options)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: pkg/kt/exec/kubectl/types.go
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
exec "os/exec"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
// MockKubernetesCliInterface is a mock of KubernetesCliInterface interface
|
||||
type MockKubernetesCliInterface struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockKubernetesCliInterfaceMockRecorder
|
||||
}
|
||||
|
||||
// MockKubernetesCliInterfaceMockRecorder is the mock recorder for MockKubernetesCliInterface
|
||||
type MockKubernetesCliInterfaceMockRecorder struct {
|
||||
mock *MockKubernetesCliInterface
|
||||
}
|
||||
|
||||
// NewMockKubernetesCliInterface creates a new mock instance
|
||||
func NewMockKubernetesCliInterface(ctrl *gomock.Controller) *MockKubernetesCliInterface {
|
||||
mock := &MockKubernetesCliInterface{ctrl: ctrl}
|
||||
mock.recorder = &MockKubernetesCliInterfaceMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockKubernetesCliInterface) EXPECT() *MockKubernetesCliInterfaceMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Version mocks base method
|
||||
func (m *MockKubernetesCliInterface) Version() *exec.Cmd {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Version")
|
||||
ret0, _ := ret[0].(*exec.Cmd)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Version indicates an expected call of Version
|
||||
func (mr *MockKubernetesCliInterfaceMockRecorder) Version() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Version", reflect.TypeOf((*MockKubernetesCliInterface)(nil).Version))
|
||||
}
|
||||
|
||||
// ApplyDashboardToCluster mocks base method
|
||||
func (m *MockKubernetesCliInterface) ApplyDashboardToCluster() *exec.Cmd {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ApplyDashboardToCluster")
|
||||
ret0, _ := ret[0].(*exec.Cmd)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ApplyDashboardToCluster indicates an expected call of ApplyDashboardToCluster
|
||||
func (mr *MockKubernetesCliInterfaceMockRecorder) ApplyDashboardToCluster() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplyDashboardToCluster", reflect.TypeOf((*MockKubernetesCliInterface)(nil).ApplyDashboardToCluster))
|
||||
}
|
||||
|
||||
// PortForwardDashboardToLocal mocks base method
|
||||
func (m *MockKubernetesCliInterface) PortForwardDashboardToLocal(port string) *exec.Cmd {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PortForwardDashboardToLocal", port)
|
||||
ret0, _ := ret[0].(*exec.Cmd)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// PortForwardDashboardToLocal indicates an expected call of PortForwardDashboardToLocal
|
||||
func (mr *MockKubernetesCliInterfaceMockRecorder) PortForwardDashboardToLocal(port interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortForwardDashboardToLocal", reflect.TypeOf((*MockKubernetesCliInterface)(nil).PortForwardDashboardToLocal), port)
|
||||
}
|
||||
|
||||
// PortForward mocks base method
|
||||
func (m *MockKubernetesCliInterface) PortForward(namespace, resource string, remotePort int) *exec.Cmd {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PortForward", namespace, resource, remotePort)
|
||||
ret0, _ := ret[0].(*exec.Cmd)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// PortForward indicates an expected call of PortForward
|
||||
func (mr *MockKubernetesCliInterfaceMockRecorder) PortForward(namespace, resource, remotePort interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortForward", reflect.TypeOf((*MockKubernetesCliInterface)(nil).PortForward), namespace, resource, remotePort)
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: pkg/kt/exec/ssh/types.go
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
exec "os/exec"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
// MockSshClIInterface is a mock of SshClIInterface interface
|
||||
type MockSshClIInterface struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockSshClIInterfaceMockRecorder
|
||||
}
|
||||
|
||||
// MockSshClIInterfaceMockRecorder is the mock recorder for MockSshClIInterface
|
||||
type MockSshClIInterfaceMockRecorder struct {
|
||||
mock *MockSshClIInterface
|
||||
}
|
||||
|
||||
// NewMockSshClIInterface creates a new mock instance
|
||||
func NewMockSshClIInterface(ctrl *gomock.Controller) *MockSshClIInterface {
|
||||
mock := &MockSshClIInterface{ctrl: ctrl}
|
||||
mock.recorder = &MockSshClIInterfaceMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockSshClIInterface) EXPECT() *MockSshClIInterfaceMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Version mocks base method
|
||||
func (m *MockSshClIInterface) Version() *exec.Cmd {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Version")
|
||||
ret0, _ := ret[0].(*exec.Cmd)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Version indicates an expected call of Version
|
||||
func (mr *MockSshClIInterfaceMockRecorder) Version() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Version", reflect.TypeOf((*MockSshClIInterface)(nil).Version))
|
||||
}
|
||||
|
||||
// ForwardRemoteRequestToLocal mocks base method
|
||||
func (m *MockSshClIInterface) ForwardRemoteRequestToLocal(localPort, remoteHost, remotePort, privateKeyPath string, remoteSSHPort int) *exec.Cmd {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ForwardRemoteRequestToLocal", localPort, remoteHost, remotePort, privateKeyPath, remoteSSHPort)
|
||||
ret0, _ := ret[0].(*exec.Cmd)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ForwardRemoteRequestToLocal indicates an expected call of ForwardRemoteRequestToLocal
|
||||
func (mr *MockSshClIInterfaceMockRecorder) ForwardRemoteRequestToLocal(localPort, remoteHost, remotePort, privateKeyPath, remoteSSHPort interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForwardRemoteRequestToLocal", reflect.TypeOf((*MockSshClIInterface)(nil).ForwardRemoteRequestToLocal), localPort, remoteHost, remotePort, privateKeyPath, remoteSSHPort)
|
||||
}
|
||||
|
||||
// DynamicForwardLocalRequestToRemote mocks base method
|
||||
func (m *MockSshClIInterface) DynamicForwardLocalRequestToRemote(remoteHost, privateKeyPath string, remoteSSHPort, proxyPort int) *exec.Cmd {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DynamicForwardLocalRequestToRemote", remoteHost, privateKeyPath, remoteSSHPort, proxyPort)
|
||||
ret0, _ := ret[0].(*exec.Cmd)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DynamicForwardLocalRequestToRemote indicates an expected call of DynamicForwardLocalRequestToRemote
|
||||
func (mr *MockSshClIInterfaceMockRecorder) DynamicForwardLocalRequestToRemote(remoteHost, privateKeyPath, remoteSSHPort, proxyPort interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DynamicForwardLocalRequestToRemote", reflect.TypeOf((*MockSshClIInterface)(nil).DynamicForwardLocalRequestToRemote), remoteHost, privateKeyPath, remoteSSHPort, proxyPort)
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: pkg/kt/exec/sshuttle/types.go
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
exec "os/exec"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
// MockSSHUttleInterface is a mock of SSHUttleInterface interface
|
||||
type MockSSHUttleInterface struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockSSHUttleInterfaceMockRecorder
|
||||
}
|
||||
|
||||
// MockSSHUttleInterfaceMockRecorder is the mock recorder for MockSSHUttleInterface
|
||||
type MockSSHUttleInterfaceMockRecorder struct {
|
||||
mock *MockSSHUttleInterface
|
||||
}
|
||||
|
||||
// NewMockSSHUttleInterface creates a new mock instance
|
||||
func NewMockSSHUttleInterface(ctrl *gomock.Controller) *MockSSHUttleInterface {
|
||||
mock := &MockSSHUttleInterface{ctrl: ctrl}
|
||||
mock.recorder = &MockSSHUttleInterfaceMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockSSHUttleInterface) EXPECT() *MockSSHUttleInterfaceMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Version mocks base method
|
||||
func (m *MockSSHUttleInterface) Version() *exec.Cmd {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Version")
|
||||
ret0, _ := ret[0].(*exec.Cmd)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Version indicates an expected call of Version
|
||||
func (mr *MockSSHUttleInterfaceMockRecorder) Version() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Version", reflect.TypeOf((*MockSSHUttleInterface)(nil).Version))
|
||||
}
|
||||
|
||||
// Connect mocks base method
|
||||
func (m *MockSSHUttleInterface) Connect(remoteHost, privateKeyPath string, remotePort int, DNSServer string, disableDNS bool, cidrs []string, debug bool) *exec.Cmd {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Connect", remoteHost, privateKeyPath, remotePort, DNSServer, disableDNS, cidrs, debug)
|
||||
ret0, _ := ret[0].(*exec.Cmd)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Connect indicates an expected call of Connect
|
||||
func (mr *MockSSHUttleInterfaceMockRecorder) Connect(remoteHost, privateKeyPath, remotePort, DNSServer, disableDNS, cidrs, debug interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Connect", reflect.TypeOf((*MockSSHUttleInterface)(nil).Connect), remoteHost, privateKeyPath, remotePort, DNSServer, disableDNS, cidrs, debug)
|
||||
}
|
||||
Reference in New Issue
Block a user