1
+ # Copyright 2023 The Kubeflow Authors.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
BIN_DIR =_output/cmd/bin
2
16
REPO_PATH ="github.com/kubeflow/mpi-operator"
3
17
REL_OSARCH ="linux/amd64"
@@ -8,22 +22,24 @@ CONTROLLER_VERSION?=v2
8
22
BASE_IMAGE_SSH_PORT? =2222
9
23
IMG_BUILDER =docker
10
24
LD_FLAGS_V2 =" \
11
- -X '${REPO_PATH}/v2/ pkg/version.GitSHA=${GitSHA}' \
12
- -X '${REPO_PATH}/v2/ pkg/version.Built=${Date}' \
13
- -X '${REPO_PATH}/v2/ pkg/version.Version=${RELEASE_VERSION}'"
25
+ -X '${REPO_PATH}/pkg/version.GitSHA=${GitSHA}' \
26
+ -X '${REPO_PATH}/pkg/version.Built=${Date}' \
27
+ -X '${REPO_PATH}/pkg/version.Version=${RELEASE_VERSION}'"
14
28
IMAGE_NAME? =mpioperator/mpi-operator
15
29
KUBEBUILDER_ASSETS_PATH := $(dir $(abspath $(firstword $(MAKEFILE_LIST ) ) ) ) bin/kubebuilder/bin
16
- KIND_VERSION =v0.11.1
30
+ KIND_VERSION =v0.17.0
17
31
# This kubectl version supports -k for kustomization.
18
- KUBECTL_VERSION =v1.21.4
19
-
32
+ KUBECTL_VERSION =v1.25.5
33
+ ENVTEST_K8S_VERSION =1.25.0
20
34
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
35
+ GOARCH =$(shell go env GOARCH)
36
+ GOOS =$(shell go env GOOS)
21
37
22
- CRD_OPTIONS ?= "crd:trivialVersions =true,preserveUnknownFields=false "
38
+ CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta =true"
23
39
24
40
build : all
25
41
26
- all : ${BIN_DIR} fmt tidy lint test mpi-operator.v2
42
+ all : ${BIN_DIR} fmt vet tidy lint test mpi-operator.v2
27
43
28
44
.PHONY : mpi-operator.v2
29
45
mpi-operator.v2 :
@@ -36,10 +52,14 @@ ${BIN_DIR}:
36
52
fmt :
37
53
go fmt ./...
38
54
55
+ .PHONY : vet
56
+ vet :
57
+ go vet ./...
58
+
39
59
.PHONY : test
40
- test : export KUBEBUILDER_ASSETS = ${KUBEBUILDER_ASSETS_PATH}
41
- test : bin/kubebuilder
42
- go test -covermode atomic -coverprofile=profile.cov ./...
60
+ test :
61
+ test : bin/envtest
62
+ KUBEBUILDER_ASSETS= " $( shell $( ENVTEST ) use $( ENVTEST_K8S_VERSION ) -p path ) " go test -covermode atomic -coverprofile=profile.cov ./...
43
63
44
64
# Only works with CONTROLLER_VERSION=v2
45
65
.PHONY : test_e2e
@@ -54,8 +74,10 @@ dev_manifest:
54
74
55
75
.PHONY : generate
56
76
generate :
57
- go generate ./pkg/... ./cmd/... && \
58
- openapi-gen --input-dirs github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1,k8s.io/api/core/v1,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/util/intstr,k8s.io/apimachinery/pkg/version,github.com/kubeflow/common/pkg/apis/common/v1 --output-package github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1 --go-header-file hack/boilerplate/boilerplate.go.txt
77
+ go generate ./pkg/... ./cmd/...
78
+ hack/update-codegen.sh
79
+ $(MAKE ) crd
80
+ hack/python-sdk/gen-sdk.sh
59
81
60
82
.PHONY : clean
61
83
clean :
@@ -80,50 +102,38 @@ test_images:
80
102
tidy :
81
103
go mod tidy -go 1.19
82
104
83
- GOLANGCI_LINT = ./bin/golangci-lint
84
- bin/golangci-lint :
85
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT ) ) v1.50.1
86
-
87
- GOOS := $(shell go env GOOS)
88
- GOARCH := $(shell go env GOARCH)
89
- K8S_VERSION := "1.19.2"
90
- bin/kubebuilder :
91
- curl -sSLo envtest-bins.tar.gz " https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-${K8S_VERSION} -${GOOS} -${GOARCH} .tar.gz"
92
- mkdir -p bin/kubebuilder
93
- tar -C bin/kubebuilder --strip-components=1 -zvxf envtest-bins.tar.gz
94
- rm envtest-bins.tar.gz
95
-
96
- bin/kubectl :
97
- mkdir -p bin
98
- curl -L -o bin/kubectl https://dl.k8s.io/release/${KUBECTL_VERSION} /bin/linux/amd64/kubectl
99
- chmod +x bin/kubectl
100
-
101
105
.PHONY : lint
102
106
lint : bin/golangci-lint # # Run golangci-lint linter
103
107
$(GOLANGCI_LINT ) run --new-from-rev=origin/master --go 1.19
104
108
105
- .PHONY : kind
106
- kind :
107
- go install sigs.k8s.io/kind@${KIND_VERSION}
108
-
109
109
# Generate CRD
110
110
crd : controller-gen
111
111
$(CONTROLLER_GEN ) $(CRD_OPTIONS ) paths=" ./..." output:crd:artifacts:config=crd
112
112
113
+ .PHONY : bin
114
+ bin :
115
+ mkdir -p $(PROJECT_DIR ) /bin
116
+
117
+ GOLANGCI_LINT = $(shell pwd) /bin/golangci-lint
118
+ .PHONY : bin/golangci-lint
119
+ bin/golangci-lint : bin
120
+ @GOBIN=
$(PROJECT_DIR ) /bin go install github.com/golangci/golangci-lint/cmd/
[email protected]
121
+
122
+ ENVTEST = $(shell pwd) /bin/setup-envtest
123
+ .PHONY : envtest
124
+ bin/envtest : bin # # Download envtest-setup locally if necessary.
125
+ @GOBIN=$(PROJECT_DIR ) /bin go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
126
+
127
+ bin/kubectl : bin
128
+ curl -L -o $(PROJECT_DIR ) /bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION} /bin/$(GOOS ) /$(GOARCH ) /kubectl
129
+ chmod +x $(PROJECT_DIR ) /bin/kubectl
130
+
131
+ .PHONY : kind
132
+ kind : bin
133
+ @GOBIN=$(PROJECT_DIR ) /bin go install sigs.k8s.io/kind@${KIND_VERSION}
134
+
113
135
# Download controller-gen locally if necessary
114
136
CONTROLLER_GEN = $(PROJECT_DIR ) /bin/controller-gen
115
- controller-gen :
116
- $(call go-get-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/[email protected] )
117
-
118
- # go-get-tool will 'go get' any package $2 and install it to $1.
119
- define go-get-tool
120
- @[ -f $(1 ) ] || { \
121
- set -e ;\
122
- TMP_DIR=$$(mktemp -d ) ;\
123
- cd $$TMP_DIR ;\
124
- go mod init tmp ;\
125
- echo "Downloading $(2 ) " ;\
126
- GOBIN=$(PROJECT_DIR ) /bin go get $(2 ) ;\
127
- rm -rf $$TMP_DIR ;\
128
- }
129
- endef
137
+ .PHONY : controller-gen
138
+ controller-gen : bin
139
+ @GOBIN=
$(PROJECT_DIR ) /bin go install sigs.k8s.io/controller-tools/cmd/
[email protected]
0 commit comments