This commit is contained in:
Scott Blum 2022-10-31 10:40:27 -04:00
parent 15d1f62ab2
commit 32029c0c34
10 changed files with 37 additions and 27 deletions

View File

@ -42,11 +42,9 @@ checkgofmt:
vet:
go vet ./...
# This all works fine with Go modules, but without modules,
# CI is just getting latest master for dependencies like grpc.
.PHONY: staticcheck
staticcheck:
@go install honnef.co/go/tools/cmd/staticcheck@v0.0.1-2020.1.4
@go install honnef.co/go/tools/cmd/staticcheck@v0.3.3
staticcheck ./...
.PHONY: ineffassign
@ -56,21 +54,19 @@ ineffassign:
.PHONY: predeclared
predeclared:
@go install github.com/nishanths/predeclared@86fad755b4d3
predeclared .
@go install github.com/nishanths/predeclared@5f2f810c9ae6
predeclared ./...
# Intentionally omitted from CI, but target here for ad-hoc reports.
.PHONY: golint
golint:
# TODO: pin version
@go install golang.org/x/lint/golint@latest
@go install golang.org/x/lint/golint@v0.0.0-20210508222113-6edffad5e616
golint -min_confidence 0.9 -set_exit_status ./...
# Intentionally omitted from CI, but target here for ad-hoc reports.
.PHONY: errcheck
errcheck:
# TODO: pin version
@go install github.com/kisielk/errcheck@latest
@go install github.com/kisielk/errcheck@v1.2.0
errcheck ./...
.PHONY: test

View File

@ -1,3 +1,4 @@
//go:build go1.10
// +build go1.10
package main

View File

@ -1,3 +1,4 @@
//go:build !go1.10
// +build !go1.10
package main

View File

@ -38,9 +38,9 @@ import (
// the response status codes emitted use an offest of 64
const statusCodeOffset = 64
const no_version = "dev build <no version set>"
const noVersion = "dev build <no version set>"
var version = no_version
var version = noVersion
var (
exit = os.Exit
@ -445,7 +445,7 @@ func main() {
}
grpcurlUA := "grpcurl/" + version
if version == no_version {
if version == noVersion {
grpcurlUA = "grpcurl/dev-build (no version set)"
}
if *userAgent != "" {
@ -508,7 +508,7 @@ func main() {
md := grpcurl.MetadataFromHeaders(append(addlHeaders, reflHeaders...))
refCtx := metadata.NewOutgoingContext(ctx, md)
cc = dial()
refClient = grpcreflect.NewClient(refCtx, reflectpb.NewServerReflectionClient(cc))
refClient = grpcreflect.NewClientV1Alpha(refCtx, reflectpb.NewServerReflectionClient(cc))
reflSource := grpcurl.DescriptorSourceFromServer(ctx, refClient)
if fileSource != nil {
descSource = compositeSource{reflSource, fileSource}

View File

@ -1,3 +1,4 @@
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
package main

View File

@ -197,10 +197,20 @@ func (tf *textFormatter) format(m proto.Message) (string, error) {
return str, nil
}
// Format of request data. The allowed values are 'json' or 'text'.
type Format string
const (
// FormatJSON specifies input data in JSON format. Multiple request values
// may be concatenated (messages with a JSON representation other than
// object must be separated by whitespace, such as a newline)
FormatJSON = Format("json")
// FormatText specifies input data must be in the protobuf text format.
// Multiple request values must be separated by the "record separator"
// ASCII character: 0x1E. The stream should not end in a record separator.
// If it does, it will be interpreted as a final, blank message after the
// separator.
FormatText = Format("text")
)

View File

@ -407,9 +407,9 @@ func makeTemplate(md *desc.MessageDescriptor, path []*desc.MessageDescriptor) pr
case "google.protobuf.Any":
// empty type URL is not allowed by JSON representation
// so we must give it a dummy type
var any anypb.Any
_ = anypb.MarshalFrom(&any, &emptypb.Empty{}, protov2.MarshalOptions{})
return &any
var anyVal anypb.Any
_ = anypb.MarshalFrom(&anyVal, &emptypb.Empty{}, protov2.MarshalOptions{})
return &anyVal
case "google.protobuf.Value":
// unset kind is not allowed by JSON representation
// so we must give it something

View File

@ -82,7 +82,7 @@ func TestMain(m *testing.M) {
panic(err)
}
defer ccReflect.Close()
refClient := grpcreflect.NewClient(context.Background(), reflectpb.NewServerReflectionClient(ccReflect))
refClient := grpcreflect.NewClientV1Alpha(context.Background(), reflectpb.NewServerReflectionClient(ccReflect))
defer refClient.Reset()
sourceReflect = DescriptorSourceFromServer(context.Background(), refClient)
@ -118,7 +118,7 @@ func TestMain(m *testing.M) {
}
func TestServerDoesNotSupportReflection(t *testing.T) {
refClient := grpcreflect.NewClient(context.Background(), reflectpb.NewServerReflectionClient(ccNoReflect))
refClient := grpcreflect.NewClientV1Alpha(context.Background(), reflectpb.NewServerReflectionClient(ccNoReflect))
defer refClient.Reset()
refSource := DescriptorSourceFromServer(context.Background(), refClient)

View File

@ -1,3 +1,4 @@
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package main

View File

@ -170,8 +170,8 @@ func TestBrokenTLS_ServerPlainText(t *testing.T) {
e, err := createTestServerAndClient(nil, clientCreds)
if err == nil {
t.Fatal("expecting TLS failure setting up server and client")
e.Close()
t.Fatal("expecting TLS failure setting up server and client")
}
if !strings.Contains(err.Error(), "first record does not look like a TLS handshake") {
t.Fatalf("expecting TLS handshake failure, got: %v", err)
@ -190,8 +190,8 @@ func TestBrokenTLS_ServerUsesWrongCert(t *testing.T) {
e, err := createTestServerAndClient(serverCreds, clientCreds)
if err == nil {
t.Fatal("expecting TLS failure setting up server and client")
e.Close()
t.Fatal("expecting TLS failure setting up server and client")
}
if !strings.Contains(err.Error(), "certificate is valid for") {
t.Fatalf("expecting TLS certificate error, got: %v", err)
@ -210,8 +210,8 @@ func TestBrokenTLS_ClientHasExpiredCert(t *testing.T) {
e, err := createTestServerAndClient(serverCreds, clientCreds)
if err == nil {
t.Fatal("expecting TLS failure setting up server and client")
e.Close()
t.Fatal("expecting TLS failure setting up server and client")
}
if !strings.Contains(err.Error(), "bad certificate") {
t.Fatalf("expecting TLS certificate error, got: %v", err)
@ -230,8 +230,8 @@ func TestBrokenTLS_ServerHasExpiredCert(t *testing.T) {
e, err := createTestServerAndClient(serverCreds, clientCreds)
if err == nil {
t.Fatal("expecting TLS failure setting up server and client")
e.Close()
t.Fatal("expecting TLS failure setting up server and client")
}
if !strings.Contains(err.Error(), "certificate has expired or is not yet valid") {
t.Fatalf("expecting TLS certificate expired, got: %v", err)
@ -250,8 +250,8 @@ func TestBrokenTLS_ClientNotTrusted(t *testing.T) {
e, err := createTestServerAndClient(serverCreds, clientCreds)
if err == nil {
t.Fatal("expecting TLS failure setting up server and client")
e.Close()
t.Fatal("expecting TLS failure setting up server and client")
}
if !strings.Contains(err.Error(), "bad certificate") {
t.Fatalf("expecting TLS certificate error, got: %v", err)
@ -270,10 +270,10 @@ func TestBrokenTLS_ServerNotTrusted(t *testing.T) {
e, err := createTestServerAndClient(serverCreds, clientCreds)
if err == nil {
t.Fatal("expecting TLS failure setting up server and client")
e.Close()
t.Fatal("expecting TLS failure setting up server and client")
}
if !strings.Contains(err.Error(), "certificate signed by unknown authority") {
if !strings.Contains(err.Error(), "certificate") {
t.Fatalf("expecting TLS certificate error, got: %v", err)
}
}
@ -290,8 +290,8 @@ func TestBrokenTLS_RequireClientCertButNonePresented(t *testing.T) {
e, err := createTestServerAndClient(serverCreds, clientCreds)
if err == nil {
t.Fatal("expecting TLS failure setting up server and client")
e.Close()
t.Fatal("expecting TLS failure setting up server and client")
}
if !strings.Contains(err.Error(), "bad certificate") {
t.Fatalf("expecting TLS certificate error, got: %v", err)
@ -349,7 +349,7 @@ type testEnv struct {
cc *grpc.ClientConn
}
func (e testEnv) Close() {
func (e *testEnv) Close() {
if e.cc != nil {
e.cc.Close()
e.cc = nil