Skip to content

Commit

Permalink
Merge pull request #167 from xmidt-org/denopink/patch/remove-old-sall…
Browse files Browse the repository at this point in the history
…ust-code

Remove deprecated sallust code
  • Loading branch information
denopink authored Jan 11, 2023
2 parents 6a37d87 + 060871d commit 5fa0212
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
- [Remove deprecated sallust code #167](https://github.com/xmidt-org/bascule/pull/167)

## [v0.11.2]
- [SetLogger Bug: Shared logger among requests creates repeating logging context #159](https://github.com/xmidt-org/bascule/issues/159)
Expand Down
4 changes: 2 additions & 2 deletions basculehttp/constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type constructor struct {
headerName string
headerDelimiter string
authorizations map[bascule.Authorization]TokenFactory
getLogger sallust.GetLoggerFunc
getLogger func(context.Context) *zap.Logger
parseURL ParseURL
onErrorResponse OnErrorResponse
onErrorHTTPResponse OnErrorHTTPResponse
Expand Down Expand Up @@ -192,7 +192,7 @@ func WithTokenFactory(key bascule.Authorization, tf TokenFactory) COption {

// WithCLogger sets the function to use to get the logger from the context.
// If no logger is set, nothing is logged.
func WithCLogger(getLogger sallust.GetLoggerFunc) COption {
func WithCLogger(getLogger func(context.Context) *zap.Logger) COption {
return func(c *constructor) {
if getLogger != nil {
c.getLogger = getLogger
Expand Down
4 changes: 2 additions & 2 deletions basculehttp/constructor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func TestConstructor(t *testing.T) {
WithHeaderDelimiter(testDelimiter),
nil,
WithTokenFactory("Basic", BasicTokenFactory{"codex": "codex"}),
WithCLogger(sallust.GetDefaultLogger),
WithCLogger(sallust.Get),
WithParseURLFunc(CreateRemovePrefixURLFunc("/test", DefaultParseURLFunc)),
WithCErrorResponseFunc(DefaultOnErrorResponse),
WithCErrorHTTPResponseFunc(LegacyOnErrorHTTPResponse),
)
c2 := NewConstructor(
WithHeaderName(""),
WithHeaderDelimiter(""),
WithCLogger(sallust.GetNilLogger),
WithCLogger(sallust.Get),
WithParseURLFunc(CreateRemovePrefixURLFunc("", nil)),
)
tests := []struct {
Expand Down
5 changes: 3 additions & 2 deletions basculehttp/enforcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package basculehttp

import (
"context"
"errors"
"net/http"

Expand Down Expand Up @@ -53,7 +54,7 @@ type EOptionsIn struct {
type enforcer struct {
notFoundBehavior NotFoundBehavior
rules map[bascule.Authorization]bascule.Validator
getLogger sallust.GetLoggerFunc
getLogger func(context.Context) *zap.Logger
onErrorResponse OnErrorResponse
}

Expand Down Expand Up @@ -144,7 +145,7 @@ func WithRules(key bascule.Authorization, v bascule.Validator) EOption {

// WithELogger sets the function to use to get the logger from the context.
// If no logger is set, nothing is logged.
func WithELogger(getLogger sallust.GetLoggerFunc) EOption {
func WithELogger(getLogger func(context.Context) *zap.Logger) EOption {
return func(e *enforcer) {
if getLogger != nil {
e.getLogger = getLogger
Expand Down
4 changes: 2 additions & 2 deletions basculehttp/enforcer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import (
func TestEnforcer(t *testing.T) {
e := NewEnforcer(
WithNotFoundBehavior(Allow),
WithELogger(sallust.GetNilLogger),
WithELogger(sallust.Get),
)
e2 := NewEnforcer(
WithRules("jwt", bascule.Validators{basculechecks.NonEmptyType()}),
WithELogger(sallust.GetDefaultLogger),
WithELogger(sallust.Get),
WithEErrorResponseFunc(DefaultOnErrorResponse),
)
emptyAttributes := bascule.NewAttributes(map[string]interface{}{})
Expand Down
5 changes: 3 additions & 2 deletions basculehttp/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package basculehttp

import (
"context"
"net"
"net/http"
"strings"
Expand Down Expand Up @@ -100,15 +101,15 @@ func ProvideLogger() fx.Option {
// add logger constructor option
fx.Annotated{
Group: "bascule_constructor_options",
Target: func(getLogger sallust.GetLoggerFunc) COption {
Target: func(getLogger func(context.Context) *zap.Logger) COption {
return WithCLogger(getLogger)
},
},

// add logger enforcer option
fx.Annotated{
Group: "bascule_enforcer_options",
Target: func(getLogger sallust.GetLoggerFunc) EOption {
Target: func(getLogger func(context.Context) *zap.Logger) EOption {
return WithELogger(getLogger)
},
},
Expand Down
7 changes: 0 additions & 7 deletions basculehttp/provide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/stretchr/testify/require"
"github.com/xmidt-org/arrange"
"github.com/xmidt-org/bascule/basculechecks"
"github.com/xmidt-org/sallust"
"github.com/xmidt-org/touchstone"
"go.uber.org/fx"
"go.uber.org/fx/fxtest"
Expand Down Expand Up @@ -77,9 +76,6 @@ capabilities:
return "current"
},
},
func() sallust.GetLoggerFunc {
return sallust.Get
},
),

// the parts we care about
Expand Down Expand Up @@ -170,9 +166,6 @@ capabilities:
return "current"
},
},
func() sallust.GetLoggerFunc {
return sallust.Get
},
),
// the parts we care about
ProvideMetrics(),
Expand Down
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/xmidt-org/arrange v0.3.0
github.com/xmidt-org/candlelight v0.0.13
github.com/xmidt-org/clortho v0.0.4
github.com/xmidt-org/sallust v0.2.0
github.com/xmidt-org/sallust v0.2.1
github.com/xmidt-org/touchstone v0.1.2
go.uber.org/fx v1.19.0
go.uber.org/zap v1.24.0
Expand All @@ -21,33 +21,33 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jtacoma/uritemplates v1.0.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.4 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx/v2 v2.0.7 // indirect
github.com/lestrrat-go/option v1.0.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/lestrrat-go/jwx/v2 v2.0.8 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/openzipkin/zipkin-go v0.4.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -67,13 +67,13 @@ require (
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/dig v1.16.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.2.0 // indirect
golang.org/x/net v0.3.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20221205194025-8222ab48f5fc // indirect
google.golang.org/grpc v1.51.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.52.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
Expand Down
Loading

0 comments on commit 5fa0212

Please sign in to comment.