layer8-interceptor-wasm
Version:
Layer8 interceptor for data encryption and decryption
42 lines (34 loc) • 1.43 kB
Plain Text
include .env
export
.PHONY: help
.DEFAULT_GOAL := help
ARG :=
VERSION :=
define set_version
if [ -f ./bin/version.txt ]; then \
VERSION=$(shell cat ./bin/version.txt | tr -d '\n'); \
else \
VERSION=0.0.1; \
echo "$(VERSION)" > ./bin/version.txt; \
fi
endef
define base64_encode
mkdir -p ./dist/`dirname $(1) | cut -d'/' -f3` && \
base64 -w 0 $(1) | sed 's/^/"/' | sed 's/$$/"/' > ./dist/`basename $(1) | cut -d'.' -f1`.json && \
echo "Encoded $(1) to ./dist/`basename $(1) | cut -d'.' -f1`.json";
endef
help: ## Show this help message
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m<target>\033[0m\n\n"} /^[a-zA-Z_-]+:.*?##/ { printf "\033[36m%-10s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
build: ## Build WASM Interceptor for the current version
@$(call set_version)
@GOOS=js GOARCH=wasm go build -ldflags="-X main.Layer8Scheme=$(LAYER8_PROXY_SCHEME) -X main.Layer8Host=$(LAYER8_PROXY_DOMAIN) -X main.Layer8Port=$(LAYER8_PROXY_PORT) -X main.Layer8Version=$(VERSION)" -o ./bin/interceptor.wasm ./main.go
@echo "Built ./bin/interceptor.wasm. Encoding..."
@make encode ARG=./bin/interceptor.wasm
encode: ## Encode the file specified by ARG or all files in ./bin if no ARG is specified
@if [ -z "$(ARG)" ]; then \
for file in `find ./bin -type f`; do \
$(call base64_encode,$$file) \
done \
else \
$(call base64_encode,$(ARG)) \
fi