-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathforwarder_test.go
49 lines (40 loc) · 883 Bytes
/
forwarder_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package forwarder
import (
"context"
"fmt"
"testing"
"github.com/namsral/flag"
)
func TestBasic(t *testing.T) {
var kubecfg string
flag.StringVar(&kubecfg, "kubeconfig", "./kubeconfig", `
the path of kubeconfig, default is '~/.kube/config'
you can configure kubeconfig by environment variable: KUBECONFIG=./kubeconfig,
or provide a option: --kubeconfig=./kubeconfig
`)
flag.Parse()
fmt.Printf("kubecfg: %v\n", kubecfg)
options := []*Option{
{
LocalPort: 8080,
RemotePort: 80,
ServiceName: "my-nginx-svc",
},
{
// LocalPort: 8081,
// RemotePort: 80,
Source: "po/my-nginx-66b6c48dd5-ttdb2",
},
}
ret, err := WithForwarders(context.Background(), options, kubecfg, nil)
if err != nil {
panic(err)
}
defer ret.Close()
ports, err := ret.Ready()
if err != nil {
panic(err)
}
fmt.Printf("ports: %+v\n", ports)
ret.Wait()
}