Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/podman/machine/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func toHumanFormat(vms []*machine.ListResponse, defaultCon *config.Connection) [
isDefault := false
// check port, in case we somehow have machines with the same name in different providers
if defaultCon != nil {
isDefault = vm.Name == defaultCon.Name && strings.Contains(defaultCon.URI, strconv.Itoa((vm.Port)))
isDefault = vm.Name == defaultCon.Name && strings.Contains(defaultCon.URI, strconv.Itoa(vm.Port))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that seem unrelated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just redundant parans yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well my comment was meant why are you changing unrelated things in this commit, anyhow not worth blocking over.

}
if isDefault {
response.Name = vm.Name + "*"
Expand Down
13 changes: 7 additions & 6 deletions cmd/podman/machine/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ func ssh(_ *cobra.Command, args []string) error {
// it implies podman cannot read its machine files, which is bad
mc, vmProvider, err = shim.VMExists(args[0])
if err != nil {
return err
}
if errors.Is(err, &define.ErrVMDoesNotExist{}) {
vmName = args[0]
} else {
var vmNotExistsErr *define.ErrVMDoesNotExist
if !errors.As(err, &vmNotExistsErr) {
return err
}
sshOpts.Args = append(sshOpts.Args, args[0])
} else {
vmName = args[0]
exists = true
}
exists = true
}

// If len is greater than 1, it means we might have been
Expand Down
35 changes: 24 additions & 11 deletions pkg/machine/e2e/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,38 @@ var _ = Describe("podman machine ssh", func() {

It("ssh to running machine and check os-type", func() {
wsl := testProvider.VMType() == define.WSLVirt
name := randomString()

// setting this name instead of randomized because we want to test when the
// machine name is and is not provided. That's what the loop below is for

name := "podman-machine-default"
i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImage(mb.imagePath).withNow()).run()
session, err := mb.setName(name).setCmd(i.withImage(mb.imagePath).withNow().withUpdateConnection(ptrBool(true))).run()
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

// pass 1
ssh := &sshMachine{}
sshSession, err := mb.setName(name).setCmd(ssh.withSSHCommand([]string{"cat", "/etc/os-release"})).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(0))
// pass 2
bm := basicMachine{}
var mcs []machineCommand
// check with the machine name
mcs = append(mcs, ssh.withSSHCommand([]string{"cat", "/etc/os-release"}))
// check without the machine name
mcs = append(mcs, bm.withPodmanCommand([]string{"machine", "ssh", "cat", "/etc/os-release"}))
for _, mc := range mcs {
sshSession, err := mb.setCmd(mc).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(0))

if wsl {
Expect(sshSession.outputToString()).To(ContainSubstring("Fedora Linux"))
} else {
Expect(sshSession.outputToString()).To(ContainSubstring("Fedora CoreOS"))
if wsl {
Expect(sshSession.outputToString()).To(ContainSubstring("Fedora Linux"))
} else {
Expect(sshSession.outputToString()).To(ContainSubstring("Fedora CoreOS"))
}
}

// keep exit code
sshSession, err = mb.setName(name).setCmd(ssh.withSSHCommand([]string{"false"})).run()
sshSession, err := mb.setName(name).setCmd(ssh.withSSHCommand([]string{"false"})).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(1))
Expect(sshSession.outputToString()).To(Equal(""))
Expand Down