Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor tweaks to the 'toolbox create --authfile ...' code #1240

Merged
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 doc/toolbox-create.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
toolbox\-create - Create a new toolbox container

## SYNOPSIS
**toolbox create** [*--authfile AUTHFILE*]
**toolbox create** [*--authfile FILE*]
[*--distro DISTRO* | *-d DISTRO*]
[*--image NAME* | *-i NAME*]
[*--release RELEASE* | *-r RELEASE*]
Expand Down
12 changes: 6 additions & 6 deletions src/cmd/create.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2019 – 2022 Red Hat Inc.
* Copyright © 2019 – 2023 Red Hat Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -176,14 +176,14 @@ func create(cmd *cobra.Command, args []string) error {
return err
}

if err := createContainer(container, image, release, true); err != nil {
if err := createContainer(container, image, release, createFlags.authFile, true); err != nil {
return err
}

return nil
}

func createContainer(container, image, release string, showCommandToEnter bool) error {
func createContainer(container, image, release, authFile string, showCommandToEnter bool) error {
if container == "" {
panic("container not specified")
}
Expand All @@ -210,7 +210,7 @@ func createContainer(container, image, release string, showCommandToEnter bool)
return errors.New(errMsg)
}

pulled, err := pullImage(image, release)
pulled, err := pullImage(image, release, authFile)
if err != nil {
return err
}
Expand Down Expand Up @@ -646,7 +646,7 @@ func getServiceSocket(serviceName string, unitName string) (string, error) {
return "", fmt.Errorf("failed to find a SOCK_STREAM socket for %s", unitName)
}

func pullImage(image, release string) (bool, error) {
func pullImage(image, release, authFile string) (bool, error) {
if ok := utils.ImageReferenceCanBeID(image); ok {
logrus.Debugf("Looking for image %s", image)

Expand Down Expand Up @@ -721,7 +721,7 @@ func pullImage(image, release string) (bool, error) {
defer s.Stop()
}

if err := podman.Pull(imageFull, createFlags.authFile); err != nil {
if err := podman.Pull(imageFull, authFile); err != nil {
var builder strings.Builder
fmt.Fprintf(&builder, "failed to pull image %s\n", imageFull)
fmt.Fprintf(&builder, "If it was a private image, log in with: podman login %s\n", domain)
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/run.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2019 – 2022 Red Hat Inc.
* Copyright © 2019 – 2023 Red Hat Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -215,7 +215,7 @@ func runCommand(container string,
return nil
}

if err := createContainer(container, image, release, false); err != nil {
if err := createContainer(container, image, release, "", false); err != nil {
return err
}
} else if containersCount == 1 && defaultContainer {
Expand Down