-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
66 lines (49 loc) · 2.66 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
.PHONY: build
OLD_CONTAINER_NAME=flomotlik/awsinfo
CONTAINER_NAME=theserverlessway/awsinfo
CONTAINER=$(CONTAINER_NAME):dev
TEST_HELPERS=tests/test-helpers
TESTFILES=tests/commands/**/*.bats tests/commands/*.bats
GIT_COMMIT=$(shell git rev-parse HEAD)
DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
build-no-cache:
docker build --pull --no-cache -t $(CONTAINER) .
create-builder:
docker buildx create --name multiarch --bootstrap --use
release:
docker buildx build --push --platform=linux/amd64,linux/arm64 -t docker.io/theserverlessway/awsinfo .
test: build-no-cache
STACKPOSTFIX=$(shell date +%s%N) ./tests/test-helpers/bats/bin/bats $(TESTFILES)
shell: build
docker run --entrypoint bash -it -v ~/.aws:/root/.aws -v `pwd`:/awsinfo -w /awsinfo -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_DEFAULT_REGION -e AWS_PROFILE -e AWS_CONFIG_FILE $(CONTAINER)
prepare:
pip install formica-cli -U
pip install awscli -U
pip install awsie -U
command-docs:
@find scripts/commands -name "*.bash" | awk '{sub(/\.bash/, "", $$0); n=split($$0,file,"/"); sub(/index/, "", file[n]); print "* [`" file[n-1] " " file[n] " `](https://github.com/theserverlessway/awsinfo/blob/master/" $$0 ".md)" }' | sort | sed "s/[[:space:]]\+\`/\`/g"
command-docs-container: build
docker run -it --entrypoint make -v `pwd`:/awsinfo -w /awsinfo $(CONTAINER) command-docs
LOG_TIMESTAMP=$(shell echo $$(($$(date +%s) * 1000)))
LOG_STREAM_NAME=test-log-stream-$(LOG_TIMESTAMP)
put-log-message:
aws logs create-log-stream --log-group-name test-log-group --log-stream-name $(LOG_STREAM_NAME)
aws logs put-log-events --log-group-name test-log-group --log-stream-name $(LOG_STREAM_NAME) --log-events timestamp=$(LOG_TIMESTAMP),message=TestMessage-$(LOG_TIMESTAMP)
FORMICA_STACK=awsinfo-integration-user
create-integration-user:
cd tests && formica new --stack $(FORMICA_STACK) --capabilities CAPABILITY_IAM
formica deploy --stack $(FORMICA_STACK)
update-integration-user:
cd tests && formica change --stack $(FORMICA_STACK) --capabilities CAPABILITY_IAM
formica deploy --stack $(FORMICA_STACK)
Command=index
COMMANDS_DIR=scripts/commands
EXAMPLE_DIR=scripts/command_example
SERVICE=${shell }
create:
@if [ -z "$$SERVICE_NAME" ]; then read -p "Enter the Service Name: " SERVICE_NAME; fi; \
read -p "Enter the Command Name [index]: " COMMAND_NAME_INPUT; \
COMMAND_NAME=$${COMMAND_NAME_INPUT:-index}; \
mkdir -p $(COMMANDS_DIR)/$$SERVICE_NAME && cp $(EXAMPLE_DIR)/command.bash $(COMMANDS_DIR)/$$SERVICE_NAME/$$COMMAND_NAME.bash && cp $(EXAMPLE_DIR)/command.md $(COMMANDS_DIR)/$$SERVICE_NAME/$$COMMAND_NAME.md
shellcheck:
find ./scripts/ -type f -name "*.bash" -o -name "*.sh" | xargs -n 1 shellcheck -f gcc