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 ##############################################################################
11 VERSION := $(shell git describe --tags)
12 BUILD := $(shell git rev-parse --short HEAD)
13 PROJECTNAME := $(shell basename "$(PWD)")
15 GOPATH := $(shell realpath "$(PWD)/../../../../../")
16 COP = ${PWD}/build/_output/bin/collectd-operator
17 IMAGE_NAME = dcr.cluster.local/collectd-operator:latest
24 ## all: Generate the k8s and openapi artifacts using operator-sdk
26 GOOS=linux GOARCH=amd64
27 operator-sdk generate k8s --verbose
28 operator-sdk generate openapi --verbose
29 #@go build -o ${COP} -gcflags all=-trimpath=${GOPATH} -asmflags all=-trimpath=${GOPATH} -mod=vendor demo/vnfs/DAaaS/collectd-operator/cmd/manager
30 @operator-sdk build ${IMAGE_NAME} --verbose
32 # The following is done this way as each patch on CI runs build and each merge runs deploy. So for build we don't need to build binary and hence
33 # no need to create a static binary with additional flags. However, for generating binary, additional build flags are necessary. This if used with
34 # mock plugin errors out for unit tests. So the seperation avoids the error.
37 build: clean test cover
42 @docker push ${IMAGE_NAME}
51 @echo "Deleting the collectd-operator binary"
52 @rm -rf ${PWD}/build/_output/bin/collectd-operator
53 @echo "Deleting the collectd-operator docker image"
54 @docker rmi ${IMAGE_NAME}
58 @go test ./... -coverprofile=coverage.out
59 @go tool cover -html=coverage.out -o coverage.html
62 ## help: Print help message
65 @echo " Requires -\\t Operator SDK v0.8.0+, go1.12.5+"
67 @echo " Choose a command run in "$(PROJECTNAME)":"
69 @sed -n 's/^## //p' $< | column -t -s ':' | sed -e 's/^/ /'