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 ##############################################################################
11 VERSION := $(shell git describe --tags)
12 BUILD := $(shell git rev-parse --short HEAD)
13 PROJECTNAME := $(shell basename "$(pwd)")
15 PromOP := ${PWD}/build/_output/bin/remote-config-operator
16 PromOP_LOCAL := ${PromOP}-local
19 override IMAGE_NAME := dcr.cluster.local:32644/remote-config-operator:latest
26 ## build: Generate the k8s and openapi artifacts using operator-sdk
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
34 ## all: Delete the image, binary, complete build, test and run coverage
37 ## debug: Build local binary for debugging
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
46 ## deploy: Build Dockerfile and publish to repository
47 deploy: build test publish
49 ## clean: clean build artifacts, image, binary
51 @echo "Deleting the remote-config-operator binary"
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
56 ## publish: Push docker image to registry
58 @docker push ${IMAGE_NAME}
66 ## cover: run tests and generate coverage report
68 @go test ./... -coverprofile=coverage.out
69 @go tool cover -html=coverage.out -o coverage.html
71 ## format: format source code
76 ## help: Print help message
79 @echo " Requires Operator SDK v0.12.0+, go1.13.1+"
81 @echo " Choose a command run in "$(PROJECTNAME)":"
83 @sed -n 's/^## //p' $< | column -t -s ':' | sed -e 's/^/ /'