Skip to content

Commit

Permalink
feat: graph-to-tree: set .targetOS also for linux pkg-manager
Browse files Browse the repository at this point in the history
Imported scratch images have linux as a package manager
DepTree should include targetOS.
  • Loading branch information
RotemS committed Mar 23, 2020
1 parent 24f0506 commit 06e55b3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/legacy/index.ts
Expand Up @@ -251,7 +251,7 @@ function constructPackageFormatVersion(pkgType: string): string {
}

function constructTargetOS(depGraph: types.DepGraph): { name: string; version: string; } | void {
if (['apk', 'apt', 'deb', 'rpm'].indexOf(depGraph.pkgManager.name) === -1) {
if (['apk', 'apt', 'deb', 'rpm', 'linux'].indexOf(depGraph.pkgManager.name) === -1) {
// .targetOS is undefined unless its a linux pkgManager
return;
}
Expand Down
30 changes: 30 additions & 0 deletions test/fixtures/os-linux-scratch-dep-graph.json
@@ -0,0 +1,30 @@
{
"schemaVersion": "1.2.0",
"pkgManager": {
"name": "linux",
"repositories": [
{
"alias": "unknown:0.0"
}
]
},
"pkgs": [
{
"id": "docker-image|scratch@0",
"info": {
"name": "docker-image|scratch",
"version": "0"
}
}
],
"graph": {
"rootNodeId": "root-node",
"nodes": [
{
"nodeId": "root-node",
"pkgId": "docker-image|scratch@0",
"deps": []
}
]
}
}
10 changes: 10 additions & 0 deletions test/fixtures/os-linux-scratch-dep-tree.json
@@ -0,0 +1,10 @@
{
"name": "docker-image|scratch",
"version": "0",
"type": "linux",
"packageFormatVersion": "linux:0.0.1",
"targetOS": {
"name": "unknown",
"version": "0.0"
}
}
6 changes: 6 additions & 0 deletions test/legacy/to-dep-tree.test.ts
Expand Up @@ -45,6 +45,12 @@ describe('dep-trees survive serialisation through dep-graphs', () => {
pkgManagerName: 'rpm',
pkgType: 'rpm',
},
{
description: 'os dep-tree (linux - scratch image)',
path: 'os-linux-scratch-dep-tree.json',
pkgManagerName: 'linux',
pkgType: 'linux',
},
{
description: 'maven dep-tree',
path: 'maven-dep-tree.json',
Expand Down

0 comments on commit 06e55b3

Please sign in to comment.