Merge pull request #39288 from dohse/do-not-order-uid-gid-mappings

Stop sorting uid and gid ranges in id maps
This commit is contained in:
Sebastiaan van Stijn 2019-06-04 20:12:30 +02:00 committed by GitHub
commit bd89b3f553
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 3 deletions

View file

@ -4,7 +4,6 @@ import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
"strings"
)
@ -203,8 +202,6 @@ func (i *IdentityMapping) GIDs() []IDMap {
func createIDMap(subidRanges ranges) []IDMap {
idMap := []IDMap{}
// sort the ranges by lowest ID first
sort.Sort(subidRanges)
containerID := 0
for _, idrange := range subidRanges {
idMap = append(idMap, IDMap{

View file

@ -0,0 +1,28 @@
package idtools // import "github.com/docker/docker/pkg/idtools"
import (
"testing"
"gotest.tools/assert"
)
func TestCreateIDMapOrder(t *testing.T) {
subidRanges := ranges{
{100000, 1000},
{1000, 1},
}
idMap := createIDMap(subidRanges)
assert.DeepEqual(t, idMap, []IDMap{
{
ContainerID: 0,
HostID: 100000,
Size: 1000,
},
{
ContainerID: 1000,
HostID: 1000,
Size: 1,
},
})
}