porting all github actions from bluesky-social/indigo to tangled CI

goat: include User-Agent header more consistently

+4 -2
cmd/goat/account.go
··· 189 189 190 190 // create a new API client to connect to the account's PDS 191 191 xrpcc := xrpc.Client{ 192 - Host: ident.PDSEndpoint(), 192 + Host: ident.PDSEndpoint(), 193 + UserAgent: userAgent(), 193 194 } 194 195 if xrpcc.Host == "" { 195 196 return fmt.Errorf("no PDS endpoint for identity") ··· 413 414 414 415 // create a new API client to connect to the account's PDS 415 416 xrpcc := xrpc.Client{ 416 - Host: pdsHost, 417 + Host: pdsHost, 418 + UserAgent: userAgent(), 417 419 } 418 420 419 421 raw = cctx.String("service-auth")
+2 -1
cmd/goat/account_migrate.go
··· 84 84 newEmail := cctx.String("new-email") 85 85 86 86 newClient := xrpc.Client{ 87 - Host: newHostURL, 87 + Host: newHostURL, 88 + UserAgent: userAgent(), 88 89 } 89 90 90 91 // connect to new host to discover service DID
+4 -2
cmd/goat/auth.go
··· 67 67 } 68 68 69 69 client := xrpc.Client{ 70 - Host: sess.PDS, 70 + Host: sess.PDS, 71 + UserAgent: userAgent(), 71 72 Auth: &xrpc.AuthInfo{ 72 73 Did: sess.DID.String(), 73 74 // NOTE: using refresh in access location for "refreshSession" call ··· 118 119 } 119 120 120 121 client := xrpc.Client{ 121 - Host: pdsURL, 122 + Host: pdsURL, 123 + UserAgent: userAgent(), 122 124 } 123 125 var token *string 124 126 if authFactorToken != "" {
+6 -3
cmd/goat/blob.go
··· 84 84 85 85 // create a new API client to connect to the account's PDS 86 86 xrpcc := xrpc.Client{ 87 - Host: pdsHost, 87 + Host: pdsHost, 88 + UserAgent: userAgent(), 88 89 } 89 90 if xrpcc.Host == "" { 90 91 return fmt.Errorf("no PDS endpoint for identity") ··· 141 142 142 143 // create a new API client to connect to the account's PDS 143 144 xrpcc := xrpc.Client{ 144 - Host: ident.PDSEndpoint(), 145 + Host: ident.PDSEndpoint(), 146 + UserAgent: userAgent(), 145 147 } 146 148 if xrpcc.Host == "" { 147 149 return fmt.Errorf("no PDS endpoint for identity") ··· 182 184 183 185 // create a new API client to connect to the account's PDS 184 186 xrpcc := xrpc.Client{ 185 - Host: ident.PDSEndpoint(), 187 + Host: ident.PDSEndpoint(), 188 + UserAgent: userAgent(), 186 189 } 187 190 if xrpcc.Host == "" { 188 191 return fmt.Errorf("no PDS endpoint for identity")
+2 -3
cmd/goat/firehose.go
··· 22 22 "github.com/bluesky-social/indigo/events/schedulers/parallel" 23 23 lexutil "github.com/bluesky-social/indigo/lex/util" 24 24 25 - "github.com/carlmjohnson/versioninfo" 26 25 "github.com/gorilla/websocket" 27 26 "github.com/urfave/cli/v2" 28 27 ) ··· 104 103 SkipHandleVerification: true, 105 104 TryAuthoritativeDNS: false, 106 105 SkipDNSDomainSuffixes: []string{".bsky.social"}, 107 - UserAgent: "goat/" + versioninfo.Short(), 106 + UserAgent: *userAgent(), 108 107 } 109 108 cdir := identity.NewCacheDirectory(&bdir, 1_000_000, time.Hour*24, time.Minute*2, time.Minute*5) 110 109 ··· 153 152 } 154 153 urlString := u.String() 155 154 con, _, err := dialer.Dial(urlString, http.Header{ 156 - "User-Agent": []string{fmt.Sprintf("goat/%s", versioninfo.Short())}, 155 + "User-Agent": []string{*userAgent()}, 157 156 }) 158 157 if err != nil { 159 158 return fmt.Errorf("subscribing to firehose failed (dialing): %w", err)
+2 -1
cmd/goat/lexicon.go
··· 232 232 233 233 // create a new API client to connect to the account's PDS 234 234 xrpcc := xrpc.Client{ 235 - Host: ident.PDSEndpoint(), 235 + Host: ident.PDSEndpoint(), 236 + UserAgent: userAgent(), 236 237 } 237 238 if xrpcc.Host == "" { 238 239 return fmt.Errorf("no PDS endpoint for identity")
+2 -1
cmd/goat/net.go
··· 16 16 17 17 slog.Debug("fetching record", "did", ident.DID.String(), "collection", aturi.Collection().String(), "rkey", aturi.RecordKey().String()) 18 18 xrpcc := xrpc.Client{ 19 - Host: ident.PDSEndpoint(), 19 + Host: ident.PDSEndpoint(), 20 + UserAgent: userAgent(), 20 21 } 21 22 resp, err := agnostic.RepoGetRecord(ctx, &xrpcc, "", aturi.Collection().String(), ident.DID.String(), aturi.RecordKey().String()) 22 23 if err != nil {
+2 -1
cmd/goat/pds.go
··· 37 37 return fmt.Errorf("PDS host is not a url: %s", pdsHost) 38 38 } 39 39 client := xrpc.Client{ 40 - Host: pdsHost, 40 + Host: pdsHost, 41 + UserAgent: userAgent(), 41 42 } 42 43 43 44 resp, err := comatproto.ServerDescribeServer(ctx, &client)
+1
cmd/goat/plc.go
··· 211 211 if err != nil { 212 212 return err 213 213 } 214 + req.Header.Set("User-Agent", *userAgent()) 214 215 q := req.URL.Query() 215 216 q.Add("count", fmt.Sprintf("%d", size)) 216 217 req.URL.RawQuery = q.Encode()
+2 -1
cmd/goat/record.go
··· 154 154 155 155 // create a new API client to connect to the account's PDS 156 156 xrpcc := xrpc.Client{ 157 - Host: ident.PDSEndpoint(), 157 + Host: ident.PDSEndpoint(), 158 + UserAgent: userAgent(), 158 159 } 159 160 if xrpcc.Host == "" { 160 161 return fmt.Errorf("no PDS endpoint for identity")
+12 -6
cmd/goat/relay.go
··· 126 126 } 127 127 128 128 client := xrpc.Client{ 129 - Host: cctx.String("relay-host"), 129 + Host: cctx.String("relay-host"), 130 + UserAgent: userAgent(), 130 131 } 131 132 132 133 collection := cctx.String("collection") ··· 196 197 } 197 198 198 199 client := xrpc.Client{ 199 - Host: cctx.String("relay-host"), 200 + Host: cctx.String("relay-host"), 201 + UserAgent: userAgent(), 200 202 } 201 203 202 204 r, err := comatproto.SyncGetRepoStatus(ctx, &client, did.String()) ··· 239 241 } 240 242 241 243 client := xrpc.Client{ 242 - Host: cctx.String("relay-host"), 244 + Host: cctx.String("relay-host"), 245 + UserAgent: userAgent(), 243 246 } 244 247 245 248 err := comatproto.SyncRequestCrawl(ctx, &client, &comatproto.SyncRequestCrawl_Input{Hostname: hostname}) ··· 258 261 } 259 262 260 263 client := xrpc.Client{ 261 - Host: cctx.String("relay-host"), 264 + Host: cctx.String("relay-host"), 265 + UserAgent: userAgent(), 262 266 } 263 267 264 268 cursor := "" ··· 313 317 } 314 318 315 319 client := xrpc.Client{ 316 - Host: cctx.String("relay-host"), 320 + Host: cctx.String("relay-host"), 321 + UserAgent: userAgent(), 317 322 } 318 323 319 324 h, err := comatproto.SyncGetHostStatus(ctx, &client, hostname) ··· 355 360 func fetchHosts(ctx context.Context, relayHost string) ([]hostInfo, error) { 356 361 357 362 client := xrpc.Client{ 358 - Host: relayHost, 363 + Host: relayHost, 364 + UserAgent: userAgent(), 359 365 } 360 366 361 367 hosts := []hostInfo{}
+1 -2
cmd/goat/relay_admin.go
··· 10 10 "net/http" 11 11 "net/url" 12 12 13 - "github.com/carlmjohnson/versioninfo" 14 13 "github.com/urfave/cli/v2" 15 14 ) 16 15 ··· 179 178 } else if c.BearerToken != "" { 180 179 req.Header.Set("Authorization", "Bearer "+c.BearerToken) 181 180 } 182 - req.Header.Set("User-Agent", fmt.Sprintf("goat/"+versioninfo.Short())) 181 + req.Header.Set("User-Agent", *userAgent()) 183 182 if buf != nil { 184 183 req.Header.Set("Content-Type", "application/json") 185 184 }
+2 -1
cmd/goat/repo.go
··· 107 107 108 108 // create a new API client to connect to the account's PDS 109 109 xrpcc := xrpc.Client{ 110 - Host: ident.PDSEndpoint(), 110 + Host: ident.PDSEndpoint(), 111 + UserAgent: userAgent(), 111 112 } 112 113 if xrpcc.Host == "" { 113 114 return fmt.Errorf("no PDS endpoint for identity")
+8
cmd/goat/util.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "fmt" 5 6 "io" 6 7 "log/slog" 7 8 "os" ··· 10 11 "github.com/bluesky-social/indigo/atproto/identity" 11 12 "github.com/bluesky-social/indigo/atproto/syntax" 12 13 14 + "github.com/carlmjohnson/versioninfo" 13 15 "github.com/urfave/cli/v2" 14 16 ) 15 17 ··· 67 69 slog.SetDefault(logger) 68 70 return logger 69 71 } 72 + 73 + // returns a pointer because that is what xrpc.Client expects 74 + func userAgent() *string { 75 + s := fmt.Sprintf("goat/" + versioninfo.Short()) 76 + return &s 77 + }