mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
pkg/specgen: cache image in generator
To prevent expensive redundant lookups and inspects on the same image, cache the image in the generator. Note that once a given image has been inspected, subsequent calls will use the libimage-internal cache. [NO TESTS NEEDED] since it is no functional change. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/containers/common/libimage"
|
||||
"github.com/containers/image/v5/manifest"
|
||||
nettypes "github.com/containers/podman/v3/libpod/network/types"
|
||||
"github.com/containers/storage/types"
|
||||
@ -512,6 +513,21 @@ type SpecGenerator struct {
|
||||
ContainerNetworkConfig
|
||||
ContainerResourceConfig
|
||||
ContainerHealthCheckConfig
|
||||
|
||||
image *libimage.Image `json:"-"`
|
||||
resolvedImageName string `json:"-"`
|
||||
}
|
||||
|
||||
// SetImage sets the associated for the generator.
|
||||
func (s *SpecGenerator) SetImage(image *libimage.Image, resolvedImageName string) {
|
||||
s.image = image
|
||||
s.resolvedImageName = resolvedImageName
|
||||
}
|
||||
|
||||
// Image returns the associated image for the generator.
|
||||
// May be nil if no image has been set yet.
|
||||
func (s *SpecGenerator) GetImage() (*libimage.Image, string) {
|
||||
return s.image, s.resolvedImageName
|
||||
}
|
||||
|
||||
type Secret struct {
|
||||
|
Reference in New Issue
Block a user