Selaa lähdekoodia

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>
Sebastiaan van Stijn 1 vuosi sitten
vanhempi
commit
74d9850bb9
1 muutettua tiedostoa jossa 10 lisäystä ja 11 poistoa
  1. 10 11
      client/buildkit/buildkit.go

+ 10 - 11
client/buildkit/buildkit.go

@@ -10,19 +10,18 @@ import (
 
 // 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.
+// API provided by the daemon. These options can be passed to [bkclient.New].
 //
-// Example: bkclient.New(ctx, "", ClientOpts(c)...)
+// Example:
+//
+//	bkclient.New(ctx, "", ClientOpts(c)...)
 func ClientOpts(c client.CommonAPIClient) []bkclient.ClientOpt {
-	session := func(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error) {
-		return c.DialHijack(ctx, "/session", proto, meta)
-	}
-	grpc := func(ctx context.Context, _ string) (net.Conn, error) {
-		return c.DialHijack(ctx, "/grpc", "h2c", nil)
-	}
-
 	return []bkclient.ClientOpt{
-		bkclient.WithSessionDialer(session),
-		bkclient.WithContextDialer(grpc),
+		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)
+		}),
 	}
 }