Skip to content

Commit 2c21a32

Browse files
committed
bump Go, buildkit-golang
- fix lint nags on casings of identifiers
1 parent 15d4cc1 commit 2c21a32

26 files changed

Lines changed: 192 additions & 191 deletions

File tree

.config/turbobob.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"builders": [
77
{
88
"name": "default",
9-
"uses": "docker://fn61/buildkit-golang:20250109_1140_037f68db",
9+
"uses": "docker://fn61/buildkit-golang:20251124_1405_720e0dc0",
1010
"mount_source": "",
1111
"mount_destination": "/workspace",
1212
"workdir": "/workspace",

cmd/edgerouter/discovery.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func discoveryList() error {
4444
}
4545

4646
tbl.AddRow(
47-
app.Id,
47+
app.ID,
4848
strings.Join(frontendDescrs, ", "),
4949
app.Backend.Describe())
5050
}
@@ -54,7 +54,7 @@ func discoveryList() error {
5454
return nil
5555
}
5656

57-
func discoveryDeleteApplication(appId string) error {
57+
func discoveryDeleteApplication(appID string) error {
5858
discoverySvc, err := newDefaultDiscoveryWithoutLogger()
5959
if err != nil {
6060
return err
@@ -68,7 +68,7 @@ func discoveryDeleteApplication(appId string) error {
6868
return err
6969
}
7070

71-
app := erconfig.FindApplication(appId, apps)
71+
app := erconfig.FindApplication(appID, apps)
7272
if app == nil {
7373
return errors.New("app to delete not found")
7474
}
@@ -100,7 +100,7 @@ func discoveryPut(content io.Reader, newOk bool) error {
100100
return err
101101
}
102102

103-
appAlreadyExists := erconfig.FindApplication(app.Id, existingApps) != nil
103+
appAlreadyExists := erconfig.FindApplication(app.ID, existingApps) != nil
104104

105105
// sanity checks
106106

@@ -109,7 +109,7 @@ func discoveryPut(content io.Reader, newOk bool) error {
109109
}
110110

111111
if !newOk && !appAlreadyExists {
112-
return errors.New("App doesn't exist. did you mean to create new with '--new'?")
112+
return errors.New("app doesn't exist. did you mean to create new with '--new'?")
113113
}
114114

115115
return discoverySvc.UpdateApplication(ctx, *app)
@@ -132,7 +132,7 @@ func discoveryPutEntry() *cobra.Command {
132132
return cmd
133133
}
134134

135-
func discoveryCat(appId string) error {
135+
func discoveryCat(appID string) error {
136136
discoverySvc, err := newDefaultDiscoveryWithoutLogger()
137137
if err != nil {
138138
return err
@@ -146,7 +146,7 @@ func discoveryCat(appId string) error {
146146
return err
147147
}
148148

149-
app := erconfig.FindApplication(appId, apps)
149+
app := erconfig.FindApplication(appID, apps)
150150
if app == nil {
151151
return errors.New("app not found")
152152
}

pkg/erbackend/authssobackend/sso.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ func New(
1414
opts erconfig.BackendOptsAuthSso,
1515
authorizedBackend http.Handler,
1616
) (http.Handler, error) {
17-
serverUrl := opts.IdServerUrl
18-
if serverUrl == "" {
19-
serverUrl = idclient.Function61
17+
serverURL := opts.IDServerURL
18+
if serverURL == "" {
19+
serverURL = idclient.Function61
2020
}
2121

22-
idpClient := idclient.New(serverUrl)
22+
idpClient := idclient.New(serverURL)
2323

2424
router := mux.NewRouter()
2525

pkg/erbackend/lambdabackend/lambdabackend.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func New(opts erconfig.BackendOptsAwsLambda, logger *log.Logger) (http.Handler,
4848
functionName: opts.FunctionName,
4949
lambda: lambda.New(
5050
awsSession,
51-
aws.NewConfig().WithCredentials(creds).WithRegion(opts.RegionId)),
51+
aws.NewConfig().WithCredentials(creds).WithRegion(opts.RegionID)),
5252
isPayloadV2: isPayloadV2,
5353
}
5454

@@ -87,7 +87,7 @@ func (b *lambdaBackend) serveHTTPModel(w http.ResponseWriter, r *http.Request) {
8787

8888
const routeKey = "$default"
8989

90-
proxyRequestJson, err := json.Marshal(events.APIGatewayV2HTTPRequest{
90+
proxyRequestJSON, err := json.Marshal(events.APIGatewayV2HTTPRequest{
9191
Version: "2.0",
9292
RouteKey: routeKey,
9393
RawPath: r.URL.Path,
@@ -120,7 +120,7 @@ func (b *lambdaBackend) serveHTTPModel(w http.ResponseWriter, r *http.Request) {
120120

121121
lambdaResponse, err := b.lambda.InvokeWithContext(r.Context(), &lambda.InvokeInput{
122122
FunctionName: aws.String(b.functionName),
123-
Payload: proxyRequestJson,
123+
Payload: proxyRequestJSON,
124124
})
125125
if err != nil {
126126
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -133,7 +133,7 @@ func (b *lambdaBackend) serveHTTPModel(w http.ResponseWriter, r *http.Request) {
133133
return
134134
}
135135

136-
if err := proxyApiGatewayResponse(payloadResponse, w); err != nil {
136+
if err := proxyAPIGatewayResponse(payloadResponse, w); err != nil {
137137
// TODO: if we already wrote headers, this will not succeed
138138
http.Error(w, err.Error(), http.StatusBadGateway)
139139
}
@@ -170,15 +170,15 @@ func (b *lambdaBackend) serveRESTModel(w http.ResponseWriter, r *http.Request) {
170170
proxyRequest.IsBase64Encoded = true
171171
}
172172

173-
proxyRequestJson, err := json.Marshal(&proxyRequest)
173+
proxyRequestJSON, err := json.Marshal(&proxyRequest)
174174
if err != nil {
175175
http.Error(w, err.Error(), http.StatusInternalServerError)
176176
return
177177
}
178178

179179
lambdaResponse, err := b.lambda.InvokeWithContext(r.Context(), &lambda.InvokeInput{
180180
FunctionName: aws.String(b.functionName),
181-
Payload: proxyRequestJson,
181+
Payload: proxyRequestJSON,
182182
})
183183
if err != nil {
184184
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -197,7 +197,7 @@ func (b *lambdaBackend) serveRESTModel(w http.ResponseWriter, r *http.Request) {
197197
return
198198
}
199199

200-
if err := proxyApiGatewayResponse(&events.APIGatewayV2HTTPResponse{
200+
if err := proxyAPIGatewayResponse(&events.APIGatewayV2HTTPResponse{
201201
StatusCode: payloadResponse.StatusCode,
202202
Headers: payloadResponse.Headers,
203203
MultiValueHeaders: payloadResponse.MultiValueHeaders,
@@ -210,7 +210,7 @@ func (b *lambdaBackend) serveRESTModel(w http.ResponseWriter, r *http.Request) {
210210
}
211211
}
212212

213-
func proxyApiGatewayResponse(payloadResponse *events.APIGatewayV2HTTPResponse, w http.ResponseWriter) error {
213+
func proxyAPIGatewayResponse(payloadResponse *events.APIGatewayV2HTTPResponse, w http.ResponseWriter) error {
214214
responseHeaders := w.Header()
215215

216216
for key, val := range payloadResponse.Headers {

pkg/erbackend/reverseproxybackend/reverseproxy.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import (
2929
// 3) press F5 from browser. this'll inject 304 Not Modified into cache (browser expects 304 but CACHE NOT)
3030
// 4) now use cURL to request the same resource (= without caching), and you'll get 304 🤦
3131

32-
func New(appId string, opts erconfig.BackendOptsReverseProxy, logger *log.Logger) (http.Handler, error) {
33-
handler, err := NewWithModifyResponse(appId, opts, nil)
32+
func New(appID string, opts erconfig.BackendOptsReverseProxy, logger *log.Logger) (http.Handler, error) {
33+
handler, err := NewWithModifyResponse(appID, opts, nil)
3434
if err != nil {
3535
return nil, err
3636
}
@@ -39,7 +39,7 @@ func New(appId string, opts erconfig.BackendOptsReverseProxy, logger *log.Logger
3939
}
4040

4141
func NewWithModifyResponse(
42-
appId string,
42+
appID string,
4343
opts erconfig.BackendOptsReverseProxy,
4444
modifyResponse func(r *http.Response) error,
4545
) (http.Handler, error) {
@@ -49,13 +49,13 @@ func NewWithModifyResponse(
4949
}
5050

5151
// transport that has optional TLS customizations and maybe caching (depending on options)
52-
transport, err := maybeWrapWithCache(appId, opts, func() http.RoundTripper {
53-
if opts.TlsConfig != nil { // got custom TLS config?
52+
transport, err := maybeWrapWithCache(appID, opts, func() http.RoundTripper {
53+
if opts.TLSConfig != nil { // got custom TLS config?
5454
return &http.Transport{
5555
TLSClientConfig: &tls.Config{
56-
ServerName: opts.TlsConfig.ServerName,
56+
ServerName: opts.TLSConfig.ServerName,
5757
//nolint:gosec // InsecureSkipVerify intentionally configurable
58-
InsecureSkipVerify: opts.TlsConfig.InsecureSkipVerify,
58+
InsecureSkipVerify: opts.TLSConfig.InsecureSkipVerify,
5959
},
6060
}
6161
} else {
@@ -72,7 +72,7 @@ func NewWithModifyResponse(
7272
//nolint:gosec // Cryptographical randomness not required here
7373
randomOriginIdx := rand.Intn(len(originUrls))
7474

75-
originUrl := originUrls[randomOriginIdx]
75+
originURL := originUrls[randomOriginIdx]
7676

7777
maybeIndexSuffix := func() string { // "/foo/" => "/foo/index.html" (if configured)
7878
if opts.IndexDocument != "" && strings.HasSuffix(req.URL.Path, "/") {
@@ -82,19 +82,19 @@ func NewWithModifyResponse(
8282
}
8383
}()
8484

85-
req.URL.Scheme = originUrl.Scheme // "http" | "https"
85+
req.URL.Scheme = originURL.Scheme // "http" | "https"
8686

8787
// this specifies the host we're connecting to
88-
req.URL.Host = originUrl.Host
88+
req.URL.Host = originURL.Host
8989

9090
// sometimes we want the outgoing request to include the original "Host: ..." header, so
9191
// the backend can see what hostname is in browser's address bar
9292
if !opts.PassHostHeader {
93-
req.Host = originUrl.Host
93+
req.Host = originURL.Host
9494
}
9595

9696
// origin's Path is "normally" empty (e.g. "http://example.com"), but can be used to add a prefix
97-
req.URL.Path = originUrl.Path + req.URL.Path + maybeIndexSuffix
97+
req.URL.Path = originURL.Path + req.URL.Path + maybeIndexSuffix
9898

9999
// remove query string if we know we're serving static content and the output does
100100
// not vary based on query string. someone malicious could even be trying to flood our
@@ -115,7 +115,7 @@ func NewWithModifyResponse(
115115
}
116116

117117
func maybeWrapWithCache(
118-
appId string,
118+
appID string,
119119
opts erconfig.BackendOptsReverseProxy,
120120
inner http.RoundTripper,
121121
) (http.RoundTripper, error) {
@@ -124,7 +124,7 @@ func maybeWrapWithCache(
124124
}
125125

126126
// there's no abstraction for getting system-level cache dir in Go
127-
cacheLocation := filepath.Join("/var/cache/edgerouter", appId)
127+
cacheLocation := filepath.Join("/var/cache/edgerouter", appID)
128128

129129
if err := os.MkdirAll(cacheLocation, 0700); err != nil {
130130
return nil, fmt.Errorf("cachingreverseproxy: %w", err)
@@ -142,21 +142,21 @@ func maybeWrapWithCache(
142142
return cache, nil
143143
}
144144

145-
func parseOriginUrls(originUrlStrs []string) ([]url.URL, error) {
146-
originUrls := []url.URL{}
145+
func parseOriginUrls(originURLStrs []string) ([]url.URL, error) {
146+
originURLs := []url.URL{}
147147

148-
for _, originUrlStr := range originUrlStrs {
149-
originUrl, err := url.Parse(originUrlStr)
148+
for _, originURLStr := range originURLStrs {
149+
originURL, err := url.Parse(originURLStr)
150150
if err != nil {
151151
return nil, err
152152
}
153153

154-
originUrls = append(originUrls, *originUrl)
154+
originURLs = append(originURLs, *originURL)
155155
}
156156

157-
if len(originUrls) == 0 {
157+
if len(originURLs) == 0 {
158158
return nil, errors.New("empty origin list")
159159
}
160160

161-
return originUrls, nil
161+
return originURLs, nil
162162
}

pkg/erbackend/statics3websitebackend/backend.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import (
1616
"github.com/function61/gokit/ezhttp"
1717
)
1818

19-
func New(appId string, opts erconfig.BackendOptsS3StaticWebsite) (http.Handler, error) {
19+
func New(appID string, opts erconfig.BackendOptsS3StaticWebsite) (http.Handler, error) {
2020
if opts.DeployedVersion == "" {
21-
errMsg := fmt.Sprintf("no deployed version for %s", appId)
21+
errMsg := fmt.Sprintf("no deployed version for %s", appID)
2222
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2323
http.Error(w, errMsg, http.StatusNotFound)
2424
}), nil
@@ -27,13 +27,13 @@ func New(appId string, opts erconfig.BackendOptsS3StaticWebsite) (http.Handler,
2727
// this is not much more than sugar on top of the much more powerful reverseproxybackend
2828

2929
// bucketPrefix looks like "sites/joonasfi-blog/versionid"
30-
origin := "https://s3." + opts.RegionId + ".amazonaws.com/" + opts.BucketName + "/" + bucketPrefix(appId, opts.DeployedVersion)
30+
origin := "https://s3." + opts.RegionID + ".amazonaws.com/" + opts.BucketName + "/" + bucketPrefix(appID, opts.DeployedVersion)
3131

3232
cacheNotFound := &cache404{}
3333

3434
// FIXME: it uses appId as cache key, thus we synthetize new cache each time a
3535
// new version is deployed
36-
return reverseproxybackend.NewWithModifyResponse(appId+"-"+opts.DeployedVersion, erconfig.BackendOptsReverseProxy{
36+
return reverseproxybackend.NewWithModifyResponse(appID+"-"+opts.DeployedVersion, erconfig.BackendOptsReverseProxy{
3737
// "/favicon.ico" =>
3838
// https://s3.us-east-1.amazonaws.com/myorg-websites/sites/joonasfi-blog/versionid/favicon.ico
3939
Origins: []string{origin},

pkg/erbackend/statics3websitebackend/deploy.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ import (
2323
)
2424

2525
type uploadJob struct {
26-
applicationId string
26+
applicationID string
2727
deploymentSpec deploymentSpec
2828
bucket *s3facade.BucketContext
2929
}
3030

3131
// atomically deploys a new version of a site to a S3 bucket, then updates service
3232
// discovery to point to the new deployed version
33-
func Deploy(ctx context.Context, tarArchive io.Reader, applicationId string, deployVersion string, discoverySvc erdiscovery.ReaderWriter) error {
33+
func Deploy(ctx context.Context, tarArchive io.Reader, applicationID string, deployVersion string, discoverySvc erdiscovery.ReaderWriter) error {
3434
apps, err := discoverySvc.ReadApplications(ctx)
3535
if err != nil {
3636
return err
3737
}
3838

39-
app := erconfig.FindApplication(applicationId, apps)
39+
app := erconfig.FindApplication(applicationID, apps)
4040
if app == nil {
41-
return fmt.Errorf("unknown applicationId: %s", applicationId)
41+
return fmt.Errorf("unknown applicationId: %s", applicationID)
4242
}
4343

4444
if app.Backend.Kind != erconfig.BackendKindS3StaticWebsite {
@@ -50,13 +50,13 @@ func Deploy(ctx context.Context, tarArchive io.Reader, applicationId string, dep
5050
bucket, err := s3facade.Bucket(
5151
s3StaticWebsiteOpts.BucketName,
5252
s3facade.CredentialsFromEnv,
53-
s3StaticWebsiteOpts.RegionId)
53+
s3StaticWebsiteOpts.RegionID)
5454
if err != nil {
5555
return err
5656
}
5757

5858
upload := &uploadJob{
59-
applicationId: app.Id,
59+
applicationID: app.ID,
6060
deploymentSpec: deploymentSpec{
6161
Version: deployVersion,
6262
DeployedAt: time.Now(),
@@ -72,7 +72,7 @@ func Deploy(ctx context.Context, tarArchive io.Reader, applicationId string, dep
7272
// to all edge routers
7373
app.Backend = erconfig.S3Backend(
7474
s3StaticWebsiteOpts.BucketName,
75-
s3StaticWebsiteOpts.RegionId,
75+
s3StaticWebsiteOpts.RegionID,
7676
upload.deploymentSpec.Version)
7777

7878
return discoverySvc.UpdateApplication(ctx, *app)
@@ -137,16 +137,16 @@ func uploadAllFiles(ctx context.Context, tarArchive io.Reader, upload *uploadJob
137137
}
138138

139139
// deployment spec
140-
deploymentSpecJson, err := json.MarshalIndent(&upload.deploymentSpec, "", " ")
140+
deploymentSpecJSON, err := json.MarshalIndent(&upload.deploymentSpec, "", " ")
141141
if err != nil {
142142
return err
143143
}
144144

145145
workItems <- &s3.PutObjectInput{
146146
Bucket: upload.bucket.Name,
147-
Key: aws.String(bucketPrefix(upload.applicationId, upload.deploymentSpec.Version) + ".deployment.json"),
147+
Key: aws.String(bucketPrefix(upload.applicationID, upload.deploymentSpec.Version) + ".deployment.json"),
148148
ContentType: aws.String("application/json"),
149-
Body: bytes.NewReader(deploymentSpecJson),
149+
Body: bytes.NewReader(deploymentSpecJSON),
150150
}
151151

152152
closeOnceAndWait()
@@ -170,7 +170,7 @@ func createUploadRequest(filePath string, content io.Reader, upload *uploadJob)
170170
ext := filepath.Ext(filePath)
171171

172172
// looks like "joonasfi-blog/versionid/"
173-
pathPrefix := bucketPrefix(upload.applicationId, upload.deploymentSpec.Version) + "/"
173+
pathPrefix := bucketPrefix(upload.applicationID, upload.deploymentSpec.Version) + "/"
174174

175175
// sometimes the entries start with a dot, and we would end up with
176176
// "sites/APP_ID/VERSION/./readme.md" unless we normalize this
@@ -207,6 +207,6 @@ func uploadWorker(ctx context.Context, s3Client *s3.S3, objects <-chan *s3.PutOb
207207
}
208208

209209
// looks like "sites/joonasfi-blog/versionid"
210-
func bucketPrefix(applicationId string, deployVersion string) string {
211-
return "sites/" + applicationId + "/" + deployVersion
210+
func bucketPrefix(applicationID string, deployVersion string) string {
211+
return "sites/" + applicationID + "/" + deployVersion
212212
}

0 commit comments

Comments
 (0)