diff --git a/README.md b/README.md index c128eb832b764806b929ed71930a42a8aaf3ee47..eac7be53bf23562bec8f23577982a87de9b94e37 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,29 @@ +[](https://code.vereign.com/gaiax/tsa/cache/-/commits/main) +[](https://code.vereign.com/gaiax/tsa/cache/-/commits/main) + # Cache service Cache service exposes HTTP interface for working with Redis. ### Basic Architecture -```mermaid -flowchart LR - A[Client] -- request --> B[Cache Service] --> C[(Redis)] +```mermaid +flowchart LR + A[Client] -- request --> B[HTTP API] + subgraph cache + B --> C[(Redis)] + end ``` ### API Documentation -The API Documentation is accessible at `/swagger-ui` path in OAS 3.0 format. -Example: `http://localhost:8080/swagger-ui` +The API Documentation is accessible at `/swagger-ui` path in OAS 3.0 format. If you +use the docker-compose environment, it's exposed at `http://localhost:8083/swagger-ui` ### Dependencies There must be a running instance of [Redis](https://redis.io/) visible to the service. -The address, username and password of the Redis in-memory store instance must be provided as environment variables. +The address, username and password of Redis must be provided as environment variables. Example: ``` @@ -28,11 +34,12 @@ REDIS_PASS="pass" ### Development -This service uses [Goa framework](https://goa.design/) v3 as a backbone. [This](https://goa.design/learn/getting-started/) is a good starting point for learning to use the framework. +This service uses [Goa framework](https://goa.design/) v3 as a backbone. +[This](https://goa.design/learn/getting-started/) is a good starting point for learning to use the framework. ### Dependencies and Vendor -The project uses Go modules for managing dependencies and we commit the `vendor` directory. +The project uses Go modules for managing dependencies, and we commit the `vendor` directory. When you add/change dependencies, be sure to clean and update the `vendor` directory before submitting your Merge Request for review. ```shell diff --git a/design/types.go b/design/types.go index 3ea641e275ca9fed03207bd7d3e052865ae005c3..b17285e5daaa8e7b0aca59f7355012848ad2999a 100644 --- a/design/types.go +++ b/design/types.go @@ -7,7 +7,7 @@ var CacheGetRequest = Type("CacheGetRequest", func() { Field(1, "key", String) Field(2, "namespace", String) Field(3, "scope", String) // Initial implementation with a single scope - Required("key", "namespace", "scope") + Required("key") }) var CacheSetRequest = Type("CacheSetRequest", func() { @@ -15,5 +15,5 @@ var CacheSetRequest = Type("CacheSetRequest", func() { Field(2, "key", String) Field(3, "namespace", String) Field(4, "scope", String) // Initial implementation with a single scope - Required("data", "key", "namespace", "scope") + Required("data", "key") }) diff --git a/gen/cache/service.go b/gen/cache/service.go index ec2b3af1d8b783c03c9ab4e4416a0d1eccac9b28..bfae15ea75b37201caac3dc39b8ea600f82c19b3 100644 --- a/gen/cache/service.go +++ b/gen/cache/service.go @@ -32,14 +32,14 @@ var MethodNames = [2]string{"Get", "Set"} // CacheGetRequest is the payload type of the cache service Get method. type CacheGetRequest struct { Key string - Namespace string - Scope string + Namespace *string + Scope *string } // CacheSetRequest is the payload type of the cache service Set method. type CacheSetRequest struct { Data interface{} Key string - Namespace string - Scope string + Namespace *string + Scope *string } diff --git a/gen/http/cache/client/cli.go b/gen/http/cache/client/cli.go index 6502a89ae3ee866ac1389db01de6fa73d87081c5..813a41a7f13f7eb4f83ad939e50e08e0a813f1a9 100644 --- a/gen/http/cache/client/cli.go +++ b/gen/http/cache/client/cli.go @@ -20,13 +20,17 @@ func BuildGetPayload(cacheGetKey string, cacheGetNamespace string, cacheGetScope { key = cacheGetKey } - var namespace string + var namespace *string { - namespace = cacheGetNamespace + if cacheGetNamespace != "" { + namespace = &cacheGetNamespace + } } - var scope string + var scope *string { - scope = cacheGetScope + if cacheGetScope != "" { + scope = &cacheGetScope + } } v := &cache.CacheGetRequest{} v.Key = key @@ -50,13 +54,17 @@ func BuildSetPayload(cacheSetBody string, cacheSetKey string, cacheSetNamespace { key = cacheSetKey } - var namespace string + var namespace *string { - namespace = cacheSetNamespace + if cacheSetNamespace != "" { + namespace = &cacheSetNamespace + } } - var scope string + var scope *string { - scope = cacheSetScope + if cacheSetScope != "" { + scope = &cacheSetScope + } } v := body res := &cache.CacheSetRequest{ diff --git a/gen/http/cache/client/encode_decode.go b/gen/http/cache/client/encode_decode.go index be26cb474f49755658db16e76b03237c882009ed..623765fd4fc138164971ad9ba9dcd35000665f70 100644 --- a/gen/http/cache/client/encode_decode.go +++ b/gen/http/cache/client/encode_decode.go @@ -45,12 +45,12 @@ func EncodeGetRequest(encoder func(*http.Request) goahttp.Encoder) func(*http.Re head := p.Key req.Header.Set("x-cache-key", head) } - { - head := p.Namespace + if p.Namespace != nil { + head := *p.Namespace req.Header.Set("x-cache-namespace", head) } - { - head := p.Scope + if p.Scope != nil { + head := *p.Scope req.Header.Set("x-cache-scope", head) } return nil @@ -119,12 +119,12 @@ func EncodeSetRequest(encoder func(*http.Request) goahttp.Encoder) func(*http.Re head := p.Key req.Header.Set("x-cache-key", head) } - { - head := p.Namespace + if p.Namespace != nil { + head := *p.Namespace req.Header.Set("x-cache-namespace", head) } - { - head := p.Scope + if p.Scope != nil { + head := *p.Scope req.Header.Set("x-cache-scope", head) } body := p.Data diff --git a/gen/http/cache/server/encode_decode.go b/gen/http/cache/server/encode_decode.go index b6587e807c913d0cd21fc1001df3baddd7353f34..a58b4a904640446b1bd0173754f71e47cf72aed3 100644 --- a/gen/http/cache/server/encode_decode.go +++ b/gen/http/cache/server/encode_decode.go @@ -35,21 +35,21 @@ func DecodeGetRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Dec return func(r *http.Request) (interface{}, error) { var ( key string - namespace string - scope string + namespace *string + scope *string err error ) key = r.Header.Get("x-cache-key") if key == "" { err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-key", "header")) } - namespace = r.Header.Get("x-cache-namespace") - if namespace == "" { - err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-namespace", "header")) + namespaceRaw := r.Header.Get("x-cache-namespace") + if namespaceRaw != "" { + namespace = &namespaceRaw } - scope = r.Header.Get("x-cache-scope") - if scope == "" { - err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-scope", "header")) + scopeRaw := r.Header.Get("x-cache-scope") + if scopeRaw != "" { + scope = &scopeRaw } if err != nil { return nil, err @@ -87,20 +87,20 @@ func DecodeSetRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Dec var ( key string - namespace string - scope string + namespace *string + scope *string ) key = r.Header.Get("x-cache-key") if key == "" { err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-key", "header")) } - namespace = r.Header.Get("x-cache-namespace") - if namespace == "" { - err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-namespace", "header")) + namespaceRaw := r.Header.Get("x-cache-namespace") + if namespaceRaw != "" { + namespace = &namespaceRaw } - scope = r.Header.Get("x-cache-scope") - if scope == "" { - err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-scope", "header")) + scopeRaw := r.Header.Get("x-cache-scope") + if scopeRaw != "" { + scope = &scopeRaw } if err != nil { return nil, err diff --git a/gen/http/cache/server/types.go b/gen/http/cache/server/types.go index c9d87f134992134625b260b82a3ceee77e0a0ee6..3efce37e69eeeb477c4424845f5f22afb2197710 100644 --- a/gen/http/cache/server/types.go +++ b/gen/http/cache/server/types.go @@ -12,7 +12,7 @@ import ( ) // NewGetCacheGetRequest builds a cache service Get endpoint payload. -func NewGetCacheGetRequest(key string, namespace string, scope string) *cache.CacheGetRequest { +func NewGetCacheGetRequest(key string, namespace *string, scope *string) *cache.CacheGetRequest { v := &cache.CacheGetRequest{} v.Key = key v.Namespace = namespace @@ -22,7 +22,7 @@ func NewGetCacheGetRequest(key string, namespace string, scope string) *cache.Ca } // NewSetCacheSetRequest builds a cache service Set endpoint payload. -func NewSetCacheSetRequest(body interface{}, key string, namespace string, scope string) *cache.CacheSetRequest { +func NewSetCacheSetRequest(body interface{}, key string, namespace *string, scope *string) *cache.CacheSetRequest { v := body res := &cache.CacheSetRequest{ Data: v, diff --git a/gen/http/cli/cache/cli.go b/gen/http/cli/cache/cli.go index 007ace38ca77de84e7e57b6d6a23f783ef89adbe..2b5bb1e94f74ca1ec99b453d3beaff6e7a5ab6aa 100644 --- a/gen/http/cli/cache/cli.go +++ b/gen/http/cli/cache/cli.go @@ -56,14 +56,14 @@ func ParseEndpoint( cacheGetFlags = flag.NewFlagSet("get", flag.ExitOnError) cacheGetKeyFlag = cacheGetFlags.String("key", "REQUIRED", "") - cacheGetNamespaceFlag = cacheGetFlags.String("namespace", "REQUIRED", "") - cacheGetScopeFlag = cacheGetFlags.String("scope", "REQUIRED", "") + cacheGetNamespaceFlag = cacheGetFlags.String("namespace", "", "") + cacheGetScopeFlag = cacheGetFlags.String("scope", "", "") cacheSetFlags = flag.NewFlagSet("set", flag.ExitOnError) cacheSetBodyFlag = cacheSetFlags.String("body", "REQUIRED", "") cacheSetKeyFlag = cacheSetFlags.String("key", "REQUIRED", "") - cacheSetNamespaceFlag = cacheSetFlags.String("namespace", "REQUIRED", "") - cacheSetScopeFlag = cacheSetFlags.String("scope", "REQUIRED", "") + cacheSetNamespaceFlag = cacheSetFlags.String("namespace", "", "") + cacheSetScopeFlag = cacheSetFlags.String("scope", "", "") ) healthFlags.Usage = healthUsage healthLivenessFlags.Usage = healthLivenessUsage diff --git a/gen/http/openapi.json b/gen/http/openapi.json index b9d430311b5a1b01b8f6f061e08c090c3e191545..2370bc6db32845023a201b929d950f54a833cbe5 100644 --- a/gen/http/openapi.json +++ b/gen/http/openapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8083","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","produces":["application/json"],"parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8083","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","produces":["application/json"],"parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}}}} \ No newline at end of file diff --git a/gen/http/openapi.yaml b/gen/http/openapi.yaml index b1bac2cdadd957be492a9618414d12516397b6b2..4cd6fad9099a1009f12801ad407bb893254fef2a 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -53,12 +53,12 @@ paths: - name: x-cache-namespace in: header description: Cache entry namespace - required: true + required: false type: string - name: x-cache-scope in: header description: Cache entry scope - required: true + required: false type: string responses: "200": @@ -83,12 +83,12 @@ paths: - name: x-cache-namespace in: header description: Cache entry namespace - required: true + required: false type: string - name: x-cache-scope in: header description: Cache entry scope - required: true + required: false type: string - name: any in: body diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json index 0ce517d7b5de2092ed45e6bb357aa14c8556a7c9..e32b4621b30aed7e9fef74ade57dad6b2249c0c1 100644 --- a/gen/http/openapi3.json +++ b/gen/http/openapi3.json @@ -1 +1 @@ -{"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8083","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Qui iusto enim est dolores dolorem et.","format":"binary"},"example":"Quisquam ab dolores distinctio quis."}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Et illum fugiat ut.","format":"binary"},"example":"Optio aliquam error nam."}}},"responses":{"201":{"description":"Created response."}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."}]} \ No newline at end of file +{"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8083","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Qui iusto enim est dolores dolorem et.","format":"binary"},"example":"Quisquam ab dolores distinctio quis."}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Et illum fugiat ut.","format":"binary"},"example":"Optio aliquam error nam."}}},"responses":{"201":{"description":"Created response."}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."}]} \ No newline at end of file diff --git a/gen/http/openapi3.yaml b/gen/http/openapi3.yaml index b936940cde419698a7133a062edd0436c1650930..625d26c77e0a17d0ab83f4257520e224c556580c 100644 --- a/gen/http/openapi3.yaml +++ b/gen/http/openapi3.yaml @@ -47,7 +47,6 @@ paths: in: header description: Cache entry namespace allowEmptyValue: true - required: true schema: type: string description: Cache entry namespace @@ -57,7 +56,6 @@ paths: in: header description: Cache entry scope allowEmptyValue: true - required: true schema: type: string description: Cache entry scope @@ -94,7 +92,6 @@ paths: in: header description: Cache entry namespace allowEmptyValue: true - required: true schema: type: string description: Cache entry namespace @@ -104,7 +101,6 @@ paths: in: header description: Cache entry scope allowEmptyValue: true - required: true schema: type: string description: Cache entry scope diff --git a/go.mod b/go.mod index e454d03a8e3ef048190790a11f09abe40c2af08c..616009be42a045932c4f1d15735bcb317052dad1 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( code.vereign.com/gaiax/tsa/golib v0.0.0-20220321093827-5fdf8f34aad9 github.com/go-redis/redis/v8 v8.11.5 github.com/kelseyhightower/envconfig v1.4.0 + github.com/stretchr/testify v1.7.0 go.uber.org/zap v1.21.0 goa.design/goa/v3 v3.7.0 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c @@ -13,6 +14,7 @@ require ( require ( github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598 // indirect github.com/dimfeld/httptreemux/v5 v5.4.0 // indirect @@ -21,6 +23,7 @@ require ( github.com/gorilla/websocket v1.5.0 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect github.com/manveru/faker v0.0.0-20171103152722-9fbc68a78c4d // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/sergi/go-diff v1.2.0 // indirect github.com/smartystreets/assertions v1.2.1 // indirect github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea // indirect @@ -31,4 +34,5 @@ require ( golang.org/x/tools v0.1.10 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/internal/service/cache/cachefakes/fake_cache.go b/internal/service/cache/cachefakes/fake_cache.go new file mode 100644 index 0000000000000000000000000000000000000000..3f6f044f8ab72d64a1dfa88934c3fad03d574b56 --- /dev/null +++ b/internal/service/cache/cachefakes/fake_cache.go @@ -0,0 +1,205 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package cachefakes + +import ( + "context" + "sync" + "time" + + "code.vereign.com/gaiax/tsa/cache/internal/service/cache" +) + +type FakeCache struct { + GetStub func(context.Context, string) ([]byte, error) + getMutex sync.RWMutex + getArgsForCall []struct { + arg1 context.Context + arg2 string + } + getReturns struct { + result1 []byte + result2 error + } + getReturnsOnCall map[int]struct { + result1 []byte + result2 error + } + SetStub func(context.Context, string, []byte, time.Duration) error + setMutex sync.RWMutex + setArgsForCall []struct { + arg1 context.Context + arg2 string + arg3 []byte + arg4 time.Duration + } + setReturns struct { + result1 error + } + setReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeCache) Get(arg1 context.Context, arg2 string) ([]byte, error) { + fake.getMutex.Lock() + ret, specificReturn := fake.getReturnsOnCall[len(fake.getArgsForCall)] + fake.getArgsForCall = append(fake.getArgsForCall, struct { + arg1 context.Context + arg2 string + }{arg1, arg2}) + stub := fake.GetStub + fakeReturns := fake.getReturns + fake.recordInvocation("Get", []interface{}{arg1, arg2}) + fake.getMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeCache) GetCallCount() int { + fake.getMutex.RLock() + defer fake.getMutex.RUnlock() + return len(fake.getArgsForCall) +} + +func (fake *FakeCache) GetCalls(stub func(context.Context, string) ([]byte, error)) { + fake.getMutex.Lock() + defer fake.getMutex.Unlock() + fake.GetStub = stub +} + +func (fake *FakeCache) GetArgsForCall(i int) (context.Context, string) { + fake.getMutex.RLock() + defer fake.getMutex.RUnlock() + argsForCall := fake.getArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeCache) GetReturns(result1 []byte, result2 error) { + fake.getMutex.Lock() + defer fake.getMutex.Unlock() + fake.GetStub = nil + fake.getReturns = struct { + result1 []byte + result2 error + }{result1, result2} +} + +func (fake *FakeCache) GetReturnsOnCall(i int, result1 []byte, result2 error) { + fake.getMutex.Lock() + defer fake.getMutex.Unlock() + fake.GetStub = nil + if fake.getReturnsOnCall == nil { + fake.getReturnsOnCall = make(map[int]struct { + result1 []byte + result2 error + }) + } + fake.getReturnsOnCall[i] = struct { + result1 []byte + result2 error + }{result1, result2} +} + +func (fake *FakeCache) Set(arg1 context.Context, arg2 string, arg3 []byte, arg4 time.Duration) error { + var arg3Copy []byte + if arg3 != nil { + arg3Copy = make([]byte, len(arg3)) + copy(arg3Copy, arg3) + } + fake.setMutex.Lock() + ret, specificReturn := fake.setReturnsOnCall[len(fake.setArgsForCall)] + fake.setArgsForCall = append(fake.setArgsForCall, struct { + arg1 context.Context + arg2 string + arg3 []byte + arg4 time.Duration + }{arg1, arg2, arg3Copy, arg4}) + stub := fake.SetStub + fakeReturns := fake.setReturns + fake.recordInvocation("Set", []interface{}{arg1, arg2, arg3Copy, arg4}) + fake.setMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3, arg4) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeCache) SetCallCount() int { + fake.setMutex.RLock() + defer fake.setMutex.RUnlock() + return len(fake.setArgsForCall) +} + +func (fake *FakeCache) SetCalls(stub func(context.Context, string, []byte, time.Duration) error) { + fake.setMutex.Lock() + defer fake.setMutex.Unlock() + fake.SetStub = stub +} + +func (fake *FakeCache) SetArgsForCall(i int) (context.Context, string, []byte, time.Duration) { + fake.setMutex.RLock() + defer fake.setMutex.RUnlock() + argsForCall := fake.setArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 +} + +func (fake *FakeCache) SetReturns(result1 error) { + fake.setMutex.Lock() + defer fake.setMutex.Unlock() + fake.SetStub = nil + fake.setReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeCache) SetReturnsOnCall(i int, result1 error) { + fake.setMutex.Lock() + defer fake.setMutex.Unlock() + fake.SetStub = nil + if fake.setReturnsOnCall == nil { + fake.setReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.setReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeCache) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.getMutex.RLock() + defer fake.getMutex.RUnlock() + fake.setMutex.RLock() + defer fake.setMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeCache) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ cache.Cache = new(FakeCache) diff --git a/internal/service/cache/service.go b/internal/service/cache/service.go index 4644cc015ed6f44f86ea7dc4b6ead5f73420f384..dddcc536b7fa04bbed72147d8a5fa93b200589e9 100644 --- a/internal/service/cache/service.go +++ b/internal/service/cache/service.go @@ -3,7 +3,6 @@ package cache import ( "context" "encoding/json" - "fmt" "time" "go.uber.org/zap" @@ -12,6 +11,8 @@ import ( "code.vereign.com/gaiax/tsa/golib/errors" ) +//go:generate counterfeiter . Cache + type Cache interface { Get(ctx context.Context, key string) ([]byte, error) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error @@ -30,17 +31,26 @@ func New(cache Cache, logger *zap.Logger) *Service { } func (s *Service) Get(ctx context.Context, req *cache.CacheGetRequest) (interface{}, error) { - var operation = zap.String("operation", "get") - if req.Key == "" || req.Namespace == "" || req.Scope == "" { - s.logger.Error("bad request: missing key or namespace or scopes", operation) - return nil, errors.New(errors.BadRequest, "bad request") + logger := s.logger.With(zap.String("operation", "get")) + + if req.Key == "" { + logger.Error("bad request: missing key") + return nil, errors.New(errors.BadRequest, "missing key") + } + + var namespace, scope string + if req.Namespace != nil { + namespace = *req.Namespace + } + if req.Scope != nil { + scope = *req.Scope } // create key from the input fields - key := makeCacheKey(req.Namespace, req.Scope, req.Key) + key := makeCacheKey(req.Key, namespace, scope) data, err := s.cache.Get(ctx, key) if err != nil { - s.logger.Error("error getting value from cache", zap.String("key", key), zap.Error(err)) + logger.Error("error getting value from cache", zap.String("key", key), zap.Error(err)) if errors.Is(errors.NotFound, err) { return nil, errors.New("key not found in cache", err) } @@ -49,7 +59,7 @@ func (s *Service) Get(ctx context.Context, req *cache.CacheGetRequest) (interfac var decodedValue interface{} if err := json.Unmarshal(data, &decodedValue); err != nil { - s.logger.Error("cannot decode json value from cache", zap.Error(err)) + logger.Error("cannot decode json value from cache", zap.Error(err)) return nil, errors.New("cannot decode json value from cache", err) } @@ -57,32 +67,47 @@ func (s *Service) Get(ctx context.Context, req *cache.CacheGetRequest) (interfac } func (s *Service) Set(ctx context.Context, req *cache.CacheSetRequest) error { - var operation = zap.String("operation", "set") + logger := s.logger.With(zap.String("operation", "set")) - if req.Key == "" || req.Namespace == "" || req.Scope == "" { - s.logger.Error("bad request: missing key or namespace or scope or data", operation) - return errors.New(errors.BadRequest, "bad request") + if req.Key == "" { + logger.Error("bad request: missing key") + return errors.New(errors.BadRequest, "missing key") + } + + var namespace, scope string + if req.Namespace != nil { + namespace = *req.Namespace + } + if req.Scope != nil { + scope = *req.Scope } // TODO(kinkov): issue #3 - evaluate key metadata (key, namespace and scope) and set TTL over a policy execution // create key from the input fields - key := makeCacheKey(req.Namespace, req.Scope, req.Key) + key := makeCacheKey(req.Key, namespace, scope) // encode payload to json bytes for storing in cache value, err := json.Marshal(req.Data) if err != nil { - s.logger.Error("error encode payload to json", zap.Error(err), operation) - return errors.New("error encode payload to json", err) + logger.Error("error encode payload to json", zap.Error(err)) + return errors.New(errors.BadRequest, "cannot encode payload to json", err) } if err := s.cache.Set(ctx, key, value, 0); err != nil { - s.logger.Error("error setting value in cache", zap.Error(err), operation) - return errors.New("error setting value in cache", err) + logger.Error("error storing value in cache", zap.Error(err)) + return errors.New("error storing value in cache", err) } return nil } -func makeCacheKey(namespace, scope, key string) string { - return fmt.Sprintf("%s,%s,%s", namespace, scope, key) +func makeCacheKey(key, namespace, scope string) string { + k := key + if namespace != "" { + k += "," + namespace + } + if scope != "" { + k += "," + scope + } + return k } diff --git a/internal/service/cache/service_test.go b/internal/service/cache/service_test.go new file mode 100644 index 0000000000000000000000000000000000000000..4e09e0314fde2420325949fbbd17e6e3f8d4d338 --- /dev/null +++ b/internal/service/cache/service_test.go @@ -0,0 +1,185 @@ +package cache_test + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "go.uber.org/zap" + + goacache "code.vereign.com/gaiax/tsa/cache/gen/cache" + "code.vereign.com/gaiax/tsa/cache/internal/service/cache" + "code.vereign.com/gaiax/tsa/cache/internal/service/cache/cachefakes" + "code.vereign.com/gaiax/tsa/golib/errors" + "code.vereign.com/gaiax/tsa/golib/ptr" +) + +func TestNew(t *testing.T) { + svc := cache.New(nil, zap.NewNop()) + assert.Implements(t, (*goacache.Service)(nil), svc) +} + +func TestService_Get(t *testing.T) { + tests := []struct { + name string + cache *cachefakes.FakeCache + req *goacache.CacheGetRequest + + res interface{} + errkind errors.Kind + errtext string + }{ + { + name: "missing cache key", + req: &goacache.CacheGetRequest{}, + errkind: errors.BadRequest, + errtext: "missing key", + }, + { + name: "error getting value from cache", + req: &goacache.CacheGetRequest{ + Key: "key", + Namespace: ptr.String("namespace"), + Scope: ptr.String("scope"), + }, + cache: &cachefakes.FakeCache{ + GetStub: func(ctx context.Context, key string) ([]byte, error) { + return nil, errors.New("some error") + }, + }, + errkind: errors.Unknown, + errtext: "some error", + }, + { + name: "key not found in cache", + req: &goacache.CacheGetRequest{ + Key: "key", + Namespace: ptr.String("namespace"), + Scope: ptr.String("scope"), + }, + cache: &cachefakes.FakeCache{ + GetStub: func(ctx context.Context, key string) ([]byte, error) { + return nil, errors.New(errors.NotFound) + }, + }, + errkind: errors.NotFound, + errtext: "key not found in cache", + }, + { + name: "value returned from cache is not json", + req: &goacache.CacheGetRequest{ + Key: "key", + Namespace: ptr.String("namespace"), + Scope: ptr.String("scope"), + }, + cache: &cachefakes.FakeCache{ + GetStub: func(ctx context.Context, key string) ([]byte, error) { + return []byte("boom"), nil + }, + }, + errkind: errors.Unknown, + errtext: "cannot decode json value from cache", + }, + { + name: "json value is successfully returned from cache", + req: &goacache.CacheGetRequest{ + Key: "key", + Namespace: ptr.String("namespace"), + Scope: ptr.String("scope"), + }, + cache: &cachefakes.FakeCache{ + GetStub: func(ctx context.Context, key string) ([]byte, error) { + return []byte(`{"test":"value"}`), nil + }, + }, + res: map[string]interface{}{"test": "value"}, + errtext: "", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + svc := cache.New(test.cache, zap.NewNop()) + res, err := svc.Get(context.Background(), test.req) + if err == nil { + assert.Empty(t, test.errtext) + assert.Equal(t, test.res, res) + } else { + assert.Nil(t, res) + assert.Error(t, err) + + e, ok := err.(*errors.Error) + assert.True(t, ok) + assert.Equal(t, test.errkind, e.Kind) + assert.Contains(t, e.Error(), test.errtext) + } + }) + } +} + +func TestService_Set(t *testing.T) { + tests := []struct { + name string + cache *cachefakes.FakeCache + req *goacache.CacheSetRequest + + res interface{} + errkind errors.Kind + errtext string + }{ + { + name: "missing cache key", + req: &goacache.CacheSetRequest{}, + errkind: errors.BadRequest, + errtext: "missing key", + }, + { + name: "error setting value in cache", + req: &goacache.CacheSetRequest{ + Key: "key", + Namespace: ptr.String("namespace"), + Scope: ptr.String("scope"), + Data: map[string]interface{}{"test": "value"}, + }, + cache: &cachefakes.FakeCache{ + SetStub: func(ctx context.Context, key string, value []byte, ttl time.Duration) error { + return errors.New(errors.Timeout, "some error") + }, + }, + errkind: errors.Timeout, + errtext: "some error", + }, + { + name: "successfully set value in cache", + req: &goacache.CacheSetRequest{ + Key: "key", + Namespace: ptr.String("namespace"), + Scope: ptr.String("scope"), + Data: map[string]interface{}{"test": "value"}, + }, + cache: &cachefakes.FakeCache{ + SetStub: func(ctx context.Context, key string, value []byte, ttl time.Duration) error { + return nil + }, + }, + errtext: "", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + svc := cache.New(test.cache, zap.NewNop()) + err := svc.Set(context.Background(), test.req) + if err == nil { + assert.Empty(t, test.errtext) + } else { + assert.Error(t, err) + e, ok := err.(*errors.Error) + assert.True(t, ok) + assert.Equal(t, test.errkind, e.Kind) + assert.Contains(t, e.Error(), test.errtext) + } + }) + } +} diff --git a/vendor/code.vereign.com/gaiax/tsa/golib/ptr/ptr.go b/vendor/code.vereign.com/gaiax/tsa/golib/ptr/ptr.go new file mode 100644 index 0000000000000000000000000000000000000000..fd522b7a70d7449dccc01ee3b2b3181eb9e7600e Binary files /dev/null and b/vendor/code.vereign.com/gaiax/tsa/golib/ptr/ptr.go differ diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..bc52e96f2b0ea97cc450e2fefbbb4cc430d1ac5a Binary files /dev/null and b/vendor/github.com/davecgh/go-spew/LICENSE differ diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go new file mode 100644 index 0000000000000000000000000000000000000000..792994785e36ca74c5545a0d93a2cdecda006678 Binary files /dev/null and b/vendor/github.com/davecgh/go-spew/spew/bypass.go differ diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go new file mode 100644 index 0000000000000000000000000000000000000000..205c28d68c474e4497e6aa1ce8b9fdeb260f4586 Binary files /dev/null and b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go differ diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go new file mode 100644 index 0000000000000000000000000000000000000000..1be8ce9457612e02a64c01b2321d087ebd6415f2 Binary files /dev/null and b/vendor/github.com/davecgh/go-spew/spew/common.go differ diff --git a/vendor/github.com/davecgh/go-spew/spew/config.go b/vendor/github.com/davecgh/go-spew/spew/config.go new file mode 100644 index 0000000000000000000000000000000000000000..2e3d22f312026ff2c863bbffcbc88b7f6fb942f5 Binary files /dev/null and b/vendor/github.com/davecgh/go-spew/spew/config.go differ diff --git a/vendor/github.com/davecgh/go-spew/spew/doc.go b/vendor/github.com/davecgh/go-spew/spew/doc.go new file mode 100644 index 0000000000000000000000000000000000000000..aacaac6f1e1e936ee0022c00e139756c9bdc2b3e Binary files /dev/null and b/vendor/github.com/davecgh/go-spew/spew/doc.go differ diff --git a/vendor/github.com/davecgh/go-spew/spew/dump.go b/vendor/github.com/davecgh/go-spew/spew/dump.go new file mode 100644 index 0000000000000000000000000000000000000000..f78d89fc1f6c454df58cd1e346817db6e30c4299 Binary files /dev/null and b/vendor/github.com/davecgh/go-spew/spew/dump.go differ diff --git a/vendor/github.com/davecgh/go-spew/spew/format.go b/vendor/github.com/davecgh/go-spew/spew/format.go new file mode 100644 index 0000000000000000000000000000000000000000..b04edb7d7ac278ae0b873a1335f37822a00bfd7c Binary files /dev/null and b/vendor/github.com/davecgh/go-spew/spew/format.go differ diff --git a/vendor/github.com/davecgh/go-spew/spew/spew.go b/vendor/github.com/davecgh/go-spew/spew/spew.go new file mode 100644 index 0000000000000000000000000000000000000000..32c0e338825308f6b9b4d0407aa5682a23e2dc9c Binary files /dev/null and b/vendor/github.com/davecgh/go-spew/spew/spew.go differ diff --git a/vendor/github.com/pmezard/go-difflib/LICENSE b/vendor/github.com/pmezard/go-difflib/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c67dad612a3dfca2b84599c640798d7be7d46728 Binary files /dev/null and b/vendor/github.com/pmezard/go-difflib/LICENSE differ diff --git a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go b/vendor/github.com/pmezard/go-difflib/difflib/difflib.go new file mode 100644 index 0000000000000000000000000000000000000000..003e99fadb4f189565b409b9509ecf30b752d25a Binary files /dev/null and b/vendor/github.com/pmezard/go-difflib/difflib/difflib.go differ diff --git a/vendor/github.com/stretchr/testify/LICENSE b/vendor/github.com/stretchr/testify/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..4b0421cf9ee47908beae4b4648babb75b09ee028 Binary files /dev/null and b/vendor/github.com/stretchr/testify/LICENSE differ diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare.go b/vendor/github.com/stretchr/testify/assert/assertion_compare.go new file mode 100644 index 0000000000000000000000000000000000000000..41649d26792461a0e999695e0c91a15d72b5898a Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/assertion_compare.go differ diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go new file mode 100644 index 0000000000000000000000000000000000000000..4dfd1229a8617f401e11efa0ad461447f31c1b3e Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/assertion_format.go differ diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl new file mode 100644 index 0000000000000000000000000000000000000000..d2bb0b81778858c364f4b3694c00cdd4c72b1c5b Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl differ diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go new file mode 100644 index 0000000000000000000000000000000000000000..25337a6f07e6e05f3f29e5493cc2ba71cc474abb Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/assertion_forward.go differ diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl new file mode 100644 index 0000000000000000000000000000000000000000..188bb9e174397295062da708cc9f5207e2331768 Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl differ diff --git a/vendor/github.com/stretchr/testify/assert/assertion_order.go b/vendor/github.com/stretchr/testify/assert/assertion_order.go new file mode 100644 index 0000000000000000000000000000000000000000..1c3b47182a726afbfb1890c5119144bad1bcf8c9 Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/assertion_order.go differ diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go new file mode 100644 index 0000000000000000000000000000000000000000..bcac4401f57fb271d4a0909e607d56d51c606e59 Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/assertions.go differ diff --git a/vendor/github.com/stretchr/testify/assert/doc.go b/vendor/github.com/stretchr/testify/assert/doc.go new file mode 100644 index 0000000000000000000000000000000000000000..c9dccc4d6cd0aad89a9ecf638d8cde1ea043a37a Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/doc.go differ diff --git a/vendor/github.com/stretchr/testify/assert/errors.go b/vendor/github.com/stretchr/testify/assert/errors.go new file mode 100644 index 0000000000000000000000000000000000000000..ac9dc9d1d6156b64c31ac0b130e7a2b1ca86f06d Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/errors.go differ diff --git a/vendor/github.com/stretchr/testify/assert/forward_assertions.go b/vendor/github.com/stretchr/testify/assert/forward_assertions.go new file mode 100644 index 0000000000000000000000000000000000000000..df189d2348f17a3d16888e2581d2a3b7a9d47e93 Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/forward_assertions.go differ diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions.go b/vendor/github.com/stretchr/testify/assert/http_assertions.go new file mode 100644 index 0000000000000000000000000000000000000000..4ed341dd28934c102aa7a40c74ee24b6555c1db1 Binary files /dev/null and b/vendor/github.com/stretchr/testify/assert/http_assertions.go differ diff --git a/vendor/gopkg.in/yaml.v3/LICENSE b/vendor/gopkg.in/yaml.v3/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..2683e4bb1f24c14aa2791e6d48ce0ecf3d8ab756 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/LICENSE differ diff --git a/vendor/gopkg.in/yaml.v3/NOTICE b/vendor/gopkg.in/yaml.v3/NOTICE new file mode 100644 index 0000000000000000000000000000000000000000..866d74a7ad79165312a2ce3904b4bdb53e6aedf7 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/NOTICE differ diff --git a/vendor/gopkg.in/yaml.v3/README.md b/vendor/gopkg.in/yaml.v3/README.md new file mode 100644 index 0000000000000000000000000000000000000000..08eb1babddfac3d8f4e006448496d0e0d1f8d720 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/README.md differ diff --git a/vendor/gopkg.in/yaml.v3/apic.go b/vendor/gopkg.in/yaml.v3/apic.go new file mode 100644 index 0000000000000000000000000000000000000000..ae7d049f182ae2419ded608e4c763487c99dff52 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/apic.go differ diff --git a/vendor/gopkg.in/yaml.v3/decode.go b/vendor/gopkg.in/yaml.v3/decode.go new file mode 100644 index 0000000000000000000000000000000000000000..df36e3a30f55508515759037e072f79fc9e9e969 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/decode.go differ diff --git a/vendor/gopkg.in/yaml.v3/emitterc.go b/vendor/gopkg.in/yaml.v3/emitterc.go new file mode 100644 index 0000000000000000000000000000000000000000..0f47c9ca8addf8e9d2e454e02842927ae825d0e9 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/emitterc.go differ diff --git a/vendor/gopkg.in/yaml.v3/encode.go b/vendor/gopkg.in/yaml.v3/encode.go new file mode 100644 index 0000000000000000000000000000000000000000..de9e72a3e638d166e96ceab3d77ce59afe6e6f8a Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/encode.go differ diff --git a/vendor/gopkg.in/yaml.v3/parserc.go b/vendor/gopkg.in/yaml.v3/parserc.go new file mode 100644 index 0000000000000000000000000000000000000000..ac66fccc059e3837d17e2a3a1bec5b6d5c398ab1 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/parserc.go differ diff --git a/vendor/gopkg.in/yaml.v3/readerc.go b/vendor/gopkg.in/yaml.v3/readerc.go new file mode 100644 index 0000000000000000000000000000000000000000..b7de0a89c462af605f889bc46ce165e5d4238add Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/readerc.go differ diff --git a/vendor/gopkg.in/yaml.v3/resolve.go b/vendor/gopkg.in/yaml.v3/resolve.go new file mode 100644 index 0000000000000000000000000000000000000000..64ae888057a5aa24c5a3a6ca0fcb08a06269e3ad Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/resolve.go differ diff --git a/vendor/gopkg.in/yaml.v3/scannerc.go b/vendor/gopkg.in/yaml.v3/scannerc.go new file mode 100644 index 0000000000000000000000000000000000000000..ca0070108f4ebe6a09a222075267e0ffca996e72 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/scannerc.go differ diff --git a/vendor/gopkg.in/yaml.v3/sorter.go b/vendor/gopkg.in/yaml.v3/sorter.go new file mode 100644 index 0000000000000000000000000000000000000000..9210ece7e97232891625ed08c549b92c0e9bb169 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/sorter.go differ diff --git a/vendor/gopkg.in/yaml.v3/writerc.go b/vendor/gopkg.in/yaml.v3/writerc.go new file mode 100644 index 0000000000000000000000000000000000000000..b8a116bf9a22b9911958f44904289a8c6b482bd2 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/writerc.go differ diff --git a/vendor/gopkg.in/yaml.v3/yaml.go b/vendor/gopkg.in/yaml.v3/yaml.go new file mode 100644 index 0000000000000000000000000000000000000000..8cec6da48d3ec4d8858ca622383c75e359faee1f Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/yaml.go differ diff --git a/vendor/gopkg.in/yaml.v3/yamlh.go b/vendor/gopkg.in/yaml.v3/yamlh.go new file mode 100644 index 0000000000000000000000000000000000000000..7c6d0077061933c97979f6c84cb659b17391e1a3 Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/yamlh.go differ diff --git a/vendor/gopkg.in/yaml.v3/yamlprivateh.go b/vendor/gopkg.in/yaml.v3/yamlprivateh.go new file mode 100644 index 0000000000000000000000000000000000000000..e88f9c54aecb54ed42665b2a08b66a4f03d999bc Binary files /dev/null and b/vendor/gopkg.in/yaml.v3/yamlprivateh.go differ diff --git a/vendor/modules.txt b/vendor/modules.txt index f36681cf42e13d967327c4095c04fbad9c5e8769..ad4af521473b392041f7318f49db06b68ffc74e4 100644 Binary files a/vendor/modules.txt and b/vendor/modules.txt differ