# Image URL to use all building/pushing image targets IMG ?= container-mom-operator:latest # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) CWD=$(shell pwd) LOCALBIN ?= $(CWD)/bin # Setting SHELL to bash allows bash commands to be executed by recipes. # Options are set to exit when a recipe line exits non-zero or a piped command fails. SHELL = /bin/bash -o pipefail .PHONY: all all: build ##@ General # The help target prints out all targets with their descriptions organized # beneath their categories. The categories are represented by '##@' and the # target descriptions by '##'. The awk command is responsible for reading the # entire set of makefiles included in this invocation, looking for lines of the # file as xyz: ## something, and then pretty-format the target and help. Then, # if there's a line with ##@ something, that gets pretty-printed as a category. # More info on the usage of ANSI control characters for terminal formatting: # https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters # More info on the awk command: # http://linuxcommand.org/lc3_adv_awk.php .PHONY: help help: ## Display this help. @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) ##@ Development .PHONY: fmt fmt: ## Format code. crystal tool format .PHONY: test test: ## Run tests. crystal spec .PHONY: test-verbose test-verbose: ## Run tests with verbose output. crystal spec -v .PHONY: test-watch test-watch: ## Run tests in watch mode. find src spec -name "*.cr" | entr -c crystal spec .PHONY: build build: fmt ## Build the operator binary. shards build --release .PHONY: run run: fmt ## Run the operator locally. crystal run src/main.cr .PHONY: docker-build docker-build: ## Build docker image with the operator. docker build -t ${IMG} . .PHONY: docker-push docker-push: ## Push docker image with the operator. docker push ${IMG} ##@ Deployment .PHONY: deploy deploy: ## Deploy operator to the cluster. kubectl apply -k config/default/ .PHONY: undeploy undeploy: ## Undeploy operator from the cluster. kubectl delete -k config/default/ ##@ Dependencies .PHONY: deps deps: ## Install dependencies. shards install .PHONY: deps-update deps-update: ## Update dependencies. shards update ##@ Clean .PHONY: clean clean: ## Clean build artifacts. rm -rf bin rm -rf lib rm -rf .shards rm -f container-mom-operator ##@ Tools .PHONY: tools tools: ## Install development tools. which entr || (echo "Installing entr for test-watch..." && brew install entr)