mirror of
https://github.com/containers/skopeo.git
synced 2025-09-08 01:59:41 +00:00
Bump github.com/containers/storage from 1.38.2 to 1.39.0
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.38.2 to 1.39.0. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/main/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.38.2...v1.39.0) --- updated-dependencies: - dependency-name: github.com/containers/storage dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
45
vendor/github.com/containers/storage/idset.go
generated
vendored
45
vendor/github.com/containers/storage/idset.go
generated
vendored
@@ -1,6 +1,9 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
"github.com/google/go-intervals/intervalset"
|
||||
"github.com/pkg/errors"
|
||||
@@ -218,3 +221,45 @@ func maxInt(a, b int) int {
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func hasOverlappingRanges(mappings []idtools.IDMap) error {
|
||||
hostIntervals := intervalset.Empty()
|
||||
containerIntervals := intervalset.Empty()
|
||||
|
||||
var conflicts []string
|
||||
|
||||
for _, m := range mappings {
|
||||
c := interval{start: m.ContainerID, end: m.ContainerID + m.Size}
|
||||
h := interval{start: m.HostID, end: m.HostID + m.Size}
|
||||
|
||||
added := false
|
||||
overlaps := false
|
||||
|
||||
containerIntervals.IntervalsBetween(c, func(x intervalset.Interval) bool {
|
||||
overlaps = true
|
||||
return false
|
||||
})
|
||||
if overlaps {
|
||||
conflicts = append(conflicts, fmt.Sprintf("%v:%v:%v", m.ContainerID, m.HostID, m.Size))
|
||||
added = true
|
||||
}
|
||||
containerIntervals.Add(intervalset.NewSet([]intervalset.Interval{c}))
|
||||
|
||||
hostIntervals.IntervalsBetween(h, func(x intervalset.Interval) bool {
|
||||
overlaps = true
|
||||
return false
|
||||
})
|
||||
if overlaps && !added {
|
||||
conflicts = append(conflicts, fmt.Sprintf("%v:%v:%v", m.ContainerID, m.HostID, m.Size))
|
||||
}
|
||||
hostIntervals.Add(intervalset.NewSet([]intervalset.Interval{h}))
|
||||
}
|
||||
|
||||
if conflicts != nil {
|
||||
if len(conflicts) == 1 {
|
||||
return errors.Wrapf(ErrInvalidMappings, "the specified UID and/or GID mapping %s conflicts with other mappings", conflicts[0])
|
||||
}
|
||||
return errors.Wrapf(ErrInvalidMappings, "the specified UID and/or GID mappings %s conflict with other mappings", strings.Join(conflicts, ", "))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user