Skip to content

Commit

Permalink
Change to go mod v2 versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Calebjh committed Jul 28, 2021
1 parent bbef708 commit f2458a7
Show file tree
Hide file tree
Showing 78 changed files with 152 additions and 152 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Atlas Application Toolkit
[![Build Status](https://img.shields.io/travis/infobloxopen/atlas-app-toolkit/master.svg?label=build)](https://travis-ci.org/infobloxopen/atlas-app-toolkit)
[![Build Status](https://img.shields.io/travis/infobloxopen/atlas-app-toolkit/v2/master.svg?label=build)](https://travis-ci.org/infobloxopen/atlas-app-toolkit/v2)

This repository provides common Go utilities and helpers that are reusable from project-to-project. The goal is to prevent code duplication by encouraging teams to use and contribute to toolkit libraries.

Expand Down
2 changes: 1 addition & 1 deletion auth/interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
mock_transport "github.com/infobloxopen/atlas-app-toolkit/mocks/transport"
mock_transport "github.com/infobloxopen/atlas-app-toolkit/v2/mocks/transport"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
Expand Down
10 changes: 5 additions & 5 deletions errors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Errors
To avoid burden of mapping errors returned from 3rd party libraries
you can gather all error mappings in one place and put an interceptor
provided by atlas-app-toolkit package in a middleware chain as following:
provided by atlas-app-toolkit/v2 package in a middleware chain as following:
```go
interceptor := errors.UnaryServerInterceptor(
// List of mappings
Expand Down Expand Up @@ -212,7 +212,7 @@ interceptor := errors.UnaryServerInterceptor(
<a name="validation"></a>
# Validation Errors

import "github.com/infobloxopen/atlas-app-toolkit/errors/mappers/validationerrors"
import "github.com/infobloxopen/atlas-app-toolkit/v2/errors/mappers/validationerrors"

`validationerrors` is a request contents validator server-side middleware for
gRPC.
Expand Down Expand Up @@ -309,14 +309,14 @@ Example Usage:

# PQ Errors

import "github.com/infobloxopen/atlas-app-toolkit/errors/mappers/pqerrors"
import "github.com/infobloxopen/atlas-app-toolkit/v2/errors/mappers/pqerrors"

`pqerrors` is a error mapper for postgres.



Dedicated error mapper for go postgres driver (lib/pq.Error) package is included under
the path of github.com/atlas-app-toolkit/errors/mappers/pqerrors. This package includes
the path of github.com/atlas-app-toolkit/v2/errors/mappers/pqerrors. This package includes
following components:

* Condition function CondPQ, CondConstraintEq, CondCodeEq for conditions involved in \*pq.Error detection,
Expand All @@ -333,7 +333,7 @@ Example Usage:
```go
import (
...
"github.com/atlas-app-toolkit/errors/mappers/pqerrors"
"github.com/atlas-app-toolkit/v2/errors/mappers/pqerrors"
)
interceptor := errors.UnaryServerInterceptor(
Expand Down
4 changes: 2 additions & 2 deletions errors/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"github.com/golang/protobuf/proto"

"github.com/infobloxopen/atlas-app-toolkit/rpc/errdetails"
"github.com/infobloxopen/atlas-app-toolkit/rpc/errfields"
"github.com/infobloxopen/atlas-app-toolkit/v2/rpc/errdetails"
"github.com/infobloxopen/atlas-app-toolkit/v2/rpc/errfields"
)

// Container struct is an entity that servers a purpose of error container and
Expand Down
4 changes: 2 additions & 2 deletions errors/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"google.golang.org/grpc/codes"

"github.com/infobloxopen/atlas-app-toolkit/rpc/errdetails"
"github.com/infobloxopen/atlas-app-toolkit/rpc/errfields"
"github.com/infobloxopen/atlas-app-toolkit/v2/rpc/errdetails"
"github.com/infobloxopen/atlas-app-toolkit/v2/rpc/errfields"
)

var UnexpectedValue = "Unexpected %q value: expected %v, got %v"
Expand Down
2 changes: 1 addition & 1 deletion errors/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package errors
import (
"context"

"github.com/infobloxopen/atlas-app-toolkit/rpc/errdetails"
"github.com/infobloxopen/atlas-app-toolkit/v2/rpc/errdetails"

"google.golang.org/grpc/codes"
)
Expand Down
4 changes: 2 additions & 2 deletions errors/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"google.golang.org/grpc/codes"

"github.com/infobloxopen/atlas-app-toolkit/rpc/errdetails"
"github.com/infobloxopen/atlas-app-toolkit/rpc/errfields"
"github.com/infobloxopen/atlas-app-toolkit/v2/rpc/errdetails"
"github.com/infobloxopen/atlas-app-toolkit/v2/rpc/errfields"
)

func initCtx() context.Context {
Expand Down
4 changes: 2 additions & 2 deletions errors/mappers/pqerrors/pqerrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/lib/pq"
"google.golang.org/grpc/codes"

"github.com/infobloxopen/atlas-app-toolkit/errors"
"github.com/infobloxopen/atlas-app-toolkit/v2/errors"
)

const (
Expand All @@ -17,7 +17,7 @@ const (
)

// ToMapFunc function converts mapping function for *pq.Error to a conventional
// MapFunc from atlas-app-toolkit/errors package.
// MapFunc from atlas-app-toolkit/v2/errors package.
func ToMapFunc(f func(context.Context, *pq.Error) (error, bool)) errors.MapFunc {
return func(ctx context.Context, err error) (error, bool) {
if pqErr, ok := err.(*pq.Error); ok {
Expand Down
2 changes: 1 addition & 1 deletion errors/mappers/pqerrors/pqerrors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/lib/pq"

"github.com/infobloxopen/atlas-app-toolkit/errors"
"github.com/infobloxopen/atlas-app-toolkit/v2/errors"
)

func TestCond(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion errors/mappers/validationerrors/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/infobloxopen/atlas-app-toolkit/util"
"github.com/infobloxopen/atlas-app-toolkit/v2/util"
"google.golang.org/grpc"
)

Expand Down
4 changes: 2 additions & 2 deletions errors/mappers/validationerrors/validationerrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package validationerrors
import (
"context"

"github.com/infobloxopen/atlas-app-toolkit/errors"
"github.com/infobloxopen/atlas-app-toolkit/v2/errors"
"google.golang.org/grpc/codes"
)

// ToMapFunc function converts mapping function for *validationerrors.Error to a conventional
// MapFunc from atlas-app-toolkit/errors package.
// MapFunc from atlas-app-toolkit/v2/errors package.
func ToMapFunc(f func(context.Context, ValidationError) (error, bool)) errors.MapFunc {
return func(ctx context.Context, err error) (error, bool) {
if vErr, ok := err.(ValidationError); ok {
Expand Down
2 changes: 1 addition & 1 deletion errors/mappers/validationerrors/validationerrors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/infobloxopen/atlas-app-toolkit/errors"
"github.com/infobloxopen/atlas-app-toolkit/v2/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down
8 changes: 4 additions & 4 deletions gateway/README-clone.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ You can also use the helper function provided in this package.
import (
"context"

"github.com/infobloxopen/atlas-app-toolkit/gateway"
"github.com/infobloxopen/atlas-app-toolkit/v2/gateway"
)

func (s *myServiceImpl) MyMethod(ctx context.Context, req *MyRequest) (*MyResponse, error) {
Expand Down Expand Up @@ -138,7 +138,7 @@ To override this behavior, the gRPC Gateway documentation recommends overwriting

```go
import (
"github.com/infobloxopen/atlas-app-toolkit/gateway"
"github.com/infobloxopen/atlas-app-toolkit/v2/gateway"
)

func init() {
Expand Down Expand Up @@ -167,7 +167,7 @@ Also you may use shortcuts like `SetCreated`, `SetUpdated`, and `SetDeleted`.

```go
import (
"github.com/infobloxopen/atlas-app-toolkit/gateway"
"github.com/infobloxopen/atlas-app-toolkit/v2/gateway"
)

func (s *myService) MyMethod(req *MyRequest) (*MyResponse, error) {
Expand Down Expand Up @@ -336,7 +336,7 @@ Here's an example that shows how to use [`DefaultProtoErrorHandler`](gateway/err
```go
import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/infobloxopen/atlas-app-toolkit/gateway"
"github.com/infobloxopen/atlas-app-toolkit/v2/gateway"

"github.com/yourrepo/yourapp"
)
Expand Down
8 changes: 4 additions & 4 deletions gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ You can also use the helper function provided in this package.
import (
"context"

"github.com/infobloxopen/atlas-app-toolkit/gateway"
"github.com/infobloxopen/atlas-app-toolkit/v2/gateway"
)

func (s *myServiceImpl) MyMethod(ctx context.Context, req *MyRequest) (*MyResponse, error) {
Expand Down Expand Up @@ -130,7 +130,7 @@ To override this behavior, the gRPC Gateway documentation recommends overwriting

```go
import (
"github.com/infobloxopen/atlas-app-toolkit/gateway"
"github.com/infobloxopen/atlas-app-toolkit/v2/gateway"
)

func init() {
Expand All @@ -157,7 +157,7 @@ Also you may use shortcuts like `SetCreated`, `SetUpdated`, and `SetDeleted`.

```go
import (
"github.com/infobloxopen/atlas-app-toolkit/gateway"
"github.com/infobloxopen/atlas-app-toolkit/v2/gateway"
)

func (s *myService) MyMethod(req *MyRequest) (*MyResponse, error) {
Expand Down Expand Up @@ -350,7 +350,7 @@ Here's an example that shows how to use [`DefaultProtoErrorHandler`](gateway/err
```go
import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/infobloxopen/atlas-app-toolkit/gateway"
"github.com/infobloxopen/atlas-app-toolkit/v2/gateway"

"github.com/yourrepo/yourapp"
)
Expand Down
4 changes: 2 additions & 2 deletions gateway/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (

"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"

"github.com/infobloxopen/atlas-app-toolkit/rpc/errdetails"
"github.com/infobloxopen/atlas-app-toolkit/rpc/errfields"
"github.com/infobloxopen/atlas-app-toolkit/v2/rpc/errdetails"
"github.com/infobloxopen/atlas-app-toolkit/v2/rpc/errfields"
)

// ProtoStreamErrorHandlerFunc handles the error as a gRPC error generated via status package and replies to the testRequest.
Expand Down
2 changes: 1 addition & 1 deletion gateway/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"reflect"
"testing"

"github.com/infobloxopen/atlas-app-toolkit/errors"
"github.com/infobloxopen/atlas-app-toolkit/v2/errors"

"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"google.golang.org/grpc/codes"
Expand Down
2 changes: 1 addition & 1 deletion gateway/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"net/http"

"github.com/infobloxopen/atlas-app-toolkit/query"
"github.com/infobloxopen/atlas-app-toolkit/v2/query"
)

//retainFields function extracts the configuration for fields that
Expand Down
2 changes: 1 addition & 1 deletion gateway/fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"
"testing"

"github.com/infobloxopen/atlas-app-toolkit/query"
"github.com/infobloxopen/atlas-app-toolkit/v2/query"
)

func TestRetain(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"

"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/infobloxopen/atlas-app-toolkit/query"
"github.com/infobloxopen/atlas-app-toolkit/v2/query"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down
2 changes: 1 addition & 1 deletion gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"
"testing"

"github.com/infobloxopen/atlas-app-toolkit/query"
"github.com/infobloxopen/atlas-app-toolkit/v2/query"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
Expand Down
2 changes: 1 addition & 1 deletion gateway/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TracingHeaderMatcher() runtime.HeaderMatcherFunc {
return ExtendedDefaultHeaderMatcher(GetXB3Headers()...)
}

// AtlasDefaultHeaderMatcher func used to add all headers used by atlas-app-toolkit
// AtlasDefaultHeaderMatcher func used to add all headers used by atlas-app-toolkit/v2
// This function also passes through all the headers that runtime.DefaultHeaderMatcher handles.
// AtlasDefaultHeaderMatcher can be used as a Incoming/Outgoing header matcher.
func AtlasDefaultHeaderMatcher() func(string) (string, bool) {
Expand Down
2 changes: 1 addition & 1 deletion gateway/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"

"github.com/golang/protobuf/proto"
"github.com/infobloxopen/atlas-app-toolkit/query"
"github.com/infobloxopen/atlas-app-toolkit/v2/query"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
)
Expand Down
2 changes: 1 addition & 1 deletion gateway/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gateway
import (
"testing"

"github.com/infobloxopen/atlas-app-toolkit/query"
"github.com/infobloxopen/atlas-app-toolkit/v2/query"
)

func TestUnsetOp(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion gateway/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"strconv"

"github.com/infobloxopen/atlas-app-toolkit/query"
"github.com/infobloxopen/atlas-app-toolkit/v2/query"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)
Expand Down
14 changes: 7 additions & 7 deletions gateway/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (
"io"
"net/http"

"github.com/golang/protobuf/proto"
"google.golang.org/grpc/grpclog"
"google.golang.org/protobuf/reflect/protoreflect"

runtime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
)

type (
// ForwardResponseMessageFunc forwards gRPC response to HTTP client inaccordance with REST API Syntax
ForwardResponseMessageFunc func(context.Context, *runtime.ServeMux, runtime.Marshaler, http.ResponseWriter, *http.Request, proto.Message, ...func(context.Context, http.ResponseWriter, proto.Message) error)
ForwardResponseMessageFunc func(context.Context, *runtime.ServeMux, runtime.Marshaler, http.ResponseWriter, *http.Request, protoreflect.ProtoMessage, ...func(context.Context, http.ResponseWriter, protoreflect.ProtoMessage) error)
// ForwardResponseStreamFunc forwards gRPC stream response to HTTP client inaccordance with REST API Syntax
ForwardResponseStreamFunc func(context.Context, *runtime.ServeMux, runtime.Marshaler, http.ResponseWriter, *http.Request, func() (proto.Message, error), ...func(context.Context, http.ResponseWriter, proto.Message) error)
ForwardResponseStreamFunc func(context.Context, *runtime.ServeMux, runtime.Marshaler, http.ResponseWriter, *http.Request, func() (protoreflect.ProtoMessage, error), ...func(context.Context, http.ResponseWriter, protoreflect.ProtoMessage) error)
)

// ResponseForwarder implements ForwardResponseMessageFunc in method ForwardMessage
// and ForwardResponseStreamFunc in method ForwardStream
// in accordance with REST API Syntax Specification.
// See: https://github.com/infobloxopen/atlas-app-toolkit#responses
// See: https://github.com/infobloxopen/atlas-app-toolkit/v2#responses
// for format of JSON response.
type ResponseForwarder struct {
OutgoingHeaderMatcher runtime.HeaderMatcherFunc
Expand Down Expand Up @@ -59,7 +59,7 @@ func NewForwardResponseStream(out runtime.HeaderMatcherFunc, meh runtime.ErrorHa
}

// ForwardMessage implements runtime.ForwardResponseMessageFunc
func (fw *ResponseForwarder) ForwardMessage(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, rw http.ResponseWriter, req *http.Request, resp proto.Message, opts ...func(context.Context, http.ResponseWriter, proto.Message) error) {
func (fw *ResponseForwarder) ForwardMessage(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, rw http.ResponseWriter, req *http.Request, resp protoreflect.ProtoMessage, opts ...func(context.Context, http.ResponseWriter, protoreflect.ProtoMessage) error) {

// fmt.Printf("First line: %+v %T %+v\n", req, resp, resp.String())
md, ok := runtime.ServerMetadataFromContext(ctx)
Expand Down Expand Up @@ -146,7 +146,7 @@ type delimited interface {

// ForwardStream implements runtime.ForwardResponseStreamFunc.
// RestStatus comes first in the chuncked result.
func (fw *ResponseForwarder) ForwardStream(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, rw http.ResponseWriter, req *http.Request, recv func() (proto.Message, error), opts ...func(context.Context, http.ResponseWriter, proto.Message) error) {
func (fw *ResponseForwarder) ForwardStream(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, rw http.ResponseWriter, req *http.Request, recv func() (protoreflect.ProtoMessage, error), opts ...func(context.Context, http.ResponseWriter, protoreflect.ProtoMessage) error) {
flusher, ok := rw.(http.Flusher)
if !ok {
grpclog.Infof("forward response stream: flush not supported in %T", rw)
Expand Down Expand Up @@ -218,7 +218,7 @@ func (fw *ResponseForwarder) ForwardStream(ctx context.Context, mux *runtime.Ser
}
}

func handleForwardResponseOptions(ctx context.Context, rw http.ResponseWriter, resp proto.Message, opts []func(context.Context, http.ResponseWriter, proto.Message) error) error {
func handleForwardResponseOptions(ctx context.Context, rw http.ResponseWriter, resp protoreflect.ProtoMessage, opts []func(context.Context, http.ResponseWriter, protoreflect.ProtoMessage) error) error {
if len(opts) == 0 {
return nil
}
Expand Down
Loading

0 comments on commit f2458a7

Please sign in to comment.