Skip to content

Commit

Permalink
5-3 test
Browse files Browse the repository at this point in the history
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
  • Loading branch information
JasonYangShadow committed Aug 29, 2024
1 parent b8a40a6 commit a7b8dd1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions cmd/internal/cli/loginargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func ObtainLoginArgs(name string) *apptainer.LoginArgs {
loginArgs.Password = loginPassword
loginArgs.Tokenfile = loginTokenFile
loginArgs.Insecure = loginInsecure
loginArgs.ReqAuthFile = reqAuthFile

if loginPasswordStdin {
p, err := io.ReadAll(os.Stdin)
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/cli/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var RegistryCmd = &cobra.Command{
var RegistryLoginCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
Run: func(_ *cobra.Command, args []string) {
if err := apptainer.RegistryLogin(remoteConfig, ObtainLoginArgs(args[0]), reqAuthFile); err != nil {
if err := apptainer.RegistryLogin(remoteConfig, ObtainLoginArgs(args[0])); err != nil {
sylog.Fatalf("%s", err)
}
},
Expand Down
6 changes: 4 additions & 2 deletions cmd/internal/cli/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,9 @@ var RemoteAddCmd = &cobra.Command{
sylog.Infof("Global option detected. Will not automatically log into remote.")
} else if !remoteNoLogin {
loginArgs := &apptainer.LoginArgs{
Name: name,
Tokenfile: loginTokenFile,
Name: name,
Tokenfile: loginTokenFile,
ReqAuthFile: reqAuthFile,
}
if err := apptainer.RemoteLogin(remoteConfig, loginArgs); err != nil {
sylog.Fatalf("%s", err)
Expand Down Expand Up @@ -392,6 +393,7 @@ var RemoteLoginCmd = &cobra.Command{
loginArgs.Password = loginPassword
loginArgs.Tokenfile = loginTokenFile
loginArgs.Insecure = loginInsecure
loginArgs.ReqAuthFile = reqAuthFile

if loginPasswordStdin {
p, err := io.ReadAll(os.Stdin)
Expand Down
6 changes: 3 additions & 3 deletions e2e/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,9 @@ func (c ctx) testDockerFallbackConfig(t *testing.T) {

c.env.RunApptainer(
t,
e2e.AsSubtest(`registry login`),
e2e.AsSubtest(`remote login`),
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("registry login"),
e2e.WithCommand("remote login"),
e2e.WithArgs([]string{"-u", e2e.DefaultUsername, "-p", e2e.DefaultPassword, registry}...),
e2e.ExpectExit(0),
)
Expand Down Expand Up @@ -776,7 +776,7 @@ func (c ctx) testDockerFallbackConfig(t *testing.T) {
t,
e2e.AsSubtest(`logout`),
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("registry logout"),
e2e.WithCommand("remote logout"),
e2e.WithArgs([]string{registry}...),
e2e.ExpectExit(0),
)
Expand Down
4 changes: 2 additions & 2 deletions internal/app/apptainer/registry_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

// RegistryLogin logs in to an OCI/Docker registry.
func RegistryLogin(usrConfigFile string, args *LoginArgs, reqAuthFile string) (err error) {
func RegistryLogin(usrConfigFile string, args *LoginArgs) (err error) {
// opening config file
file, err := os.OpenFile(usrConfigFile, os.O_RDWR|os.O_CREATE, 0o600)
if err != nil {
Expand All @@ -38,7 +38,7 @@ func RegistryLogin(usrConfigFile string, args *LoginArgs, reqAuthFile string) (e
return err
}

if err := c.Login(args.Name, args.Username, args.Password, args.Insecure, reqAuthFile); err != nil {
if err := c.Login(args.Name, args.Username, args.Password, args.Insecure, args.ReqAuthFile); err != nil {
return fmt.Errorf("while login to %s: %s", args.Name, err)
}

Expand Down
13 changes: 7 additions & 6 deletions internal/app/apptainer/remote_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (
)

type LoginArgs struct {
Name string
Username string
Password string
Tokenfile string
Insecure bool
Name string
Username string
Password string
Tokenfile string
Insecure bool
ReqAuthFile string
}

// ErrLoginAborted is raised when the login process has been aborted by the user
Expand Down Expand Up @@ -77,7 +78,7 @@ func RemoteLogin(usrConfigFile string, args *LoginArgs) (err error) {
return fmt.Errorf("--tokenfile is only supported for login to a remote endpoint, not OCI (docker/oras) or keyservers")
}
sylog.Warningf("'remote login' is deprecated for registries or keyservers and will be removed in a future release; running 'registry login'")
return RegistryLogin(usrConfigFile, args, "")
return RegistryLogin(usrConfigFile, args)
}

// truncating file before writing new contents and syncing to commit file
Expand Down

0 comments on commit a7b8dd1

Please sign in to comment.