Merge pull request #3579 from thaJeztah/bump_hashicorp_deps

Bump hashicorp deps
This commit is contained in:
Michael Crosby 2019-08-26 11:44:46 -04:00 committed by GitHub
commit dfd76b3484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 52 additions and 11 deletions

View File

@ -42,9 +42,9 @@ github.com/syndtr/gocapability d98352740cb2c55f81556b63d4a1ec64c5a319c2
gotest.tools v2.3.0 gotest.tools v2.3.0
github.com/google/go-cmp v0.2.0 github.com/google/go-cmp v0.2.0
go.etcd.io/bbolt v1.3.3 go.etcd.io/bbolt v1.3.3
github.com/hashicorp/errwrap 7554cd9344cec97297fa6649b055a8c98c2a1e55 github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/go-multierror ed905158d87462226a13fe39ddf685ea65f1c11f github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/golang-lru v0.5.1 github.com/hashicorp/golang-lru v0.5.3
go.opencensus.io v0.22.0 go.opencensus.io v0.22.0
# cri dependencies # cri dependencies

View File

@ -48,7 +48,7 @@ func main() {
// We can use the Contains helpers to check if an error contains // We can use the Contains helpers to check if an error contains
// another error. It is safe to do this with a nil error, or with // another error. It is safe to do this with a nil error, or with
// an error that doesn't even use the errwrap package. // an error that doesn't even use the errwrap package.
if errwrap.Contains(err, ErrNotExist) { if errwrap.Contains(err, "does not exist") {
// Do something // Do something
} }
if errwrap.ContainsType(err, new(os.PathError)) { if errwrap.ContainsType(err, new(os.PathError)) {

1
vendor/github.com/hashicorp/errwrap/go.mod generated vendored Normal file
View File

@ -0,0 +1 @@
module github.com/hashicorp/errwrap

View File

@ -13,7 +13,7 @@ type ErrorFormatFunc func([]error) string
// that occurred along with a bullet point list of the errors. // that occurred along with a bullet point list of the errors.
func ListFormatFunc(es []error) string { func ListFormatFunc(es []error) string {
if len(es) == 1 { if len(es) == 1 {
return fmt.Sprintf("1 error occurred:\n\n* %s", es[0]) return fmt.Sprintf("1 error occurred:\n\t* %s\n\n", es[0])
} }
points := make([]string, len(es)) points := make([]string, len(es))
@ -22,6 +22,6 @@ func ListFormatFunc(es []error) string {
} }
return fmt.Sprintf( return fmt.Sprintf(
"%d errors occurred:\n\n%s", "%d errors occurred:\n\t%s\n\n",
len(es), strings.Join(points, "\n")) len(es), strings.Join(points, "\n\t"))
} }

3
vendor/github.com/hashicorp/go-multierror/go.mod generated vendored Normal file
View File

@ -0,0 +1,3 @@
module github.com/hashicorp/go-multierror
require github.com/hashicorp/errwrap v1.0.0

View File

@ -40,11 +40,11 @@ func (e *Error) GoString() string {
} }
// WrappedErrors returns the list of errors that this Error is wrapping. // WrappedErrors returns the list of errors that this Error is wrapping.
// It is an implementatin of the errwrap.Wrapper interface so that // It is an implementation of the errwrap.Wrapper interface so that
// multierror.Error can be used with that library. // multierror.Error can be used with that library.
// //
// This method is not safe to be called concurrently and is no different // This method is not safe to be called concurrently and is no different
// than accessing the Errors field directly. It is implementd only to // than accessing the Errors field directly. It is implemented only to
// satisfy the errwrap.Wrapper interface. // satisfy the errwrap.Wrapper interface.
func (e *Error) WrappedErrors() []error { func (e *Error) WrappedErrors() []error {
return e.Errors return e.Errors

16
vendor/github.com/hashicorp/go-multierror/sort.go generated vendored Normal file
View File

@ -0,0 +1,16 @@
package multierror
// Len implements sort.Interface function for length
func (err Error) Len() int {
return len(err.Errors)
}
// Swap implements sort.Interface function for swapping elements
func (err Error) Swap(i, j int) {
err.Errors[i], err.Errors[j] = err.Errors[j], err.Errors[i]
}
// Less implements sort.Interface function for determining order
func (err Error) Less(i, j int) bool {
return err.Errors[i].Error() < err.Errors[j].Error()
}

View File

@ -1 +1,3 @@
module github.com/hashicorp/golang-lru module github.com/hashicorp/golang-lru
go 1.12

View File

@ -73,6 +73,9 @@ func (c *LRU) Add(key, value interface{}) (evicted bool) {
func (c *LRU) Get(key interface{}) (value interface{}, ok bool) { func (c *LRU) Get(key interface{}) (value interface{}, ok bool) {
if ent, ok := c.items[key]; ok { if ent, ok := c.items[key]; ok {
c.evictList.MoveToFront(ent) c.evictList.MoveToFront(ent)
if ent.Value.(*entry) == nil {
return nil, false
}
return ent.Value.(*entry).value, true return ent.Value.(*entry).value, true
} }
return return
@ -142,6 +145,19 @@ func (c *LRU) Len() int {
return c.evictList.Len() return c.evictList.Len()
} }
// Resize changes the cache size.
func (c *LRU) Resize(size int) (evicted int) {
diff := c.Len() - size
if diff < 0 {
diff = 0
}
for i := 0; i < diff; i++ {
c.removeOldest()
}
c.size = size
return diff
}
// removeOldest removes the oldest item from the cache. // removeOldest removes the oldest item from the cache.
func (c *LRU) removeOldest() { func (c *LRU) removeOldest() {
ent := c.evictList.Back() ent := c.evictList.Back()

View File

@ -10,7 +10,7 @@ type LRUCache interface {
// updates the "recently used"-ness of the key. #value, isFound // updates the "recently used"-ness of the key. #value, isFound
Get(key interface{}) (value interface{}, ok bool) Get(key interface{}) (value interface{}, ok bool)
// Check if a key exsists in cache without updating the recent-ness. // Checks if a key exists in cache without updating the recent-ness.
Contains(key interface{}) (ok bool) Contains(key interface{}) (ok bool)
// Returns key's value without updating the "recently used"-ness of the key. // Returns key's value without updating the "recently used"-ness of the key.
@ -31,6 +31,9 @@ type LRUCache interface {
// Returns the number of items in the cache. // Returns the number of items in the cache.
Len() int Len() int
// Clear all cache entries // Clears all cache entries.
Purge() Purge()
// Resizes cache, returning number evicted
Resize(int) int
} }