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, )
| 270 | |
| 271 | // Configure the given client container so that it can connect to the given engine service |
| 272 | func (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. |
no test coverage detected