MCPcopy Index your code
hub / github.com/dagger/dagger / InstallClient

Method InstallClient

toolchains/engine-dev/main.go:272–316  ·  view source on GitHub ↗

Configure the given client container so that it can connect to the given engine service

(
	ctx context.Context,
	// The client container to configure
	client *dagger.Container,
	// The engine service to bind
	// +optional
	service *dagger.Service,
	// +optional
	version string,
)

Source from the content-addressed store, hash-verified

270
271// Configure the given client container so that it can connect to the given engine service
272func (dev *EngineDev) InstallClient(
273 ctx context.Context,
274 // The client container to configure
275 client *dagger.Container,
276 // The engine service to bind
277 // +optional
278 service *dagger.Service,
279 // +optional
280 version string,
281) (*dagger.Container, error) {
282 if service == nil {
283 var err error
284 service, err = dev.Service(
285 ctx,
286 "", // name
287 false, // gpuSupport
288 false, // sharedCache
289 false, // metrics
290 version,
291 )
292 if err != nil {
293 return nil, err
294 }
295 }
296 cliPath := "/.dagger-cli"
297 endpoint, err := service.Endpoint(ctx, dagger.ServiceEndpointOpts{Port: 1234, Scheme: "tcp"})
298 if err != nil {
299 return nil, err
300 }
301 client = client.
302 WithServiceBinding("dagger-engine", service).
303 // FIXME: retrieve endpoint dynamically?
304 WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpoint).
305 WithMountedFile(cliPath, dag.DaggerCli(dagger.DaggerCliOpts{Version: version}).Binary()).
306 WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliPath).
307 WithSymlink(cliPath, "/usr/local/bin/dagger")
308 if cfg := dev.ClientDockerConfig; cfg != nil {
309 client = client.WithMountedSecret(
310 "${HOME}/.docker/config.json",
311 cfg,
312 dagger.ContainerWithMountedSecretOpts{Expand: true},
313 )
314 }
315 return client, nil
316}
317
318// Introspect the engine API schema, and return it as a json-encoded file.
319// This file is used by SDKs to generate clients.

Callers 3

testContainerMethod · 0.95
PlaygroundMethod · 0.95
invokeFunction · 0.45

Calls 9

ServiceMethod · 0.95
EndpointMethod · 0.45
WithSymlinkMethod · 0.45
WithEnvVariableMethod · 0.45
WithMountedFileMethod · 0.45
WithServiceBindingMethod · 0.45
BinaryMethod · 0.45
DaggerCliMethod · 0.45
WithMountedSecretMethod · 0.45

Tested by

no test coverage detected