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
7 changes: 4 additions & 3 deletions pkg/specgen/generate/pod_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,15 @@ func PodConfigToSpec(rt *libpod.Runtime, spec *specgen.PodSpecGenerator, infraOp
return nil, err
}

if len(spec.InfraContainerSpec.Image) > 0 {
spec.InfraImage = spec.InfraContainerSpec.Image
}

spec.Name = name
}

// need to reset hostname, name etc of both pod and infra
spec.Hostname = ""

if len(spec.InfraContainerSpec.Image) > 0 {
spec.InfraImage = spec.InfraContainerSpec.Image
}
return pod, nil
}
10 changes: 10 additions & 0 deletions test/e2e/generate_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,14 @@ var _ = Describe("Podman generate spec", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
})

It("generate spec for pod with no infra container", func() {
session := podmanTest.Podman([]string{"pod", "create", "--share", "none", "--name", "podspecgen2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

session = podmanTest.Podman([]string{"generate", "spec", "--compact", "podspecgen2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
})
})