forked from universityofadelaide/shepherd-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (77 loc) · 2.77 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
# Image URL to use all building/pushing image targets
IMG ?= docker.io/uofa/shepherd-operator:latest
IMG_BUILDER ?= uofa/shepherd-operator:builder-latest
NAMESPACE ?= myproject
SERVICE_ACCOUNT=shepherd
# Disable go modules (use dep)
export GO111MODULE=off
all: test manager
# Run tests
test: generate fmt vet manifests
go test ./pkg/... ./cmd/... -coverprofile cover.out
ci: ci-test ci-lint
ci-test:
go test \
./cmd/... \
./pkg/controller/... \
./pkg/utils/...
ci-lint: fmt
git diff --exit-code
# Build manager binary
manager: generate fmt vet
go build -o bin/manager github.com/universityofadelaide/shepherd-operator/cmd/manager
# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet
oc login -u system:admin
nohup go run ./cmd/manager/main.go --metrics-addr=":8081" &
sleep 5
echo "Use tail -f nohup.out to check on backups."
oc login -u developer -p developer
run-inline: generate fmt vet
oc login -u system:admin
go run ./cmd/manager/main.go --metrics-addr=":8081"
debug: manager
oc login -u system:admin
DEBUG="debug" go run ./cmd/manager/main.go --metrics-addr=":8081"
# Install CRDs and RBAC into a cluster
install: manifests
oc login -u system:admin
kubectl apply -f config/crds
kubectl apply -f config/rbac
oc login -u developer -p developer
kustomize:
@echo "updating kustomize namespace to ${NAMESPACE}"
sed -i'' -e 's@namespace: .*@namespace: '"${NAMESPACE}"'@' ./config/default/kustomization.yaml
docker run --rm -it \
-v $(CURDIR):/go/src/github.com/universityofadelaide/shepherd-operator \
--workdir /go/src/github.com/universityofadelaide/shepherd-operator \
${IMG_BUILDER} kustomize build config/default -o ./config/deploy.yaml
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests install kustomize
kubectl apply -f ./config/deploy.yaml
# Generate manifests e.g. CRD, RBAC etc.
manifests:
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go rbac --service-account=$(SERVICE_ACCOUNT) --service-account-namespace=$(NAMESPACE)
# Run go fmt against code
fmt:
go fmt ./pkg/... ./cmd/...
# Run go vet against code
vet:
go vet ./pkg/... ./cmd/...
# Generate code
generate:
ifndef GOPATH
$(error GOPATH not defined, please define GOPATH. Run "go help gopath" to learn more about GOPATH)
endif
go generate ./pkg/... ./cmd/...
# Build the docker image
docker-build: test
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
docker build -t ${IMG_BUILDER} -f Dockerfile.builder .
# Push the docker image
docker-push:
docker push ${IMG}
docker push ${IMG_BUILDER}