mirror of
https://github.com/containers/podman.git
synced 2026-03-13 08:01:19 +08:00
Simplify setting up Runtime.imageContext
- Don't allocate it on-demand, it will always be created in the end. - Embed the SystemContext directly, without using a pointer, to make it clear it always exists. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
@@ -67,7 +67,7 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
|
||||
SignaturePolicyPath: options.SignaturePolicyPath,
|
||||
ReportWriter: options.ReportWriter,
|
||||
Squash: options.Squash,
|
||||
SystemContext: c.runtime.imageContext,
|
||||
SystemContext: &c.runtime.imageContext,
|
||||
PreferredManifestType: options.PreferredManifestType,
|
||||
OverrideChanges: append(append([]string{}, options.Changes...), options.CommitOptions.OverrideChanges...),
|
||||
OverrideConfig: options.CommitOptions.OverrideConfig,
|
||||
|
||||
@@ -512,7 +512,7 @@ func (c *Container) setupStorage(ctx context.Context) error {
|
||||
}
|
||||
c.config.Name = name
|
||||
}
|
||||
containerInfo, containerInfoErr = c.runtime.storageService.CreateContainerStorage(ctx, c.runtime.imageContext, c.config.RootfsImageName, c.config.RootfsImageID, c.config.Name, c.config.ID, options)
|
||||
containerInfo, containerInfoErr = c.runtime.storageService.CreateContainerStorage(ctx, &c.runtime.imageContext, c.config.RootfsImageName, c.config.RootfsImageID, c.config.Name, c.config.ID, options)
|
||||
|
||||
if !generateName || !errors.Is(containerInfoErr, storage.ErrDuplicateName) {
|
||||
break
|
||||
|
||||
@@ -1108,7 +1108,7 @@ func (c *Container) createCheckpointImage(ctx context.Context, options Container
|
||||
|
||||
commitOptions := buildah.CommitOptions{
|
||||
Squash: true,
|
||||
SystemContext: c.runtime.imageContext,
|
||||
SystemContext: &c.runtime.imageContext,
|
||||
}
|
||||
|
||||
// Create checkpoint image
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"go.podman.io/common/pkg/config"
|
||||
"go.podman.io/common/pkg/secrets"
|
||||
"go.podman.io/image/v5/manifest"
|
||||
"go.podman.io/image/v5/types"
|
||||
"go.podman.io/storage"
|
||||
"go.podman.io/storage/pkg/fileutils"
|
||||
"go.podman.io/storage/pkg/idtools"
|
||||
@@ -221,9 +220,6 @@ func WithRegistriesConf(path string) RuntimeOption {
|
||||
if err := fileutils.Exists(path); err != nil {
|
||||
return fmt.Errorf("locating specified registries.conf: %w", err)
|
||||
}
|
||||
if rt.imageContext == nil {
|
||||
rt.imageContext = &types.SystemContext{}
|
||||
}
|
||||
|
||||
rt.imageContext.SystemRegistriesConfPath = path
|
||||
return nil
|
||||
|
||||
@@ -71,7 +71,7 @@ type Runtime struct {
|
||||
state State
|
||||
store storage.Store
|
||||
storageService *storageService
|
||||
imageContext *types.SystemContext
|
||||
imageContext types.SystemContext
|
||||
defaultOCIRuntime OCIRuntime
|
||||
ociRuntimes map[string]OCIRuntime
|
||||
runtimeFlags []string
|
||||
@@ -436,10 +436,8 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
|
||||
runtime.eventer = eventer
|
||||
|
||||
// Set up containers/image
|
||||
if runtime.imageContext == nil {
|
||||
runtime.imageContext = &types.SystemContext{
|
||||
BigFilesTemporaryDir: parse.GetTempDir(),
|
||||
}
|
||||
if runtime.imageContext.BigFilesTemporaryDir == "" {
|
||||
runtime.imageContext.BigFilesTemporaryDir = parse.GetTempDir()
|
||||
}
|
||||
runtime.imageContext.SignaturePolicyPath = runtime.config.Engine.SignaturePolicyPath
|
||||
|
||||
@@ -910,7 +908,7 @@ func (r *Runtime) configureStore() error {
|
||||
r.storageService = getStorageService(r.store)
|
||||
|
||||
runtimeOptions := &libimage.RuntimeOptions{
|
||||
SystemContext: r.imageContext,
|
||||
SystemContext: &r.imageContext,
|
||||
}
|
||||
libimageRuntime, err := libimage.RuntimeFromStore(store, runtimeOptions)
|
||||
if err != nil {
|
||||
|
||||
@@ -136,7 +136,7 @@ func (r *Runtime) newVolume(ctx context.Context, noCreatePluginVolume bool, opti
|
||||
}
|
||||
storageConfig.LabelOpts = []string{fmt.Sprintf("filetype:%s", context["type"])}
|
||||
}
|
||||
if _, err := r.storageService.CreateContainerStorage(ctx, r.imageContext, imgString, image.ID(), volume.config.StorageName, volume.config.StorageID, storageConfig); err != nil {
|
||||
if _, err := r.storageService.CreateContainerStorage(ctx, &r.imageContext, imgString, image.ID(), volume.config.StorageName, volume.config.StorageID, storageConfig); err != nil {
|
||||
return nil, fmt.Errorf("creating backing storage for image driver: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
|
||||
Reference in New Issue
Block a user