Skip to content

Commit

Permalink
remove github.com/mailgun/holster (#46916)
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrato authored Oct 2, 2024
1 parent 2c9863b commit 73ef050
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 263 deletions.
2 changes: 1 addition & 1 deletion e
Submodule e updated from c2ed83 to b0128e
1 change: 0 additions & 1 deletion e_imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ import (
_ "github.com/jackc/pgx/v5/pgxpool"
_ "github.com/jonboulle/clockwork"
_ "github.com/julienschmidt/httprouter"
_ "github.com/mailgun/holster/v3/clock"
_ "github.com/mitchellh/mapstructure"
_ "github.com/okta/okta-sdk-golang/v2/okta"
_ "github.com/okta/okta-sdk-golang/v2/okta/query"
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ require (
github.com/julienschmidt/httprouter v1.3.0 // replaced
github.com/keys-pub/go-libfido2 v1.5.3-0.20220306005615-8ab03fb1ec27 // replaced
github.com/lib/pq v1.10.9
github.com/mailgun/holster/v3 v3.16.2
github.com/mailgun/mailgun-go/v4 v4.16.0
github.com/mailgun/timetools v0.0.0-20170619190023-f3a7b8ffff47
github.com/mailgun/ttlmap v0.0.0-20170619185759-c1c17f74874f
Expand Down
77 changes: 0 additions & 77 deletions go.sum

Large diffs are not rendered by default.

28 changes: 15 additions & 13 deletions integrations/access/mattermost/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

"github.com/go-resty/resty/v2"
"github.com/gravitational/trace"
"github.com/mailgun/holster/v3/collections"
lru "github.com/hashicorp/golang-lru/v2"

"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/types/accesslist"
Expand Down Expand Up @@ -59,6 +59,7 @@ var postTextTemplate = template.Must(template.New("description").Parse(
{{else if eq .Status "PENDING"}}**Approve**: ` + "`tsh request review --approve {{.ID}}`" + `
**Deny**: ` + "`tsh request review --deny {{.ID}}`" + `{{end}}`,
))

var reviewCommentTemplate = template.Must(template.New("review comment").Parse(
`{{.Author}} reviewed the request at {{.Created.Format .TimeFormat}}.
Resolution: {{.ProposedStateEmoji}} {{.ProposedState}}.
Expand All @@ -81,11 +82,14 @@ type Bot struct {
webProxyURL *url.URL
}

type getMeKey struct{}
type getChannelByTeamNameAndNameKey struct {
team string
name string
}
type (
getMeKey struct{}
getChannelByTeamNameAndNameKey struct {
team string
name string
}
)

type getUserByEmail struct {
email string
}
Expand All @@ -108,7 +112,10 @@ func NewBot(conf Config, clusterName, webProxyAddr string) (Bot, error) {
}
}

cache := collections.NewLRUCache(mmCacheSize)
cache, err := lru.New[any, etagCacheEntry](mmCacheSize)
if err != nil {
return Bot{}, trace.Wrap(err, "failed to create cache")
}

client := resty.
NewWithClient(&http.Client{
Expand Down Expand Up @@ -173,16 +180,11 @@ func NewBot(conf Config, clusterName, webProxyAddr string) (Bot, error) {
return nil
}

val, ok := cache.Get(cacheKey)
res, ok := cache.Get(cacheKey)
if !ok {
return nil
}

res, ok := val.(etagCacheEntry)
if !ok {
return trace.Errorf("etag cache entry of unknown type %T", val)
}

req.SetHeader("If-None-Match", res.etag)
req.SetResult(res.value)
return nil
Expand Down
1 change: 0 additions & 1 deletion integrations/event-handler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ require (
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailgun/holster/v3 v3.16.2 // indirect
github.com/mailgun/minheap v0.0.0-20170619185613-3dbe6c6bf55f // indirect
github.com/mailgun/timetools v0.0.0-20170619190023-f3a7b8ffff47 // indirect
github.com/mailgun/ttlmap v0.0.0-20170619185759-c1c17f74874f // indirect
Expand Down
88 changes: 0 additions & 88 deletions integrations/event-handler/go.sum

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion integrations/terraform/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ require (
github.com/lib/pq v1.10.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mailgun/holster/v3 v3.16.2 // indirect
github.com/mailgun/minheap v0.0.0-20170619185613-3dbe6c6bf55f // indirect
github.com/mailgun/timetools v0.0.0-20170619190023-f3a7b8ffff47 // indirect
github.com/mailgun/ttlmap v0.0.0-20170619185759-c1c17f74874f // indirect
Expand Down
69 changes: 0 additions & 69 deletions integrations/terraform/go.sum

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions lib/services/local/crown_jewels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/jonboulle/clockwork"
"github.com/mailgun/holster/v3/clock"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/timestamppb"
Expand Down Expand Up @@ -145,7 +144,7 @@ func TestUpdateCrownJewel(t *testing.T) {
service := getService(t)
prepopulate(t, service, 1)

expiry := timestamppb.New(clock.Now().Add(30 * time.Minute))
expiry := timestamppb.New(time.Now().Add(30 * time.Minute))

// Fetch the object from the backend so the revision is populated.
obj, err := service.GetCrownJewel(ctx, getObject(t, 0).GetMetadata().GetName())
Expand All @@ -169,7 +168,7 @@ func TestUpdateCrownJewelMissingRevision(t *testing.T) {
service := getService(t)
prepopulate(t, service, 1)

expiry := timestamppb.New(clock.Now().Add(30 * time.Minute))
expiry := timestamppb.New(time.Now().Add(30 * time.Minute))

obj := getObject(t, 0)
obj.Metadata.Expires = expiry
Expand Down
3 changes: 1 addition & 2 deletions lib/services/local/databaseobject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/jonboulle/clockwork"
"github.com/mailgun/holster/v3/clock"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
Expand Down Expand Up @@ -158,7 +157,7 @@ func TestUpdateDatabaseObject(t *testing.T) {
service := getService(t)
prepopulate(t, service, 1)

expiry := timestamppb.New(clock.Now().Add(30 * time.Minute))
expiry := timestamppb.New(time.Now().Add(30 * time.Minute))

obj := getObject(t, 0)
obj.Metadata.Expires = expiry
Expand Down
5 changes: 2 additions & 3 deletions lib/services/local/statichostuser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/gravitational/trace"
"github.com/jonboulle/clockwork"
"github.com/mailgun/holster/v3/clock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/testing/protocmp"
Expand Down Expand Up @@ -130,7 +129,7 @@ func TestUpdateStaticHostUser(t *testing.T) {
service := getStaticHostUserService(t)
prepopulateStaticHostUsers(t, service, 1)

expiry := timestamppb.New(clock.Now().Add(30 * time.Minute))
expiry := timestamppb.New(time.Now().Add(30 * time.Minute))

// Fetch the object from the backend so the revision is populated.
key := getStaticHostUser(0).GetMetadata().GetName()
Expand All @@ -154,7 +153,7 @@ func TestUpdateStaticHostUserMissingRevision(t *testing.T) {
service := getStaticHostUserService(t)
prepopulateStaticHostUsers(t, service, 1)

expiry := timestamppb.New(clock.Now().Add(30 * time.Minute))
expiry := timestamppb.New(time.Now().Add(30 * time.Minute))

obj := getStaticHostUser(0)
obj.Metadata.Expires = expiry
Expand Down
5 changes: 2 additions & 3 deletions lib/services/local/user_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/jonboulle/clockwork"
"github.com/mailgun/holster/v3/clock"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/timestamppb"
Expand Down Expand Up @@ -139,7 +138,7 @@ func TestUpdateUserTask(t *testing.T) {
service := getUserTasksService(t)
prepopulateUserTask(t, service, 1)

expiry := timestamppb.New(clock.Now().Add(30 * time.Minute))
expiry := timestamppb.New(time.Now().Add(30 * time.Minute))

// Fetch the object from the backend so the revision is populated.
obj, err := service.GetUserTask(ctx, getUserTaskObject(t, 0).GetMetadata().GetName())
Expand All @@ -163,7 +162,7 @@ func TestUpdateUserTaskMissingRevision(t *testing.T) {
service := getUserTasksService(t)
prepopulateUserTask(t, service, 1)

expiry := timestamppb.New(clock.Now().Add(30 * time.Minute))
expiry := timestamppb.New(time.Now().Add(30 * time.Minute))

obj := getUserTaskObject(t, 0)
obj.Metadata.Expires = expiry
Expand Down

0 comments on commit 73ef050

Please sign in to comment.