github.com/kubeflow/training-operator@v1.7.0/Makefile (about)

     1  # Image URL to use all building/pushing image targets
     2  IMG ?= kubeflow/training-operator:latest
     3  # CRD generation options
     4  CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=400"
     5  
     6  # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
     7  ifeq (,$(shell go env GOBIN))
     8  GOBIN=$(shell go env GOPATH)/bin
     9  else
    10  GOBIN=$(shell go env GOBIN)
    11  endif
    12  
    13  # Setting SHELL to bash allows bash commands to be executed by recipes.
    14  # This is a requirement for 'setup-envtest.sh' in the test target.
    15  # Options are set to exit when a recipe line exits non-zero or a piped command fails.
    16  SHELL = /usr/bin/env bash -o pipefail
    17  .SHELLFLAGS = -ec
    18  
    19  all: build
    20  
    21  ##@ General
    22  
    23  # The help target prints out all targets with their descriptions organized
    24  # beneath their categories. The categories are represented by '##@' and the
    25  # target descriptions by '##'. The awk commands is responsible for reading the
    26  # entire set of makefiles included in this invocation, looking for lines of the
    27  # file as xyz: ## something, and then pretty-format the target and help. Then,
    28  # if there's a line with ##@ something, that gets pretty-printed as a category.
    29  # More info on the usage of ANSI control characters for terminal formatting:
    30  # https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
    31  # More info on the awk command:
    32  # http://linuxcommand.org/lc3_adv_awk.php
    33  
    34  help: ## Display this help.
    35  	@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n  make \033[36m<target>\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)
    36  
    37  ##@ Development
    38  
    39  manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
    40  	$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=training-operator webhook paths="./pkg/..." output:crd:artifacts:config=manifests/base/crds output:rbac:artifacts:config=manifests/base/rbac
    41  
    42  generate: controller-gen ## Generate apidoc, sdk and code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. 
    43  	$(CONTROLLER_GEN) object:headerFile="hack/boilerplate/boilerplate.go.txt" paths="./pkg/apis/..."
    44  	hack/update-codegen.sh
    45  	hack/python-sdk/gen-sdk.sh
    46  	$(MAKE) apidoc
    47  
    48  apidoc:
    49  	hack/generate-apidoc.sh
    50  
    51  fmt: ## Run go fmt against code.
    52  	go fmt ./...
    53  
    54  vet: ## Run go vet against code.
    55  	go vet ./...
    56  
    57  GOLANGCI_LINT=$(shell which golangci-lint)
    58  golangci-lint:
    59  ifeq ($(GOLANGCI_LINT),)
    60  	curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.53.3
    61  	$(info golangci-lint has been installed)
    62  endif
    63  	golangci-lint run --timeout 5m --go 1.20 ./...
    64  
    65  ENVTEST_K8S_VERSION ?= 1.27
    66  HAS_SETUP_ENVTEST := $(shell command -v setup-envtest;)
    67  
    68  testall: manifests generate fmt vet golangci-lint test ## Run tests.
    69  
    70  test: envtest
    71  	KUBEBUILDER_ASSETS="$(shell setup-envtest use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
    72  
    73  envtest:
    74  ifndef HAS_SETUP_ENVTEST
    75  	go install sigs.k8s.io/controller-runtime/tools/setup-envtest@116a1b831fffe7ccc3c8145306c3e1a3b1b14ffa # v0.15.0
    76  	@echo "setup-envtest has been installed"
    77  endif
    78  	@echo "setup-envtest has already installed"
    79  
    80  build: generate fmt vet ## Build manager binary.
    81  	go build -o bin/manager cmd/training-operator.v1/main.go
    82  
    83  run: manifests generate fmt vet ## Run a controller from your host.
    84  	go run ./cmd/training-operator.v1/main.go
    85  
    86  docker-build: test ## Build docker image with the manager.
    87  	docker build -t ${IMG} -f build/images/training-operator/Dockerfile .
    88  
    89  docker-push: ## Push docker image with the manager.
    90  	docker push ${IMG}
    91  
    92  ##@ Deployment
    93  
    94  install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
    95  	$(KUSTOMIZE) build manifests/base/crds | kubectl apply -f -
    96  
    97  uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
    98  	$(KUSTOMIZE) build manifests/base/crds | kubectl delete -f -
    99  
   100  deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
   101  	cd manifests/overlays/standalone && $(KUSTOMIZE) edit set image kubeflow/training-operator=${IMG}
   102  	$(KUSTOMIZE) build manifests/overlays/standalone | kubectl apply -f -
   103  
   104  undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
   105  	$(KUSTOMIZE) build manifests/overlays/standalone | kubectl delete -f -
   106  
   107  PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
   108  
   109  CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
   110  controller-gen: ## Download controller-gen locally if necessary.
   111  	GOBIN=$(PROJECT_DIR)/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.0
   112  
   113  KUSTOMIZE = $(shell pwd)/bin/kustomize
   114  kustomize: ## Download kustomize locally if necessary.
   115  	GOBIN=$(PROJECT_DIR)/bin go install sigs.k8s.io/kustomize/kustomize/v4@v4.5.7