This repository has been archived by the owner on Apr 21, 2021. It is now read-only.
forked from SAP-archive/karydia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (67 loc) · 2.47 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
74
75
76
77
78
79
80
81
82
83
# Copyright (C) 2019 SAP SE or an SAP affiliate company. All rights reserved.
# This file is licensed under the Apache Software License, v. 2 except as
# noted otherwise in the LICENSE file.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
DEV_POSTFIX=-dev
PROD_IMAGE=eu.gcr.io/gardener-project/karydia/karydia
DEV_IMAGE=$(PROD_IMAGE)$(DEV_POSTFIX)
KUBERNETES_SERVER ?= ""
KUBECONFIG_PATH ?= "$(HOME)/.kube/config"
VERSION=$(shell git describe --tags --always --dirty)
.PHONY: all
all: build
.PHONY: build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/karydia \
-ldflags "-s -X github.com/karydia/karydia.Version=$(VERSION)" \
cli/main.go
.PHONY: build-debug
build-debug:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/karydia \
-gcflags="all=-N -l" \
-ldflags "-X github.com/karydia/karydia.Version=$(VERSION)" \
cli/main.go
.PHONY: container
container:
docker build --target prod-image -t $(PROD_IMAGE) .
.PHONY: container-dev
container-dev:
docker build --target dev-image -t $(DEV_IMAGE) .
.PHONY: deploy-dev
deploy-dev:
kubectl cp bin/karydia -n kube-system $(shell kubectl get pods -n=kube-system --selector=app=karydia --output=jsonpath='{.items[0].metadata.name}'):/usr/local/bin/karydia$(DEV_POSTFIX)
.PHONY: debug-dev
debug-dev:
kubectl port-forward -n kube-system pod/$(shell kubectl get pods -n=kube-system --selector=app=karydia --output=jsonpath='{.items[0].metadata.name}') 2345
.PHONY: codegen
codegen:
hack/update-codegen.sh
.PHONY: test-only
test-only:
go test $(shell go list ./... | grep -v /vendor/ | grep -v /tests/)
.PHONY: fmt
fmt:
@if [ -n "$(shell gofmt -l pkg cli tests)" ]; then \
echo "Go code is not formatted!";\
exit 1;\
fi
.PHONY: test
test: fmt test-only
.PHONY: test-coverage
test-coverage:
go test -coverprofile=cov.out $(shell go list ./... | grep -v /vendor/ | grep -v /tests/)
go tool cover -html=cov.out
.PHONY: e2e-test
e2e-test:
go test -v ./tests/e2e/... --server $(KUBERNETES_SERVER) --kubeconfig $(KUBECONFIG_PATH)