forked from kubernetes-sigs/kube-storage-version-migrator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (63 loc) · 2.5 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
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
STAGING_REGISTRY := gcr.io/k8s-staging-storage-migrator
VERSION ?= v0.1
NAMESPACE ?= kube-system
DELETE ?= "gcloud container images delete"
COMPONENTS = initializer migrator trigger
.PHONY: test
test:
go test ./pkg/...
.PHONY: all
all:
ifeq ($(WHAT),)
go install sigs.k8s.io/kube-storage-version-migrator/cmd/...
else
go install sigs.k8s.io/kube-storage-version-migrator/$(WHAT)
endif
.PHONY: all-images
all-images: $(COMPONENTS:%=image-%)
image-%:
docker build --no-cache -t $(REGISTRY)/storage-version-migration-$*:$(VERSION) --file cmd/$*/Dockerfile .
.PHONY: e2e-test
e2e-test:
CGO_ENABLED=0 GOOS=linux GO111MODULE=on go test -c -o ./test/e2e/e2e.test ./test/e2e
.PHONY: local-manifests
local-manifests:
mkdir -p manifests.local
cp manifests/* manifests.local/
find ./manifests.local -type f -exec sed -i -e "s|REGISTRY|$(REGISTRY)|g" {} \;
find ./manifests.local -type f -exec sed -i -e "s|VERSION|$(VERSION)|g" {} \;
find ./manifests.local -type f -exec sed -i -e "s|NAMESPACE|$(NAMESPACE)|g" {} \;
.PHONY: push-all
push-all: $(COMPONENTS:%=push-%)
push-%: image-%
docker push $(REGISTRY)/storage-version-migration-$*:$(VERSION)
.PHONY: release-staging release-alias-tag
release-staging: ## Builds and push container images to the staging bucket.
REGISTRY=$(STAGING_REGISTRY) $(MAKE) push-all release-alias-tag
.PHONY: release-alias-tag
release-alias-tag: $(COMPONENTS:%=release-alias-tag-%)
release-alias-tag-%: # Adds the tag to the last build tag. BASE_REF comes from the cloudbuild.yaml
gcloud container images add-tag --quiet $(REGISTRY)/storage-version-migration-$*:$(VERSION) $(REGISTRY)/storage-version-migration-$*:$(BASE_REF)
.PHONY: delete-all-images
delete-all-images: $(COMPONENTS:%=delete-image-%)
delete-image-%:
eval "$(DELETE) $(REGISTRY)/storage-version-migration-$*:$(VERSION)"
.PHONY: clean
clean:
$(RM) -r _output
$(RM) -r manifests.local
$(RM) test/e2e/e2e.test