Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker pull graphics #80

Merged
merged 9 commits into from
Jan 30, 2019
Merged
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ jobs:
- 1.11.x
env:
- GO111MODULE=on
- DOCKER_TLS_VERIFY=1
- secure: U0WHj8cs5dMFrfabxgmhl7Id6UL3+kELfIee7tREvBj3UKZl6iS2P6wA8oQkyvwLH1h+mO0QdTnQqwtH6cUnP1jNHG15loN3KM1504OB64UEv0AnOezrPZLhDQwBWT7T+Rw6iBjBWGUk9KdCuT5/JKlP46ZllRVuMphhtnJwGVggFL+W2ol6oL8qg1/pVT6HZNEwfsbBe3HH3EYw8mhvhM2WjscQKEjiNiIClKwO/IcJdZ0iCUSKvTk20nNIGOnIMfAXtmwMGJAB/nRmHDnzV3ijxyUsCPo6Ae2f/bJsU1The0gCItw9yAag6ckeeudPQtLLRlzZr/Z5l2Z05qWRr7v2BIIVDrs7lBYPUCkoJGy8azCTAnB3BdR0iv/w+6L/p5eK9rHxtW8zI+8rgswfxmAzZjAVDMuIDXXg/PUkK/g27UmzInUmf3gOJk9hItfYtT43hVqp0ZfFTZBtrwOjwVriHKl7o4jGwIkBWWr7UeFzASL0QE45e6yYxlobyuF/plww6ECe/tbGUrXRd52M01VWEqJqHqFZ3v/QUU7ZoYMYLZHAelXrQ9ymIFgBRiXCOCFrofzjMt8KgKEUHre++pBm6E9boUW3mcc6p9Wsi/Mh1cVjr/Fk3T0+4TqTm+Yo2yyabmOCQlRHubLRYcwOdJ9dkXBMIcS7IsQ6szG6kR8=
go_import_path: github.com/buildpack/lifecycle
script: |
openssl aes-256-cbc -K $encrypted_e607085e6307_key -iv $encrypted_e607085e6307_iv -in .travis/key.pem.enc -out .travis/key.pem -d
test -z "$(bin/format | tee >(cat >&2))"
export DOCKER_CERT_PATH=$PWD/.travis/
go test -v ./...
go test -tags=image -v ./image/...
go test -v -parallel=1 -p=1 -count=1 ./...
- stage: build and push images
if: branch = master AND fork = false
env:
Expand Down
32 changes: 0 additions & 32 deletions .travis/ca.pem

This file was deleted.

30 changes: 0 additions & 30 deletions .travis/cert.pem

This file was deleted.

Binary file removed .travis/key.pem.enc
Binary file not shown.
4 changes: 2 additions & 2 deletions cmd/analyzer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package main

import (
"flag"
"github.com/buildpack/lifecycle/image"
"log"
"os"

"github.com/BurntSushi/toml"

"github.com/buildpack/lifecycle"
"github.com/buildpack/lifecycle/cmd"
"github.com/buildpack/lifecycle/image"
)

var (
Expand Down Expand Up @@ -60,7 +60,7 @@ func analyzer() error {

var err error
var previousImage image.Image
factory, err := image.NewFactory(image.WithEnvKeychain, image.WithLegacyEnvKeychain)
factory, err := image.NewFactory(image.WithOutWriter(os.Stdout), image.WithEnvKeychain, image.WithLegacyEnvKeychain)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func export() error {
ArtifactsDir: artifactsDir,
}

factory, err := image.NewFactory(image.WithEnvKeychain, image.WithLegacyEnvKeychain)
factory, err := image.NewFactory(image.WithOutWriter(os.Stdout), image.WithEnvKeychain, image.WithLegacyEnvKeychain)
if err != nil {
return err
}
Expand Down
10 changes: 9 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
module github.com/buildpack/lifecycle

require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/BurntSushi/toml v0.3.1
github.com/dgodd/dockerdial v1.0.1
github.com/Microsoft/go-winio v0.4.11 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/docker/distribution v2.7.0+incompatible // indirect
github.com/docker/docker v0.7.3-0.20181027010111-b8e87cfdad8d
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.3.3 // indirect
github.com/gogo/protobuf v1.2.0 // indirect
github.com/golang/mock v1.2.0
github.com/google/go-cmp v0.2.0
github.com/google/go-containerregistry v0.0.0-20190110221225-f514e780f7cd
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/mux v1.6.2 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/pkg/errors v0.8.0
github.com/sclevine/spec v1.0.0
github.com/sirupsen/logrus v1.2.0 // indirect
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc // indirect
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 // indirect
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect
google.golang.org/grpc v1.17.0 // indirect
gotest.tools v2.2.0+incompatible // indirect
)
14 changes: 0 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgodd/dockerdial v1.0.1 h1:6XixGQxeytsIdVsbI4y+EHuv8QcxxH6ySJZLkm3jk5o=
github.com/dgodd/dockerdial v1.0.1/go.mod h1:MJmK56eTylC3KU7DR6bc3k9jmbpURO8rDOsGbfj+c6o=
github.com/docker/distribution v0.0.0-20180327202408-83389a148052/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.7.0+incompatible h1:neUDAlf3wX6Ml4HdqTrbcOHXtfRN0TFIwt6YFL7N9RU=
github.com/docker/distribution v2.7.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v0.7.3-0.20181027010111-b8e87cfdad8d h1:i8JkxYtxGIN2F2bHkhzj0S6iKQBOUSQrLbeVHWpOs4I=
Expand All @@ -21,12 +18,10 @@ github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKoh
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
Expand All @@ -40,10 +35,7 @@ github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
Expand All @@ -56,26 +48,22 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sclevine/spec v1.0.0 h1:ILQ08A/CHCz8GGqivOvI54Hy1U40wwcpkf7WtB1MQfY=
github.com/sclevine/spec v1.0.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
github.com/sirupsen/logrus v1.1.1/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc h1:a3CU5tJYVj92DY2LaA1kUkrsqD5/3mLDhx2NcNqyW+0=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181025063200-d989b31c8746/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
Expand All @@ -86,10 +74,8 @@ golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGm
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
google.golang.org/grpc v1.17.0 h1:TRJYBgMclJvGYn2rIMjj+h9KtMt5r1Ij7ODVRIZkwhk=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
gotest.tools v2.1.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
11 changes: 11 additions & 0 deletions image/factory.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package image

import (
"io"
"io/ioutil"

"github.com/docker/docker/client"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/pkg/errors"
Expand All @@ -13,11 +16,13 @@ type Factory struct {
Docker *client.Client
FS *fs.FS
Keychain authn.Keychain
Out io.Writer
}

func NewFactory(ops ...func(*Factory)) (*Factory, error) {
f := &Factory{
FS: &fs.FS{},
Out: ioutil.Discard,
Keychain: authn.DefaultKeychain,
}

Expand All @@ -41,6 +46,12 @@ func WithLegacyEnvKeychain(factory *Factory) {
factory.Keychain = authn.NewMultiKeychain(&auth.LegacyEnvKeychain{}, factory.Keychain)
}

func WithOutWriter(w io.Writer) func(factory *Factory) {
return func(factory *Factory) {
factory.Out = w
}
}

func newDocker() (*client.Client, error) {
docker, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("1.38"))
if err != nil {
Expand Down
12 changes: 9 additions & 3 deletions image/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/docker/docker/api/types"
dockertypes "github.com/docker/docker/api/types"
dockerclient "github.com/docker/docker/client"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/docker/pkg/term"
"github.com/google/go-containerregistry/pkg/name"
"github.com/pkg/errors"

Expand All @@ -42,7 +44,7 @@ type local struct {

func (f *Factory) NewLocal(repoName string, pull bool) (Image, error) {
if pull {
if err := f.pullImage(f.Docker, repoName); err != nil {
if err := f.pullImage(f.Out, f.Docker, repoName); err != nil {
return nil, fmt.Errorf("failed to pull image '%s' : %s", repoName, err)
}
}
Expand Down Expand Up @@ -408,7 +410,7 @@ func (l *local) prevDownload() error {
return outerErr
}

func (f *Factory) pullImage(dockerCli *dockerclient.Client, ref string) error {
func (f *Factory) pullImage(output io.Writer, dockerCli *dockerclient.Client, ref string) error {
regAuth, err := f.registryAuth(ref)
if err != nil {
return errors.Wrap(err, "auth for docker pull")
Expand All @@ -426,9 +428,13 @@ func (f *Factory) pullImage(dockerCli *dockerclient.Client, ref string) error {
return err
}
}
if _, err := io.Copy(ioutil.Discard, rc); err != nil {

termFd, isTerm := term.GetFdInfo(output)
err = jsonmessage.DisplayJSONMessagesStream(rc, output, termFd, isTerm, nil)
if err != nil {
return err
}

return rc.Close()
}

Expand Down
Loading