-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
74 lines (64 loc) · 2.77 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
67
68
69
70
71
72
73
PROG_NAME=olm-mermaid-graph
#OUTPUT_TYPE=png # or pdf
OUTPUT_TYPE=svg
MERMAID_TEMP_SCRIPT=mermaid.mer
#TODO: this can go back to `latest` tag once https://github.com/mermaid-js/mermaid-cli/issues/266 is fixed
MERMAID_IMAGE=docker.io/minlag/mermaid-cli:20210503120233a6e5e8
CONTAINER_ENGINE?=docker
IMAGE?=registry.redhat.io/redhat/redhat-operator-index:v4.7
# commented out versions show various options for defining this variable,
# including pointing it at an index file created for your operator locally (see README-local-package-graph.md)
#INDEX_DB_PATH_AND_NAME?=/Users/btofel/workspace/sample-operator/test-registry.db
#INDEX_DB_PATH_AND_NAME?=olm_catalog_indexes/index.db.4.6.community-operators
INDEX_DB_PATH_AND_NAME?=olm_catalog_indexes/index.db.4.7.redhat-operators
# To introduce efficiencies for pulling new images for the Red Hat index,
# we can use the registry.redhat.io v2 api directly. Set these parameters
# if you want to only update when something newer is out there
REGISTRY_REDHAT_IO_USER?=NOTSET
REGISTRY_REDHAT_IO_PASS?=NOTSET
detected_OS := $(shell uname 2>/dev/null || echo Unknown)
.PHONY: all
all: build
.PHONY: build
build:
go build -o bin/$(PROG_NAME) ./
.PHONY: install
install:
go install
get-index:
$(CONTAINER_ENGINE) login registry.redhat.io
ifneq ($(REGISTRY_REDHAT_IO_PASS),NOTSET)
@# Don't un-@ this next line as it will show the password in the log
@./get-index.sh $(CONTAINER_ENGINE) ${IMAGE} ${REGISTRY_REDHAT_IO_USER} ${REGISTRY_REDHAT_IO_PASS}
else
@# If a user doesn't set the password, then let's just force a refresh
$(CONTAINER_ENGINE) rmi -f $(IMAGE) | true
endif
$(CONTAINER_ENGINE) run --rm --entrypoint cat $(IMAGE) /database/index.db > \
$(INDEX_DB_PATH_AND_NAME)
run: build
sed 's+olm_catalog_indexes/index.db.4.6.redhat-operators+$(INDEX_DB_PATH_AND_NAME)+' sqlite3.sql > sqlite3_exec.sql
cp $(PWD)/config.json /tmp/config.json
sqlite3 -bail -init sqlite3_exec.sql 2>/dev/null | bin/$(PROG_NAME) $(ARGS) 1>$(MERMAID_TEMP_SCRIPT)
cp $(PWD)/$(MERMAID_TEMP_SCRIPT) /tmp/$(MERMAID_TEMP_SCRIPT)
touch /tmp/$(MERMAID_TEMP_SCRIPT).$(OUTPUT_TYPE)
chmod o+w /tmp/$(MERMAID_TEMP_SCRIPT).$(OUTPUT_TYPE)
$(CONTAINER_ENGINE) pull $(MERMAID_IMAGE)
$(CONTAINER_ENGINE) run \
--privileged \
-v /tmp/$(MERMAID_TEMP_SCRIPT):/$(MERMAID_TEMP_SCRIPT) \
-v /tmp/$(MERMAID_TEMP_SCRIPT).$(OUTPUT_TYPE):/tmp/$(MERMAID_TEMP_SCRIPT).$(OUTPUT_TYPE) \
-v /tmp/config.json:/config.json \
-v /tmp:/app/.cache/yarn \
-it \
$(MERMAID_IMAGE) \
-c /config.json -i /$(MERMAID_TEMP_SCRIPT) -o /tmp/$(MERMAID_TEMP_SCRIPT).$(OUTPUT_TYPE)
echo "output $(OUTPUT_TYPE) file is /tmp/$(MERMAID_TEMP_SCRIPT).$(OUTPUT_TYPE)"
ifeq ($(detected_OS),Darwin)
open /tmp/$(MERMAID_TEMP_SCRIPT).$(OUTPUT_TYPE)
endif
.PHONY: clean
clean:
rm -r bin
rm mermaid.mer
rm /tmp/mermaid.mer.png