allow multiple destinations, error handling for each push
This commit is contained in:
parent
7d0466db37
commit
4c190a7037
|
|
@ -85,10 +85,9 @@ var RootCmd = &cobra.Command{
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, destination := range destinations {
|
if err := executor.DoPush(ref, image, destinations, tarPath); err != nil {
|
||||||
if err := executor.DoPush(ref, image, destination, tarPath); err != nil {
|
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
}
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,9 @@ func DoBuild(dockerfilePath, srcContext, snapshotMode string, args []string) (na
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func DoPush(ref name.Reference, image v1.Image, destination, tarPath string) error {
|
func DoPush(ref name.Reference, image v1.Image, destinations []string, tarPath string) error {
|
||||||
|
// continue pushing unless an error occurs
|
||||||
|
for _, destination := range destinations {
|
||||||
// Push the image
|
// Push the image
|
||||||
destRef, err := name.NewTag(destination, name.WeakValidation)
|
destRef, err := name.NewTag(destination, name.WeakValidation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -189,7 +191,14 @@ func DoPush(ref name.Reference, image v1.Image, destination, tarPath string) err
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return remote.Write(destRef, image, pushAuth, http.DefaultTransport, wo)
|
|
||||||
|
err = remote.Write(destRef, image, pushAuth, http.DefaultTransport, wo)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(fmt.Errorf("Failed to push to destination %s", destination))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
func saveStageDependencies(index int, stages []instructions.Stage, buildArgs *dockerfile.BuildArgs) error {
|
func saveStageDependencies(index int, stages []instructions.Stage, buildArgs *dockerfile.BuildArgs) error {
|
||||||
// First, get the files in this stage later stages will need
|
// First, get the files in this stage later stages will need
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue