Skip to content

Commit 0bf9f6b

Browse files
authored
Merge pull request #1464 from jonjohnsonjr/dag-priority
dag: Respect provider-priority
2 parents b12424d + f43a3fd commit 0bf9f6b

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

pkg/dag/graph.go

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"path"
1414
"reflect"
1515
"sort"
16+
"strconv"
1617
"strings"
1718

1819
"github.com/dominikbraun/graph"
@@ -904,20 +905,36 @@ func getKeyMaterial(key string) ([]byte, error) {
904905
return b, nil
905906
}
906907

908+
func getPriority(pkg *Configuration) uint64 {
909+
val := pkg.Package.Dependencies.ProviderPriority
910+
if val == "" {
911+
return 0
912+
}
913+
priority, err := strconv.ParseUint(val, 10, 64)
914+
if err != nil {
915+
// I don't care to plumb this error around, sorry everyone.
916+
// There are other places that will catch this not being an integer.
917+
return 0
918+
}
919+
return priority
920+
}
921+
907922
func singlePackageResolver(ctx context.Context, pkg *Configuration, arch string) *apk.PkgResolver {
908923
repo := apk.NewRepositoryFromComponents(Local, "latest", "", arch)
924+
909925
packages := []*apk.Package{
910926
{
911-
Arch: arch,
912-
Name: pkg.Package.Name,
913-
Version: fullVersion(&pkg.Package),
914-
Description: pkg.Package.Description,
915-
License: pkg.Package.LicenseExpression(),
916-
Origin: pkg.Package.Name,
917-
URL: pkg.Package.URL,
918-
Dependencies: pkg.Environment.Contents.Packages,
919-
Provides: pkg.Package.Dependencies.Provides,
920-
RepoCommit: pkg.Package.Commit,
927+
Arch: arch,
928+
Name: pkg.Package.Name,
929+
Version: fullVersion(&pkg.Package),
930+
Description: pkg.Package.Description,
931+
License: pkg.Package.LicenseExpression(),
932+
Origin: pkg.Package.Name,
933+
URL: pkg.Package.URL,
934+
Dependencies: pkg.Environment.Contents.Packages,
935+
ProviderPriority: getPriority(pkg),
936+
Provides: pkg.Package.Dependencies.Provides,
937+
RepoCommit: pkg.Package.Commit,
921938
},
922939
}
923940
index := &apk.APKIndex{

0 commit comments

Comments
 (0)