github.com/kyma-project/kyma/components/asset-store-controller-manager@v0.0.0-20191203152857-3792b5df17c5/Makefile (about)

     1  
     2  # Image URL to use all building/pushing image targets
     3  APP_NAME ?= asset-store-controller-manager
     4  IMG ?= $(APP_NAME):latest
     5  IMG-CI = $(DOCKER_PUSH_REPOSITORY)$(DOCKER_PUSH_DIRECTORY)/$(APP_NAME):$(DOCKER_TAG)
     6  # Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
     7  CRD_OPTIONS ?= "crd:trivialVersions=true"
     8  
     9  # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
    10  ifeq (,$(shell go env GOBIN))
    11  GOBIN=$(shell go env GOPATH)/bin
    12  else
    13  GOBIN=$(shell go env GOBIN)
    14  endif
    15  
    16  all: test manager
    17  
    18  pull-licenses:
    19  ifdef LICENSE_PULLER_PATH
    20  	bash $(LICENSE_PULLER_PATH)
    21  else
    22  	mkdir -p licenses
    23  endif
    24  
    25  # Run tests
    26  test: generate fmt vet manifests
    27  	go test -coverprofile=cover.out ./...
    28  	@echo "Total test coverage: $$(go tool cover -func=cover.out | grep total | awk '{print $$3}')"
    29  	@rm cover.out
    30  
    31  # Build manager binary
    32  manager: generate fmt vet
    33  	go build -o bin/manager main.go
    34  
    35  # Run against the configured Kubernetes cluster in ~/.kube/config
    36  run: generate fmt vet manifests
    37  	go run ./main.go
    38  
    39  # Install CRDs into a cluster
    40  install: manifests
    41  	kustomize build config/crd | kubectl apply -f -
    42  
    43  # Deploy controller in the configured Kubernetes cluster in ~/.kube/config
    44  deploy: manifests
    45  	cd config/manager && kustomize edit set image controller=${IMG}
    46  	kustomize build config/default | kubectl apply -f -
    47  
    48  # Generate manifests e.g. CRD, RBAC etc.
    49  manifests: controller-gen
    50  	$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
    51  
    52  # Run go fmt against code
    53  fmt:
    54  	go fmt ./...
    55  
    56  # Run go vet against code
    57  vet:
    58  	go vet ./...
    59  
    60  # Generate code
    61  generate: controller-gen
    62  	$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."
    63  
    64  # Build the docker image
    65  docker-build: test pull-licenses
    66  	docker build . -t ${IMG}
    67  
    68  # Push the docker image
    69  docker-push:
    70  	docker tag $(IMG) $(IMG-CI)
    71  	docker push $(IMG-CI)
    72  
    73  # find or download controller-gen
    74  # download controller-gen if necessary
    75  controller-gen:
    76  ifeq (, $(shell which controller-gen))
    77  	go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0
    78  CONTROLLER_GEN=$(GOBIN)/controller-gen
    79  else
    80  CONTROLLER_GEN=$(shell which controller-gen)
    81  endif
    82  
    83  ci-pr: docker-build docker-push
    84  ci-master: docker-build docker-push
    85  ci-release: docker-build docker-push