Skip to content

Commit 9891f25

Browse files
authored
Merge pull request #632 from carlosms/sdk-analyzer-name
Add analyer-name to lookout-sdk comments
2 parents eab90e9 + 4cb280d commit 9891f25

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

cmd/lookout-sdk/event.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (c *EventCommand) initDataServer(srv *lookout.DataServerHandler) (startFunc
167167
return start, stop
168168
}
169169

170-
func (c *EventCommand) analyzerClient() (lookout.AnalyzerClient, error) {
170+
func (c *EventCommand) analyzer() (lookout.Analyzer, error) {
171171
if c.Args.Analyzer == "" {
172172
c.Args.Analyzer = "ipv4://localhost:9930"
173173
}
@@ -177,7 +177,7 @@ func (c *EventCommand) analyzerClient() (lookout.AnalyzerClient, error) {
177177

178178
grpcAddr, err := pb.ToGoGrpcAddress(c.Args.Analyzer)
179179
if err != nil {
180-
return nil, fmt.Errorf("Can't resolve address of analyzer '%s': %s", c.Args.Analyzer, err)
180+
return lookout.Analyzer{}, fmt.Errorf("Can't resolve address of analyzer '%s': %s", c.Args.Analyzer, err)
181181
}
182182

183183
timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Second)
@@ -188,10 +188,18 @@ func (c *EventCommand) analyzerClient() (lookout.AnalyzerClient, error) {
188188
grpc.WithBlock(),
189189
)
190190
if err != nil {
191-
return nil, fmt.Errorf("Can't connect to analyzer '%s': %s", grpcAddr, err)
191+
return lookout.Analyzer{}, fmt.Errorf("Can't connect to analyzer '%s': %s", grpcAddr, err)
192192
}
193193

194-
return lookout.NewAnalyzerClient(conn), nil
194+
client := lookout.NewAnalyzerClient(conn)
195+
196+
return lookout.Analyzer{
197+
Client: client,
198+
Config: lookout.AnalyzerConfig{
199+
Name: "test-analyzer",
200+
Addr: c.Args.Analyzer,
201+
},
202+
}, nil
195203
}
196204

197205
func (c *EventCommand) parseConfig() (types.Struct, error) {

cmd/lookout-sdk/push.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (c *PushCommand) Execute(args []string) error {
5555
stopCh <- startDataServer()
5656
}()
5757

58-
client, err := c.analyzerClient()
58+
analyzer, err := c.analyzer()
5959
if err != nil {
6060
return err
6161
}
@@ -64,7 +64,7 @@ func (c *PushCommand) Execute(args []string) error {
6464
Poster: json.NewPoster(os.Stdout),
6565
FileGetter: dataHandler.FileGetter,
6666
Analyzers: map[string]lookout.Analyzer{
67-
"test-analyzer": lookout.Analyzer{Client: client},
67+
analyzer.Config.Name: analyzer,
6868
},
6969
ExitOnError: true,
7070
})

cmd/lookout-sdk/review.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (c *ReviewCommand) Execute(args []string) error {
5151
stopCh <- startDataServer()
5252
}()
5353

54-
client, err := c.analyzerClient()
54+
analyzer, err := c.analyzer()
5555
if err != nil {
5656
return err
5757
}
@@ -60,7 +60,7 @@ func (c *ReviewCommand) Execute(args []string) error {
6060
Poster: json.NewPoster(os.Stdout),
6161
FileGetter: dataHandler.FileGetter,
6262
Analyzers: map[string]lookout.Analyzer{
63-
"test-analyzer": lookout.Analyzer{Client: client},
63+
analyzer.Config.Name: analyzer,
6464
},
6565
ExitOnError: true,
6666
})

0 commit comments

Comments
 (0)