Skip to content

Commit

Permalink
Some updates:
Browse files Browse the repository at this point in the history
- Fedora 30 base image for builder image
- Go 1.12.8
- Go 1.12 branch for goimports
- K8s 1.13.4 versions of deepcopy-gen, defaulter-gen
- newer bazel packages for dealing with newer Go version

Signed-off-by: Marc Sluiter <[email protected]>
  • Loading branch information
slintes committed Oct 24, 2019
1 parent bfc3fa5 commit 1ea108e
Show file tree
Hide file tree
Showing 76 changed files with 725 additions and 1,375 deletions.
27 changes: 27 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# See https://github.com/bazelbuild/bazel/issues/7899
load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair")

py_runtime(
name = "py2_runtime",
interpreter_path = "/usr/bin/python2",
python_version = "PY2",
)

py_runtime(
name = "py3_runtime",
interpreter_path = "/usr/bin/python3",
python_version = "PY3",
)

py_runtime_pair(
name = "py_runtime_pair",
py2_runtime = ":py2_runtime",
py3_runtime = ":py3_runtime",
)

toolchain(
name = "py_toolchain",
toolchain = "py_runtime_pair",
toolchain_type = "@bazel_tools//tools/python:toolchain_type",
)

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@io_bazel_rules_go//go:def.bzl", "nogo")
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ push: bazel-push-images

bazel-tests:
hack/dockerized "hack/bazel-fmt.sh && bazel test \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--test_output=errors -- //pkg/..."

Expand Down
95 changes: 67 additions & 28 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,45 @@ load(
# Additional bazel rules
http_archive(
name = "io_bazel_rules_go",
sha256 = "301c8b39b0808c49f98895faa6aa8c92cbd605ab5ad4b6a3a652da33a1a2ba2e",
sha256 = "078f2a9569fa9ed846e60805fb5fb167d6f6c4ece48e6d409bf5fb2154eaf0d8",
urls = [
"https://github.com/bazelbuild/rules_go/releases/download/0.18.0/rules_go-0.18.0.tar.gz",
"https:/storage.googleapis.com/builddeps/301c8b39b0808c49f98895faa6aa8c92cbd605ab5ad4b6a3a652da33a1a2ba2e",
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/v0.20.0/rules_go-v0.20.0.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.20.0/rules_go-v0.20.0.tar.gz",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "7949fc6cc17b5b191103e97481cf8889217263acf52e00b560683413af204fcb",
sha256 = "41bff2a0b32b02f20c227d234aa25ef3783998e5453f7eade929704dcff7cd4b",
urls = [
"https://github.com/bazelbuild/bazel-gazelle/releases/download/0.16.0/bazel-gazelle-0.16.0.tar.gz",
"https://storage.googleapis.com/builddeps/7949fc6cc17b5b191103e97481cf8889217263acf52e00b560683413af204fcb",
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.0/bazel-gazelle-v0.19.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.0/bazel-gazelle-v0.19.0.tar.gz",
],
)

http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "e0b5b400cfef17d65886365dc7289cb4ef8dfe07066165607413a271a32aa2a4",
strip_prefix = "buildtools-db073457c5a56d810e46efc18bb93a4fd7aa7b5e",
# version 0.20.0
url = "https://github.com/bazelbuild/buildtools/archive/db073457c5a56d810e46efc18bb93a4fd7aa7b5e.zip",
name = "com_google_protobuf",
sha256 = "cd218dc003eacc167e51e3ce856f6c2e607857225ef86b938d95650fcbb2f8e4",
strip_prefix = "protobuf-6d4e7fd7966c989e38024a8ea693db83758944f1",
# version 3.10.0
urls = [
"https://github.com/google/protobuf/archive/6d4e7fd7966c989e38024a8ea693db83758944f1.zip",
],
)

load(
"@bazel_tools//tools/build_defs/repo:git.bzl",
"git_repository",
http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "875d0c49953e221cfc35d2a3846e502f366dfa4024b271fa266b186ca4664b37",
strip_prefix = "buildtools-5bcc31df55ec1de770cb52887f2e989e7068301f",
# version 0.29.0
url = "https://github.com/bazelbuild/buildtools/archive/5bcc31df55ec1de770cb52887f2e989e7068301f.zip",
)

http_archive(
name = "io_bazel_rules_docker",
sha256 = "aed1c249d4ec8f703edddf35cbe9dfaca0b5f5ea6e4cd9e83e99f3b0d1136c3d",
strip_prefix = "rules_docker-0.7.0",
urls = [
"https://github.com/bazelbuild/rules_docker/archive/v0.7.0.tar.gz",
"https://storage.googleapis.com/builddeps/aed1c249d4ec8f703edddf35cbe9dfaca0b5f5ea6e4cd9e83e99f3b0d1136c3d",
],
sha256 = "413bb1ec0895a8d3249a01edf24b82fd06af3c8633c9fb833a0cb1d4b234d46d",
strip_prefix = "rules_docker-0.12.0",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.12.0/rules_docker-v0.12.0.tar.gz"],
)

http_archive(
Expand All @@ -59,19 +61,17 @@ http_archive(
# Libvirt dependencies
http_file(
name = "libvirt_libs",
sha256 = "f9c70f8f45af8623f85c06e2a84b0c37c5ec30764d1bccc381d43b01436dce1c",
sha256 = "9ff62eb0ed238882a652444e0feb876a9d7878a45fd026a18f64e7ab98faebf0",
urls = [
"https://copr-be.cloud.fedoraproject.org/results/%40virtmaint-sig/for-kubevirt/fedora-30-x86_64/00967888-libvirt/libvirt-libs-5.0.0-1.fc30.x86_64.rpm",
"https://storage.googleapis.com/builddeps/f9c70f8f45af8623f85c06e2a84b0c37c5ec30764d1bccc381d43b01436dce1c",
"https://copr-be.cloud.fedoraproject.org/results/%40virtmaint-sig/for-kubevirt/fedora-30-x86_64/01034621-libvirt/libvirt-libs-5.0.0-2.fc30.x86_64.rpm",
],
)

http_file(
name = "libvirt_devel",
sha256 = "7d8e7a2d92fc3b5d8d660637683f16475779a036466484b93a0bb6a54b256027",
sha256 = "e34ca39bb94786b901a626143527f86cae1b6f1c8d1414165465d89e146a612e",
urls = [
"https://copr-be.cloud.fedoraproject.org/results/%40virtmaint-sig/for-kubevirt/fedora-30-x86_64/00967888-libvirt/libvirt-devel-5.0.0-1.fc30.x86_64.rpm",
"https://storage.googleapis.com/builddeps/7d8e7a2d92fc3b5d8d660637683f16475779a036466484b93a0bb6a54b256027",
"https://copr-be.cloud.fedoraproject.org/results/%40virtmaint-sig/for-kubevirt/fedora-30-x86_64/01034621-libvirt/libvirt-devel-5.0.0-2.fc30.x86_64.rpm",
],
)

Expand Down Expand Up @@ -130,11 +130,14 @@ load(
go_rules_dependencies()

go_register_toolchains(
go_version = "1.11.5",
go_version = "1.12.8",
nogo = "@//:nogo_vet",
)

load("@com_github_atlassian_bazel_tools//goimports:deps.bzl", "goimports_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

goimports_dependencies()

Expand All @@ -150,6 +153,11 @@ load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_depen

buildifier_dependencies()

load(
"@bazel_tools//tools/build_defs/repo:git.bzl",
"git_repository",
)

# Winrmcli dependencies
go_repository(
name = "com_github_masterzen_winrmcli",
Expand Down Expand Up @@ -234,7 +242,7 @@ container_repositories()
# Pull base image fedora28
container_pull(
name = "fedora",
digest = "sha256:9c78c69f748953ba8fdb6eb9982e1abefe281d9b931a13f251eb8aec988353de",
digest = "sha256:f4ca3e9814bef8468b59cc3dea90ab52bcb3747057731f7ab7645d923731fed6",
registry = "index.docker.io",
repository = "library/fedora",
#tag = "30",
Expand Down Expand Up @@ -364,3 +372,34 @@ http_file(
"https://storage.googleapis.com/builddeps/5694c041bcebc273cbf9a67f7210b2dd93c517aba55d93d20980b5bdf4be3751",
],
)

# some repos which are not part of go_rules anymore
go_repository(
name = "com_github_golang_glog",
importpath = "github.com/golang/glog",
sum = "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=",
version = "v0.0.0-20160126235308-23def4e6c14b",
)

go_repository(
name = "org_golang_google_grpc",
importpath = "google.golang.org/grpc",
sum = "h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s=",
version = "v1.24.0",
)

go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=",
version = "v0.0.0-20190311183353-d8887717615a",
)

go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=",
version = "v0.3.0",
)

register_toolchains("//:py_toolchain")
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/prometheus-operator v0.0.0-20181206002233-dd6f23e7207c h1:AUZCalMUTDZyPXPreDiI5kP7xN/YRmQyprrTJ0oLNKk=
github.com/coreos/prometheus-operator v0.0.0-20181206002233-dd6f23e7207c/go.mod h1:SO+r5yZUacDFPKHfPoUjI3hMsH+ZUdiuNNhuSq3WoSg=
github.com/coreos/prometheus-operator v0.31.1 h1:+pS6+Ha01vuoGBh5glhfngk2sB1ELwe6tbXhMkMmp/U=
github.com/coreos/prometheus-operator v0.31.1/go.mod h1:vHwtP2e+VmEeS6m6lgp87aH+npGVRQsCi5jhcuQA1sA=
github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
6 changes: 4 additions & 2 deletions hack/bazel-build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ source hack/config.sh

for tag in ${docker_tag} ${docker_tag_alt}; do
bazel build \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
--define container_prefix=${docker_prefix} \
--define image_prefix=${image_prefix} \
--define container_tag=${tag} \
Expand All @@ -35,8 +36,9 @@ done
# for the imagePrefix operator test
if [[ $image_prefix_alt ]]; then
bazel build \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
--define container_prefix=${docker_prefix} \
--define image_prefix=${image_prefix_alt} \
--define container_tag=${docker_tag} \
Expand Down
16 changes: 14 additions & 2 deletions hack/bazel-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,48 @@ mkdir -p ${CMD_OUT_DIR}/dump

# Build all binaries for amd64
bazel build \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--stamp \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
//tools/csv-generator/... //cmd/... //staging/src/kubevirt.io/client-go/examples/...

# Copy dump binary to a reachable place outside of the build container
bazel run \
--stamp \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
:build-dump -- ${CMD_OUT_DIR}/dump/dump

# build platform native virtctl explicitly
bazel run \
--stamp \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
:build-virtctl -- ${CMD_OUT_DIR}/virtctl/virtctl

# cross-compile virtctl for

# linux
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--stamp \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
:build-virtctl -- ${CMD_OUT_DIR}/virtctl/virtctl-${KUBEVIRT_VERSION}-linux-amd64

# darwin
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 \
--stamp \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
:build-virtctl -- ${CMD_OUT_DIR}/virtctl/virtctl-${KUBEVIRT_VERSION}-darwin-amd64

# windows
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:windows_amd64 \
--stamp \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
:build-virtctl -- ${CMD_OUT_DIR}/virtctl/virtctl-${KUBEVIRT_VERSION}-windows-amd64.exe
10 changes: 7 additions & 3 deletions hack/bazel-fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@
set -e

source hack/common.sh
source hack/config.sh

shfmt -i 4 -w ${KUBEVIRT_DIR}/hack/ ${KUBEVIRT_DIR}/images/
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
//:gazelle -- pkg/ tools/ tests/ cmd/
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
//:goimports
# allign BAZEL files to a single format
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
//:buildifier
15 changes: 11 additions & 4 deletions hack/bazel-generate.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
#!/usr/bin/env bash

source hack/common.sh
source hack/config.sh

# remove libvirt BUILD file to regenerate it each time
rm -f vendor/github.com/libvirt/libvirt-go/BUILD.bazel

# generate BUILD files
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
//:gazelle

# inject changes to libvirt BUILD file
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
-- @com_github_bazelbuild_buildtools//buildozer 'add cdeps //:libvirt-libs //:libvirt-headers' //vendor/github.com/libvirt/libvirt-go:go_default_library
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
-- @com_github_bazelbuild_buildtools//buildozer 'add copts -Ibazel-out/k8-fastbuild/genfiles' //vendor/github.com/libvirt/libvirt-go:go_default_library
# allign BAZEL files to a single format
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
//:buildifier
6 changes: 4 additions & 2 deletions hack/bazel-push-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ source hack/config.sh

for tag in ${docker_tag} ${docker_tag_alt}; do
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
--define container_prefix=${docker_prefix} \
--define image_prefix=${image_prefix} \
--define container_tag=${tag} \
Expand All @@ -35,8 +36,9 @@ done
# for the imagePrefix operator test
if [[ $image_prefix_alt ]]; then
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--workspace_status_command=./hack/print-workspace-status.sh \
--host_force_python=${bazel_py} \
--define container_prefix=${docker_prefix} \
--define image_prefix=${image_prefix_alt} \
--define container_tag=${docker_tag} \
Expand Down
Loading

0 comments on commit 1ea108e

Please sign in to comment.