moby/client/buildkit/buildkit.go
Sebastiaan van Stijn 74d9850bb9
client/buildkit: ClientOpts: update docs to use doc-links, and inline
inline the closures, and update the GoDoc to use doc-links to the related
buildkit function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-01 16:19:36 +02:00

27 lines
827 B
Go

package buildkit
import (
"context"
"net"
"github.com/docker/docker/client"
bkclient "github.com/moby/buildkit/client"
)
// ClientOpts returns a list of buildkit client options which allows the
// caller to create a buildkit client which will connect to the buildkit
// API provided by the daemon. These options can be passed to [bkclient.New].
//
// Example:
//
// bkclient.New(ctx, "", ClientOpts(c)...)
func ClientOpts(c client.CommonAPIClient) []bkclient.ClientOpt {
return []bkclient.ClientOpt{
bkclient.WithSessionDialer(func(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error) {
return c.DialHijack(ctx, "/session", proto, meta)
}),
bkclient.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) {
return c.DialHijack(ctx, "/grpc", "h2c", nil)
}),
}
}