Skip to content

Commit

Permalink
Also load untagged images.
Browse files Browse the repository at this point in the history
  • Loading branch information
n-g committed Feb 29, 2024
1 parent 608e59c commit f93683d
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
// backwards compat for docker driver only:
// this ensures the build results in a docker image.
opt.Exports = []client.ExportEntry{{Type: "image", Attrs: map[string]string{}}}
} else if nodeDriver.Features(ctx)[driver.DefaultLoadTagged] && len(opt.Tags) > 0 {
} else if nodeDriver.Features(ctx)[driver.DefaultLoad] {
opt.Exports = []client.ExportEntry{{Type: "docker", Attrs: map[string]string{}}}
}
}
Expand Down Expand Up @@ -504,7 +504,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
if noMobyDriver != nil && !noDefaultLoad() && noPrintFunc(opt) {
var noOutputTargets []string
for name, opt := range opt {
if noMobyDriver.Features(ctx)[driver.DefaultLoadTagged] && len(opt.Tags) > 0 {
if noMobyDriver.Features(ctx)[driver.DefaultLoad] {
continue
}

Expand Down
36 changes: 18 additions & 18 deletions driver/docker-container/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ type Driver struct {

// if you add fields, remember to update docs:
// https://github.com/docker/docs/blob/main/content/build/drivers/docker-container.md
netMode string
image string
memory opts.MemBytes
memorySwap opts.MemSwapBytes
cpuQuota int64
cpuPeriod int64
cpuShares int64
cpusetCpus string
cpusetMems string
cgroupParent string
restartPolicy container.RestartPolicy
env []string
defaultLoadTagged bool
netMode string
image string
memory opts.MemBytes
memorySwap opts.MemSwapBytes
cpuQuota int64
cpuPeriod int64
cpuShares int64
cpusetCpus string
cpusetMems string
cgroupParent string
restartPolicy container.RestartPolicy
env []string
defaultLoad bool
}

func (d *Driver) IsMobyDriver() bool {
Expand Down Expand Up @@ -427,11 +427,11 @@ func (d *Driver) Factory() driver.Factory {

func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
return map[driver.Feature]bool{
driver.OCIExporter: true,
driver.DockerExporter: true,
driver.CacheExport: true,
driver.MultiPlatform: true,
driver.DefaultLoadTagged: d.defaultLoadTagged,
driver.OCIExporter: true,
driver.DockerExporter: true,
driver.CacheExport: true,
driver.MultiPlatform: true,
driver.DefaultLoad: d.defaultLoad,
}
}

Expand Down
4 changes: 2 additions & 2 deletions driver/docker-container/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ func (f *factory) New(ctx context.Context, cfg driver.InitConfig) (driver.Driver
if err != nil {
return nil, err
}
case k == "default-load-tagged":
d.defaultLoadTagged, err = strconv.ParseBool(v)
case k == "default-load":
d.defaultLoad, err = strconv.ParseBool(v)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions driver/docker/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
c.Close()
}
d.features.list = map[driver.Feature]bool{
driver.OCIExporter: useContainerdSnapshotter,
driver.DockerExporter: useContainerdSnapshotter,
driver.CacheExport: useContainerdSnapshotter,
driver.MultiPlatform: useContainerdSnapshotter,
driver.DefaultLoadTagged: true,
driver.OCIExporter: useContainerdSnapshotter,
driver.DockerExporter: useContainerdSnapshotter,
driver.CacheExport: useContainerdSnapshotter,
driver.MultiPlatform: useContainerdSnapshotter,
driver.DefaultLoad: true,
}
})
return d.features.list
Expand Down
2 changes: 1 addition & 1 deletion driver/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ const DockerExporter Feature = "Docker exporter"
const CacheExport Feature = "Cache export"
const MultiPlatform Feature = "Multi-platform build"

const DefaultLoadTagged Feature = "Automatically load tagged images"
const DefaultLoad Feature = "Automatically load images"
28 changes: 14 additions & 14 deletions driver/kubernetes/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ type Driver struct {

// if you add fields, remember to update docs:
// https://github.com/docker/docs/blob/main/content/build/drivers/kubernetes.md
minReplicas int
deployment *appsv1.Deployment
configMaps []*corev1.ConfigMap
clientset *kubernetes.Clientset
deploymentClient clientappsv1.DeploymentInterface
podClient clientcorev1.PodInterface
configMapClient clientcorev1.ConfigMapInterface
podChooser podchooser.PodChooser
defaultLoadTagged bool
minReplicas int
deployment *appsv1.Deployment
configMaps []*corev1.ConfigMap
clientset *kubernetes.Clientset
deploymentClient clientappsv1.DeploymentInterface
podClient clientcorev1.PodInterface
configMapClient clientcorev1.ConfigMapInterface
podChooser podchooser.PodChooser
defaultLoad bool
}

func (d *Driver) IsMobyDriver() bool {
Expand Down Expand Up @@ -234,11 +234,11 @@ func (d *Driver) Factory() driver.Factory {

func (d *Driver) Features(_ context.Context) map[driver.Feature]bool {
return map[driver.Feature]bool{
driver.OCIExporter: true,
driver.DockerExporter: d.DockerAPI != nil,
driver.CacheExport: true,
driver.MultiPlatform: true, // Untested (needs multiple Driver instances)
driver.DefaultLoadTagged: d.defaultLoadTagged,
driver.OCIExporter: true,
driver.DockerExporter: d.DockerAPI != nil,
driver.CacheExport: true,
driver.MultiPlatform: true, // Untested (needs multiple Driver instances)
driver.DefaultLoad: d.defaultLoad,
}
}

Expand Down
12 changes: 6 additions & 6 deletions driver/kubernetes/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ func (f *factory) New(ctx context.Context, cfg driver.InitConfig) (driver.Driver
clientset: clientset,
}

deploymentOpt, loadbalance, namespace, defaultLoadTagged, err := f.processDriverOpts(deploymentName, namespace, cfg)
deploymentOpt, loadbalance, namespace, defaultLoad, err := f.processDriverOpts(deploymentName, namespace, cfg)
if nil != err {
return nil, err
}

d.defaultLoadTagged = defaultLoadTagged
d.defaultLoad = defaultLoad

d.deployment, d.configMaps, err = manifest.NewDeployment(deploymentOpt)
if err != nil {
Expand Down Expand Up @@ -113,7 +113,7 @@ func (f *factory) processDriverOpts(deploymentName string, namespace string, cfg
ConfigFiles: cfg.Files,
}

defaultLoadTagged := false
defaultLoad := false

deploymentOpt.Qemu.Image = bkimage.QemuImage

Expand Down Expand Up @@ -218,8 +218,8 @@ func (f *factory) processDriverOpts(deploymentName string, namespace string, cfg
if v != "" {
deploymentOpt.Qemu.Image = v
}
case "default-load-tagged":
defaultLoadTagged, err = strconv.ParseBool(v)
case "default-load":
defaultLoad, err = strconv.ParseBool(v)
if err != nil {
return nil, "", "", false, err
}
Expand All @@ -228,7 +228,7 @@ func (f *factory) processDriverOpts(deploymentName string, namespace string, cfg
}
}

return deploymentOpt, loadbalance, namespace, defaultLoadTagged, nil
return deploymentOpt, loadbalance, namespace, defaultLoad, nil
}

func splitMultiValues(in string, itemsep string, kvsep string) (map[string]string, error) {
Expand Down
12 changes: 6 additions & 6 deletions driver/remote/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Driver struct {
// if you add fields, remember to update docs:
// https://github.com/docker/docs/blob/main/content/build/drivers/remote.md
*tlsOpts
defaultLoadTagged bool
defaultLoad bool
}

type tlsOpts struct {
Expand Down Expand Up @@ -146,11 +146,11 @@ func loadTLS(opts *tlsOpts) (*tls.Config, error) {

func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
return map[driver.Feature]bool{
driver.OCIExporter: true,
driver.DockerExporter: true,
driver.CacheExport: true,
driver.MultiPlatform: true,
driver.DefaultLoadTagged: d.defaultLoadTagged,
driver.OCIExporter: true,
driver.DockerExporter: true,
driver.CacheExport: true,
driver.MultiPlatform: true,
driver.DefaultLoad: d.defaultLoad,
}
}

Expand Down
4 changes: 2 additions & 2 deletions driver/remote/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ func (f *factory) New(ctx context.Context, cfg driver.InitConfig) (driver.Driver
}
tls.key = v
tlsEnabled = true
case "default-load-tagged":
case "default-load":
parsed, err := strconv.ParseBool(v)
if err != nil {
return nil, err
}
d.defaultLoadTagged = parsed
d.defaultLoad = parsed
default:
return nil, errors.Errorf("invalid driver option %s for remote driver", k)
}
Expand Down

0 comments on commit f93683d

Please sign in to comment.