From 97aa82d4339770b97505b7c8ffaba58d4ec2c52f Mon Sep 17 00:00:00 2001 From: Or Shoval Date: Sun, 21 Jul 2024 11:39:30 +0300 Subject: [PATCH] WIP Signed-off-by: Or Shoval --- .gitignore | 2 ++ passt/Dockerfile | 22 ++++++++++++++++++ passt/install-kubevirt.sh | 49 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 passt/Dockerfile create mode 100755 passt/install-kubevirt.sh diff --git a/.gitignore b/.gitignore index bd5105d4..6301ec17 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ go.work # output dir for the hack/cluster.sh artifacts and e2e tests .output + +passt/_kubevirt diff --git a/passt/Dockerfile b/passt/Dockerfile new file mode 100644 index 00000000..bf6af026 --- /dev/null +++ b/passt/Dockerfile @@ -0,0 +1,22 @@ +FROM docker.io/library/golang:1.22 as builder + +WORKDIR /workspace + +COPY passt/_kubevirt/cmd/cniplugins/passt-binding/cmd/ cmd/cniplugins/passt-binding/cmd/ +COPY passt/_kubevirt/cmd/cniplugins/passt-binding/pkg/ cmd/cniplugins/passt-binding/pkg/ +COPY passt/_kubevirt/pkg/util/ /workspace/pkg/util/ +COPY passt/_kubevirt/staging/ staging/ + +COPY passt/_kubevirt/go.mod go.mod +COPY passt/_kubevirt/go.sum go.sum +RUN go mod edit -replace=kubevirt.io/kubevirt/cmd/cniplugins/passt-binding/pkg/plugin=/workspace/cmd/cniplugins/passt-binding/pkg/plugin +RUN go mod edit -replace=kubevirt.io/kubevirt/pkg/util/sysctl=/workspace/pkg/util/sysctl +RUN go mod edit -replace=kubevirt.io/kubevirt/pkg/util=/workspace/pkg/util +RUN go mod download + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o network-passt-binding cmd/cniplugins/passt-binding/cmd/cni.go + +FROM registry.access.redhat.com/ubi8/ubi-minimal +WORKDIR / +RUN mkdir /cni +COPY --from=builder /workspace/network-passt-binding /cni/network-passt-binding diff --git a/passt/install-kubevirt.sh b/passt/install-kubevirt.sh new file mode 100755 index 00000000..3e2320bf --- /dev/null +++ b/passt/install-kubevirt.sh @@ -0,0 +1,49 @@ +#!/bin/bash -e +# +# This file is part of the KubeVirt project +# +# 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. +# +# Copyright 2024 Red Hat, Inc. +# + +export KUBEVIRT_COMMIT=01c651ba0677f759220ce0fa43530477bbe8ee23 + +KUBEVIRT_REPO='https://github.com/kubevirt/kubevirt.git' +REPO_PATH=${REPO_PATH:-"passt/_kubevirt"} + +function cluster::_get_repo() { + git --git-dir ${REPO_PATH}/.git config --get remote.origin.url +} + +function cluster::_get_sha() { + git --git-dir ${REPO_PATH}/.git rev-parse HEAD +} + +function cluster::install() { + if [ -d ${REPO_PATH} ]; then + if [ $(cluster::_get_repo) != ${KUBEVIRT_REPO} -o $(cluster::_get_sha) != ${KUBEVIRT_COMMIT} ]; then + rm -rf ${REPO_PATH} + fi + fi + + if [ ! -d ${REPO_PATH} ]; then + git clone ${KUBEVIRT_REPO} ${REPO_PATH} + ( + cd ${REPO_PATH} + git checkout ${KUBEVIRT_COMMIT} + ) + fi +} + +cluster::install