Prometheus Kafka Writer Microservice
[demo.git] / vnfs / DAaaS / microservices / prom-kafka-writer / Makefile
1 # SPDX-license-identifier: Apache-2.0
2 ##############################################################################
3 # Copyright (c) 2019 Intel Corporation
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 # Common
11 VERSION := $(shell git describe --tags)
12 BUILD := $(shell git rev-parse --short HEAD)
13 PROJECTNAME := $(shell basename "$(PWD)")
14
15 ROOTPATH := $(shell realpath "$(PWD)/../")
16 PKA := prom-kafka-writer
17 ifndef IMAGE_NAME
18 override IMAGE_NAME := dcr.cluster.local:32644/prom-kafka-writer:latest
19 endif
20
21 export GO111MODULE=on
22
23 .PHONY: clean plugins
24
25 ## build: Build the binary for prom-kafka-writer
26 build: clean format
27         GOOS=linux GOARCH=amd64
28         @go mod download
29         @go build -o ./bin/prom-kafka-writer -v ./cmd/prom-kafka-writer
30
31 ## all: Delete the image, binary, complete build, test and run coverage
32 all: build test cover
33 ## debug: Build local binary for debugging
34 debug:
35         @echo "Use Cloud Code VSCode plugin or Skaffold to debug"
36
37 ## deploy: Build Dockerfile and publish to repository
38 deploy: build test publish
39
40 ## publish: Push docker image to repository
41 publish:
42         @docker push ${IMAGE_NAME}
43 .PHONY: test
44 ## test: run tests
45 test: clean
46         @go test -v ./...
47 ## format: format source code
48 format:
49         @go fmt ./...
50
51 ## clean: clean build artifacts, image, binary 
52 clean: format
53         @echo "Deleting the prom-kafka-writer binary"
54         @rm -rf ${PKA}
55         @echo "Deleting the prom-kafka-writer docker image"
56         @docker 2>/dev/null rmi ${IMAGE_NAME} | true
57
58 .PHONY: cover
59 ## cover: run tests and generate coverage report
60 cover:
61         @go test ./... -coverprofile=coverage.out
62         @go tool cover -html=coverage.out -o coverage.html
63
64 .PHONY: help
65 ## help: Print help message
66 help: Makefile
67         @echo
68         @echo " Requires librdkafka v1.1.0 or later, go1.12.5+"
69         @echo
70         @echo " Choose a command run in "$(PROJECTNAME)":"
71         @echo
72         @sed -n 's/^## //p' $< | column -t -s ':' |  sed -e 's/^/ /'
73         @echo