Skip to content

Commit 890e179

Browse files
committed
Code cleanup
- Remove legacy/unused code - Reorder imports
1 parent 2610aeb commit 890e179

File tree

13 files changed

+32
-479
lines changed

13 files changed

+32
-479
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin

cmd/agent/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ import (
2020
"crypto/tls"
2121
"crypto/x509"
2222
"fmt"
23-
"sigs.k8s.io/apiserver-network-proxy/pkg/agent/agentclient"
23+
"io/ioutil"
24+
"net/http"
25+
"os"
26+
2427
"github.com/golang/glog"
2528
"github.com/prometheus/client_golang/prometheus"
2629
"github.com/spf13/cobra"
2730
"github.com/spf13/pflag"
2831
"google.golang.org/grpc"
2932
"google.golang.org/grpc/credentials"
30-
"io/ioutil"
31-
"net/http"
32-
"os"
33+
"sigs.k8s.io/apiserver-network-proxy/pkg/agent/agentclient"
3334
)
3435

3536
func main() {

cmd/client/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import (
2020
"crypto/tls"
2121
"crypto/x509"
2222
"fmt"
23-
"github.com/spf13/pflag"
24-
"google.golang.org/grpc"
25-
"google.golang.org/grpc/credentials"
2623
"io"
2724
"io/ioutil"
2825
"os"
2926

30-
"sigs.k8s.io/apiserver-network-proxy/pkg/agent/client"
3127
"github.com/golang/glog"
3228
"github.com/spf13/cobra"
29+
"github.com/spf13/pflag"
30+
"google.golang.org/grpc"
31+
"google.golang.org/grpc/credentials"
32+
"sigs.k8s.io/apiserver-network-proxy/pkg/agent/client"
3333
)
3434

3535
func main() {

cmd/proxy/main.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,22 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"crypto/tls"
21+
"crypto/x509"
2022
"fmt"
21-
"github.com/prometheus/client_golang/prometheus"
22-
"google.golang.org/grpc/credentials"
23+
"io/ioutil"
2324
"net"
2425
"net/http"
2526
"os"
2627

27-
"google.golang.org/grpc"
28-
29-
"crypto/tls"
30-
"crypto/x509"
31-
"sigs.k8s.io/apiserver-network-proxy/pkg/agent/agentserver"
32-
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
3328
"github.com/golang/glog"
29+
"github.com/prometheus/client_golang/prometheus"
3430
"github.com/spf13/cobra"
3531
"github.com/spf13/pflag"
36-
"io/ioutil"
32+
"google.golang.org/grpc"
33+
"google.golang.org/grpc/credentials"
34+
"sigs.k8s.io/apiserver-network-proxy/pkg/agent/agentserver"
35+
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
3736
)
3837

3938
func main() {

examples/legacy/client/main.go

Lines changed: 0 additions & 89 deletions
This file was deleted.

examples/legacy/server/main.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

pkg/agent/agentclient/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import (
2323
"sync"
2424
"sync/atomic"
2525

26-
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
2726
"github.com/golang/glog"
2827
"google.golang.org/grpc"
28+
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
2929
)
3030

3131
type AgentClient struct {

pkg/agent/agentserver/server.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@ limitations under the License.
1717
package agentserver
1818

1919
import (
20+
"fmt"
2021
"io"
22+
"net"
2123

22-
"fmt"
23-
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
2424
"github.com/golang/glog"
25-
"net"
25+
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
2626
)
2727

2828
// ProxyClientConnection...
2929
type ProxyClientConnection struct {
30-
Mode string
31-
Grpc agent.ProxyService_ProxyServer
32-
// Http http.ResponseWriter
30+
Mode string
31+
Grpc agent.ProxyService_ProxyServer
3332
Http net.Conn
3433
connected chan struct{}
3534
connectID int64
@@ -74,14 +73,14 @@ func NewProxyServer() *ProxyServer {
7473
}
7574
}
7675

77-
// Agent ...
76+
// Proxy handles incoming streams from gRPC frontend.
7877
func (s *ProxyServer) Proxy(stream agent.ProxyService_ProxyServer) error {
7978
glog.Info("proxy request from client")
8079

8180
recvCh := make(chan *agent.Packet, 10)
8281
stopCh := make(chan error)
8382

84-
go s.serveRecv(stream, recvCh)
83+
go s.serveRecvFrontend(stream, recvCh)
8584

8685
defer func() {
8786
close(recvCh)
@@ -106,7 +105,7 @@ func (s *ProxyServer) Proxy(stream agent.ProxyService_ProxyServer) error {
106105
return <-stopCh
107106
}
108107

109-
func (s *ProxyServer) serveRecv(stream agent.ProxyService_ProxyServer, recvCh <-chan *agent.Packet) {
108+
func (s *ProxyServer) serveRecvFrontend(stream agent.ProxyService_ProxyServer, recvCh <-chan *agent.Packet) {
110109
glog.Info("start serve recv ...")
111110
for pkt := range recvCh {
112111
switch pkt.Type {

pkg/agent/agentserver/tunnel.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ limitations under the License.
1717
package agentserver
1818

1919
import (
20-
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
21-
"github.com/golang/glog"
2220
"io"
2321
"math/rand"
2422
"net/http"
23+
24+
"github.com/golang/glog"
25+
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
2526
)
2627

2728
type Tunnel struct {

pkg/agent/client/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ import (
2424
"net"
2525
"time"
2626

27-
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
2827
"github.com/golang/glog"
29-
3028
"google.golang.org/grpc"
29+
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
3130
)
3231

3332
// Tunnel provides ability to dial a connection through itself

0 commit comments

Comments
 (0)