Browse code

Switch to depend on docker imagebuilder

Clayton Coleman authored on 2016/08/04 23:23:21
Showing 1 changed files
... ...
@@ -7,6 +7,7 @@ import (
7 7
 	"path/filepath"
8 8
 	"strings"
9 9
 
10
+	dockertypes "github.com/docker/engine-api/types"
10 11
 	docker "github.com/fsouza/go-dockerclient"
11 12
 	"github.com/golang/glog"
12 13
 	"github.com/spf13/cobra"
... ...
@@ -15,9 +16,9 @@ import (
15 15
 	kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
16 16
 	"k8s.io/kubernetes/pkg/util/interrupt"
17 17
 
18
+	dockerbuilder "github.com/openshift/imagebuilder/dockerclient"
18 19
 	cmdutil "github.com/openshift/origin/pkg/cmd/util"
19 20
 	"github.com/openshift/origin/pkg/cmd/util/clientcmd"
20
-	"github.com/openshift/origin/pkg/util/docker/dockerfile/builder"
21 21
 )
22 22
 
23 23
 const (
... ...
@@ -46,7 +47,7 @@ type DockerbuildOptions struct {
46 46
 
47 47
 	MountSpecs []string
48 48
 
49
-	Mounts         []builder.Mount
49
+	Mounts         []dockerbuilder.Mount
50 50
 	Directory      string
51 51
 	Tag            string
52 52
 	DockerfilePath string
... ...
@@ -101,13 +102,13 @@ func (o *DockerbuildOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command,
101 101
 		o.DockerfilePath = filepath.Join(o.Directory, "Dockerfile")
102 102
 	}
103 103
 
104
-	var mounts []builder.Mount
104
+	var mounts []dockerbuilder.Mount
105 105
 	for _, s := range o.MountSpecs {
106 106
 		segments := strings.Split(s, ":")
107 107
 		if len(segments) != 2 {
108 108
 			return kcmdutil.UsageError(cmd, "--mount must be of the form SOURCE:DEST")
109 109
 		}
110
-		mounts = append(mounts, builder.Mount{SourcePath: segments[0], DestinationPath: segments[1]})
110
+		mounts = append(mounts, dockerbuilder.Mount{SourcePath: segments[0], DestinationPath: segments[1]})
111 111
 	}
112 112
 	o.Mounts = mounts
113 113
 
... ...
@@ -132,13 +133,23 @@ func (o *DockerbuildOptions) Run() error {
132 132
 		return err
133 133
 	}
134 134
 	defer f.Close()
135
-	e := builder.NewClientExecutor(o.Client)
135
+	e := dockerbuilder.NewClientExecutor(o.Client)
136 136
 	e.Out, e.ErrOut = o.Out, o.Err
137 137
 	e.AllowPull = o.AllowPull
138 138
 	e.Directory = o.Directory
139 139
 	e.TransientMounts = o.Mounts
140 140
 	e.Tag = o.Tag
141
-	e.AuthFn = o.Keyring.Lookup
141
+	e.AuthFn = func(image string) ([]dockertypes.AuthConfig, bool) {
142
+		auth, ok := o.Keyring.Lookup(image)
143
+		if !ok {
144
+			return nil, false
145
+		}
146
+		var engineAuth []dockertypes.AuthConfig
147
+		for _, c := range auth {
148
+			engineAuth = append(engineAuth, c.AuthConfig)
149
+		}
150
+		return engineAuth, true
151
+	}
142 152
 	e.LogFn = func(format string, args ...interface{}) {
143 153
 		if glog.V(2) {
144 154
 			glog.Infof("Builder: "+format, args...)