From e8cae6a5300a1b2493d7d9a4774b753f5f1a0204 Mon Sep 17 00:00:00 2001 From: Simon Marty Date: Wed, 21 Jun 2023 14:27:30 -0700 Subject: [PATCH] Upgrade deps, clean up compiler warnings, clean up generated overview on pkg.go.dev (#55) --- .gitignore | 21 ++++++++++ go.mod | 6 ++- go.sum | 66 ++++++++++++++++++++++++++++++-- scintegtests/integration_test.go | 15 ++++++-- secretcache/cacheConfig.go | 2 - secretcache/cacheHook.go | 2 - secretcache/cacheItem.go | 2 - secretcache/cacheObject.go | 2 - secretcache/cacheVersion.go | 2 - secretcache/error.go | 2 - secretcache/lruCache.go | 2 - secretcache/lruCache_test.go | 2 +- secretcache/versionInfo.go | 4 +- 13 files changed, 101 insertions(+), 27 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3b735ec --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work diff --git a/go.mod b/go.mod index 7ed9b9b..00b3342 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,8 @@ module github.com/aws/aws-secretsmanager-caching-go go 1.12 -require github.com/aws/aws-sdk-go v1.19.23 +require ( + github.com/aws/aws-sdk-go v1.44.287 + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.11.0 // indirect +) diff --git a/go.sum b/go.sum index b3a04ab..0857556 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,62 @@ -github.com/aws/aws-sdk-go v1.19.23 h1:euoy2X3HKkQUtsRXlC9ZuFruesVfKpsAl1brCTphClM= -github.com/aws/aws-sdk-go v1.19.23/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/aws/aws-sdk-go v1.44.287 h1:CUq2/h0gZ2LOCF61AgQSEMPMfas4gTiQfHBO88gGET0= +github.com/aws/aws-sdk-go v1.44.287/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/scintegtests/integration_test.go b/scintegtests/integration_test.go index 2fca7ca..f78afd6 100644 --- a/scintegtests/integration_test.go +++ b/scintegtests/integration_test.go @@ -2,15 +2,16 @@ package scintegtests import ( "bytes" + "math/rand" + "regexp" + "testing" + "time" + "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/secretsmanager" "github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface" "github.com/aws/aws-secretsmanager-caching-go/secretcache" - "math/rand" - "regexp" - "testing" - "time" ) var ( @@ -355,6 +356,12 @@ func integTest_getSecretStringWithTTL(t *testing.T, api secretsmanageriface.Secr time.Sleep(time.Nanosecond * time.Duration(ttlNanoSeconds)) resultString, err = cache.GetSecretString(*createResult.ARN) + + if err != nil { + t.Error(err) + return *createResult.ARN + } + if updatedSecretString != resultString { t.Errorf("Expected cached secret to be same as updated version - \"%s\", \"%s\"", resultString, updatedSecretString) return *createResult.ARN diff --git a/secretcache/cacheConfig.go b/secretcache/cacheConfig.go index c1300bf..7c5f14d 100644 --- a/secretcache/cacheConfig.go +++ b/secretcache/cacheConfig.go @@ -11,8 +11,6 @@ // ANY KIND, either express or implied. See the License for the specific // language governing permissions and limitations under the License. -// Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager -// Also exports a CacheHook, for pre-store and post-fetch processing of cached values package secretcache const ( diff --git a/secretcache/cacheHook.go b/secretcache/cacheHook.go index e66e654..19b0e41 100644 --- a/secretcache/cacheHook.go +++ b/secretcache/cacheHook.go @@ -11,8 +11,6 @@ // ANY KIND, either express or implied. See the License for the specific // language governing permissions and limitations under the License. -// Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager -// Also exports a CacheHook, for pre-store and post-fetch processing of cached values package secretcache // CacheHook is an interface to hook into the local in-memory cache. This interface will allow diff --git a/secretcache/cacheItem.go b/secretcache/cacheItem.go index 55b26cf..cb915af 100644 --- a/secretcache/cacheItem.go +++ b/secretcache/cacheItem.go @@ -11,8 +11,6 @@ // ANY KIND, either express or implied. See the License for the specific // language governing permissions and limitations under the License. -// Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager -// Also exports a CacheHook, for pre-store and post-fetch processing of cached values package secretcache import ( diff --git a/secretcache/cacheObject.go b/secretcache/cacheObject.go index c3fa8ad..79802f8 100644 --- a/secretcache/cacheObject.go +++ b/secretcache/cacheObject.go @@ -11,8 +11,6 @@ // ANY KIND, either express or implied. See the License for the specific // language governing permissions and limitations under the License. -// Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager -// Also exports a CacheHook, for pre-store and post-fetch processing of cached values package secretcache import ( diff --git a/secretcache/cacheVersion.go b/secretcache/cacheVersion.go index d8f2889..8dd51dc 100644 --- a/secretcache/cacheVersion.go +++ b/secretcache/cacheVersion.go @@ -11,8 +11,6 @@ // ANY KIND, either express or implied. See the License for the specific // language governing permissions and limitations under the License. -// Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager -// Also exports a CacheHook, for pre-store and post-fetch processing of cached values package secretcache import ( diff --git a/secretcache/error.go b/secretcache/error.go index 92fd42b..3872343 100644 --- a/secretcache/error.go +++ b/secretcache/error.go @@ -11,8 +11,6 @@ // ANY KIND, either express or implied. See the License for the specific // language governing permissions and limitations under the License. -// Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager -// Also exports a CacheHook, for pre-store and post-fetch processing of cached values package secretcache type baseError struct { diff --git a/secretcache/lruCache.go b/secretcache/lruCache.go index 7a6cd23..2db8152 100644 --- a/secretcache/lruCache.go +++ b/secretcache/lruCache.go @@ -11,8 +11,6 @@ // ANY KIND, either express or implied. See the License for the specific // language governing permissions and limitations under the License. -// Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager -// Also exports a CacheHook, for pre-store and post-fetch processing of cached values package secretcache import ( diff --git a/secretcache/lruCache_test.go b/secretcache/lruCache_test.go index 64da87b..96fd595 100644 --- a/secretcache/lruCache_test.go +++ b/secretcache/lruCache_test.go @@ -121,7 +121,7 @@ func TestLRUCacheRecent(t *testing.T) { } } - if val, found := lruCache.get("0"); !found || 0 != val.(int) { + if val, found := lruCache.get("0"); !found || val.(int) != 0 { t.Fatalf("Expected to find val in cache - %d", 0) } } diff --git a/secretcache/versionInfo.go b/secretcache/versionInfo.go index 3c845b9..2c64684 100644 --- a/secretcache/versionInfo.go +++ b/secretcache/versionInfo.go @@ -11,14 +11,12 @@ // ANY KIND, either express or implied. See the License for the specific // language governing permissions and limitations under the License. -// Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager -// Also exports a CacheHook, for pre-store and post-fetch processing of cached values package secretcache const ( VersionNumber = "1" MajorRevisionNumber = "1" - MinorRevisionNumber = "0" + MinorRevisionNumber = "2" BugfixRevisionNumber = "0" )