cmd/create, pkg/utils: Simplify hint after creating a container
A subsequent commit will add support for configuration files, which can override the default toolbox image. Since this override affects all commands, it effectively ends up adding a fourth option to the 'enter' command, other than the existing options to change the distribution, release and container. This makes it a lot more difficult to reason when only 'toolbox enter --release N' is enough to enter the created container. https://github.com/containers/toolbox/pull/828 https://github.com/containers/toolbox/pull/851
This commit is contained in:
parent
6a37695086
commit
5824f0adcb
3 changed files with 8 additions and 10 deletions
|
@ -178,7 +178,7 @@ func createContainer(container, image, release string, showCommandToEnter bool)
|
|||
panic("release not specified")
|
||||
}
|
||||
|
||||
enterCommand := getEnterCommand(container, release)
|
||||
enterCommand := getEnterCommand(container)
|
||||
|
||||
logrus.Debugf("Checking if container %s already exists", container)
|
||||
|
||||
|
@ -503,15 +503,12 @@ func getDBusSystemSocket() (string, error) {
|
|||
return pathEvaled, nil
|
||||
}
|
||||
|
||||
func getEnterCommand(container, release string) string {
|
||||
func getEnterCommand(container string) string {
|
||||
var enterCommand string
|
||||
containerNamePrefixDefaultWithRelease := utils.ContainerNamePrefixDefault + "-" + release
|
||||
|
||||
switch container {
|
||||
case utils.ContainerNameDefault:
|
||||
enterCommand = fmt.Sprintf("%s enter", executableBase)
|
||||
case containerNamePrefixDefaultWithRelease:
|
||||
enterCommand = fmt.Sprintf("%s enter --release %s", executableBase, release)
|
||||
default:
|
||||
enterCommand = fmt.Sprintf("%s enter %s", executableBase, container)
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
containerNamePrefixDefault = "fedora-toolbox"
|
||||
|
||||
distroDefault = "fedora"
|
||||
|
||||
preservedEnvironmentVariables = []string{
|
||||
|
@ -112,8 +114,7 @@ var (
|
|||
)
|
||||
|
||||
var (
|
||||
ContainerNameDefault string
|
||||
ContainerNamePrefixDefault = "fedora-toolbox"
|
||||
ContainerNameDefault string
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -124,14 +125,14 @@ func init() {
|
|||
if distroObj, supportedDistro := supportedDistros[hostID]; supportedDistro {
|
||||
release, err := GetHostVersionID()
|
||||
if err == nil {
|
||||
ContainerNamePrefixDefault = distroObj.ContainerNamePrefix
|
||||
containerNamePrefixDefault = distroObj.ContainerNamePrefix
|
||||
distroDefault = hostID
|
||||
releaseDefault = release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ContainerNameDefault = ContainerNamePrefixDefault + "-" + releaseDefault
|
||||
ContainerNameDefault = containerNamePrefixDefault + "-" + releaseDefault
|
||||
}
|
||||
|
||||
func AskForConfirmation(prompt string) bool {
|
||||
|
|
|
@ -62,7 +62,7 @@ teardown() {
|
|||
|
||||
assert_success
|
||||
assert_output --partial "Created container: fedora-toolbox-32"
|
||||
assert_output --partial "Enter with: toolbox enter --release 32"
|
||||
assert_output --partial "Enter with: toolbox enter fedora-toolbox-32"
|
||||
|
||||
# Make sure the container has actually been created
|
||||
run podman ps -a
|
||||
|
|
Loading…
Reference in a new issue