Update to BuildKit 0.12
* Supersedes https://github.com/moby/moby/pull/44530
* Supersedes https://github.com/moby/moby/pull/46035

**- What I did**
Update containerd (library) to v1.7 and BuildKit to v0.12.

Make changes to the code to adjust to the new dependency versions, and fix some TODOs that were waiting on these updates. Leave some new TODOs as well, mostly related to the builder-next code and having to re-implement some things instead of re-using them from BuildKit.

**- How I did it**
With help from my IDE, and with assistance from others (@tonistiigi, @crazy-max, @rumpl) where I ran out of skill and/or time.

**- How to verify it**
CI ✅ 

**- Description for the changelog**
* Update buildkit to `v0.12.2`.
* Update containerd to `v1.7.6`.

**- A picture of a cute animal (not mandatory but encouraged)**
![](https://cdn.discordapp.com/attachments/1132712576812318750/1139648380230975508/20230811_215535.jpg)

builder/builder-next/exporter/overrides/wrapper.go
package overrides

import (
	"context"
	"strings"

	"github.com/moby/buildkit/exporter"
)

// TODO(vvoland): Use buildkit consts once they're public
// https://github.com/moby/buildkit/pull/3694
const (
	keyImageName      = "name"
	keyUnpack         = "unpack"
	keyDanglingPrefix = "dangling-name-prefix"
)

// Wraps the containerimage exporter's Resolve method to apply moby-specific
// overrides to the exporter attributes.
type imageExporterMobyWrapper struct {
	exp exporter.Exporter
}

func NewExporterWrapper(exp exporter.Exporter) (exporter.Exporter, error) {
	return &imageExporterMobyWrapper{exp: exp}, nil
}

// Resolve applies moby specific attributes to the request.
func (e *imageExporterMobyWrapper) Resolve(ctx context.Context, exporterAttrs map[string]string) (exporter.ExporterInstance, error) {
	if exporterAttrs == nil {
		exporterAttrs = make(map[string]string)
	}
	reposAndTags, err := SanitizeRepoAndTags(strings.Split(exporterAttrs[keyImageName], ","))
	if err != nil {
		return nil, err
	}
	exporterAttrs[keyImageName] = strings.Join(reposAndTags, ",")
	exporterAttrs[keyUnpack] = "true"
	if _, has := exporterAttrs[keyDanglingPrefix]; !has {
		exporterAttrs[keyDanglingPrefix] = "moby-dangling"
	}

	return e.exp.Resolve(ctx, exporterAttrs)
}

package overrides

import (
	"context"
	"strings"

	"github.com/moby/buildkit/exporter"
	"github.com/moby/buildkit/exporter/containerimage/exptypes"
)

// Wraps the containerimage exporter's Resolve method to apply moby-specific
// overrides to the exporter attributes.
type imageExporterMobyWrapper struct {
	exp exporter.Exporter
}

func NewExporterWrapper(exp exporter.Exporter) (exporter.Exporter, error) {
	return &imageExporterMobyWrapper{exp: exp}, nil
}

// Resolve applies moby specific attributes to the request.
func (e *imageExporterMobyWrapper) Resolve(ctx context.Context, exporterAttrs map[string]string) (exporter.ExporterInstance, error) {
	if exporterAttrs == nil {
		exporterAttrs = make(map[string]string)
	}
	reposAndTags, err := SanitizeRepoAndTags(strings.Split(exporterAttrs[string(exptypes.OptKeyName)], ","))
	if err != nil {
		return nil, err
	}
	exporterAttrs[string(exptypes.OptKeyName)] = strings.Join(reposAndTags, ",")
	exporterAttrs[string(exptypes.OptKeyUnpack)] = "true"
	if _, has := exporterAttrs[string(exptypes.OptKeyDanglingPrefix)]; !has {
		exporterAttrs[string(exptypes.OptKeyDanglingPrefix)] = "moby-dangling"
	}

	return e.exp.Resolve(ctx, exporterAttrs)
}

Right, my thought (and specific inexperience) is that maybe we can change the protobuf definition to use the newtype, and existing clients with the old generated code will continue to interoperate as it's just a type alias to string. That breaks the Go API a little; but in theory the protobuf is the stable component and the generated Go code can change (ala containerd v1.7).