mirror of
https://github.com/containers/podman.git
synced 2025-12-03 03:39:44 +08:00
update c/common to latest main
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
2
vendor/github.com/containers/common/pkg/config/connections.go
generated
vendored
2
vendor/github.com/containers/common/pkg/config/connections.go
generated
vendored
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/containers/storage/pkg/ioutils"
|
||||
)
|
||||
|
||||
const connectionsFile = "podman-connections.conf"
|
||||
const connectionsFile = "podman-connections.json"
|
||||
|
||||
// connectionsConfigFile returns the path to the rw connections config file
|
||||
func connectionsConfigFile() (string, error) {
|
||||
|
||||
18
vendor/github.com/containers/common/pkg/config/new.go
generated
vendored
18
vendor/github.com/containers/common/pkg/config/new.go
generated
vendored
@@ -78,19 +78,8 @@ func newLocked(options *Options) (*Config, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("finding config on system: %w", err)
|
||||
}
|
||||
// connectionsPath, err := connectionsConfigFile()
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
for _, path := range configs {
|
||||
// var dests []*Destination
|
||||
// if path == connectionsPath {
|
||||
// // Store the dest pointers so we know after the load if there are new pointers
|
||||
// // the connection changed and thus is read write.
|
||||
// dests = maps.Values(config.Engine.ServiceDestinations)
|
||||
// }
|
||||
|
||||
// Merge changes in later configs with the previous configs.
|
||||
// Each config file that specified fields, will override the
|
||||
// previous fields.
|
||||
@@ -99,13 +88,6 @@ func newLocked(options *Options) (*Config, error) {
|
||||
}
|
||||
logrus.Debugf("Merged system config %q", path)
|
||||
logrus.Tracef("%+v", config)
|
||||
|
||||
// // if there is a new dest now we know it is read write as it was in the connections.conf file
|
||||
// for _, dest := range config.Engine.ServiceDestinations {
|
||||
// if !slices.Contains(dests, dest) {
|
||||
// dest.ReadWrite = true
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
modules, err := options.modules()
|
||||
|
||||
15
vendor/github.com/containers/common/pkg/ssh/connection_golang.go
generated
vendored
15
vendor/github.com/containers/common/pkg/ssh/connection_golang.go
generated
vendored
@@ -99,7 +99,7 @@ func golangConnectionDial(options ConnectionDialOptions) (*ConnectionDialReport,
|
||||
return &ConnectionDialReport{dial}, nil
|
||||
}
|
||||
|
||||
func golangConnectionExec(options ConnectionExecOptions) (*ConnectionExecReport, error) {
|
||||
func golangConnectionExec(options ConnectionExecOptions, input io.Reader) (*ConnectionExecReport, error) {
|
||||
if !strings.HasPrefix(options.Host, "ssh://") {
|
||||
options.Host = "ssh://" + options.Host
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func golangConnectionExec(options ConnectionExecOptions) (*ConnectionExecReport,
|
||||
return nil, fmt.Errorf("failed to connect: %w", err)
|
||||
}
|
||||
|
||||
out, err := ExecRemoteCommand(dialAdd, strings.Join(options.Args, " "))
|
||||
out, err := ExecRemoteCommandWithInput(dialAdd, strings.Join(options.Args, " "), input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -189,6 +189,10 @@ func golangConnectionScp(options ConnectionScpOptions) (*ConnectionScpReport, er
|
||||
// ExecRemoteCommand takes a ssh client connection and a command to run and executes the
|
||||
// command on the specified client. The function returns the Stdout from the client or the Stderr
|
||||
func ExecRemoteCommand(dial *ssh.Client, run string) ([]byte, error) {
|
||||
return ExecRemoteCommandWithInput(dial, run, nil)
|
||||
}
|
||||
|
||||
func ExecRemoteCommandWithInput(dial *ssh.Client, run string, input io.Reader) ([]byte, error) {
|
||||
sess, err := dial.NewSession() // new ssh client session
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -197,8 +201,11 @@ func ExecRemoteCommand(dial *ssh.Client, run string) ([]byte, error) {
|
||||
|
||||
var buffer bytes.Buffer
|
||||
var bufferErr bytes.Buffer
|
||||
sess.Stdout = &buffer // output from client funneled into buffer
|
||||
sess.Stderr = &bufferErr // err form client funneled into buffer
|
||||
sess.Stdout = &buffer // output from client funneled into buffer
|
||||
sess.Stderr = &bufferErr // err from client funneled into buffer
|
||||
if input != nil {
|
||||
sess.Stdin = input
|
||||
}
|
||||
if err := sess.Run(run); err != nil { // run the command on the ssh client
|
||||
return nil, fmt.Errorf("%v: %w", bufferErr.String(), err)
|
||||
}
|
||||
|
||||
6
vendor/github.com/containers/common/pkg/ssh/connection_native.go
generated
vendored
6
vendor/github.com/containers/common/pkg/ssh/connection_native.go
generated
vendored
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -100,7 +101,7 @@ func nativeConnectionCreate(options ConnectionCreateOptions) error {
|
||||
})
|
||||
}
|
||||
|
||||
func nativeConnectionExec(options ConnectionExecOptions) (*ConnectionExecReport, error) {
|
||||
func nativeConnectionExec(options ConnectionExecOptions, input io.Reader) (*ConnectionExecReport, error) {
|
||||
dst, uri, err := Validate(options.User, options.Host, options.Port, options.Identity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -134,6 +135,9 @@ func nativeConnectionExec(options ConnectionExecOptions) (*ConnectionExecReport,
|
||||
info := exec.Command(ssh, args...)
|
||||
info.Stdout = output
|
||||
info.Stderr = errors
|
||||
if input != nil {
|
||||
info.Stdin = input
|
||||
}
|
||||
err = info.Run()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
9
vendor/github.com/containers/common/pkg/ssh/ssh.go
generated
vendored
9
vendor/github.com/containers/common/pkg/ssh/ssh.go
generated
vendored
@@ -2,6 +2,7 @@ package ssh
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
@@ -27,15 +28,19 @@ func Dial(options *ConnectionDialOptions, kind EngineMode) (*ssh.Client, error)
|
||||
}
|
||||
|
||||
func Exec(options *ConnectionExecOptions, kind EngineMode) (string, error) {
|
||||
return ExecWithInput(options, kind, nil)
|
||||
}
|
||||
|
||||
func ExecWithInput(options *ConnectionExecOptions, kind EngineMode, input io.Reader) (string, error) {
|
||||
var rep *ConnectionExecReport
|
||||
var err error
|
||||
if kind == NativeMode {
|
||||
rep, err = nativeConnectionExec(*options)
|
||||
rep, err = nativeConnectionExec(*options, input)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else {
|
||||
rep, err = golangConnectionExec(*options)
|
||||
rep, err = golangConnectionExec(*options, input)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
9
vendor/github.com/containers/common/pkg/supplemented/supplemented.go
generated
vendored
9
vendor/github.com/containers/common/pkg/supplemented/supplemented.go
generated
vendored
@@ -14,6 +14,7 @@ import (
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// supplementedImageReference groups multiple references together.
|
||||
@@ -139,7 +140,7 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
}
|
||||
sources[manifestDigest] = src
|
||||
|
||||
// Parse the manifest as a list of images.
|
||||
// Parse the manifest as a list of images and artifacts.
|
||||
list, err := manifest.ListFromBlob(manifestBytes, manifestType)
|
||||
if err != nil {
|
||||
return fmt.Errorf("parsing manifest blob %q as a %q: %w", string(manifestBytes), manifestType, err)
|
||||
@@ -155,7 +156,11 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
}
|
||||
chaseInstances = []digest.Digest{instance}
|
||||
case cp.CopySpecificImages:
|
||||
chaseInstances = s.instances
|
||||
for _, instance := range list.Instances() {
|
||||
if slices.Contains(s.instances, instance) {
|
||||
chaseInstances = append(chaseInstances, instance)
|
||||
}
|
||||
}
|
||||
case cp.CopyAllImages:
|
||||
chaseInstances = list.Instances()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user