mirror of
https://github.com/containers/image.git
synced 2025-04-18 19:44:05 +03:00
Replace Set.AddSlice with Set.AddSeq, use it in more places
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
76ad3e74fc
commit
51d3a1c0ea
@ -83,7 +83,7 @@ func platformCompressionMap(list internalManifest.List, instanceDigests []digest
|
||||
platformSet = set.New[string]()
|
||||
res[platform] = platformSet
|
||||
}
|
||||
platformSet.AddSlice(instanceDetails.ReadOnly.CompressionAlgorithmNames)
|
||||
platformSet.AddSeq(slices.Values(instanceDetails.ReadOnly.CompressionAlgorithmNames))
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
@ -242,9 +242,7 @@ func (w *Writer) ensureManifestItemLocked(layerDescriptors []manifest.Schema2Des
|
||||
}
|
||||
|
||||
knownRepoTags := set.New[string]()
|
||||
for _, repoTag := range item.RepoTags {
|
||||
knownRepoTags.Add(repoTag)
|
||||
}
|
||||
knownRepoTags.AddSeq(slices.Values(item.RepoTags))
|
||||
for _, tag := range repoTags {
|
||||
// For github.com/docker/docker consumers, this works just as well as
|
||||
// refString := ref.String()
|
||||
|
@ -31,8 +31,8 @@ func (s *Set[E]) Add(v E) {
|
||||
s.m[v] = struct{}{} // Possibly writing the same struct{}{} presence marker again.
|
||||
}
|
||||
|
||||
func (s *Set[E]) AddSlice(slice []E) {
|
||||
for _, v := range slice {
|
||||
func (s *Set[E]) AddSeq(seq iter.Seq[E]) {
|
||||
for v := range seq {
|
||||
s.Add(v)
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ func TestAdd(t *testing.T) {
|
||||
assert.False(t, s.Contains(3))
|
||||
}
|
||||
|
||||
func TestAddSlice(t *testing.T) {
|
||||
func TestAddSeq(t *testing.T) {
|
||||
s := NewWithValues(1)
|
||||
s.Add(2)
|
||||
s.AddSlice([]int{3, 4})
|
||||
s.AddSeq(slices.Values([]int{3, 4}))
|
||||
assert.ElementsMatch(t, []int{1, 2, 3, 4}, slices.Collect(s.All()))
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"maps"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -93,9 +94,7 @@ func GetAllCredentials(sys *types.SystemContext) (map[string]types.DockerAuthCon
|
||||
// Credential helpers in the auth file have a
|
||||
// direct mapping to a registry, so we can just
|
||||
// walk the map.
|
||||
for registry := range fileContents.CredHelpers {
|
||||
allKeys.Add(registry)
|
||||
}
|
||||
allKeys.AddSeq(maps.Keys(fileContents.CredHelpers))
|
||||
for key := range fileContents.AuthConfigs {
|
||||
key := normalizeAuthFileKey(key, path.legacyFormat)
|
||||
if key == normalizedDockerIORegistry {
|
||||
@ -115,9 +114,7 @@ func GetAllCredentials(sys *types.SystemContext) (map[string]types.DockerAuthCon
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
for registry := range creds {
|
||||
allKeys.Add(registry)
|
||||
}
|
||||
allKeys.AddSeq(maps.Keys(creds))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user