Skip to content

Commit 11997a9

Browse files
author
OpenShift Bot
authored
Merge pull request #9705 from bparees/push_error
Merged by openshift-bot
2 parents 72fdd09 + 103c403 commit 11997a9

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

pkg/build/builder/docker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (d *DockerBuilder) Build() error {
118118
}
119119
glog.V(0).Infof("\nPushing image %s ...", pushTag)
120120
if err := pushImage(d.dockerClient, pushTag, pushAuthConfig); err != nil {
121-
return fmt.Errorf("Failed to push image: %v", err)
121+
return reportPushFailure(err, authPresent, pushAuthConfig)
122122
}
123123
glog.V(0).Infof("Push successful")
124124
}

pkg/build/builder/sti.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -267,19 +267,7 @@ func (s *S2IBuilder) Build() error {
267267
}
268268
glog.V(0).Infof("\nPushing image %s ...", pushTag)
269269
if err := pushImage(s.dockerClient, pushTag, pushAuthConfig); err != nil {
270-
// write extended error message to assist in problem resolution
271-
msg := fmt.Sprintf("Failed to push image. Response from registry is: %v", err)
272-
if authPresent {
273-
glog.V(0).Infof("Registry server Address: %s", pushAuthConfig.ServerAddress)
274-
glog.V(0).Infof("Registry server User Name: %s", pushAuthConfig.Username)
275-
glog.V(0).Infof("Registry server Email: %s", pushAuthConfig.Email)
276-
passwordPresent := "<<empty>>"
277-
if len(pushAuthConfig.Password) > 0 {
278-
passwordPresent = "<<non-empty>>"
279-
}
280-
glog.V(0).Infof("Registry server Password: %s", passwordPresent)
281-
}
282-
return errors.New(msg)
270+
return reportPushFailure(err, authPresent, pushAuthConfig)
283271
}
284272
glog.V(0).Infof("Push successful")
285273
}

pkg/build/builder/util.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"strconv"
1313
"strings"
1414

15+
docker "github.com/fsouza/go-dockerclient"
16+
1517
s2iapi "github.com/openshift/source-to-image/pkg/api"
1618
)
1719

@@ -175,3 +177,18 @@ func MergeEnv(oldEnv, newEnv []string) []string {
175177
}
176178
return result
177179
}
180+
181+
func reportPushFailure(err error, authPresent bool, pushAuthConfig docker.AuthConfiguration) error {
182+
// write extended error message to assist in problem resolution
183+
if authPresent {
184+
glog.V(0).Infof("Registry server Address: %s", pushAuthConfig.ServerAddress)
185+
glog.V(0).Infof("Registry server User Name: %s", pushAuthConfig.Username)
186+
glog.V(0).Infof("Registry server Email: %s", pushAuthConfig.Email)
187+
passwordPresent := "<<empty>>"
188+
if len(pushAuthConfig.Password) > 0 {
189+
passwordPresent = "<<non-empty>>"
190+
}
191+
glog.V(0).Infof("Registry server Password: %s", passwordPresent)
192+
}
193+
return fmt.Errorf("Failed to push image: %v", err)
194+
}

0 commit comments

Comments
 (0)