Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ KUBEVIRTCI_REGISTRY_PREFIX=registry:5000/kubevirt
PORT=$(shell ./cluster-up/cli.sh ports registry)

BUILD_IMAGE ?= quay.io/konveyor/builder
OCI_BIN ?= $(shell if podman ps >/dev/null 2>&1; then echo podman; elif docker ps >/dev/null 2>&1; then echo docker; fi)
TLS_SETTING := $(if $(filter $(OCI_BIN),podman),--tls-verify=false,)
export OCI_BIN
export TLS_SETTING

all: build-image

Expand Down Expand Up @@ -104,20 +108,22 @@ _output/bin/$(GOOS)/$(GOARCH)/$(BIN): build-dirs ${SRC_FILES}
./hack/build/build.sh'"

TTY := $(shell tty -s && echo "-t")
PODMAN_SPECIFIC_FLAG := $(if $(filter $(OCI_BIN),podman),--userns=keep-id,)

shell: build-dirs
@echo "running docker: $@"
@docker run \
@${OCI_BIN} run \
-e GOFLAGS \
-i $(TTY) \
--rm \
-u $$(id -u):$$(id -g) \
$(PODMAN_SPECIFIC_FLAG) \
-v "$$(pwd)/_output/bin:/output:delegated" \
-v $$(pwd)/.go/pkg:/go/pkg \
-v $$(pwd)/.go/src:/go/src \
-v $$(pwd)/.go/std:/go/std \
-v $$(pwd)/.go/bin:/go/bin \
-v $$(pwd):/go/src/kubevirt-velero-plugin:z \
-v $$(pwd):/go/src/kubevirt-velero-plugin \
-v $$(pwd)/.go/std/$(GOOS)_$(GOARCH):/usr/local/go/pkg/$(GOOS)_$(GOARCH)_static \
-v "$$(pwd)/.go/go-build:/.cache/go-build:delegated" \
-e CGO_ENABLED=0 \
Expand All @@ -135,11 +141,11 @@ container-name:
build-image: build-all
@echo -e "${GREEN}Building plugin image${WHITE}"
cp Dockerfile _output/bin/$(GOOS)/$(GOARCH)/Dockerfile
docker build -t ${DOCKER_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG} -f _output/bin/$(GOOS)/$(GOARCH)/Dockerfile _output/bin/$(GOOS)/$(GOARCH)
${OCI_BIN} build -t ${DOCKER_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG} -f _output/bin/$(GOOS)/$(GOARCH)/Dockerfile _output/bin/$(GOOS)/$(GOARCH)

push: build-image
@echo -e "${GREEN}Pushing plugin image to local registry${WHITE}"
@docker push ${DOCKER_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG}
@${OCI_BIN} push ${DOCKER_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG}

gomod-update: modules vendor

Expand All @@ -150,7 +156,7 @@ clean-dirs:

clean: clean-dirs
@echo "cleaning"
docker rmi $(BUILD_IMAGE)
${OCI_BIN} rmi $(BUILD_IMAGE)

test: build-dirs
@echo -e "${GREEN}Testing${WHITE}"
Expand Down
5 changes: 1 addition & 4 deletions hack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ GnuMake is used to drive a set of scripts that handle linting, testing, compilin

NOTE: Standard builds require a running Docker daemon!

The standard workflow is performed inside a helper container to normalize the build and test environment for all devs. Building in the host environment is supported by the Makefile, but is not recommended.

Docker builds may be disabled by setting DOCKER=0; e.g.
$ make all DOCKER=0
The standard workflow is performed inside a helper container to normalize the build and test environment for all devs.

`$ make all` executes the full workflow. For granular control of the workflow, several Make targets are defined:

Expand Down
1 change: 0 additions & 1 deletion hack/build/build-functest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ else
fi
(cd $test_path; go install github.com/onsi/ginkgo/ginkgo@latest)
(cd $test_path; GOFLAGS= go get github.com/onsi/gomega)
(cd $test_path; go mod tidy; go mod vendor)
test_out_path=${test_path}/_out
mkdir -p ${test_out_path}
(cd $test_path; $ginkgo_path build .)
Expand Down
8 changes: 3 additions & 5 deletions hack/build/cluster-push-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ source ${KUBEVIRTCI_PATH}cluster/$KUBEVIRT_PROVIDER/provider.sh

LOCAL_CLUSTER_REGISTRY_PREFIX=localhost:${PORT}/kubevirt

docker tag ${DOCKER_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG} ${LOCAL_CLUSTER_REGISTRY_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG}
docker push ${LOCAL_CLUSTER_REGISTRY_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG}
${OCI_BIN} tag ${DOCKER_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG} ${LOCAL_CLUSTER_REGISTRY_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG}
${OCI_BIN} push ${TLS_SETTING} ${LOCAL_CLUSTER_REGISTRY_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG}

# fetch latest version so it is available when container starts
${_ssh} node01 "sudo docker pull ${KUBEVIRTCI_REGISTRY_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG}"


${_ssh} node01 "sudo podman pull ${KUBEVIRTCI_REGISTRY_PREFIX}/${IMAGE_NAME}:${DOCKER_TAG}"
5 changes: 0 additions & 5 deletions hack/cluster-deploy-prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ _kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${KUBEV
_kubectl apply -f https://github.com/kubevirt/containerized-data-importer/releases/download/${CDI_VERSION}/cdi-operator.yaml
_kubectl apply -f https://github.com/kubevirt/containerized-data-importer/releases/download/${CDI_VERSION}/cdi-cr.yaml


# pre fetch fedora test image
${_ssh} node01 "sudo docker pull quay.io/kubevirt/fedora-with-test-tooling-container-disk"


_kubectl wait -n kubevirt deployment/virt-operator --for=condition=Available --timeout=${KUBEVIRT_DEPLOYMENT_TIMEOUT}s

# Ensure the KubeVirt CR is created
Expand Down
10 changes: 3 additions & 7 deletions hack/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#See the License for the specific language governing permissions and
#limitations under the License.

KUBEVIRT_MEMORY_SIZE=${KUBEVIRT_MEMORY_SIZE:-9216M}

if [ -f cluster-up/hack/common.sh ]; then
source cluster-up/hack/common.sh
fi
Expand All @@ -27,10 +29,6 @@ TESTS_OUT_DIR=${OUT_DIR}/tests
BUILD_DIR=${PLUGIN_DIR}/hack/build
CACHE_DIR=${OUT_DIR}/gocache

DOCKER_HOST_SOCK=${DOCKER_HOST_SOCK:-/run/docker.sock}
DOCKER_GUEST_SOCK=${DOCKER_GUEST_SOCK:-/run/docker.sock}
DOCKER_CMD=${DOCKER_CMD:-docker -H unix://${DOCKER_HOST_SOCK}}

if [[ $(which go 2>/dev/null) ]]; then
GOOS=$(go env GOOS)
GOARCH=$(go env GOARCH)
Expand All @@ -54,6 +52,4 @@ CDI_VERSION=${CDI_VERSION:-v1.48.0}
KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-k8s-1.23}
KUBEVIRT_DEPLOYMENT_TIMEOUT=${KUBEVIRT_DEPLOYMENT_TIMEOUT:-480}

KUBEVIRT_MEMORY_SIZE=${KUBEVIRT_MEMORY_SIZE:-9216M}

source cluster-up/hack/config.sh
source cluster-up/hack/config.sh
4 changes: 2 additions & 2 deletions hack/run-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -e
readonly ARTIFACTS_PATH="${ARTIFACTS}"

# Setup a cluster
make cluster-up cluster-push-image cluster-sync CLUSTER_PREFIX='-p pull-kvp-functional-test'
make cluster-up cluster-push-image cluster-sync

# Run the tests
make test-functional CLUSTER_PREFIX='-p pull-kvp-functional-test' TEST_ARGS="--test-args=--junit-output=${ARTIFACTS_PATH}/junit.functest.xml"
make test-functional TEST_ARGS="--test-args=--junit-output=${ARTIFACTS_PATH}/junit.functest.xml"
1 change: 0 additions & 1 deletion hack/velero/deploy-velero.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ if [ -z "$KUBEVIRTCI_PATH" ]; then
fi

script_dir="$(cd "$(dirname "$0")" && pwd -P)"
DOCKER_GUEST_SOCK=/var/run/docker.sock
velero_dir=${script_dir}/../velero
source "${script_dir}"/../config.sh

Expand Down
1 change: 0 additions & 1 deletion hack/velero/undeploy-velero.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ if [ -z "$KUBEVIRTCI_PATH" ]; then
fi


DOCKER_GUEST_SOCK=/var/run/docker.sock
velero_dir=./hack/velero
source ./hack/config.sh

Expand Down