mirror of https://github.com/containers/podman.git
Merge pull request #21735 from jakecorrenti/inspect-conn-vals
machine: Add `ConnectionInfo` to inspect
This commit is contained in:
commit
59b6f48d90
|
@ -72,12 +72,18 @@ func inspect(cmd *cobra.Command, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
podmanSocket, podmanPipe, err := mc.ConnectionInfo(provider.VMType())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
ii := machine.InspectInfo{
|
ii := machine.InspectInfo{
|
||||||
// TODO I dont think this is useful
|
ConfigDir: *dirs.ConfigDir,
|
||||||
ConfigPath: *dirs.ConfigDir,
|
ConnectionInfo: machine.ConnectionConfig{
|
||||||
// TODO Fill this out
|
PodmanSocket: podmanSocket,
|
||||||
ConnectionInfo: machine.ConnectionConfig{},
|
PodmanPipe: podmanPipe,
|
||||||
Created: mc.Created,
|
},
|
||||||
|
Created: mc.Created,
|
||||||
// TODO This is no longer applicable; we dont care about the provenance
|
// TODO This is no longer applicable; we dont care about the provenance
|
||||||
// of the image
|
// of the image
|
||||||
Image: machine.ImageConfig{
|
Image: machine.ImageConfig{
|
||||||
|
|
|
@ -25,7 +25,7 @@ Print results with a Go template.
|
||||||
|
|
||||||
| **Placeholder** | **Description** |
|
| **Placeholder** | **Description** |
|
||||||
| ------------------- | --------------------------------------------------------------------- |
|
| ------------------- | --------------------------------------------------------------------- |
|
||||||
| .ConfigPath ... | Machine configuration file location |
|
| .ConfigDir ... | Machine configuration directory location |
|
||||||
| .ConnectionInfo ... | Machine connection information |
|
| .ConnectionInfo ... | Machine connection information |
|
||||||
| .Created ... | Machine creation time (string, ISO3601) |
|
| .Created ... | Machine creation time (string, ISO3601) |
|
||||||
| .Image ... | Machine image config |
|
| .Image ... | Machine image config |
|
||||||
|
|
|
@ -107,7 +107,7 @@ type DistributionDownload interface {
|
||||||
CleanCache() error
|
CleanCache() error
|
||||||
}
|
}
|
||||||
type InspectInfo struct {
|
type InspectInfo struct {
|
||||||
ConfigPath define.VMFile
|
ConfigDir define.VMFile
|
||||||
ConnectionInfo ConnectionConfig
|
ConnectionInfo ConnectionConfig
|
||||||
Created time.Time
|
Created time.Time
|
||||||
Image ImageConfig
|
Image ImageConfig
|
||||||
|
|
|
@ -282,7 +282,7 @@ var _ = Describe("podman machine init", func() {
|
||||||
Expect(session).To(Exit(0))
|
Expect(session).To(Exit(0))
|
||||||
|
|
||||||
inspect := new(inspectMachine)
|
inspect := new(inspectMachine)
|
||||||
inspect = inspect.withFormat("{{.ConfigPath.Path}}")
|
inspect = inspect.withFormat("{{.ConfigDir.Path}}")
|
||||||
inspectSession, err := mb.setCmd(inspect).run()
|
inspectSession, err := mb.setCmd(inspect).run()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
cfgpth := filepath.Join(inspectSession.outputToString(), fmt.Sprintf("%s.json", name))
|
cfgpth := filepath.Join(inspectSession.outputToString(), fmt.Sprintf("%s.json", name))
|
||||||
|
|
|
@ -2,6 +2,7 @@ package e2e_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/containers/podman/v5/pkg/machine"
|
"github.com/containers/podman/v5/pkg/machine"
|
||||||
|
"github.com/containers/podman/v5/pkg/machine/define"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
|
@ -66,13 +67,12 @@ var _ = Describe("podman inspect stop", func() {
|
||||||
err = jsoniter.Unmarshal(inspectSession.Bytes(), &inspectInfo)
|
err = jsoniter.Unmarshal(inspectSession.Bytes(), &inspectInfo)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
// TODO Re-enable this for tests once inspect is fixed
|
switch testProvider.VMType() {
|
||||||
// switch testProvider.VMType() {
|
case define.WSLVirt:
|
||||||
// case define.WSLVirt:
|
Expect(inspectInfo[0].ConnectionInfo.PodmanPipe.GetPath()).To(ContainSubstring("podman-"))
|
||||||
// Expect(inspectInfo[0].ConnectionInfo.PodmanPipe.GetPath()).To(ContainSubstring("podman-"))
|
default:
|
||||||
// default:
|
Expect(inspectInfo[0].ConnectionInfo.PodmanSocket.GetPath()).To(HaveSuffix("podman.sock"))
|
||||||
// Expect(inspectInfo[0].ConnectionInfo.PodmanSocket.GetPath()).To(HaveSuffix("podman.sock"))
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
inspect := new(inspectMachine)
|
inspect := new(inspectMachine)
|
||||||
inspect = inspect.withFormat("{{.Name}}")
|
inspect = inspect.withFormat("{{.Name}}")
|
||||||
|
|
|
@ -297,6 +297,35 @@ func (mc *MachineConfig) IsFirstBoot() (bool, error) {
|
||||||
return mc.LastUp == never, nil
|
return mc.LastUp == never, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mc *MachineConfig) ConnectionInfo(vmtype define.VMType) (*define.VMFile, *define.VMFile, error) {
|
||||||
|
var (
|
||||||
|
socket *define.VMFile
|
||||||
|
pipe *define.VMFile
|
||||||
|
)
|
||||||
|
|
||||||
|
if vmtype == define.HyperVVirt || vmtype == define.WSLVirt {
|
||||||
|
pipeName := mc.Name
|
||||||
|
if !strings.HasPrefix(pipeName, "podman") {
|
||||||
|
pipeName = "podman-" + pipeName
|
||||||
|
}
|
||||||
|
pipe = &define.VMFile{Path: `\\.\pipe\` + pipeName}
|
||||||
|
}
|
||||||
|
|
||||||
|
if vmtype == define.WSLVirt {
|
||||||
|
return nil, pipe, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
sockName := "podman.sock"
|
||||||
|
dataDir, err := mc.DataDir()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("Resolving data dir: %s", err.Error())
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
socket, err = define.NewMachineFile(filepath.Join(dataDir.Path, sockName), &sockName)
|
||||||
|
return socket, pipe, err
|
||||||
|
}
|
||||||
|
|
||||||
// LoadMachineByName returns a machine config based on the vm name and provider
|
// LoadMachineByName returns a machine config based on the vm name and provider
|
||||||
func LoadMachineByName(name string, dirs *define.MachineDirs) (*MachineConfig, error) {
|
func LoadMachineByName(name string, dirs *define.MachineDirs) (*MachineConfig, error) {
|
||||||
fullPath, err := dirs.ConfigDir.AppendToNewVMFile(name+".json", nil)
|
fullPath, err := dirs.ConfigDir.AppendToNewVMFile(name+".json", nil)
|
||||||
|
|
Loading…
Reference in New Issue