This repository has been archived by the owner on Oct 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
72 lines (57 loc) · 2.41 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
.PHONY: clean test appjs docker push mock
IMAGE ?= hjacobs/kube-web-view
GITDIFFHASH = $(shell git diff | md5sum | cut -c 1-4)
VERSION ?= $(shell git describe --tags --always --dirty=-dirty-$(GITDIFFHASH))
VERSIONPY = $(shell echo $(VERSION) | cut -d- -f 1)
TAG ?= $(VERSION)
TTYFLAGS = $(shell test -t 0 && echo "-it")
OSNAME := $(shell uname | perl -ne 'print lc($$_)')
default: docker
.PHONY: poetry
poetry:
poetry install
.PHONY: test
test: poetry lint test.unit test.e2e
.PHONY: lint
lint:
poetry run pre-commit run --all-files
.PHONY: test.unit
test.unit:
poetry run coverage run --source=kube_web -m py.test tests/unit
poetry run coverage report
.PHONY: test.e2e
test.e2e: docker
env TEST_IMAGE=$(IMAGE):$(TAG) \
poetry run pytest -v -r=a \
--log-cli-level info \
--log-cli-format '%(asctime)s %(levelname)s %(message)s' \
--cluster-name kube-web-view-e2e \
tests/e2e
docker:
docker build --build-arg "VERSION=$(VERSION)" -t "$(IMAGE):$(TAG)" .
@echo 'Docker image $(IMAGE):$(TAG) can now be used.'
push: docker
docker push "$(IMAGE):$(TAG)"
docker tag "$(IMAGE):$(TAG)" "$(IMAGE):latest"
docker push "$(IMAGE):latest"
mock:
docker run $(TTYFLAGS) -p 8080:8080 "$(IMAGE):$(TAG)" --mock
.PHONY: docs
docs:
poetry run sphinx-build docs docs/_build
.PHONY: run
run:
poetry run python3 -m kube_web --show-container-logs --debug "--object-links=ingresses=javascript:alert('{name}')" "--label-links=application=javascript:alert('Application label has value {label_value}')|eye|This is a link!" --preferred-api-versions=deployments=apps/v1
.PHONY: run.kind
run.kind:
poetry run python3 -m kube_web --kubeconfig-context=kind-kube-web-view-e2e --debug --show-container-logs --search-default-resource-types=deployments,pods,configmaps --default-label-columns=pods=app "--default-hidden-columns=pods=Nominated Node" --exclude-namespaces=.*forbidden.* --resource-view-prerender-hook=kube_web.example_hooks.resource_view_prerender
.PHONY: mirror
mirror:
git push --mirror [email protected]:hjacobs/kube-web-view.git
.PHONY: version
version:
# poetry only accepts a narrow version format
sed -i "s/^version = .*/version = \"${VERSIONPY}\"/" pyproject.toml
sed -i "s/^version = .*/version = \"${VERSION}\"/" docs/conf.py
sed -i "s/^__version__ = .*/__version__ = \"${VERSION}\"/" kube_web/__init__.py
sed -i "s/v=[0-9A-Za-z._-]*/v=${VERSION}/g" kube_web/templates/base.html