Skip to content

Commit e91cc72

Browse files
committed
cmd/relui: fetch Twitter API secret in production deployment
Use flag code from CL 386054 to define a -twitter-api-secret flag. In the production deployment, configure it to fetch the Twitter API credentials for making tweets at twitter.com/golang, and reconfigure the site header accordingly. Tested locally via "secret:go-dashboard-dev/staging-twitter-api-secret" as the -twitter-api-secret flag value. For golang/go#47402. Fixes golang/go#51122. Change-Id: Ib2fcf5cd9add14f954cac4eddab3d6fa6032eb02 Reviewed-on: https://go-review.googlesource.com/c/build/+/387274 Trust: Dmitri Shuralyov <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> Reviewed-by: Alex Rakoczy <[email protected]>
1 parent c208fcd commit e91cc72

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

cmd/relui/deployment-prod.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ spec:
2525
- "./relui"
2626
- "--listen-https-selfsigned=:444"
2727
- "--base-url=https://build.golang.org/releases"
28+
# Define the site header and external service configuration.
29+
- "--site-title=Go Releases"
30+
- "--site-header-css=Site-header--production"
31+
- "--twitter-api-secret=secret:symbolic-datum-552/twitter-api-secret"
2832
ports:
2933
- containerPort: 444
3034
env:

cmd/relui/main.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,29 @@ import (
1414
"github.com/jackc/pgx/v4/pgxpool"
1515
"golang.org/x/build/internal/https"
1616
"golang.org/x/build/internal/relui"
17+
"golang.org/x/build/internal/secret"
1718
"golang.org/x/build/internal/task"
1819
)
1920

2021
var (
21-
baseURL = flag.String("base-url", "", "Prefix URL for routing and links.")
22+
baseURL = flag.String("base-url", "", "Prefix URL for routing and links.")
23+
siteTitle = flag.String("site-title", "Go Releases", "Site title.")
24+
siteHeaderCSS = flag.String("site-header-css", "", "Site header CSS class name. Can be used to pick a look for the header.")
25+
2226
downUp = flag.Bool("migrate-down-up", false, "Run all Up migration steps, then the last down migration step, followed by the final up migration. Exits after completion.")
2327
migrateOnly = flag.Bool("migrate-only", false, "Exit after running migrations. Migrations are run by default.")
2428
pgConnect = flag.String("pg-connect", "", "Postgres connection string or URI. If empty, libpq connection defaults are used.")
2529
)
2630

2731
func main() {
32+
if err := secret.InitFlagSupport(context.Background()); err != nil {
33+
log.Fatalln(err)
34+
}
35+
var twitterAPI secret.TwitterCredentials
36+
secret.JSONVarFlag(&twitterAPI, "twitter-api-secret", "Twitter API secret to use for workflows involving tweeting.")
2837
https.RegisterFlags(flag.CommandLine)
2938
flag.Parse()
39+
3040
ctx := context.Background()
3141
if err := relui.InitDB(ctx, *pgConnect); err != nil {
3242
log.Fatalf("relui.InitDB() = %v", err)
@@ -47,13 +57,12 @@ func main() {
4757
// Keep these appropriately in sync.
4858
var (
4959
siteHeader = relui.SiteHeader{
50-
Title: "Go Releases (work in progress)",
51-
CSSClass: "Site-header--workInProgress",
60+
Title: *siteTitle,
61+
CSSClass: *siteHeaderCSS,
5262
}
5363
extCfg = task.ExternalConfig{
54-
// TODO(go.dev/issue/51122): Once secrets are available from prod deployment and we're ready, pass them here.
5564
// TODO(go.dev/issue/51150): When twitter client creation is factored out from task package, update code here.
56-
DryRun: true,
65+
TwitterAPI: twitterAPI,
5766
}
5867
)
5968

internal/relui/static/styles.css

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ h6 {
4343
}
4444
.Header {
4545
padding: 0.625rem;
46+
background: #d6d6d6;
47+
color: #171d27;
4648
}
4749
.Site-header--production .Header {
4850
background: #e0ebf5;
4951
color: #375eab;
5052
}
51-
.Site-header--workInProgress .Header {
52-
background: #d6d6d6;
53-
color: #171d27;
54-
}
5553
.Header-title {
5654
font-size: 1.5rem;
5755
margin: 0;

0 commit comments

Comments
 (0)