disable push step if no registry was configured

This commit is contained in:
Matthew Fisher 2018-03-20 17:12:38 -07:00
Родитель 148e3ccc29
Коммит 9f99686810
2 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -12,10 +12,18 @@ $ cd examples/example-python
## Draft Setup
Before we start, we need to set a default registry where we will be pushing all of our images to. In this case, we want to push images to our custom registry sitting at `myregistry.com` so the image will be pushed and pulled from `myregistry.com/example-python`, so to do that, we run
For minikube environments, the recommended way to get started is by talking to minikube's Docker daemon. To do this, we run
```shell
$ eval $(minikube docker-env)
```
draft config set registry myregistry.com
Draft will pick up on this and build Docker images using Minikube's in-cluster Docker daemon, making the build process quick and speedy.
If we're using a cloud-provided solution like [Azure Container Service](https://azure.microsoft.com/en-us/services/container-service/), we need to configure a registry where we will be pushing all of our images to, so all nodes in the Kubernetes cluster can pull the images we build using Draft. for this example, we want to push images to our registry sitting at `myregistry.com`, and pull those images down to the Kubernetes cluster from that same registry. To do that, we run
```shell
$ draft config set registry myregistry.com
```
This command tells Draft to push images to this Docker registry, and for Kubernetes to pull images from this Docker registry.

Просмотреть файл

@ -3,7 +3,6 @@ package builder
import (
"bytes"
"crypto/sha256"
"errors"
"fmt"
"io"
"io/ioutil"
@ -300,9 +299,11 @@ func (b *Builder) Up(ctx context.Context, bctx *Context) <-chan *Summary {
fmt.Printf("buildApp: buildImg error: %v\n", err)
return
}
if err := b.pushImg(ctx, app, ch); err != nil {
fmt.Printf("buildApp: pushImg error: %v\n", err)
return
if app.ctx.Env.Registry != "" {
if err := b.pushImg(ctx, app, ch); err != nil {
fmt.Printf("buildApp: pushImg error: %v\n", err)
return
}
}
if err := b.release(ctx, app, ch); err != nil {
fmt.Printf("buildApp: release error: %v\n", err)
@ -347,10 +348,6 @@ func (b *Builder) buildImg(ctx context.Context, app *AppContext, out chan<- *Sum
msgc := make(chan string)
errc := make(chan error)
go func() {
if app.ctx.Env.Registry == "" {
errc <- errors.New("No registry was configured")
return
}
buildopts := types.ImageBuildOptions{Tags: []string{app.img}}
resp, err := b.DockerClient.Client().ImageBuild(ctx, app.buf, buildopts)
if err != nil {