diff --git a/cmd/podman/registry/config.go b/cmd/podman/registry/config.go index a118fdc4dd..5b0e1a7ef3 100644 --- a/cmd/podman/registry/config.go +++ b/cmd/podman/registry/config.go @@ -51,7 +51,7 @@ func newPodmanConfig() { os.Exit(1) } - cfg, err := config.NewConfig("") + cfg, err := config.Default() if err != nil { fmt.Fprint(os.Stderr, "Failed to obtain podman configuration: "+err.Error()) os.Exit(1) diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 5c65be96d4..4a80c688f5 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -449,7 +449,7 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) { _ = pFlags.MarkHidden(networkBackendFlagName) rootFlagName := "root" - pFlags.StringVar(&cfg.Engine.StaticDir, rootFlagName, "", "Path to the root directory in which data, including images, is stored") + pFlags.StringVar(&cfg.Engine.StaticDir, rootFlagName, cfg.Engine.StaticDir, "Path to the root directory in which data, including images, is stored") _ = cmd.RegisterFlagCompletionFunc(rootFlagName, completion.AutocompleteDefault) pFlags.StringVar(&opts.RegistriesConf, "registries-conf", "", "Path to a registries.conf to use for image processing") @@ -468,13 +468,13 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) { _ = cmd.RegisterFlagCompletionFunc(storageDriverFlagName, completion.AutocompleteNone) tmpdirFlagName := "tmpdir" - pFlags.StringVar(&opts.Engine.TmpDir, tmpdirFlagName, "", "Path to the tmp directory for libpod state content.\n\nNote: use the environment variable 'TMPDIR' to change the temporary storage location for container images, '/var/tmp'.\n") + pFlags.StringVar(&opts.Engine.TmpDir, tmpdirFlagName, opts.Engine.TmpDir, "Path to the tmp directory for libpod state content.\n\nNote: use the environment variable 'TMPDIR' to change the temporary storage location for container images, '/var/tmp'.\n") _ = cmd.RegisterFlagCompletionFunc(tmpdirFlagName, completion.AutocompleteDefault) pFlags.BoolVar(&opts.Trace, "trace", false, "Enable opentracing output (default false)") volumePathFlagName := "volumepath" - pFlags.StringVar(&opts.Engine.VolumePath, volumePathFlagName, "", "Path to the volume directory in which volume data is stored") + pFlags.StringVar(&opts.Engine.VolumePath, volumePathFlagName, opts.Engine.VolumePath, "Path to the volume directory in which volume data is stored") _ = cmd.RegisterFlagCompletionFunc(volumePathFlagName, completion.AutocompleteDefault) // Hide these flags for both ABI and Tunneling diff --git a/libpod/runtime.go b/libpod/runtime.go index 0828c19d53..56013c3480 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -165,7 +165,7 @@ func SetXdgDirs() error { // NewRuntime creates a new container runtime // Options can be passed to override the default configuration for the runtime func NewRuntime(ctx context.Context, options ...RuntimeOption) (*Runtime, error) { - conf, err := config.NewConfig("") + conf, err := config.Default() if err != nil { return nil, err } @@ -1169,3 +1169,8 @@ func (r *Runtime) RemoteURI() string { func (r *Runtime) SetRemoteURI(uri string) { r.config.Engine.RemoteURI = uri } + +// Config returns the system config +func (r *Runtime) Config() *config.Config { + return r.config +} diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go index 412532954b..65b83ca5ac 100644 --- a/pkg/api/handlers/libpod/images.go +++ b/pkg/api/handlers/libpod/images.go @@ -604,6 +604,7 @@ func ImagesRemove(w http.ResponseWriter, r *http.Request) { } func ImageScp(w http.ResponseWriter, r *http.Request) { + runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder) query := struct { Destination string `schema:"destination"` @@ -618,7 +619,7 @@ func ImageScp(w http.ResponseWriter, r *http.Request) { sourceArg := utils.GetName(r) - rep, source, dest, _, err := domainUtils.ExecuteTransfer(sourceArg, query.Destination, []string{}, query.Quiet, ssh.GolangMode) + rep, source, dest, _, err := domainUtils.ExecuteTransfer(sourceArg, query.Destination, []string{}, query.Quiet, ssh.GolangMode, runtime.Config()) if err != nil { utils.Error(w, http.StatusInternalServerError, err) return diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go index 1775ec24c1..e0be329c1e 100644 --- a/pkg/domain/infra/abi/images.go +++ b/pkg/domain/infra/abi/images.go @@ -685,7 +685,7 @@ func (ir *ImageEngine) Sign(ctx context.Context, names []string, options entitie } func (ir *ImageEngine) Scp(ctx context.Context, src, dst string, parentFlags []string, quiet bool, sshMode ssh.EngineMode) error { - rep, source, dest, flags, err := domainUtils.ExecuteTransfer(src, dst, parentFlags, quiet, sshMode) + rep, source, dest, flags, err := domainUtils.ExecuteTransfer(src, dst, parentFlags, quiet, sshMode, ir.Libpod.Config()) if err != nil { return err } diff --git a/pkg/domain/utils/scp.go b/pkg/domain/utils/scp.go index 19567551e6..7c88c376ff 100644 --- a/pkg/domain/utils/scp.go +++ b/pkg/domain/utils/scp.go @@ -17,7 +17,7 @@ import ( "github.com/sirupsen/logrus" ) -func ExecuteTransfer(src, dst string, parentFlags []string, quiet bool, sshMode ssh.EngineMode) (*entities.ImageLoadReport, *entities.ImageScpOptions, *entities.ImageScpOptions, []string, error) { +func ExecuteTransfer(src, dst string, parentFlags []string, quiet bool, sshMode ssh.EngineMode, conf *config.Config) (*entities.ImageLoadReport, *entities.ImageScpOptions, *entities.ImageScpOptions, []string, error) { source := entities.ImageScpOptions{} dest := entities.ImageScpOptions{} sshInfo := entities.ImageScpConnections{} @@ -33,11 +33,6 @@ func ExecuteTransfer(src, dst string, parentFlags []string, quiet bool, sshMode return nil, nil, nil, nil, err } - confR, err := config.NewConfig("") // create a hand made config for the remote engine since we might use remote and native at once - if err != nil { - return nil, nil, nil, nil, fmt.Errorf("could not make config: %w", err) - } - locations := []*entities.ImageScpOptions{} cliConnections := []string{} args := []string{src} @@ -94,7 +89,7 @@ func ExecuteTransfer(src, dst string, parentFlags []string, quiet bool, sshMode return nil, nil, nil, nil, err } - confR.Engine = config.EngineConfig{Remote: true, CgroupManager: "cgroupfs", ServiceDestinations: serv} // pass the service dest (either remote or something else) to engine + conf.Engine = config.EngineConfig{Remote: true, CgroupManager: "cgroupfs", ServiceDestinations: serv} // pass the service dest (either remote or something else) to engine saveCmd, loadCmd := CreateCommands(source, dest, parentFlags, podman) switch {