Skip to content

Commit 7fe2557

Browse files
author
tomabraham
committed
split up common pkg + move interceptor to grpc
1 parent 8c708ac commit 7fe2557

19 files changed

+28
-13
lines changed
File renamed without changes.
File renamed without changes.

common/helpers.go grpc/common/helpers.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package common
33
import (
44
"context"
55

6+
httpcommon "github.com/Azure/aks-middleware/http/common"
67
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging"
78
"google.golang.org/grpc/metadata"
89
)
@@ -22,10 +23,10 @@ func getMetadata(ctx context.Context) map[string]string {
2223
return headersFromMD
2324
}
2425
for _, key := range []string{
25-
RequestIDMetadataHeader,
26-
CorrelationIDKey,
27-
OperationIDKey,
28-
ARMClientRequestIDKey,
26+
httpcommon.RequestIDMetadataHeader,
27+
httpcommon.CorrelationIDKey,
28+
httpcommon.OperationIDKey,
29+
httpcommon.ARMClientRequestIDKey,
2930
} {
3031
if vals := md.Get(key); len(vals) > 0 {
3132
headersFromMD[key] = vals[0]
File renamed without changes.
File renamed without changes.
File renamed without changes.

interceptor/interceptor.go grpc/interceptor/interceptor.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"io"
55
"os"
66

7-
"github.com/Azure/aks-middleware/common"
8-
"github.com/Azure/aks-middleware/common/autologger"
97
"github.com/Azure/aks-middleware/grpc/client/mdforward"
8+
"github.com/Azure/aks-middleware/grpc/common"
9+
"github.com/Azure/aks-middleware/grpc/common/autologger"
1010
"github.com/Azure/aks-middleware/grpc/server/ctxlogger"
1111
"github.com/Azure/aks-middleware/grpc/server/requestid"
1212
"github.com/Azure/aks-middleware/grpc/server/responseheader"
13+
httpcommon "github.com/Azure/aks-middleware/http/common"
1314

1415
log "log/slog"
1516
"strings"
@@ -144,7 +145,7 @@ func DefaultServerInterceptors(options ServerInterceptorLogOptions) []grpc.Unary
144145
logging.WithLogOnEvents(logging.FinishCall),
145146
logging.WithFieldsFromContext(common.GetFields),
146147
),
147-
responseheader.UnaryServerInterceptor(common.MetadataToHeader),
148+
responseheader.UnaryServerInterceptor(httpcommon.MetadataToHeader),
148149
recovery.UnaryServerInterceptor(common.GetRecoveryOpts()...),
149150
}
150151
}

grpc/server/ctxlogger/ctxlogger.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
log "log/slog"
99

1010
loggable "buf.build/gen/go/service-hub/loggable/protocolbuffers/go/proto"
11-
"github.com/Azure/aks-middleware/common"
11+
"github.com/Azure/aks-middleware/grpc/common"
1212
"google.golang.org/grpc"
1313
"google.golang.org/protobuf/encoding/protojson"
1414
"google.golang.org/protobuf/proto"

grpc/server/requestid/requestid.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"encoding/base64"
88
"io"
99

10-
"github.com/Azure/aks-middleware/common"
10+
"github.com/Azure/aks-middleware/http/common"
1111
"google.golang.org/grpc"
1212
"google.golang.org/grpc/metadata"
1313
)

http/client/azuresdk/policy/policy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"net/http"
66
"time"
77

8-
"github.com/Azure/aks-middleware/common/logging"
8+
"github.com/Azure/aks-middleware/http/common/logging"
99
armPolicy "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/policy"
1010
azcorePolicy "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
1111
"google.golang.org/grpc/codes"

http/client/direct/restlogger/restlogger.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"net/http"
66
"time"
77

8-
"github.com/Azure/aks-middleware/common/logging"
8+
"github.com/Azure/aks-middleware/http/common/logging"
99
)
1010

1111
type LoggingRoundTripper struct {

http/common/common_suite_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package common_test
2+
3+
import (
4+
"testing"
5+
6+
. "github.com/onsi/ginkgo/v2"
7+
. "github.com/onsi/gomega"
8+
)
9+
10+
func TestCommon(t *testing.T) {
11+
RegisterFailHandler(Fail)
12+
RunSpecs(t, "Common Suite")
13+
}
File renamed without changes.
File renamed without changes.

common/logging/logging.go http/common/logging/logging.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"time"
99

10-
"github.com/Azure/aks-middleware/common"
10+
"github.com/Azure/aks-middleware/http/common"
1111
azcorePolicy "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
1212
)
1313

File renamed without changes.

common/logging/logging_test.go http/common/logging/logging_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"net/url"
99
"time"
1010

11-
"github.com/Azure/aks-middleware/common/logging"
11+
"github.com/Azure/aks-middleware/http/common/logging"
1212
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
1313
. "github.com/onsi/ginkgo/v2"
1414
. "github.com/onsi/gomega"

0 commit comments

Comments
 (0)