Skip to content

Commit

Permalink
Merge pull request #1907 from mtrmac/go1.21
Browse files Browse the repository at this point in the history
Update to Go 1.21
  • Loading branch information
openshift-merge-bot[bot] committed Apr 24, 2024
2 parents 408479e + 663f3a3 commit eb9c232
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ vendor_task:
cross_task:
alias: cross
container:
image: golang:1.20
image: golang:1.21
build_script: make cross


Expand All @@ -191,6 +191,6 @@ success_task:
- vendor
- cross
container:
image: golang:1.20
image: golang:1.21
clone_script: 'mkdir -p "$CIRRUS_WORKING_DIR"' # Source code not needed
script: /bin/true
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
go 1.20
go 1.21

// Warning: Ensure the "go" and "toolchain" versions match exactly to prevent unwanted auto-updates
toolchain go1.21.0

module github.com/containers/storage

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -148,6 +149,7 @@ golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand Down
30 changes: 8 additions & 22 deletions idset.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (s *idSet) findAvailable(n int) (*idSet, error) {
iterator, cancel := s.iterator()
defer cancel()
for i := iterator(); n > 0 && i != nil; i = iterator() {
i.end = minInt(i.end, i.start+n)
i.end = min(i.end, i.start+n)
intervals = append(intervals, *i)
n -= i.length()
}
Expand All @@ -129,7 +129,7 @@ func (s *idSet) zip(container *idSet) []idtools.IDMap {
defer containerCancel()
var out []idtools.IDMap
for h, c := hostIterator(), containerIterator(); h != nil && c != nil; {
if n := minInt(h.length(), c.length()); n > 0 {
if n := min(h.length(), c.length()); n > 0 {
out = append(out, idtools.IDMap{
ContainerID: c.start,
HostID: h.start,
Expand Down Expand Up @@ -159,12 +159,12 @@ type interval struct {
}

func (i interval) length() int {
return maxInt(0, i.end-i.start)
return max(0, i.end-i.start)
}

func (i interval) Intersect(other intervalset.Interval) intervalset.Interval {
j := other.(interval)
return interval{start: maxInt(i.start, j.start), end: minInt(i.end, j.end)}
return interval{start: max(i.start, j.start), end: min(i.end, j.end)}
}

func (i interval) Before(other intervalset.Interval) bool {
Expand All @@ -183,15 +183,15 @@ func (i interval) Bisect(other intervalset.Interval) (intervalset.Interval, inte
}
// Subtracting [j.start, j.end) is equivalent to the union of intersecting (-inf, j.start) and
// [j.end, +inf).
left := interval{start: i.start, end: minInt(i.end, j.start)}
right := interval{start: maxInt(i.start, j.end), end: i.end}
left := interval{start: i.start, end: min(i.end, j.start)}
right := interval{start: max(i.start, j.end), end: i.end}
return left, right
}

func (i interval) Adjoin(other intervalset.Interval) intervalset.Interval {
j := other.(interval)
if !i.IsZero() && !j.IsZero() && (i.end == j.start || j.end == i.start) {
return interval{start: minInt(i.start, j.start), end: maxInt(i.end, j.end)}
return interval{start: min(i.start, j.start), end: max(i.end, j.end)}
}
return interval{}
}
Expand All @@ -204,24 +204,10 @@ func (i interval) Encompass(other intervalset.Interval) intervalset.Interval {
case j.IsZero():
return i
default:
return interval{start: minInt(i.start, j.start), end: maxInt(i.end, j.end)}
return interval{start: min(i.start, j.start), end: max(i.end, j.end)}
}
}

func minInt(a, b int) int {
if a < b {
return a
}
return b
}

func maxInt(a, b int) int {
if a < b {
return b
}
return a
}

func hasOverlappingRanges(mappings []idtools.IDMap) error {
hostIntervals := intervalset.Empty()
containerIntervals := intervalset.Empty()
Expand Down
10 changes: 0 additions & 10 deletions idset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,8 @@ import (

"github.com/containers/storage/pkg/idtools"
"github.com/google/go-intervals/intervalset"
"github.com/stretchr/testify/assert"
)

func TestMinMaxInt(t *testing.T) {
assert.Equal(t, 5, minInt(5, 8))
assert.Equal(t, 3, minInt(10, 3))
assert.Equal(t, 2, minInt(2, 2))
assert.Equal(t, 8, maxInt(5, 8))
assert.Equal(t, 10, maxInt(10, 3))
assert.Equal(t, 2, maxInt(2, 2))
}

func allIntervals(s *idSet) []interval {
iterator, cancel := s.iterator()
defer cancel()
Expand Down
7 changes: 0 additions & 7 deletions pkg/archive/changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ import (
"github.com/stretchr/testify/require"
)

func max(x, y int) int {
if x >= y {
return x
}
return y
}

func copyDir(src, dst string) error {
cmd := exec.Command("cp", "-a", src, dst)
if runtime.GOOS == solaris {
Expand Down

0 comments on commit eb9c232

Please sign in to comment.