Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pkg/logo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

# Minify the logo into a favicon.
genrule(
name = "favicon",
srcs = [":buildbarn_logo.svg"],
outs = ["favicon.svg"],
# Remove embedded draw.io content attribute and svg comments.
cmd = "tr -d '\n' < $(location :buildbarn_logo.svg) | sed -e 's/ content=\"[^\"]*\"//' -e 's/<!--[^!]*-->//g' > $@",
)

go_library(
name = "logo",
srcs = ["logo.go"],
embedsrcs = ["favicon.svg"],
importpath = "github.com/buildbarn/bb-storage/pkg/logo",
visibility = ["//visibility:public"],
)
21 changes: 21 additions & 0 deletions pkg/logo/buildbarn_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions pkg/logo/logo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package logo

import (
_ "embed" // For "go:embed".
"encoding/base64"
"html/template"
)

//go:embed favicon.svg
var faviconSvg []byte

// FaviconSvg holds the Buildbarn logo and can be used as favicon in web browsers.
var FaviconSvg = faviconSvg

// EmbeddedFaviconURL has encoded FaviconSvg into a 'data:' URL,
// to be embedded in a web site.
//
// Example:
//
// <link href="{{EmbeddedFaviconURL}}" rel="icon">
var EmbeddedFaviconURL = template.URL("data:image/svg+xml;base64," + base64.StdEncoding.EncodeToString(FaviconSvg))
2 changes: 2 additions & 0 deletions pkg/otel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/clock",
"//pkg/logo",
"@io_opentelemetry_go_otel//attribute",
"@io_opentelemetry_go_otel//codes",
"@io_opentelemetry_go_otel//propagation",
Expand Down Expand Up @@ -45,6 +46,7 @@ go_test(
deps = [
":otel",
"//internal/mock",
"//pkg/logo",
"//pkg/testutil",
"@com_github_golang_mock//gomock",
"@com_github_stretchr_testify//require",
Expand Down
1 change: 1 addition & 0 deletions pkg/otel/active_spans.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<title>Active OpenTelemetry spans</title>
<link href="{{favicon_url}}" rel="icon">
<style>{{stylesheet}}</style>
</head>
<body>
Expand Down
4 changes: 3 additions & 1 deletion pkg/otel/active_spans_reporting_http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/buildbarn/bb-storage/pkg/clock"
"github.com/buildbarn/bb-storage/pkg/logo"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
Expand All @@ -20,7 +21,8 @@ var (
//go:embed active_spans.html
activeSpansTemplateBody string
activeSpansTemplate = template.Must(template.New("ActiveSpans").Funcs(template.FuncMap{
"stylesheet": func() template.CSS { return stylesheet },
"favicon_url": func() template.URL { return logo.EmbeddedFaviconURL },
"stylesheet": func() template.CSS { return stylesheet },
"timestamp_rfc3339": func(t time.Time) string {
// Converts a timestamp to RFC3339 format.
return t.Format("2006-01-02T15:04:05.999Z07:00")
Expand Down
3 changes: 3 additions & 0 deletions pkg/otel/active_spans_reporting_http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
_ "embed" // For "go:embed".
"errors"
"html/template"
"io"
"net/http"
"net/http/httptest"
Expand All @@ -12,6 +13,7 @@ import (
"time"

"github.com/buildbarn/bb-storage/internal/mock"
"github.com/buildbarn/bb-storage/pkg/logo"
"github.com/buildbarn/bb-storage/pkg/otel"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
Expand All @@ -38,6 +40,7 @@ func requireEqualBody(t *testing.T, expectedBody string, hh http.Handler) {
<html>
<head>
<title>Active OpenTelemetry spans</title>
<link href="` + template.URLQueryEscaper(logo.EmbeddedFaviconURL) + `" rel="icon">
<style>` + stylesheet + `</style>
</head>
<body>
Expand Down