forked from migtools/mig-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
134 lines (111 loc) · 4.7 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Image URL to use all building/pushing image targets
IMG ?= quay.io/ocpmigrate/mig-controller:latest
GOOS ?= `go env GOOS`
GOBIN ?= ${GOPATH}/bin
GO111MODULE = auto
KUBECONFIG_POSTFIX ?= mig-controller
export BUILDTAGS ?= containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp exclude_graphdriver_overlay
ci: all
all: test manager
# Run tests
test: generate fmt vet manifests
go test -tags "${BUILDTAGS}" ./pkg/... ./cmd/... -coverprofile cover.out
# Build manager binary
manager: generate fmt vet
go build -tags "${BUILDTAGS}" -o bin/manager github.com/konveyor/mig-controller/cmd/manager
# Run against the configured Kubernetes cluster in ~/.kube/config after login as mig controller SA
run: generate fmt vet
./hack/controller-sa-login.sh
KUBECONFIG=$(KUBECONFIG)-${KUBECONFIG_POSTFIX} ./hack/start-local-controller.sh
# Same as `make run`, but skips generate, fmt, vet. Useful for quick iteration.
run-fast:
./hack/controller-sa-login.sh
KUBECONFIG=$(KUBECONFIG)-${KUBECONFIG_POSTFIX} ./hack/start-local-controller.sh
# Run against the configured Kubernetes cluster in ~/.kube/config, skip login to mig-controller SA
run-skip-sa-login: generate fmt vet
./hack/start-local-controller.sh
tilt:
IMG=${IMG} TEMPLATE=${TEMPLATE} tilt up --hud=false --no-browser --file tools/tilt/Tiltfile
# Patch MigrationController CR to use local mig-controller + discovery service
use-local-controller:
oc --namespace openshift-migration patch migrationcontroller migration-controller --type=json \
--patch '[{ "op": "add", "path": "/spec/discovery_api_url", "value": "http://localhost:8080" }]'
oc --namespace openshift-migration patch migrationcontroller migration-controller --type=json \
--patch '[{ "op": "replace", "path": "/spec/migration_controller", "value": false }]'
# Patch MigrationController CR to use on-cluster mig-controller + discovery service
use-oncluster-controller:
oc --namespace openshift-migration patch migrationcontroller migration-controller --type=json \
--patch '[{ "op": "replace", "path": "/spec/migration_controller", "value": true }]'
oc --namespace openshift-migration patch migrationcontroller migration-controller --type=json \
--patch '[{ "op": "remove", "path": "/spec/discovery_api_url" }]'
# Install CRDs into a cluster
install: manifests
kubectl apply -f config/crds
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
kubectl apply -f config/crds
kustomize build config/default | kubectl apply -f -
# Provide CRDs that work back to k8s 1.11
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
# Generate manifests e.g. CRD, Webhooks
manifests:
${CONTROLLER_GEN} ${CRD_OPTIONS} crd rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crds/bases
mv config/migration.openshift.io*yaml config/crds
rm -rf config/crds/bases
# Copy sample CRs to a new 'migsamples' directory that is in .gitignore to avoid committing SA tokens
samples:
mkdir -p migsamples
cp -v config/samples/* migsamples
# Run go fmt against code
fmt:
go fmt ./pkg/... ./cmd/...
# Run go vet against code
vet:
go vet -tags "${BUILDTAGS}" -structtag=false ./pkg/... ./cmd/...
# Generate code
generate: conversion-gen controller-gen
${CONTROLLER_GEN} object:headerFile="./hack/boilerplate.go.txt" paths="./..."
# Generate conversion functions
conversion-gen: conversion-gen-dl
${CONVERSION_GEN} --go-header-file ./hack/boilerplate.go.txt --output-file-base zz_conversion_generated -i github.com/konveyor/mig-controller/pkg/compat/conversion/...
# Build the docker image
#docker-build: test
docker-build:
docker build . -t ${IMG}
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml
# Push the docker image
docker-push:
docker push ${IMG}
# find or download controller-gen
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
# find or download controller-gen
# download controller-gen if necessary
conversion-gen-dl:
ifeq (, $(shell which conversion-gen))
@{ \
set -e ;\
CONVERSION_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONVERSION_GEN_TMP_DIR ;\
go mod init tmp ;\
go get k8s.io/code-generator/cmd/[email protected] ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONVERSION_GEN=$(GOBIN)/conversion-gen
else
CONVERSION_GEN=$(shell which conversion-gen)
endif