forked from replicatedhq/replicated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
136 lines (119 loc) · 4.16 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
135
136
.PHONY: docker shell deps test pacts publish-pacts get-spec-prod get-spec-local gen-models build docs package_docker_docs
API_PKGS=apps channels releases
VERSION=$(shell git describe)
ABBREV_VERSION=$(shell git describe --abbrev=0)
VERSION_PACKAGE = github.com/replicatedhq/replicated/pkg/version
DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
GIT_TREE = $(shell git rev-parse --is-inside-work-tree 2>/dev/null)
ifneq "$(GIT_TREE)" ""
define GIT_UPDATE_INDEX_CMD
git update-index --assume-unchanged
endef
define GIT_SHA
`git rev-parse HEAD`
endef
else
define GIT_UPDATE_INDEX_CMD
echo "Not a git repo, skipping git update-index"
endef
define GIT_SHA
""
endef
endif
define LDFLAGS
-ldflags "\
-X ${VERSION_PACKAGE}.version=${VERSION} \
-X ${VERSION_PACKAGE}.gitSHA=${GIT_SHA} \
-X ${VERSION_PACKAGE}.buildTime=${DATE} \
"
endef
docker:
docker build -t replicatedhq.replicated .
shell:
docker run --rm -it \
--volume `pwd`:/go/src/github.com/replicatedhq/replicated \
replicatedhq.replicated
deps:
docker run --rm \
--volume `pwd`:/go/src/github.com/replicatedhq/replicated \
replicatedhq.replicated glide install
test:
go test ./cli/test
pacts:
docker build -t replicated-cli-test -f hack/Dockerfile.testing .
docker run --rm --name replicated-cli-tests \
-v `pwd`:/go/src/github.com/replicatedhq/replicated \
replicated-cli-test \
go test -v ./pkg/...
publish-pacts:
curl \
--silent --output /dev/null --show-error --fail \
--user ${PACT_BROKER_USERNAME}:${PACT_BROKER_PASSWORD} \
-X PUT \
-H "Content-Type: application/json" \
-d@pacts/replicated-cli-vendor-graphql-api.json \
https://replicated-pact-broker.herokuapp.com/pacts/provider/vendor-graphql-api/consumer/replicated-cli/version/$(ABBREV_VERSION)
curl \
--silent --output /dev/null --show-error --fail \
--user ${PACT_BROKER_USERNAME}:${PACT_BROKER_PASSWORD} \
-X PUT \
-H "Content-Type: application/json" \
-d@pacts/replicated-cli-kots-vendor-graphql-api.json \
https://replicated-pact-broker.herokuapp.com/pacts/provider/vendor-graphql-api/consumer/replicated-cli-kots/version/$(ABBREV_VERSION)
curl \
--silent --output /dev/null --show-error --fail \
--user ${PACT_BROKER_USERNAME}:${PACT_BROKER_PASSWORD} \
-X PUT \
-H "Content-Type: application/json" \
-d@pacts/replicated-cli-vendor-api.json \
https://replicated-pact-broker.herokuapp.com/pacts/provider/vendor-api/consumer/replicated-cli/version/$(ABBREV_VERSION)
# fetch the swagger specs from the production Vendor API
get-spec-prod:
mkdir -p gen/spec/
curl -o gen/spec/v1.json https://api.replicated.com/vendor/v1/spec/vendor-api.json
curl -o gen/spec/v2.json https://api.replicated.com/vendor/v2/spec/swagger.json; # TODO this is still wrong, need to find where this is hosted
# generate the swagger specs from the local replicatedcom/vendor-api repo
get-spec-local:
mkdir -p gen/spec/
docker run --rm \
--volume ${GOPATH}/src/github.com:/go/src/github.com \
replicatedhq.replicated /bin/bash -c ' \
for PKG in ${API_PKGS}; do \
swagger generate spec \
-b ../../replicatedcom/vendor-api/handlers/replv1/$$PKG \
-o gen/spec/$$PKG.json; \
done \
&& swagger generate spec \
-b ../../replicatedcom/vendor-api/handlers/replv2 \
-o gen/spec/v2.json'
# generate from the specs in gen/spec, which come from either get-spec-prod or get-spec-local
gen-models:
docker run --rm \
--volume `pwd`:/local \
swaggerapi/swagger-codegen-cli generate \
-Dmodels -DmodelsDocs=false \
-i /local/gen/spec/v1.json \
-l go \
-o /local/gen/go/v1; \
# TODO this will fail, see note above in get-spec-prod
docker run --rm \
--volume `pwd`:/local \
swaggerapi/swagger-codegen-cli generate \
-Dmodels -DmodelsDocs=false \
-i /local/gen/spec/v2.json \
-l go \
-o /local/gen/go/v2;
build:
go build \
${LDFLAGS} \
-i \
-o replicated \
cli/main.go
mv replicated ${GOPATH}/bin
docs:
go run docs/generate.go --path ./gen/docs
package_docker_docs: docs
docker login -p $(QUAY_PASS) -u $(QUAY_USER) quay.io
docker build -t quay.io/replicatedcom/vendor-cli-docs:release -f docs/Dockerfile .
docker push quay.io/replicatedcom/vendor-cli-docs:release
docker rmi -f quay.io/replicatedcom/vendor-cli-docs:release