Skip to content

Commit 8ec9e67

Browse files
committed
use latest core client to support HA & LB
1 parent f26892f commit 8ec9e67

File tree

12 files changed

+90
-78
lines changed

12 files changed

+90
-78
lines changed

.github/workflows/goreleaser.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ jobs:
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
1416

1517
- name: Set up environment variables
1618
run: |
1719
echo "::set-env name=VERSION::$(git describe --tags $(git rev-list --tags --max-count=1))"
1820
19-
- name: Unshallow
20-
run: git fetch --prune --unshallow
21-
2221
- name: Set up Go
2322
uses: actions/setup-go@v2
2423
with:

commands/container.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ func setContainersStatus(c *cli.Context) error {
677677
}
678678

679679
func listContainers(c *cli.Context) error {
680-
client := setupAndGetGRPCConnection().GetRPCClient()
680+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
681681

682682
opts := &pb.ListContainersOptions{
683683
Appname: c.Args().First(),
@@ -784,7 +784,7 @@ func reallocContainers(c *cli.Context) error {
784784
}
785785

786786
func execContainer(c *cli.Context) (err error) {
787-
client := setupAndGetGRPCConnection().GetRPCClient()
787+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
788788

789789
opts := &pb.ExecuteContainerOptions{
790790
ContainerId: c.Args().First(),

commands/core.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func CoreCommand() *cli.Command {
2323
}
2424

2525
func info(c *cli.Context) error {
26-
client := setupAndGetGRPCConnection().GetRPCClient()
26+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
2727
opts := &pb.Empty{}
2828
coreInfo, err := client.Info(c.Context, opts)
2929
if err != nil {

commands/image.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func ImageCommand() *cli.Command {
115115

116116
func buildImage(c *cli.Context) error {
117117
opts := generateBuildOpts(c)
118-
client := setupAndGetGRPCConnection().GetRPCClient()
118+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
119119
resp, err := client.BuildImage(context.Background(), opts)
120120
if err != nil {
121121
return cli.Exit(err, -1)
@@ -175,7 +175,7 @@ func cacheImage(c *cli.Context) error {
175175
Nodename: c.String("nodename"),
176176
}
177177

178-
client := setupAndGetGRPCConnection().GetRPCClient()
178+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
179179
resp, err := client.CacheImage(context.Background(), opts)
180180
if err != nil {
181181
return cli.Exit(err, -1)
@@ -206,7 +206,7 @@ func cleanImage(c *cli.Context) error {
206206
Nodename: c.String("nodename"),
207207
Prune: c.Bool("prune"),
208208
}
209-
client := setupAndGetGRPCConnection().GetRPCClient()
209+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
210210
resp, err := client.RemoveImage(context.Background(), opts)
211211
if err != nil {
212212
return cli.Exit(err, -1)

commands/lambda.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type window struct {
2424
}
2525

2626
func runLambda(c *cli.Context) error {
27-
client := setupAndGetGRPCConnection().GetRPCClient()
27+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
2828
code, err := lambda(c, client)
2929
if err == nil {
3030
return cli.Exit("", code)

commands/main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package commands
22

33
import (
4+
"context"
45
"fmt"
56

67
"github.com/projecteru2/core/client"
@@ -84,18 +85,22 @@ func GlobalFlags() []cli.Flag {
8485
}
8586
}
8687

87-
func setupAndGetGRPCConnection() *client.Client {
88+
func setupAndGetGRPCConnection(ctx context.Context) *client.Client {
8889
_ = setupLog("INFO")
8990
if debug {
9091
_ = setupLog("DEBUG")
9192
}
9293

93-
return client.NewClient(eru, types.AuthConfig{Username: username, Password: password})
94+
cli, err := client.NewClient(ctx, eru, types.AuthConfig{Username: username, Password: password})
95+
if err != nil {
96+
log.Fatalf("[setupAndGetGRPCConnection] create client failed %v", err)
97+
}
98+
return cli
9499
}
95100

96101
func checkParamsAndGetClient(c *cli.Context) (pb.CoreRPCClient, error) {
97102
if c.NArg() == 0 {
98103
return nil, fmt.Errorf("not specify arguments")
99104
}
100-
return setupAndGetGRPCConnection().GetRPCClient(), nil
105+
return setupAndGetGRPCConnection(c.Context).GetRPCClient(), nil
101106
}

commands/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func NodeCommand() *cli.Command {
188188
}
189189

190190
func listNodeContainers(c *cli.Context) error {
191-
client := setupAndGetGRPCConnection().GetRPCClient()
191+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
192192

193193
nodename := c.Args().First()
194194
if nodename == "" {

commands/pod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func PodCommand() *cli.Command {
7777
}
7878

7979
func listPods(c *cli.Context) error {
80-
client := setupAndGetGRPCConnection().GetRPCClient()
80+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
8181
resp, err := client.ListPods(context.Background(), &pb.Empty{})
8282
if err != nil {
8383
log.Fatalf("[ListPods] send request failed %v", err)

commands/publish.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func dumpELB(c *cli.Context) error {
8181
}
8282

8383
func publishContainers(c *cli.Context) error {
84-
client := setupAndGetGRPCConnection().GetRPCClient()
84+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
8585

8686
app := c.String("app")
8787
elb := c.String("elb")

commands/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func status(c *cli.Context) error {
17-
client := setupAndGetGRPCConnection().GetRPCClient()
17+
client := setupAndGetGRPCConnection(c.Context).GetRPCClient()
1818
name := c.Args().First()
1919
entry := c.String("entry")
2020
node := c.String("node")

0 commit comments

Comments
 (0)