From f9231f419f0c9a1488da294c6ca038a027b6ffa8 Mon Sep 17 00:00:00 2001 From: alei Date: Fri, 21 Dec 2018 21:40:46 +0800 Subject: [PATCH] go fmt --- pkg/agent/config.go | 12 ++++++------ pkg/agent/runtime.go | 24 ++++++++++++------------ pkg/agent/server.go | 2 +- pkg/plugin/cmd.go | 13 ++++++------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/pkg/agent/config.go b/pkg/agent/config.go index 7449bd9..35acc28 100644 --- a/pkg/agent/config.go +++ b/pkg/agent/config.go @@ -8,9 +8,9 @@ import ( var ( DefaultConfig = Config{ - DockerEndpoint: "unix:///var/run/docker.sock", - DockerTimeout: 30 * time.Second, - StreamIdleTimeout: 10 * time.Minute, + DockerEndpoint: "unix:///var/run/docker.sock", + DockerTimeout: 30 * time.Second, + StreamIdleTimeout: 10 * time.Minute, StreamCreationTimeout: 15 * time.Second, ListenAddress: "0.0.0.0:10027", @@ -18,9 +18,9 @@ var ( ) type Config struct { - DockerEndpoint string `yaml:"docker_endpoint,omitempty"` - DockerTimeout time.Duration `yaml:"docker_timeout,omitempty"` - StreamIdleTimeout time.Duration `yaml:"stream_idle_timeout,omitempty"` + DockerEndpoint string `yaml:"docker_endpoint,omitempty"` + DockerTimeout time.Duration `yaml:"docker_timeout,omitempty"` + StreamIdleTimeout time.Duration `yaml:"stream_idle_timeout,omitempty"` StreamCreationTimeout time.Duration `yaml:"stream_creation_timeout,omitempty"` ListenAddress string `yaml:"listen_address,omitempty"` diff --git a/pkg/agent/runtime.go b/pkg/agent/runtime.go index 2322150..24675c1 100644 --- a/pkg/agent/runtime.go +++ b/pkg/agent/runtime.go @@ -20,7 +20,7 @@ import ( // RuntimeManager is responsible for docker operation type RuntimeManager struct { - client *dockerclient.Client + client *dockerclient.Client timeout time.Duration } @@ -30,7 +30,7 @@ func NewRuntimeManager(host string, timeout time.Duration) (*RuntimeManager, err return nil, err } return &RuntimeManager{ - client: client, + client: client, timeout: timeout, }, nil } @@ -39,7 +39,7 @@ func NewRuntimeManager(host string, timeout time.Duration) (*RuntimeManager, err // we use this struct in order to inject debug info (image, command) in the debug procedure type DebugAttacher struct { runtime *RuntimeManager - image string + image string command []string } @@ -108,16 +108,16 @@ func (m *RuntimeManager) CreateContainer(targetId string, image string, command config := &container.Config{ Entrypoint: strslice.StrSlice(command), - Image: image, - Tty: true, - OpenStdin: true, - StdinOnce: true, + Image: image, + Tty: true, + OpenStdin: true, + StdinOnce: true, } hostConfig := &container.HostConfig{ NetworkMode: container.NetworkMode(m.containerMode(targetId)), - UsernsMode: container.UsernsMode(m.containerMode(targetId)), - IpcMode: container.IpcMode(m.containerMode(targetId)), - PidMode: container.PidMode(m.containerMode(targetId)), + UsernsMode: container.UsernsMode(m.containerMode(targetId)), + IpcMode: container.IpcMode(m.containerMode(targetId)), + PidMode: container.PidMode(m.containerMode(targetId)), } ctx, cancel := m.getTimeoutContext() defer cancel() @@ -154,7 +154,7 @@ func (m *RuntimeManager) CleanContainer(id string) { log.Printf("error remove container: %s\n", id) } } - case <- statusCh: + case <-statusCh: if err := m.RmContainer(id, false); err != nil { log.Printf("error remove container: %s\n", id) } @@ -264,4 +264,4 @@ func (m *RuntimeManager) getTimeoutContext() (context.Context, context.CancelFun func (m *RuntimeManager) containerMode(id string) string { return fmt.Sprintf("container:%s", id) -} \ No newline at end of file +} diff --git a/pkg/agent/server.go b/pkg/agent/server.go index e320ea9..f2a06c0 100644 --- a/pkg/agent/server.go +++ b/pkg/agent/server.go @@ -18,7 +18,7 @@ const ( ) type Server struct { - config *Config + config *Config runtimeApi *RuntimeManager } diff --git a/pkg/plugin/cmd.go b/pkg/plugin/cmd.go index 20296fd..9718ace 100644 --- a/pkg/plugin/cmd.go +++ b/pkg/plugin/cmd.go @@ -31,8 +31,8 @@ const ( # override entrypoint of debug container kubectl debug POD_NAME --image aylei/debug-jvm /bin/bash ` - defaultImage = "aylei/troubleshoot:latest" - defaultRetain = false + defaultImage = "aylei/troubleshoot:latest" + defaultRetain = false defaultAgentPort = 10027 ) @@ -45,7 +45,7 @@ type DebugOptions struct { // Pod select options Namespace string - PodName string + PodName string // Debug options RetainContainer bool @@ -54,10 +54,10 @@ type DebugOptions struct { Command []string AgentPort int - Flags *genericclioptions.ConfigFlags + Flags *genericclioptions.ConfigFlags PodClient coreclient.PodsGetter Args []string - Config *restclient.Config + Config *restclient.Config genericclioptions.IOStreams } @@ -132,7 +132,6 @@ func (o *DebugOptions) Complete(cmd *cobra.Command, args []string, argsLenAtDash } o.PodClient = clientset.CoreV1() - return nil } @@ -263,4 +262,4 @@ func (o *DebugOptions) setupTTY() term.TTY { t.Out = stdout } return t -} \ No newline at end of file +}