mirror of https://github.com/docker/buildx.git
driver: refactor GetDriver func to take init config
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
3005743f7c
commit
4304d388ef
|
@ -148,8 +148,19 @@ func (b *Builder) LoadNodes(ctx context.Context, opts ...LoadNodesOption) (_ []N
|
||||||
kcc = kccInCluster
|
kcc = kccInCluster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
d, err := driver.GetDriver(ctx, factory, driver.InitConfig{
|
||||||
d, err := driver.GetDriver(ctx, driver.BuilderName(n.Name), factory, n.Endpoint, dockerapi, imageopt.Auth, kcc, n.BuildkitdFlags, n.Files, n.DriverOpts, n.Platforms, b.opts.contextPathHash, lno.dialMeta)
|
Name: driver.BuilderName(n.Name),
|
||||||
|
EndpointAddr: n.Endpoint,
|
||||||
|
DockerAPI: dockerapi,
|
||||||
|
KubeClientConfig: kcc,
|
||||||
|
BuildkitdFlags: n.BuildkitdFlags,
|
||||||
|
Files: n.Files,
|
||||||
|
DriverOpts: n.DriverOpts,
|
||||||
|
Auth: imageopt.Auth,
|
||||||
|
Platforms: n.Platforms,
|
||||||
|
ContextPathHash: b.opts.contextPathHash,
|
||||||
|
DialMeta: lno.dialMeta,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
node.Err = err
|
node.Err = err
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (k KubeClientConfigInCluster) Namespace() (string, bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type InitConfig struct {
|
type InitConfig struct {
|
||||||
// This object needs updates to be generic for different drivers
|
// TODO: This object needs updates to be generic for different drivers
|
||||||
Name string
|
Name string
|
||||||
EndpointAddr string
|
EndpointAddr string
|
||||||
DockerAPI dockerclient.APIClient
|
DockerAPI dockerclient.APIClient
|
||||||
|
@ -104,28 +104,15 @@ func GetFactory(name string, instanceRequired bool) (Factory, error) {
|
||||||
return nil, errors.Errorf("failed to find driver %q", name)
|
return nil, errors.Errorf("failed to find driver %q", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDriver(ctx context.Context, name string, f Factory, endpointAddr string, api dockerclient.APIClient, auth Auth, kcc KubeClientConfig, buildkitdFlags []string, files map[string][]byte, do map[string]string, platforms []specs.Platform, contextPathHash string, dialMeta map[string][]string) (*DriverHandle, error) {
|
func GetDriver(ctx context.Context, f Factory, cfg InitConfig) (*DriverHandle, error) {
|
||||||
ic := InitConfig{
|
|
||||||
EndpointAddr: endpointAddr,
|
|
||||||
DockerAPI: api,
|
|
||||||
KubeClientConfig: kcc,
|
|
||||||
Name: name,
|
|
||||||
BuildkitdFlags: buildkitdFlags,
|
|
||||||
DriverOpts: do,
|
|
||||||
Auth: auth,
|
|
||||||
Platforms: platforms,
|
|
||||||
ContextPathHash: contextPathHash,
|
|
||||||
DialMeta: dialMeta,
|
|
||||||
Files: files,
|
|
||||||
}
|
|
||||||
if f == nil {
|
if f == nil {
|
||||||
var err error
|
var err error
|
||||||
f, err = GetDefaultFactory(ctx, endpointAddr, api, false, dialMeta)
|
f, err = GetDefaultFactory(ctx, cfg.EndpointAddr, cfg.DockerAPI, false, cfg.DialMeta)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d, err := f.New(ctx, ic)
|
d, err := f.New(ctx, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue