Skip to content

Commit

Permalink
ova: fix the version of encoding/gob
Browse files Browse the repository at this point in the history
Unfortunately, we rely on 'encoding/gob' to determine the UUID of VMs
from OVAs and this package has changed in Go 1.21 in a way we get a
different UUID compared to the one we get with Go 1.20 for the same
input, which could break existing OVA providers.

Therefore, this package integrates the relevant pieces from
'encoding/gob' of Go 1.20 so that we can bump Go to 1.21 without
breaking compatibility with OVA providers that were defined in lower
versions of Forklift.

Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed May 7, 2024
1 parent c092229 commit c047881
Show file tree
Hide file tree
Showing 10 changed files with 2,366 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
run:
skip-dirs:
- pkg/lib/gob
linters:
enable:
- ginkgolinter
Expand Down
5 changes: 4 additions & 1 deletion cmd/ova-provider-server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ go_library(
srcs = ["ova-provider-server.go"],
importpath = "github.com/konveyor/forklift-controller/cmd/ova-provider-server",
visibility = ["//visibility:private"],
deps = ["//vendor/github.com/google/uuid"],
deps = [
"//pkg/lib/gob",
"//vendor/github.com/google/uuid",
],
)

go_binary(
Expand Down
3 changes: 2 additions & 1 deletion cmd/ova-provider-server/ova-provider-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"archive/tar"
"bytes"
"crypto/sha256"
"encoding/gob"
"encoding/hex"
"encoding/json"
"encoding/xml"
Expand All @@ -17,6 +16,8 @@ import (
"strconv"
"strings"

"github.com/konveyor/forklift-controller/pkg/lib/gob"

"github.com/google/uuid"
)

Expand Down
15 changes: 15 additions & 0 deletions pkg/lib/gob/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "gob",
srcs = [
"decoder.go",
"enc_helpers.go",
"encode.go",
"encoder.go",
"error.go",
"type.go",
],
importpath = "github.com/konveyor/forklift-controller/pkg/lib/gob",
visibility = ["//visibility:public"],
)
10 changes: 10 additions & 0 deletions pkg/lib/gob/decoder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package gob

// tooBig provides a sanity check for sizes; used in several places. Upper limit
// of is 1GB on 32-bit systems, 8GB on 64-bit, allowing room to grow a little
// without overflow.
const tooBig = (1 << 30) << (^uint(0) >> 62)
Loading

0 comments on commit c047881

Please sign in to comment.