| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. |
| 4 |
| 5 package buildbot |
| 6 |
| 7 import ( |
| 8 "google.golang.org/grpc" |
| 9 "google.golang.org/grpc/codes" |
| 10 |
| 11 "github.com/luci/luci-go/common/proto/google" |
| 12 milo "github.com/luci/luci-go/milo/api/proto" |
| 13 "golang.org/x/net/context" |
| 14 ) |
| 15 |
| 16 type BuildbotService struct{} |
| 17 |
| 18 var errNotFoundGRPC = grpc.Errorf(codes.NotFound, "Master Not Found") |
| 19 |
| 20 func (s *BuildbotService) GetCompressedMasterJSON( |
| 21 c context.Context, req *milo.MasterRequest) (*milo.CompressedMasterJSON,
error) { |
| 22 |
| 23 if req.Name == "" { |
| 24 return nil, grpc.Errorf(codes.InvalidArgument, "No master specif
ied") |
| 25 } |
| 26 |
| 27 entry, err := getMasterEntry(c, req.Name) |
| 28 switch { |
| 29 case err == errMasterNotFound: |
| 30 return nil, errNotFoundGRPC |
| 31 |
| 32 case err != nil: |
| 33 return nil, err |
| 34 } |
| 35 |
| 36 return &milo.CompressedMasterJSON{ |
| 37 Internal: entry.Internal, |
| 38 Modified: &google.Timestamp{ |
| 39 Seconds: entry.Modified.Unix(), |
| 40 Nanos: int32(entry.Modified.Nanosecond()), |
| 41 }, |
| 42 Data: entry.Data, |
| 43 }, nil |
| 44 } |
| OLD | NEW |