Skip to content

Commit

Permalink
add: checking multiple registries in config file
Browse files Browse the repository at this point in the history
Signed-off-by: Lazar Slavković-Raco <[email protected]>

# Conflicts:
#	cmd/podman/login.go
#	cmd/podman/logout.go
  • Loading branch information
lslavkov committed Dec 24, 2024
1 parent d3cd509 commit 5b6052e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/podman/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/containers/common/pkg/auth"
"github.com/containers/common/pkg/completion"
"github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v5/cmd/podman/common"
"github.com/containers/podman/v5/cmd/podman/registry"
Expand Down Expand Up @@ -98,7 +99,15 @@ func login(cmd *cobra.Command, args []string) error {
sysCtx := &types.SystemContext{
DockerInsecureSkipTLSVerify: skipTLS,
}
<<<<<<< HEAD
common.SetRegistriesConfPath(sysCtx)
=======
setRegistriesConfPath(sysCtx)
registriesFromFile, _ := sysregistriesv2.UnqualifiedSearchRegistries(sysCtx)
if len(registriesFromFile) > 1 {
return errors.New("multiple registries in registry.conf, a registry must be provided")
}
>>>>>>> 39123de11f (add: checking multiple registries in config file)
loginOptions.GetLoginSet = cmd.Flag("get-login").Changed
return auth.Login(context.Background(), sysCtx, &loginOptions.LoginOptions, args)
}
10 changes: 10 additions & 0 deletions cmd/podman/logout.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"errors"
"os"

"github.com/containers/common/pkg/auth"
"github.com/containers/common/pkg/completion"
"github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v5/cmd/podman/common"
"github.com/containers/podman/v5/cmd/podman/registry"
Expand Down Expand Up @@ -49,6 +51,14 @@ func init() {
// Implementation of podman-logout.
func logout(cmd *cobra.Command, args []string) error {
sysCtx := &types.SystemContext{}
<<<<<<< HEAD
common.SetRegistriesConfPath(sysCtx)
=======
setRegistriesConfPath(sysCtx)
registriesFromFile, _ := sysregistriesv2.UnqualifiedSearchRegistries(sysCtx)
if len(registriesFromFile) > 1 {
return errors.New("multiple registries in registry.conf, a registry must be provided")
}
>>>>>>> 39123de11f (add: checking multiple registries in config file)
return auth.Logout(sysCtx, &logoutOptions, args)
}

0 comments on commit 5b6052e

Please sign in to comment.