Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit 5ebd304

Browse files
committed
Login before build on build-push
If the username and password is set then do the login before the build on build-push so that users can build using base images from a secure private registry. Signed-off-by: Nick Adcock <[email protected]>
1 parent 776ef5a commit 5ebd304

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

cmd/build_push.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ import (
88
)
99

1010
func buildPush(cmd command.Runner) error {
11+
registry := options.GetRegistry()
12+
login, err := options.GetLoginOptions()
13+
if err != nil {
14+
return err
15+
}
16+
if login.Username != "" && login.Password != "" {
17+
if err := command.RunLogin(cmd, login, registry); err != nil {
18+
return err
19+
}
20+
}
21+
1122
github, err := options.GetGitHubOptions()
1223
if err != nil {
1324
return err
1425
}
1526

16-
registry := options.GetRegistry()
1727
tags, err := options.GetTags(registry, github)
1828
if err != nil {
1929
return err
@@ -30,16 +40,6 @@ func buildPush(cmd command.Runner) error {
3040
if shouldPush, err := options.ShouldPush(); err != nil {
3141
return err
3242
} else if shouldPush {
33-
login, err := options.GetLoginOptions()
34-
if err != nil {
35-
return err
36-
}
37-
if login.Username != "" && login.Password != "" {
38-
if err := command.RunLogin(cmd, login, registry); err != nil {
39-
return err
40-
}
41-
}
42-
4343
return command.RunPush(cmd, tags)
4444
}
4545

0 commit comments

Comments
 (0)