Skip to content

Commit ebd9930

Browse files
authored
Merge pull request #559 from chainifynet/feature/cache
Caching Materials Manager and Memory cache implementation
2 parents 455f47c + 1473723 commit ebd9930

29 files changed

+3687
-355
lines changed

.golangci.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ linters:
5959
- zerologlint
6060
# enable these on the next golangci-lint release:
6161
# - intrange
62-
62+
- fatcontext
63+
- iface
64+
- recvcheck
6365
linters-settings:
6466
errorlint:
6567
errorf: true

.mockery.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ with-expecter: true
22
# remove 845 fix when V3 is released
33
# https://vektra.github.io/mockery/latest/deprecations/#issue-845-fix
44
issue-845-fix: true
5+
resolve-type-alias: false
56
filename: "{{.InterfaceName}}_mock.go"
67
mock-build-tags: "mocks"
8+
disable-version-string: false
79
packages:
810
github.com/chainifynet/aws-encryption-sdk-go/pkg/model:
911
interfaces:
@@ -45,6 +47,9 @@ packages:
4547
GcmCrypter:
4648
AEADEncrypter:
4749
AEADDecrypter:
50+
CacheEntry:
51+
Cache:
52+
CacheHasher:
4853
github.com/chainifynet/aws-encryption-sdk-go/pkg/model/format:
4954
interfaces:
5055
MessageAAD:

Makefile

+21-12
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,26 @@ SDK_PKGS=./pkg/...
1414
RUN_NONE=-run NOTHING
1515
RUN_INTEG=-run '^Test_Integration_'
1616

17+
.DEFAULT_GOAL := help
18+
19+
.PHONY: help
20+
help: ## Show the help menu
21+
@echo "Usage: make <target>"
22+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
23+
1724
.PHONY: all deps mocks mocks-build-tag vet lint lint-ci lint-local unit
1825
all: unit ## Run all the checks and tests
1926
@echo "All checks and tests"
2027

21-
deps:
28+
deps: ## Install development dependencies
2229
@echo "Installing dependencies"
2330
@go mod download -x all
2431
@go install gotest.tools/gotestsum@latest
2532
@go install github.com/golangci/golangci-lint/cmd/[email protected]
2633
@go install github.com/vektra/mockery/[email protected]
2734
@#go get github.com/stretchr/testify/[email protected]
2835

29-
mocks:
36+
mocks: ## Generate mocks
3037
@echo "Generating mocks"
3138
@mockery
3239
@#$(MAKE) mocks-build-tag
@@ -39,19 +46,21 @@ mocks-build-tag:
3946
find ./mocks/ -name '*_mock.go' -exec sed -i '/^package/ i //go:build mocks\n' {} +; \
4047
fi
4148

42-
lint: mocks vet lint-ci
49+
lint: mocks vet lint-ci ## Generate mocks and run all linters
4350

4451
lint-ci:
4552
@echo "Running golangci-lint"
4653
@golangci-lint run --build-tags=${CI_TAGS} --out-format=colored-line-number ./...
4754

4855
lint-local:
4956
@echo "Running golangci-lint locally"
57+
@which golangci-lint
58+
@golangci-lint --version
5059
@golangci-lint run --build-tags=${CI_TAGS} ./...
5160

5261
.PHONY: examples lint-examples run-examples
5362

54-
examples: lint-examples run-examples
63+
examples: lint-examples run-examples ## Lint and run all examples
5564

5665
lint-examples:
5766
@for dir in $(shell find ./example -type d -mindepth 1 -maxdepth 1); do \
@@ -67,15 +76,15 @@ run-examples:
6776
echo "================"; \
6877
done
6978

70-
vet:
79+
vet: ## Run go vet
7180
@go vet ${BUILD_TAGS} --all ${SDK_PKGS}
7281

7382
##
7483
# Unit tests
7584
##
7685
.PHONY: unit-race unit-pkg
7786

78-
unit: lint unit-pkg
87+
unit: lint unit-pkg ## Run all unit tests
7988

8089
unit-pkg:
8190
@gotestsum -f ${GOTESTSUM_FMT} -- -timeout=4m ${BUILD_TAGS} ${SDK_PKGS}
@@ -90,9 +99,9 @@ unit-race:
9099

91100
e2e: lint e2e-deps e2e-test-cli e2e-test-short
92101

93-
e2e-test: e2e-test-cli e2e-test-short
102+
e2e-test: e2e-test-cli e2e-test-short ## Run e2e short integration tests
94103

95-
e2e-deps:
104+
e2e-deps: ## Install e2e dependencies
96105
@echo "Installing e2e dependencies"
97106
@pip install aws-encryption-sdk-cli
98107
@aws-encryption-cli --version
@@ -106,11 +115,11 @@ e2e-test-short:
106115
@echo "Running e2e short tests"
107116
@gotestsum -f ${GOTESTSUM_FMT} -- -short -timeout=10m -tags "integration" ${RUN_INTEG} ./test/e2e/...
108117

109-
e2e-test-full:
118+
e2e-test-full: ## Run all e2e integration tests
110119
@echo "Running full e2e tests, it will take a while"
111120
@gotestsum -f ${GOTESTSUM_FMT} -- -timeout=15m -tags "integration" ${RUN_INTEG} ./test/e2e/...
112121

113-
e2e-test-slow:
122+
e2e-test-slow: ## Run all slow e2e integration tests
114123
@echo "Running very slow e2e tests"
115124
@gotestsum -f testname -- -timeout=30m -tags "integration,slow" ${RUN_INTEG} ./test/e2e/...
116125

@@ -120,12 +129,12 @@ e2e-test-slow:
120129

121130
.PHONY: test-cover cover-html
122131

123-
test-cover:
132+
test-cover: ## Run tests with coverage
124133
@#CGO_ENABLED=1 go test -count=1 -coverpkg=./... -covermode=atomic -coverprofile coverage.out ./...
125134
@CGO_ENABLED=1 go test -timeout=10m -tags example,mocks,codegen,integration -cpu=2 -count=1 -coverpkg=./... -covermode=atomic -coverprofile=coverage.out ./pkg/...
126135
@#CGO_ENABLED=1 go test -tags ${CI_TAGS} -count=1 -coverpkg=./... -covermode=atomic -coverprofile coverage.out ./pkg/...
127136
@grep -v -E -f .covignore coverage.out > coverage.filtered.out
128137
@mv coverage.filtered.out coverage.out
129138

130-
cover-html:
139+
cover-html: ## Convert coverage to HTML report
131140
@go tool cover -html=coverage.out -o coverage.html

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# AWS Encryption SDK for Go
22

3+
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)
34
[![Go Unit](https://github.com/chainifynet/aws-encryption-sdk-go/actions/workflows/go-unit.yml/badge.svg?branch=main)](https://github.com/chainifynet/aws-encryption-sdk-go/actions/workflows/go-unit.yml)
45
[![Go E2E](https://github.com/chainifynet/aws-encryption-sdk-go/actions/workflows/go-e2e.yml/badge.svg?branch=main)](https://github.com/chainifynet/aws-encryption-sdk-go/actions/workflows/go-e2e.yml)
56
[![Go Report Card](https://goreportcard.com/badge/github.com/chainifynet/aws-encryption-sdk-go)](https://goreportcard.com/report/github.com/chainifynet/aws-encryption-sdk-go)
67
[![codecov](https://codecov.io/gh/chainifynet/aws-encryption-sdk-go/graph/badge.svg?token=YPZT7IOJMM)](https://codecov.io/gh/chainifynet/aws-encryption-sdk-go)
78
![Code style: gofmt](https://img.shields.io/badge/code_style-gofmt-00ADD8.svg)
89
[![Go Reference](https://pkg.go.dev/badge/github.com/chainifynet/aws-encryption-sdk-go.svg)](https://pkg.go.dev/github.com/chainifynet/aws-encryption-sdk-go)
9-
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fchainifynet%2Faws-encryption-sdk-go.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fchainifynet%2Faws-encryption-sdk-go?ref=badge_shield)
1010

1111
This project is an implementation of the [AWS Encryption SDK](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/reference.html) for the Go programming language, providing a set of libraries for developers to easily add encryption and decryption functionality to their Go applications. This implementation is inspired by the [aws-encryption-sdk-python](https://github.com/aws/aws-encryption-sdk-python) and follows the [AWS Encryption SDK specification](https://github.com/awslabs/aws-encryption-sdk-specification/tree/c35fbd91b28303d69813119088c44b5006395eb4) closely.
1212

@@ -26,7 +26,6 @@ This SDK aims to fill that gap, offering Go developers the tools to implement en
2626

2727
### Current Limitations
2828

29-
- Does not support the Caching Materials Manager feature yet.
3029
- Does not support KMS aliases at this stage.
3130
- Raw Master Key provider does not support RSA encryption.
3231
- Only framed content type is supported.
@@ -187,7 +186,7 @@ if err != nil {
187186

188187
## TODO
189188

190-
- [ ] Add support for Caching Materials Manager.
189+
- [x] Add support for Caching Materials Manager [#559](https://github.com/chainifynet/aws-encryption-sdk-go/pull/559).
191190
- [x] Add support for Message Format Version 1 [#170](https://github.com/chainifynet/aws-encryption-sdk-go/pull/170).
192191
- [x] Add support for AWS KMS Multi-Region Keys [#46](https://github.com/chainifynet/aws-encryption-sdk-go/pull/46).
193192
- [ ] Add support for KMS aliases.

0 commit comments

Comments
 (0)