| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package buildinfo | 5 package buildinfo |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "github.com/luci/luci-go/grpc/grpcutil" | 8 "github.com/luci/luci-go/grpc/grpcutil" |
| 9 "github.com/luci/luci-go/luci_config/common/cfgtypes" | 9 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 10 milo "github.com/luci/luci-go/milo/api/proto" | 10 milo "github.com/luci/luci-go/milo/api/proto" |
| 11 "github.com/luci/luci-go/milo/appengine/buildbot" |
| 11 | 12 |
| 12 "google.golang.org/grpc/codes" | 13 "google.golang.org/grpc/codes" |
| 13 | 14 |
| 14 "golang.org/x/net/context" | 15 "golang.org/x/net/context" |
| 15 ) | 16 ) |
| 16 | 17 |
| 17 // Service is a BuildInfoServer implementation. | 18 // Service is a BuildInfoServer implementation. |
| 18 type Service struct{} | 19 type Service struct { |
| 20 » // BuildBot is the BuildInfoProvider for the BuildBot service. |
| 21 » BuildBot buildbot.BuildInfoProvider |
| 22 } |
| 19 | 23 |
| 20 var _ milo.BuildInfoServer = (*Service)(nil) | 24 var _ milo.BuildInfoServer = (*Service)(nil) |
| 21 | 25 |
| 22 // Get implements milo.BuildInfoServer. | 26 // Get implements milo.BuildInfoServer. |
| 23 func (svc *Service) Get(c context.Context, req *milo.BuildInfoRequest) (*milo.Bu
ildInfoResponse, error) { | 27 func (svc *Service) Get(c context.Context, req *milo.BuildInfoRequest) (*milo.Bu
ildInfoResponse, error) { |
| 24 projectHint := cfgtypes.ProjectName(req.ProjectHint) | 28 projectHint := cfgtypes.ProjectName(req.ProjectHint) |
| 25 if projectHint != "" { | 29 if projectHint != "" { |
| 26 if err := projectHint.Validate(); err != nil { | 30 if err := projectHint.Validate(); err != nil { |
| 27 return nil, grpcutil.Errf(codes.InvalidArgument, "invali
d project hint: %s", err.Error()) | 31 return nil, grpcutil.Errf(codes.InvalidArgument, "invali
d project hint: %s", err.Error()) |
| 28 } | 32 } |
| 29 } | 33 } |
| 30 | 34 |
| 31 switch { | 35 switch { |
| 32 case req.GetBuildbot() != nil: | 36 case req.GetBuildbot() != nil: |
| 33 » » return nil, grpcutil.Unimplemented | 37 » » resp, err := svc.BuildBot.GetBuildInfo(c, req.GetBuildbot(), pro
jectHint) |
| 38 » » if err != nil { |
| 39 » » » return nil, err |
| 40 » » } |
| 41 » » return resp, nil |
| 34 | 42 |
| 35 case req.GetSwarming() != nil: | 43 case req.GetSwarming() != nil: |
| 36 return nil, grpcutil.Unimplemented | 44 return nil, grpcutil.Unimplemented |
| 37 | 45 |
| 38 default: | 46 default: |
| 39 » » return nil, grpcutil.Unimplemented | 47 » » return nil, grpcutil.Errf(codes.InvalidArgument, "must supply a
build") |
| 40 } | 48 } |
| 41 } | 49 } |
| OLD | NEW |