Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Unified Diff: client/cmd/logdog_annotee/link.go

Issue 1916813002: Annotee: Add project name support. (Closed) Base URL: https://github.com/luci/luci-go@logdog-project-collector-butler
Patch Set: Better URL generation. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | client/cmd/logdog_annotee/main.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/logdog_annotee/link.go
diff --git a/client/cmd/logdog_annotee/link.go b/client/cmd/logdog_annotee/link.go
new file mode 100644
index 0000000000000000000000000000000000000000..0506b66d3bf784bea29021ec6e8fc2664cbfeb6b
--- /dev/null
+++ b/client/cmd/logdog_annotee/link.go
@@ -0,0 +1,37 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package main
+
+import (
+ "fmt"
+ "net/url"
+ "strings"
+
+ "github.com/luci/luci-go/common/config"
+ "github.com/luci/luci-go/common/logdog/types"
+)
+
+type coordinatorLinkGenerator struct {
+ base types.StreamName
+ project config.ProjectName
+ prefix types.StreamName
+}
+
+func (g *coordinatorLinkGenerator) canGenerateLinks() bool {
+ return (g.base != "" && g.prefix != "")
+}
+
+func (g *coordinatorLinkGenerator) GetLink(names ...types.StreamName) string {
+ links := make([]string, len(names))
+ for i, n := range names {
+ streamName := string(g.prefix.Join(n))
+ proj := g.project
+ if proj == "" {
+ proj = "_"
+ }
+ links[i] = fmt.Sprintf("s=%s", url.QueryEscape(fmt.Sprintf("%s/%s", proj, streamName)))
+ }
+ return fmt.Sprintf("https://%s.appspot.com/v/?%s", g.base, strings.Join(links, "&"))
+}
« no previous file with comments | « no previous file | client/cmd/logdog_annotee/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698