Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Go version to 1.22 #87

Merged
merged 3 commits into from
Feb 22, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.19.x, 1.20.x, 1.21.x]
go-version: [1.20.x, 1.21.x, 1.22.x]
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -32,5 +32,5 @@ jobs:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
run: make test
- name: lint
if: matrix.go-version == '1.21.x'
if: matrix.go-version == '1.22.x'
run: make lint
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ linters:
- golint # deprecated by Go team
- gomnd # some unnamed constants are okay
- ifshort # deprecated by author
- inamedparam # convention is not followed
- interfacer # deprecated by author
- ireturn # "accept interfaces, return structs" isn't ironclad
- lll # don't want hard limits for line length
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2023 Buf Technologies, Inc.
Copyright 2023-2024 Buf Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-print-directory
BIN := .tmp/bin
COPYRIGHT_YEARS := 2023
COPYRIGHT_YEARS := 2023-2024
LICENSE_IGNORE := -e internal/testdata/
# Set to use a different compiler. For example, `GO=go1.18rc1 make test`.
GO ?= go
BUF_VERSION ?= v1.26.1
GOLANGCI_LINT_VERSION ?= v1.54.1
BUF_VERSION ?= v1.29.0
GOLANGCI_LINT_VERSION ?= v1.56.2

.PHONY: help
help: ## Describe useful make targets
Expand Down
4 changes: 2 additions & 2 deletions cache.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,7 +63,7 @@ func decodeForCache(data []byte) (*prototransformv1alpha1.CacheEntry, error) {
}

func isCorrectCacheEntry(entry *prototransformv1alpha1.CacheEntry, schemaID string, syms []string) bool {
return entry.Id == schemaID && isSuperSet(entry.IncludedSymbols, syms)
return entry.GetId() == schemaID && isSuperSet(entry.GetIncludedSymbols(), syms)
}

func isSuperSet(have, want []string) bool {
Expand Down
2 changes: 1 addition & 1 deletion cache/filecache/filecache.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions cache/filecache/filecache_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -174,7 +174,7 @@ func TestSanitize(t *testing.T) {
func checkFiles(t *testing.T, dir string, mode fs.FileMode, names map[string]struct{}) {
t.Helper()
err := fs.WalkDir(os.DirFS(dir), ".", func(path string, dirEntry fs.DirEntry, err error) error {
if !assert.NoError(t, err) {
if !assert.NoError(t, err) { //nolint:testifylint
return nil
}
if dirEntry.IsDir() {
Expand All @@ -190,7 +190,7 @@ func checkFiles(t *testing.T, dir string, mode fs.FileMode, names map[string]str
}
delete(names, path)
info, err := dirEntry.Info()
if !assert.NoErrorf(t, err, "failed to get file info for %s", path) {
if !assert.NoErrorf(t, err, "failed to get file info for %s", path) { //nolint:testifylint
return nil
}
assert.Equal(t, mode, info.Mode())
Expand Down
2 changes: 1 addition & 1 deletion cache/internal/cachetesting/cachetesting.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cache/memcache/memcache.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cache/memcache/memcache_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cache/rediscache/rediscache.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cache/rediscache/rediscache_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cache_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
15 changes: 8 additions & 7 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,7 @@
package prototransform

import (
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -83,22 +84,22 @@ type SchemaWatcherConfig struct {

func (c *SchemaWatcherConfig) validate() error {
if c.SchemaPoller == nil {
return fmt.Errorf("schema poller not provided")
return errors.New("schema poller not provided")
}
if c.PollingPeriod < 0 {
return fmt.Errorf("polling period duration cannot be negative")
return errors.New("polling period duration cannot be negative")
}
if c.Jitter < 0 {
return fmt.Errorf("jitter cannot be negative")
return errors.New("jitter cannot be negative")
}
if c.Jitter > 1.0 {
return fmt.Errorf("jitter cannot be greater than 1.0 (100%%)")
return errors.New("jitter cannot be greater than 1.0 (100%)")
}
if c.Leaser != nil && c.Cache == nil {
return fmt.Errorf("leaser config should only be present when cache config also present")
return errors.New("leaser config should only be present when cache config also present")
}
if c.Leaser != nil && c.CurrentProcess != nil && len(c.CurrentProcess) == 0 {
return fmt.Errorf("current process is empty but not nil; leave nil or set to non-empty value")
return errors.New("current process is empty but not nil; leave nil or set to non-empty value")
}
for _, sym := range c.IncludeSymbols {
if sym == "" {
Expand Down
2 changes: 1 addition & 1 deletion converter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions converter_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,7 +33,7 @@ import (
func TestSchemaService_ConvertMessage(t *testing.T) {
t.Parallel()
// create schema for message to convert
sourceFile := fakeFileDescriptorSet().File[0]
sourceFile := fakeFileDescriptorSet().GetFile()[0]

// create test message
fileDescriptor, err := protodesc.NewFile(sourceFile, nil)
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions filter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -90,7 +90,7 @@ func redactList(value protoreflect.Value, redaction func(protoreflect.FieldDescr
}

func redactMap(value protoreflect.Value, redaction func(protoreflect.FieldDescriptor) bool) {
value.Map().Range(func(mapKey protoreflect.MapKey, mapValue protoreflect.Value) bool {
value.Map().Range(func(_ protoreflect.MapKey, mapValue protoreflect.Value) bool {
redactMessage(mapValue.Message(), redaction)
return true
})
Expand Down
2 changes: 1 addition & 1 deletion filter_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion format.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/bufbuild/prototransform

go 1.19
go 1.20

require (
buf.build/gen/go/bufbuild/reflect/connectrpc/go v1.14.0-20240117202343-bf8f65e8876c.1
Expand Down
2 changes: 1 addition & 1 deletion internal/proto/buf/prototransform/v1alpha1/cache.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion internal/proto/buf/prototransform/v1alpha1/lease.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion internal/proto/gen/buf/prototransform/v1alpha1/cache.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/proto/gen/buf/prototransform/v1alpha1/lease.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jitter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion jitter_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion leaser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion leaser/internal/leasertesting/leasertesting.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion leaser/memcacheleaser/memcacheleaser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion leaser/memcacheleaser/memcacheleaser_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion leaser/polling_leaser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion leaser/redisleaser/redisleaser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion leaser/redisleaser/redisleaser_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
9 changes: 5 additions & 4 deletions reflect_client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@ package prototransform

import (
"context"
"errors"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -49,7 +50,7 @@ func NewDefaultFileDescriptorSetServiceClient(token string) reflectv1beta1connec
connect.UnaryInterceptorFunc(func(call connect.UnaryFunc) connect.UnaryFunc {
return func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) {
// decorate user-agent with the name of the package
userAgent := fmt.Sprintf("%s prototransform-go", req.Header().Get("User-Agent"))
userAgent := req.Header().Get("User-Agent") + " prototransform-go"
req.Header().Set("User-Agent", userAgent)
return call(ctx, req)
}
Expand All @@ -68,7 +69,7 @@ func NewDefaultFileDescriptorSetServiceClient(token string) reflectv1beta1connec
//
// To get a token from the environment (e.g. BUF_TOKEN env var), see BufTokenFromEnvironment.
func NewAuthInterceptor(token string) connect.Interceptor {
bearerAuthValue := fmt.Sprintf("Bearer %s", token)
bearerAuthValue := "Bearer " + token
return connect.UnaryInterceptorFunc(func(next connect.UnaryFunc) connect.UnaryFunc {
return func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) {
request.Header().Set("Authorization", bearerAuthValue)
Expand All @@ -84,7 +85,7 @@ func BufTokenFromEnvironment(moduleRef string) (string, error) {
parts := strings.SplitN(moduleRef, "/", 2)
envBufToken := os.Getenv("BUF_TOKEN")
if envBufToken == "" {
return "", fmt.Errorf("no BUF_TOKEN environment variable set")
return "", errors.New("no BUF_TOKEN environment variable set")
}
tok := parseBufToken(envBufToken, parts[0])
if tok == "" {
Expand Down
4 changes: 2 additions & 2 deletions reflect_client_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestReflectClientLargeRequest(t *testing.T) {
// downloading the entire response.
resp, err := getFileDescriptorSet(ctx, client, req)
require.NoError(t, err)
require.GreaterOrEqual(t, len(resp.Msg.FileDescriptorSet.File), 42)
require.GreaterOrEqual(t, len(resp.Msg.GetFileDescriptorSet().GetFile()), 42)

// If we ask for one fewer type, we should be below the limit and get back
// a "not modified" response code instead of a response body.
Expand Down
4 changes: 2 additions & 2 deletions resolver.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Buf Technologies, Inc.
// Copyright 2023-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,7 +47,7 @@ type resolver struct {
func newResolver(fileDescriptors *descriptorpb.FileDescriptorSet) (*resolver, error) {
var result resolver
// TODO(TCN-925): maybe should reparse unrecognized fields in fileDescriptors after creating resolver?
if len(fileDescriptors.File) == 0 {
if len(fileDescriptors.GetFile()) == 0 {
return &result, nil
}
files, err := protodesc.FileOptions{AllowUnresolvable: true}.NewFiles(fileDescriptors)
Expand Down
Loading
Loading