forked from openshift/elasticsearch-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
115 lines (90 loc) · 3.01 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
CURPATH=$(PWD)
TARGET_DIR=$(CURPATH)/_output
GOBUILD=go build
BUILD_GOPATH=$(TARGET_DIR):$(TARGET_DIR)/vendor:$(CURPATH)/cmd
IMAGE_BUILDER_OPTS=
IMAGE_BUILDER?=imagebuilder
IMAGE_BUILD=$(IMAGE_BUILDER)
export IMAGE_TAGGER?=docker tag
export APP_NAME=elasticsearch-operator
IMAGE_TAG?=quay.io/openshift/origin-$(APP_NAME):latest
export IMAGE_TAG
APP_REPO=github.com/openshift/$(APP_NAME)
TARGET=$(TARGET_DIR)/bin/$(APP_NAME)
KUBECONFIG?=$(HOME)/.kube/config
MAIN_PKG=cmd/manager/main.go
RUN_LOG?=elasticsearch-operator.log
RUN_PID?=elasticsearch-operator.pid
# go source files, ignore vendor directory
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
#.PHONY: all build clean install uninstall fmt simplify check run
.PHONY: all build clean fmt simplify run
all: build #check install
operator-sdk: get-dep
@if ! type -p operator-sdk ; \
then if [ ! -d $(GOPATH)/src/github.com/operator-framework/operator-sdk ] ; \
then git clone https://github.com/operator-framework/operator-sdk --branch master $(GOPATH)/src/github.com/operator-framework/operator-sdk ; \
fi ; \
cd $(GOPATH)/src/github.com/operator-framework/operator-sdk ; \
make dep ; \
make install || sudo make install || cd commands/operator-sdk && sudo go install ; \
fi
gendeepcopy: operator-sdk
@operator-sdk generate k8s
imagebuilder:
@if [ $${USE_IMAGE_STREAM:-false} = false ] && ! type -p imagebuilder ; \
then go get -u github.com/openshift/imagebuilder/cmd/imagebuilder ; \
fi
get-dep:
@if ! type -p dep ; then \
cd $(GOPATH) ; \
if [ ! -d $(GOPATH)/bin ]; then \
mkdir bin; \
fi; \
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh ; \
fi
build: fmt
@mkdir -p $(TARGET_DIR)/src/$(APP_REPO)
@cp -ru $(CURPATH)/pkg $(TARGET_DIR)/src/$(APP_REPO)
@cp -ru $(CURPATH)/vendor/* $(TARGET_DIR)/src
@GOPATH=$(BUILD_GOPATH) $(GOBUILD) $(LDFLAGS) -o $(TARGET) $(MAIN_PKG)
clean:
@rm -rf $(TARGET_DIR)
image: imagebuilder
@if [ $${USE_IMAGE_STREAM:-false} = false ] && [ $${SKIP_BUILD:-false} = false ] ; \
then hack/build-image.sh $(IMAGE_TAG) $(IMAGE_BUILDER) $(IMAGE_BUILDER_OPTS) ; \
fi
test-e2e:
hack/test-e2e.sh
test-unit:
@go test -v ./pkg/... ./cmd/...
fmt:
@gofmt -l -w cmd && \
gofmt -l -w pkg && \
gofmt -l -w test
simplify:
@gofmt -s -l -w $(SRC)
deploy: deploy-setup deploy-image
hack/deploy.sh
.PHONY: deploy
deploy-no-build: deploy-setup
hack/deploy.sh
.PHONY: deploy
deploy-image: image
hack/deploy-image.sh
.PHONY: deploy-image
deploy-example: deploy
@oc create -n openshift-logging -f hack/cr.yaml
.PHONY: deploy-example
deploy-setup:
EXCLUSIONS="05-deployment.yaml image-references" hack/deploy-setup.sh
.PHONY: deploy-setup
run: deploy deploy-example
@ALERTS_FILE_PATH=files/prometheus_alerts.yml \
RULES_FILE_PATH=files/prometheus_rules.yml \
OPERATOR_NAME=elasticsearch-operator WATCH_NAMESPACE=openshift-logging \
KUBERNETES_CONFIG=/etc/origin/master/admin.kubeconfig \
go run ${MAIN_PKG} > $(RUN_LOG) 2>&1 & echo $$! > $(RUN_PID)
undeploy:
hack/undeploy.sh
.PHONY: undeploy