Skip to content

Commit

Permalink
Add support for --compat-auth-file in login/logout
Browse files Browse the repository at this point in the history
This mostly just inherits the c/common/pkg/auth implementation,
except that AuthFilePath and DockerCompatAuthFilePath can not be set
simultaneously, so don't always set AuthFilePath. c/common already
defaults to the same locations internally.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Nov 7, 2023
1 parent 0b17b91 commit 482c6f3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/buildah/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func loginCmd(c *cobra.Command, args []string, iopts *loginReply) error {
if err != nil {
return fmt.Errorf("building system context: %w", err)
}
// parse.SystemContextFromOptions may point this field to an auth.json or to a .docker/config.json;
// that’s fair enough for reads, but incorrect for writes (the two files have incompatible formats),
// and it interferes with the auth.Login’s own argument parsing.
systemContext.AuthFilePath = ""
ctx := getContext()
iopts.loginOpts.GetLoginSet = c.Flag("get-login").Changed
return auth.Login(ctx, systemContext, &iopts.loginOpts, args)
Expand Down
4 changes: 4 additions & 0 deletions cmd/buildah/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ func logoutCmd(c *cobra.Command, args []string, iopts *auth.LogoutOptions) error
if err != nil {
return fmt.Errorf("building system context: %w", err)
}
// parse.SystemContextFromOptions may point this field to an auth.json or to a .docker/config.json;
// that’s fair enough for reads, but incorrect for writes (the two files have incompatible formats),
// and it interferes with the auth.Logout’s own argument parsing.
systemContext.AuthFilePath = ""
return auth.Logout(systemContext, iopts, args)
}
4 changes: 4 additions & 0 deletions docs/buildah-login.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Path of the authentication file. Default is ${XDG_\RUNTIME\_DIR}/containers/auth
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
environment variable. `export REGISTRY_AUTH_FILE=path`

**--compat-auth-file**=*path*

Instead of updating the default credentials file, update the one at *path*, and use a Docker-compatible format.

**--cert-dir** *path*

Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
Expand Down
4 changes: 4 additions & 0 deletions docs/buildah-logout.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Path of the authentication file. Default is ${XDG_\RUNTIME\_DIR}/containers/auth
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
environment variable. `export REGISTRY_AUTH_FILE=path`

**--compat-auth-file**=*path*

Instead of updating the default credentials file, update the one at *path*, and use a Docker-compatible format.

**--help**, **-h**

Print usage statement
Expand Down

0 comments on commit 482c6f3

Please sign in to comment.