Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 annotee | |
| 6 | |
| 7 import ( | |
| 8 "github.com/luci/luci-go/logdog/common/types" | |
| 9 "github.com/luci/luci-go/logdog/common/viewer" | |
| 10 "github.com/luci/luci-go/luci_config/common/cfgtypes" | |
| 11 ) | |
| 12 | |
| 13 // LinkGenerator generates links for a given log stream. | |
| 14 type LinkGenerator interface { | |
| 15 // GetLink returns a link for the specified aggregate streams. | |
|
nodir
2017/02/28 00:22:38
typo
dnj
2017/02/28 00:24:43
Acknowledged.
| |
| 16 // | |
| 17 // If no link could be generated, GetLink may return an empty string. | |
| 18 GetLink(name ...types.StreamName) string | |
| 19 } | |
| 20 | |
| 21 // CoordinatorLinkGenerator is a LinkGenerator implementation | |
| 22 type CoordinatorLinkGenerator struct { | |
| 23 Host string | |
| 24 Project cfgtypes.ProjectName | |
| 25 Prefix types.StreamName | |
| 26 } | |
| 27 | |
| 28 // CanGenerateLinks returns true if g is sufficiently configured to generate | |
| 29 // LogDog Coordinator links. | |
| 30 func (g *CoordinatorLinkGenerator) CanGenerateLinks() bool { | |
| 31 return (g.Host != "" && g.Prefix != "") | |
| 32 } | |
| 33 | |
| 34 // GetLink implements LinkGenerator. | |
| 35 func (g *CoordinatorLinkGenerator) GetLink(names ...types.StreamName) string { | |
| 36 paths := make([]types.StreamPath, len(names)) | |
| 37 for i, name := range names { | |
| 38 paths[i] = g.Prefix.AsPathPrefix(name) | |
| 39 } | |
| 40 return viewer.GetURL(g.Host, g.Project, paths...) | |
| 41 } | |
| OLD | NEW |