forked from kubernetes-sigs/gateway-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
173 lines (143 loc) · 5.14 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Copyright 2019 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.
# We need all the Make variables exported as env vars.
# Note that the ?= operator works regardless.
# Enable Go modules.
export GO111MODULE=on
# The registry to push container images to.
export REGISTRY ?= gcr.io/k8s-staging-gateway-api
# These are overridden by cloudbuild.yaml when run by Prow.
# Prow gives this a value of the form vYYYYMMDD-hash.
# (It's similar to `git describe` output, and for non-tag
# builds will give vYYYYMMDD-COMMITS-HASH where COMMITS is the
# number of commits since the last tag.)
export GIT_TAG ?= dev
# Prow gives this the reference it's called on.
# The test-infra config job only allows our cloudbuild to
# be called on `main` and semver tags, so this will be
# set to one of those things.
export BASE_REF ?= main
# The commit hash of the current checkout
# Used to pass a binary version for main,
# overridden to semver for tagged versions.
# Cloudbuild will set this in the environment to the
# commit SHA, since the Prow does not seem to check out
# a git repo.
export COMMIT ?= $(shell git rev-parse --short HEAD)
DOCKER ?= docker
# TOP is the current directory where this Makefile lives.
TOP := $(dir $(firstword $(MAKEFILE_LIST)))
# ROOT is the root of the mkdocs tree.
ROOT := $(abspath $(TOP))
# Command-line flags passed to "go test" for the conformance
# test. These are passed after the "-args" flag.
CONFORMANCE_FLAGS ?=
GO_TEST_FLAGS ?=
all: generate vet fmt verify test
# Run generators for protos, Deepcopy funcs, CRDs, and docs.
.PHONY: generate
generate: update-codegen
.PHONY: update-codegen
update-codegen:
hack/update-codegen.sh
.PHONY: build-install-yaml
build-install-yaml:
hack/build-install-yaml.sh
# Run go fmt against code
fmt:
go fmt ./...
# Run go vet against code
vet:
go vet ./...
# Run go test against code
test:
go test -race -cover ./apis/... ./conformance/utils/...
# Run tests for each submodule.
cd "conformance/echo-basic" && go test -race -cover ./...
cd "gwctl" && go test -race -cover ./...
# Run tests for CRDs validation
.PHONY: test.crds-validation
test.crds-validation:
./hack/test-crds-validation.sh $(VERSION)
# Run conformance tests against controller implementation
.PHONY: conformance
conformance:
go test ${GO_TEST_FLAGS} -v ./conformance -run TestConformance -args ${CONFORMANCE_FLAGS}
# Install CRD's and example resources to a pre-existing cluster.
.PHONY: install
install: crd example
# Install the CRD's to a pre-existing cluster.
.PHONY: crd
crd:
kubectl kustomize config/crd | kubectl apply -f -
# Install the example resources to a pre-existing cluster.
.PHONY: example
example:
hack/install-examples.sh
# Remove installed CRD's and CR's.
.PHONY: uninstall
uninstall:
hack/delete-crds.sh
# Run static analysis.
.PHONY: verify
verify:
hack/verify-all.sh -v
# Build the documentation.
.PHONY: docs
docs:
hack/make-docs.sh
.PHONY: update-conformance-image-refs
update-conformance-image-refs:
hack/update-conformance-image-refs.sh
# Verify if support Docker Buildx.
.PHONY: image.buildx.verify
image.buildx.verify:
docker version
$(eval PASS := $(shell docker buildx --help | grep "docker buildx" ))
@if [ -z "$(PASS)" ]; then \
echo "Cannot find docker buildx, please install first."; \
exit 1;\
else \
echo "===========> Support docker buildx"; \
docker buildx version; \
fi
export BUILDX_CONTEXT = gateway-api-builder
export BUILDX_PLATFORMS = linux/amd64,linux/arm64
# Setup multi-arch docker buildx environment.
.PHONY: image.multiarch.setup
image.multiarch.setup: image.buildx.verify
# Ensure qemu is in binfmt_misc.
# Docker desktop already has these in versions recent enough to have buildx,
# We only need to do this setup on linux hosts.
@if [ "$(shell uname)" == "Linux" ]; then \
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes; \
fi
# Ensure we use a builder that can leverage it, we need to recreate one.
docker buildx rm $(BUILDX_CONTEXT) || :
docker buildx create --use --name $(BUILDX_CONTEXT) --platform "${BUILDX_PLATFORMS}"
# Build and Push Multi Arch Images.
.PHONY: release-staging
release-staging: image.multiarch.setup
hack/build-and-push.sh
# Generate a virtualenv install, which is useful for hacking on the
# docs since it installs mkdocs and all the right dependencies.
#
# On Ubuntu, this requires the python3-venv package.
virtualenv: .venv
.venv: requirements.txt
@echo Creating a virtualenv in $@"... "
@python3 -m venv $@ || (rm -rf $@ && exit 1)
@echo Installing packages in $@"... "
@$@/bin/python3 -m pip install -q -r requirements.txt || (rm -rf $@ && exit 1)
@echo To enter the virtualenv type \"source $@/bin/activate\", to exit type \"deactivate\"