Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Zunker <[email protected]>
  • Loading branch information
czunker committed Sep 27, 2023
1 parent f28f5db commit 16fd703
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions providers/os/connection/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,15 @@ func NewWithClose(id uint32, conf *inventory.Config, asset *inventory.Asset, clo

func newWithFlattenedImage(id uint32, conf *inventory.Config, asset *inventory.Asset, img *v1.Image, closeFn func()) (*TarConnection, error) {
imageFilename := ""
if asset.Connections[0].Options[FLATTENED_IMAGE] != "" {
log.Debug().Str("tar", asset.Connections[0].Options[FLATTENED_IMAGE]).Msg("tar> use cached tar file")
imageFilename = asset.Connections[0].Options[FLATTENED_IMAGE]
} else {
useCached := false
if asset != nil && len(asset.Connections) > 0 {
if x, ok := asset.Connections[0].Options[FLATTENED_IMAGE]; ok && x != "" {
log.Debug().Str("tar", asset.Connections[0].Options[FLATTENED_IMAGE]).Msg("tar> use cached tar file")
imageFilename = asset.Connections[0].Options[FLATTENED_IMAGE]
useCached = true
}
}
if !useCached {
f, err := cache.RandomFile()
if err != nil {
return nil, err
Expand Down Expand Up @@ -282,10 +287,12 @@ func newWithFlattenedImage(id uint32, conf *inventory.Config, asset *inventory.A
},
},
}
if asset.Connections[0].Options == nil {
asset.Connections[0].Options = map[string]string{}
if asset != nil && len(asset.Connections) > 0 {
if asset.Connections[0].Options == nil {
asset.Connections[0].Options = map[string]string{}
}
asset.Connections[0].Options[FLATTENED_IMAGE] = imageFilename
}
asset.Connections[0].Options[FLATTENED_IMAGE] = imageFilename

err := c.LoadFile(imageFilename)
if err != nil {
Expand Down

0 comments on commit 16fd703

Please sign in to comment.