Remote Write Config and Filter operator
[demo.git] / vnfs / DAaaS / microservices / remote-config-operator / Makefile
1 PDX-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 PromOP := ${PWD}/build/_output/bin/remote-config-operator
16 PromOP_LOCAL := ${PromOP}-local
17
18 ifndef IMAGE_NAME
19 override IMAGE_NAME := dcr.cluster.local:32644/remote-config-operator:latest
20 endif
21
22 export GO111MODULE=on
23
24 .PHONY: clean publish
25
26 ## build: Generate the k8s and openapi artifacts using operator-sdk
27 build: clean
28         GOOS=linux GOARCH=amd64
29         @operator-sdk generate k8s --verbose
30         @operator-sdk generate openapi --verbose
31         @operator-sdk build ${IMAGE_NAME} --verbose
32         @go build -o ${PromOP_LOCAL} remote-config-operator/cmd/manager
33
34 ## all: Delete the image, binary, complete build, test and run coverage
35 all: build test cover
36
37 ## debug: Build local binary for debugging
38 debug:
39         @echo "Deleting ${PromOP_LOCAL} binary"
40         @rm -rf ${PromOP_LOCAL}
41         operator-sdk generate k8s --verbose
42         operator-sdk generate openapi --verbose
43         @echo "Building ${PromOP_LOCAL} binary"
44         @go build -o ${PromOP_LOCAL} remote-config-operator/cmd/manager
45
46 ## deploy: Build Dockerfile and publish to repository
47 deploy: build test publish
48
49 ## clean: clean build artifacts, image, binary
50 clean:
51         @echo "Deleting the remote-config-operator binary"
52         @rm -rf ${PromOP}
53         @rm -rf ${PromOP_LOCAL}
54         @if docker images $(IMAGE_NAME) | awk '{ print $$2 }' | grep -q -F latest; then echo "Deleting the remote-config-operator docker image";  docker rmi ${IMAGE_NAME}; fi
55
56 ## publish: Push docker image to registry
57 publish:
58         @docker push ${IMAGE_NAME}
59
60 .PHONY: test
61 ## test: run tests
62 test: clean
63         @go test -v ./...
64
65 .PHONY: cover
66 ## cover: run tests and generate coverage report
67 cover:
68         @go test ./... -coverprofile=coverage.out
69         @go tool cover -html=coverage.out -o coverage.html
70
71 ## format: format source code
72 format:
73         @go fmt ./...
74
75 .PHONY: help
76 ## help: Print help message
77 help: Makefile
78         @echo
79         @echo " Requires Operator SDK v0.12.0+, go1.13.1+"
80         @echo
81         @echo " Choose a command run in "$(PROJECTNAME)":"
82         @echo
83         @sed -n 's/^## //p' $< | column -t -s ':' |  sed -e 's/^/ /'
84         @echo