velero/Makefile

399 lines
13 KiB
Makefile
Raw Normal View History

# Copyright 2016 The Kubernetes Authors.
#
# Modifications Copyright 2020 the Velero contributors.
#
# 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.
# The binary to build (just the basename).
BIN ?= velero
# This repo's root import path (under GOPATH).
PKG := github.com/vmware-tanzu/velero
# Where to push the docker image.
REGISTRY ?= velero
GCR_REGISTRY ?= gcr.io/velero-gcp
# Image name
IMAGE ?= $(REGISTRY)/$(BIN)
GCR_IMAGE ?= $(GCR_REGISTRY)/$(BIN)
# We allow the Dockerfile to be configurable to enable the use of custom Dockerfiles
# that pull base images from different registries.
VELERO_DOCKERFILE ?= Dockerfile
BUILDER_IMAGE_DOCKERFILE ?= hack/build-image/Dockerfile
# Calculate the realpath of the build-image Dockerfile as we `cd` into the hack/build
# directory before this Dockerfile is used and any relative path will not be valid.
BUILDER_IMAGE_DOCKERFILE_REALPATH := $(shell realpath $(BUILDER_IMAGE_DOCKERFILE))
# Build image handling. We push a build image for every changed version of
# /hack/build-image/Dockerfile. We tag the dockerfile with the short commit hash
# of the commit that changed it. When determining if there is a build image in
# the registry to use we look for one that matches the current "commit" for the
# Dockerfile else we make one.
# In the case where the Dockerfile for the build image has been overridden using
# the BUILDER_IMAGE_DOCKERFILE variable, we always force a build.
ifneq "$(origin BUILDER_IMAGE_DOCKERFILE)" "file"
BUILDER_IMAGE_TAG := "custom"
else
BUILDER_IMAGE_TAG := $(shell git log -1 --pretty=%h $(BUILDER_IMAGE_DOCKERFILE))
endif
BUILDER_IMAGE := $(REGISTRY)/build-image:$(BUILDER_IMAGE_TAG)
BUILDER_IMAGE_CACHED := $(shell docker images -q ${BUILDER_IMAGE} 2>/dev/null )
HUGO_IMAGE := hugo-builder
# Which architecture to build - see $(ALL_ARCH) for options.
# if the 'local' rule is being run, detect the ARCH from 'go env'
# if it wasn't specified by the caller.
local : ARCH ?= $(shell go env GOOS)-$(shell go env GOARCH)
ARCH ?= linux-amd64
VERSION ?= main
TAG_LATEST ?= false
ifeq ($(TAG_LATEST), true)
IMAGE_TAGS ?= $(IMAGE):$(VERSION) $(IMAGE):latest
GCR_IMAGE_TAGS ?= $(GCR_IMAGE):$(VERSION) $(GCR_IMAGE):latest
else
IMAGE_TAGS ?= $(IMAGE):$(VERSION)
GCR_IMAGE_TAGS ?= $(GCR_IMAGE):$(VERSION)
endif
# check buildx is enabled
# macOS/Windows docker cli without Docker Desktop license: https://github.com/abiosoft/colima
# To add buildx to docker cli: https://github.com/abiosoft/colima/discussions/273#discussioncomment-2684502
ifeq ($(shell docker buildx inspect 2>/dev/null | awk '/Status/ { print $$2 }'), running)
BUILDX_ENABLED ?= true
# if emulated docker cli from podman, assume enabled
# emulated docker cli from podman: https://podman-desktop.io/docs/migrating-from-docker/emulating-docker-cli-with-podman
# podman known issues:
# - on remote podman, such as on macOS,
# --output issue: https://github.com/containers/podman/issues/15922
else ifeq ($(shell cat $(shell which docker) | grep -c "exec podman"), 1)
BUILDX_ENABLED ?= true
else
BUILDX_ENABLED ?= false
endif
define BUILDX_ERROR
buildx not enabled, refusing to run this recipe
see: https://velero.io/docs/main/build-from-source/#making-images-and-updating-velero for more info
endef
# The version of restic binary to be downloaded
RESTIC_VERSION ?= 0.15.0
CLI_PLATFORMS ?= linux-amd64 linux-arm linux-arm64 darwin-amd64 darwin-arm64 windows-amd64 linux-ppc64le
BUILDX_PLATFORMS ?= $(subst -,/,$(ARCH))
BUILDX_OUTPUT_TYPE ?= image
# set git sha and tree state
GIT_SHA = $(shell git rev-parse HEAD)
ifneq ($(shell git status --porcelain 2> /dev/null),)
GIT_TREE_STATE ?= dirty
else
GIT_TREE_STATE ?= clean
endif
###
### These variables should not need tweaking.
###
platform_temp = $(subst -, ,$(ARCH))
GOOS = $(word 1, $(platform_temp))
GOARCH = $(word 2, $(platform_temp))
GOPROXY ?= https://proxy.golang.org
Set `GOBIN` so Makefile don't modify $PATH on `go install` Fix realPath resolving when cloud credentials is prefixed by `~` for home dir Use `~/.docker/config.json` if REGISTRY_CREDENTIAL_FILE not defined and skip step if does not exists since it is optional Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Set `GOBIN` so Makefile don't modify $PATH on `go install` Fix realPath resolving when cloud credentials is prefixed by `~` for home dir Use `~/.docker/config.json` if REGISTRY_CREDENTIAL_FILE not defined and skip step if does not exists since it is optional Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add kind testdata storageclass Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add kind testdata storageclass Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> log `Start to install Azure VolumeSnapshotClass ...` only on azure when csi is enabled Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add BSL_CONFIG example and notes Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Makefile: Set `GOBIN` for `_output/...` Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> README spacing Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> StandbyClusterObjectStoreProvider typo Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Specify velero namespace during get/delete command Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Use object stores rather than cloudProvider for bucket queries Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Remove debug print Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> simplify NS get changes, add velero NS to `DeleteBackupResource` Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Skip file system backups on kind which uses hostPath volumes Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add StorageClass change test to PR kind e2e Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add more tests to pr Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add NS mapping to PR e2e Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add `SKIP_KIND` to some jobs containing volumes Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Remove kind from kibishii tests Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Label volume resource policies as restic, skip restic/snapshot tests, add more tests Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> TTLTest is a snapshot test Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Remove non working tests Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Resolve https://github.com/vmware-tanzu/velero/pull/7353#issuecomment-1925660077 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> address https://github.com/vmware-tanzu/velero/pull/7353/files#r1477218762 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Address https://github.com/vmware-tanzu/velero/pull/7353#issuecomment-1923414840 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
2024-01-24 19:28:58 +00:00
GOBIN=$$(pwd)/.go/bin
# If you want to build all binaries, see the 'all-build' rule.
# If you want to build all containers, see the 'all-containers' rule.
all:
@$(MAKE) build
@$(MAKE) build BIN=velero-restore-helper
build-%:
@$(MAKE) --no-print-directory ARCH=$* build
@$(MAKE) --no-print-directory ARCH=$* build BIN=velero-restore-helper
all-build: $(addprefix build-, $(CLI_PLATFORMS))
all-containers:
@$(MAKE) --no-print-directory container
@$(MAKE) --no-print-directory container BIN=velero-restore-helper
local: build-dirs
# Add DEBUG=1 to enable debug locally
GOOS=$(GOOS) \
GOARCH=$(GOARCH) \
Set `GOBIN` so Makefile don't modify $PATH on `go install` Fix realPath resolving when cloud credentials is prefixed by `~` for home dir Use `~/.docker/config.json` if REGISTRY_CREDENTIAL_FILE not defined and skip step if does not exists since it is optional Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Set `GOBIN` so Makefile don't modify $PATH on `go install` Fix realPath resolving when cloud credentials is prefixed by `~` for home dir Use `~/.docker/config.json` if REGISTRY_CREDENTIAL_FILE not defined and skip step if does not exists since it is optional Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add kind testdata storageclass Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add kind testdata storageclass Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> log `Start to install Azure VolumeSnapshotClass ...` only on azure when csi is enabled Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add BSL_CONFIG example and notes Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Makefile: Set `GOBIN` for `_output/...` Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> README spacing Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> StandbyClusterObjectStoreProvider typo Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Specify velero namespace during get/delete command Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Use object stores rather than cloudProvider for bucket queries Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Remove debug print Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> simplify NS get changes, add velero NS to `DeleteBackupResource` Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Skip file system backups on kind which uses hostPath volumes Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add StorageClass change test to PR kind e2e Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add more tests to pr Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add NS mapping to PR e2e Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add `SKIP_KIND` to some jobs containing volumes Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Remove kind from kibishii tests Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Label volume resource policies as restic, skip restic/snapshot tests, add more tests Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> TTLTest is a snapshot test Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Remove non working tests Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Resolve https://github.com/vmware-tanzu/velero/pull/7353#issuecomment-1925660077 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> address https://github.com/vmware-tanzu/velero/pull/7353/files#r1477218762 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Address https://github.com/vmware-tanzu/velero/pull/7353#issuecomment-1923414840 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
2024-01-24 19:28:58 +00:00
GOBIN=$(GOBIN) \
VERSION=$(VERSION) \
Allow registry to be configured at build time This adds a new `buildinfo` variable `ImageRegistry` that can set at build time like the `Version` variable. This allows us to customise the Velero binary to use different registries. If the variable is set, this variable wille be used when creating the URIs for both the main `velero` and `velero-restic-restore-helper` images. If it is not set, default to using Dockerhub (`velero/velero`, `velero/velero-restic-restore-helper`). There are numerous ways in which the Velero binary can be built so all of them have been updated to add the new link time flag to set the variable: * `make local` (used for local developer builds to build for the local OS and ARCH) * `make build` (used by developers and also VMware internal builds to build a specific OS and ARCH) * Goreleaser config (used when creating OSS release binaries) * Dockerfile (used to build the Velero binary used within the image) All of these workflows are currently triggered from our Makefile where the variable `REGISTRY` is already available with the default value of `velero` and used to build the image tag. Where the new `ImageRegistry` build variable is needed, we pass through this Makefile variable to those tasks so it can be used accordingly. The GitHub action and the `./hack/docker-push.sh` script used to push container images has not been modified. This will continue to use the default registry specified in the Makefile and will not explicitly pass it in. Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>
2021-07-06 20:14:46 +00:00
REGISTRY=$(REGISTRY) \
PKG=$(PKG) \
BIN=$(BIN) \
GIT_SHA=$(GIT_SHA) \
GIT_TREE_STATE=$(GIT_TREE_STATE) \
OUTPUT_DIR=$$(pwd)/_output/bin/$(GOOS)/$(GOARCH) \
./hack/build.sh
build: _output/bin/$(GOOS)/$(GOARCH)/$(BIN)
_output/bin/$(GOOS)/$(GOARCH)/$(BIN): build-dirs
@echo "building: $@"
$(MAKE) shell CMD="-c '\
GOOS=$(GOOS) \
GOARCH=$(GOARCH) \
Set `GOBIN` so Makefile don't modify $PATH on `go install` Fix realPath resolving when cloud credentials is prefixed by `~` for home dir Use `~/.docker/config.json` if REGISTRY_CREDENTIAL_FILE not defined and skip step if does not exists since it is optional Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Set `GOBIN` so Makefile don't modify $PATH on `go install` Fix realPath resolving when cloud credentials is prefixed by `~` for home dir Use `~/.docker/config.json` if REGISTRY_CREDENTIAL_FILE not defined and skip step if does not exists since it is optional Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add kind testdata storageclass Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add kind testdata storageclass Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> log `Start to install Azure VolumeSnapshotClass ...` only on azure when csi is enabled Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add BSL_CONFIG example and notes Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Makefile: Set `GOBIN` for `_output/...` Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> README spacing Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> StandbyClusterObjectStoreProvider typo Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Specify velero namespace during get/delete command Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Use object stores rather than cloudProvider for bucket queries Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Remove debug print Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> simplify NS get changes, add velero NS to `DeleteBackupResource` Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Skip file system backups on kind which uses hostPath volumes Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add StorageClass change test to PR kind e2e Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add more tests to pr Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add NS mapping to PR e2e Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Add `SKIP_KIND` to some jobs containing volumes Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Remove kind from kibishii tests Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Label volume resource policies as restic, skip restic/snapshot tests, add more tests Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> TTLTest is a snapshot test Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Remove non working tests Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Resolve https://github.com/vmware-tanzu/velero/pull/7353#issuecomment-1925660077 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> address https://github.com/vmware-tanzu/velero/pull/7353/files#r1477218762 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com> Address https://github.com/vmware-tanzu/velero/pull/7353#issuecomment-1923414840 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
2024-01-24 19:28:58 +00:00
GOBIN=$(GOBIN) \
VERSION=$(VERSION) \
Allow registry to be configured at build time This adds a new `buildinfo` variable `ImageRegistry` that can set at build time like the `Version` variable. This allows us to customise the Velero binary to use different registries. If the variable is set, this variable wille be used when creating the URIs for both the main `velero` and `velero-restic-restore-helper` images. If it is not set, default to using Dockerhub (`velero/velero`, `velero/velero-restic-restore-helper`). There are numerous ways in which the Velero binary can be built so all of them have been updated to add the new link time flag to set the variable: * `make local` (used for local developer builds to build for the local OS and ARCH) * `make build` (used by developers and also VMware internal builds to build a specific OS and ARCH) * Goreleaser config (used when creating OSS release binaries) * Dockerfile (used to build the Velero binary used within the image) All of these workflows are currently triggered from our Makefile where the variable `REGISTRY` is already available with the default value of `velero` and used to build the image tag. Where the new `ImageRegistry` build variable is needed, we pass through this Makefile variable to those tasks so it can be used accordingly. The GitHub action and the `./hack/docker-push.sh` script used to push container images has not been modified. This will continue to use the default registry specified in the Makefile and will not explicitly pass it in. Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>
2021-07-06 20:14:46 +00:00
REGISTRY=$(REGISTRY) \
PKG=$(PKG) \
BIN=$(BIN) \
GIT_SHA=$(GIT_SHA) \
GIT_TREE_STATE=$(GIT_TREE_STATE) \
OUTPUT_DIR=/output/$(GOOS)/$(GOARCH) \
./hack/build.sh'"
TTY := $(shell tty -s && echo "-t")
# Example: make shell CMD="date > datefile"
shell: build-dirs build-env
@# bind-mount the Velero root dir in at /github.com/vmware-tanzu/velero
@# because the Kubernetes code-generator tools require the project to
@# exist in a directory hierarchy ending like this (but *NOT* necessarily
@# under $GOPATH).
@docker run \
-e GOFLAGS \
-e GOPROXY \
-i $(TTY) \
--rm \
-u $$(id -u):$$(id -g) \
-v "$$(pwd):/github.com/vmware-tanzu/velero:delegated" \
-v "$$(pwd)/_output/bin:/output:delegated" \
-v "$$(pwd)/.go/pkg:/go/pkg:delegated" \
-v "$$(pwd)/.go/std:/go/std:delegated" \
-v "$$(pwd)/.go/std/$(GOOS)/$(GOARCH):/usr/local/go/pkg/$(GOOS)_$(GOARCH)_static:delegated" \
-v "$$(pwd)/.go/go-build:/.cache/go-build:delegated" \
Add linter (#2615) * Add linter to Makefile and build image * Also make it part of verify step Signed-off-by: Tony Batard <tbatard@pivotal.io> * clean up of Makefile and permissions for .go/golangci-lint Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * changed verify-lint.sh to lint.sh to avoid breaking ci Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Add changelog Signed-off-by: Tony Batard <tbatard@pivotal.io> * Add LINTERS option to run only specific linters * e.g. make lint LINTERS=unused,deadcode Signed-off-by: Tony Batard <tbatard@pivotal.io> * adding timeout to golangci-lint, and checking cache Signed-off-by: Matyas Danter <mdanter@vmware.com> * Fixed some formatting and added comments Signed-off-by: Matyas Danter <mdanter@vmware.com> * modifying lint script to use golangci.yaml Signed-off-by: Matyas Danter <mdanter@vmware.com> * update to move default linters to Makefile Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Adding documentation for lint make targets. Signed-off-by: Matyas Danter <mdanter@vmware.com> * Update Copyright with current year Signed-off-by: Tony Batard <tbatard@pivotal.io> * initial git workflow commit Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Added lint-all target and implemented -n as default * Added a local-lint-all and lint-all target that will show lint errors for all of the codebase * changed the default of lint and local-lint to only show new lint errors Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * updated docs to reflect new target Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Duffie Cooley <cooleyd@vmware.com> Co-authored-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Matyas Danter <mdanter@vmware.com>
2020-06-30 16:51:10 +00:00
-v "$$(pwd)/.go/golangci-lint:/.cache/golangci-lint:delegated" \
-w /github.com/vmware-tanzu/velero \
$(BUILDER_IMAGE) \
/bin/sh $(CMD)
container:
ifneq ($(BUILDX_ENABLED), true)
$(error $(BUILDX_ERROR))
endif
@docker buildx build --pull \
--output=type=$(BUILDX_OUTPUT_TYPE) \
--platform $(BUILDX_PLATFORMS) \
$(addprefix -t , $(IMAGE_TAGS)) \
$(addprefix -t , $(GCR_IMAGE_TAGS)) \
--build-arg=GOPROXY=$(GOPROXY) \
--build-arg=PKG=$(PKG) \
--build-arg=BIN=$(BIN) \
--build-arg=VERSION=$(VERSION) \
--build-arg=GIT_SHA=$(GIT_SHA) \
--build-arg=GIT_TREE_STATE=$(GIT_TREE_STATE) \
Allow registry to be configured at build time This adds a new `buildinfo` variable `ImageRegistry` that can set at build time like the `Version` variable. This allows us to customise the Velero binary to use different registries. If the variable is set, this variable wille be used when creating the URIs for both the main `velero` and `velero-restic-restore-helper` images. If it is not set, default to using Dockerhub (`velero/velero`, `velero/velero-restic-restore-helper`). There are numerous ways in which the Velero binary can be built so all of them have been updated to add the new link time flag to set the variable: * `make local` (used for local developer builds to build for the local OS and ARCH) * `make build` (used by developers and also VMware internal builds to build a specific OS and ARCH) * Goreleaser config (used when creating OSS release binaries) * Dockerfile (used to build the Velero binary used within the image) All of these workflows are currently triggered from our Makefile where the variable `REGISTRY` is already available with the default value of `velero` and used to build the image tag. Where the new `ImageRegistry` build variable is needed, we pass through this Makefile variable to those tasks so it can be used accordingly. The GitHub action and the `./hack/docker-push.sh` script used to push container images has not been modified. This will continue to use the default registry specified in the Makefile and will not explicitly pass it in. Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>
2021-07-06 20:14:46 +00:00
--build-arg=REGISTRY=$(REGISTRY) \
--build-arg=RESTIC_VERSION=$(RESTIC_VERSION) \
-f $(VELERO_DOCKERFILE) .
@echo "container: $(IMAGE):$(VERSION)"
ifeq ($(BUILDX_OUTPUT_TYPE)_$(REGISTRY), registry_velero)
docker pull $(IMAGE):$(VERSION)
rm -f $(BIN)-$(VERSION).tar
docker save $(IMAGE):$(VERSION) -o $(BIN)-$(VERSION).tar
gzip -f $(BIN)-$(VERSION).tar
endif
SKIP_TESTS ?=
test: build-dirs
ifneq ($(SKIP_TESTS), 1)
@$(MAKE) shell CMD="-c 'hack/test.sh $(WHAT)'"
endif
test-local: build-dirs
ifneq ($(SKIP_TESTS), 1)
hack/test.sh $(WHAT)
endif
verify:
ifneq ($(SKIP_TESTS), 1)
@$(MAKE) shell CMD="-c 'hack/verify-all.sh'"
endif
Add linter (#2615) * Add linter to Makefile and build image * Also make it part of verify step Signed-off-by: Tony Batard <tbatard@pivotal.io> * clean up of Makefile and permissions for .go/golangci-lint Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * changed verify-lint.sh to lint.sh to avoid breaking ci Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Add changelog Signed-off-by: Tony Batard <tbatard@pivotal.io> * Add LINTERS option to run only specific linters * e.g. make lint LINTERS=unused,deadcode Signed-off-by: Tony Batard <tbatard@pivotal.io> * adding timeout to golangci-lint, and checking cache Signed-off-by: Matyas Danter <mdanter@vmware.com> * Fixed some formatting and added comments Signed-off-by: Matyas Danter <mdanter@vmware.com> * modifying lint script to use golangci.yaml Signed-off-by: Matyas Danter <mdanter@vmware.com> * update to move default linters to Makefile Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Adding documentation for lint make targets. Signed-off-by: Matyas Danter <mdanter@vmware.com> * Update Copyright with current year Signed-off-by: Tony Batard <tbatard@pivotal.io> * initial git workflow commit Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Added lint-all target and implemented -n as default * Added a local-lint-all and lint-all target that will show lint errors for all of the codebase * changed the default of lint and local-lint to only show new lint errors Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * updated docs to reflect new target Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Duffie Cooley <cooleyd@vmware.com> Co-authored-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Matyas Danter <mdanter@vmware.com>
2020-06-30 16:51:10 +00:00
lint:
ifneq ($(SKIP_TESTS), 1)
@$(MAKE) shell CMD="-c 'hack/lint.sh'"
Add linter (#2615) * Add linter to Makefile and build image * Also make it part of verify step Signed-off-by: Tony Batard <tbatard@pivotal.io> * clean up of Makefile and permissions for .go/golangci-lint Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * changed verify-lint.sh to lint.sh to avoid breaking ci Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Add changelog Signed-off-by: Tony Batard <tbatard@pivotal.io> * Add LINTERS option to run only specific linters * e.g. make lint LINTERS=unused,deadcode Signed-off-by: Tony Batard <tbatard@pivotal.io> * adding timeout to golangci-lint, and checking cache Signed-off-by: Matyas Danter <mdanter@vmware.com> * Fixed some formatting and added comments Signed-off-by: Matyas Danter <mdanter@vmware.com> * modifying lint script to use golangci.yaml Signed-off-by: Matyas Danter <mdanter@vmware.com> * update to move default linters to Makefile Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Adding documentation for lint make targets. Signed-off-by: Matyas Danter <mdanter@vmware.com> * Update Copyright with current year Signed-off-by: Tony Batard <tbatard@pivotal.io> * initial git workflow commit Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Added lint-all target and implemented -n as default * Added a local-lint-all and lint-all target that will show lint errors for all of the codebase * changed the default of lint and local-lint to only show new lint errors Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * updated docs to reflect new target Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Duffie Cooley <cooleyd@vmware.com> Co-authored-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Matyas Danter <mdanter@vmware.com>
2020-06-30 16:51:10 +00:00
endif
local-lint:
ifneq ($(SKIP_TESTS), 1)
@hack/lint.sh
Add linter (#2615) * Add linter to Makefile and build image * Also make it part of verify step Signed-off-by: Tony Batard <tbatard@pivotal.io> * clean up of Makefile and permissions for .go/golangci-lint Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * changed verify-lint.sh to lint.sh to avoid breaking ci Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Add changelog Signed-off-by: Tony Batard <tbatard@pivotal.io> * Add LINTERS option to run only specific linters * e.g. make lint LINTERS=unused,deadcode Signed-off-by: Tony Batard <tbatard@pivotal.io> * adding timeout to golangci-lint, and checking cache Signed-off-by: Matyas Danter <mdanter@vmware.com> * Fixed some formatting and added comments Signed-off-by: Matyas Danter <mdanter@vmware.com> * modifying lint script to use golangci.yaml Signed-off-by: Matyas Danter <mdanter@vmware.com> * update to move default linters to Makefile Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Adding documentation for lint make targets. Signed-off-by: Matyas Danter <mdanter@vmware.com> * Update Copyright with current year Signed-off-by: Tony Batard <tbatard@pivotal.io> * initial git workflow commit Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Added lint-all target and implemented -n as default * Added a local-lint-all and lint-all target that will show lint errors for all of the codebase * changed the default of lint and local-lint to only show new lint errors Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * updated docs to reflect new target Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Duffie Cooley <cooleyd@vmware.com> Co-authored-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Matyas Danter <mdanter@vmware.com>
2020-06-30 16:51:10 +00:00
endif
update:
@$(MAKE) shell CMD="-c 'hack/update-all.sh'"
# update-crd is for development purpose only, it is faster than update, so is a shortcut when you want to generate CRD changes only
update-crd:
@$(MAKE) shell CMD="-c 'hack/update-3generated-crd-code.sh'"
build-dirs:
@mkdir -p _output/bin/$(GOOS)/$(GOARCH)
Add linter (#2615) * Add linter to Makefile and build image * Also make it part of verify step Signed-off-by: Tony Batard <tbatard@pivotal.io> * clean up of Makefile and permissions for .go/golangci-lint Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * changed verify-lint.sh to lint.sh to avoid breaking ci Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Add changelog Signed-off-by: Tony Batard <tbatard@pivotal.io> * Add LINTERS option to run only specific linters * e.g. make lint LINTERS=unused,deadcode Signed-off-by: Tony Batard <tbatard@pivotal.io> * adding timeout to golangci-lint, and checking cache Signed-off-by: Matyas Danter <mdanter@vmware.com> * Fixed some formatting and added comments Signed-off-by: Matyas Danter <mdanter@vmware.com> * modifying lint script to use golangci.yaml Signed-off-by: Matyas Danter <mdanter@vmware.com> * update to move default linters to Makefile Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Adding documentation for lint make targets. Signed-off-by: Matyas Danter <mdanter@vmware.com> * Update Copyright with current year Signed-off-by: Tony Batard <tbatard@pivotal.io> * initial git workflow commit Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> * Added lint-all target and implemented -n as default * Added a local-lint-all and lint-all target that will show lint errors for all of the codebase * changed the default of lint and local-lint to only show new lint errors Signed-off-by: Duffie Cooley <cooleyd@vmware.com> * updated docs to reflect new target Signed-off-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Duffie Cooley <cooleyd@vmware.com> Co-authored-by: mtritabaugh <mtritabaugh@vmware.com> Co-authored-by: Matyas Danter <mdanter@vmware.com>
2020-06-30 16:51:10 +00:00
@mkdir -p .go/src/$(PKG) .go/pkg .go/bin .go/std/$(GOOS)/$(GOARCH) .go/go-build .go/golangci-lint
build-env:
@# if we have overridden the value for the build-image Dockerfile,
@# force a build using that Dockerfile
@# if we detect changes in dockerfile force a new build-image
@# else if we dont have a cached image make one
@# finally use the cached image
ifneq "$(origin BUILDER_IMAGE_DOCKERFILE)" "file"
@echo "Dockerfile for builder image has been overridden to $(BUILDER_IMAGE_DOCKERFILE)"
@echo "Preparing a new builder-image"
$(MAKE) build-image
else ifneq ($(shell git diff --quiet HEAD -- $(BUILDER_IMAGE_DOCKERFILE); echo $$?), 0)
@echo "Local changes detected in $(BUILDER_IMAGE_DOCKERFILE)"
@echo "Preparing a new builder-image"
$(MAKE) build-image
else ifneq ($(BUILDER_IMAGE_CACHED),)
@echo "Using Cached Image: $(BUILDER_IMAGE)"
else
@echo "Trying to pull build-image: $(BUILDER_IMAGE)"
docker pull -q $(BUILDER_IMAGE) || $(MAKE) build-image
endif
build-image:
@# When we build a new image we just untag the old one.
@# This makes sure we don't leave the orphaned image behind.
$(eval old_id=$(shell docker image inspect --format '{{ .ID }}' ${BUILDER_IMAGE} 2>/dev/null))
ifeq ($(BUILDX_ENABLED), true)
@cd hack/build-image && docker buildx build --build-arg=GOPROXY=$(GOPROXY) --output=type=docker --pull -t $(BUILDER_IMAGE) -f $(BUILDER_IMAGE_DOCKERFILE_REALPATH) .
else
@cd hack/build-image && docker build --build-arg=GOPROXY=$(GOPROXY) --pull -t $(BUILDER_IMAGE) -f $(BUILDER_IMAGE_DOCKERFILE_REALPATH) .
endif
$(eval new_id=$(shell docker image inspect --format '{{ .ID }}' ${BUILDER_IMAGE} 2>/dev/null))
@if [ "$(old_id)" != "" ] && [ "$(old_id)" != "$(new_id)" ]; then \
docker rmi -f $$id || true; \
fi
push-build-image:
@# this target will push the build-image it assumes you already have docker
@# credentials needed to accomplish this.
@# Pushing will be skipped if a custom Dockerfile was used to build the image.
ifneq "$(origin BUILDER_IMAGE_DOCKERFILE)" "file"
@echo "Dockerfile for builder image has been overridden"
@echo "Skipping push of custom image"
else
docker push $(BUILDER_IMAGE)
endif
build-image-hugo:
cd site && docker build --pull -t $(HUGO_IMAGE) .
clean:
# if we have a cached image then use it to run go clean --modcache
# this test checks if we there is an image id in the BUILDER_IMAGE_CACHED variable.
ifneq ($(strip $(BUILDER_IMAGE_CACHED)),)
$(MAKE) shell CMD="-c 'go clean --modcache'"
docker rmi -f $(BUILDER_IMAGE) || true
endif
rm -rf .go _output
docker rmi $(HUGO_IMAGE)
.PHONY: modules
modules:
go mod tidy
.PHONY: verify-modules
verify-modules: modules
@if !(git diff --quiet HEAD -- go.sum go.mod); then \
echo "go module files are out of date, please commit the changes to go.mod and go.sum"; exit 1; \
fi
ci: verify-modules verify all test
changelog:
hack/release-tools/changelog.sh
# release builds a GitHub release using goreleaser within the build container.
#
# To dry-run the release, which will build the binaries/artifacts locally but
# will *not* create a GitHub release:
# GITHUB_TOKEN=an-invalid-token-so-you-dont-accidentally-push-release \
# RELEASE_NOTES_FILE=changelogs/CHANGELOG-1.2.md \
# PUBLISH=false \
# make release
#
# To run the release, which will publish a *DRAFT* GitHub release in github.com/vmware-tanzu/velero
# (you still need to review/publish the GitHub release manually):
# GITHUB_TOKEN=your-github-token \
# RELEASE_NOTES_FILE=changelogs/CHANGELOG-1.2.md \
# PUBLISH=true \
# make release
release:
$(MAKE) shell CMD="-c '\
GITHUB_TOKEN=$(GITHUB_TOKEN) \
RELEASE_NOTES_FILE=$(RELEASE_NOTES_FILE) \
PUBLISH=$(PUBLISH) \
Allow registry to be configured at build time This adds a new `buildinfo` variable `ImageRegistry` that can set at build time like the `Version` variable. This allows us to customise the Velero binary to use different registries. If the variable is set, this variable wille be used when creating the URIs for both the main `velero` and `velero-restic-restore-helper` images. If it is not set, default to using Dockerhub (`velero/velero`, `velero/velero-restic-restore-helper`). There are numerous ways in which the Velero binary can be built so all of them have been updated to add the new link time flag to set the variable: * `make local` (used for local developer builds to build for the local OS and ARCH) * `make build` (used by developers and also VMware internal builds to build a specific OS and ARCH) * Goreleaser config (used when creating OSS release binaries) * Dockerfile (used to build the Velero binary used within the image) All of these workflows are currently triggered from our Makefile where the variable `REGISTRY` is already available with the default value of `velero` and used to build the image tag. Where the new `ImageRegistry` build variable is needed, we pass through this Makefile variable to those tasks so it can be used accordingly. The GitHub action and the `./hack/docker-push.sh` script used to push container images has not been modified. This will continue to use the default registry specified in the Makefile and will not explicitly pass it in. Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>
2021-07-06 20:14:46 +00:00
REGISTRY=$(REGISTRY) \
./hack/release-tools/goreleaser.sh'"
serve-docs: build-image-hugo
docker run \
--rm \
-v "$$(pwd)/site:/srv/hugo" \
-it -p 1313:1313 \
$(HUGO_IMAGE) \
server --bind=0.0.0.0 --enableGitInfo=false
# gen-docs generates a new versioned docs directory under site/content/docs.
# Please read the documentation in the script for instructions on how to use it.
gen-docs:
@hack/release-tools/gen-docs.sh
.PHONY: test-e2e
✨ Add more E2E tests and improvement (#3111) * remove checked in binary and update test/e2e Makefile Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * remove platform specific tests for now Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * install velero before running tests and robust makefiles Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * changelog Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * running e2e tests expects credentials file to be supplied run e2e tests on velero/velero:main image by default Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * refactor to parameterize tests Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * rename files to use provider tests convention Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * rename tests file Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * remove providerName config Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * run kibishii test on azure Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * refactor to make bsl vsl configurable Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * skip e2e tests when not explicitly running e2e tests Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * update e2e docs Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * refactor and update docs Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * refactor Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * cleanup Signed-off-by: Ashish Amarnath <ashisham@vmware.com> * use velero's exec package Signed-off-by: Ashish Amarnath <ashisham@vmware.com> Co-authored-by: Dave Smith-Uchida <dsmithuchida@vmware.com>
2020-12-10 00:26:05 +00:00
test-e2e: local
$(MAKE) -e VERSION=$(VERSION) -C test/ run-e2e
.PHONY: test-perf
test-perf: local
$(MAKE) -e VERSION=$(VERSION) -C test/ run-perf
go-generate:
go generate ./pkg/...
# requires an authenticated gh cli
# gh: https://cli.github.com/
# First create a PR
# gh pr create --title 'Title name' --body 'PR body'
# by default uses PR title as changelog body but can be overwritten like so
# make new-changelog CHANGELOG_BODY="Changes you have made"
new-changelog: GH_LOGIN ?= $(shell gh pr view --json author --jq .author.login 2> /dev/null)
new-changelog: GH_PR_NUMBER ?= $(shell gh pr view --json number --jq .number 2> /dev/null)
new-changelog: CHANGELOG_BODY ?= "$(shell gh pr view --json title --jq .title)"
new-changelog:
@if [ "$(GH_LOGIN)" = "" ]; then \
echo "branch does not have PR or cli not logged in, try 'gh auth login' or 'gh pr create'"; \
exit 1; \
fi
@mkdir -p ./changelogs/unreleased/ && \
echo $(CHANGELOG_BODY) > ./changelogs/unreleased/$(GH_PR_NUMBER)-$(GH_LOGIN) && \
echo "\"$(CHANGELOG_BODY)\" added to ./changelogs/unreleased/$(GH_PR_NUMBER)-$(GH_LOGIN)"