@dagger.io/dagger 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,6 +53,20 @@ export var CacheSharingMode;
53
53
  */
54
54
  CacheSharingMode[CacheSharingMode["Shared"] = 2] = "Shared";
55
55
  })(CacheSharingMode || (CacheSharingMode = {}));
56
+ /**
57
+ * Transport layer network protocol associated to a port.
58
+ */
59
+ export var NetworkProtocol;
60
+ (function (NetworkProtocol) {
61
+ /**
62
+ * TCP (Transmission Control Protocol)
63
+ */
64
+ NetworkProtocol[NetworkProtocol["Tcp"] = 0] = "Tcp";
65
+ /**
66
+ * UDP (User Datagram Protocol)
67
+ */
68
+ NetworkProtocol[NetworkProtocol["Udp"] = 1] = "Udp";
69
+ })(NetworkProtocol || (NetworkProtocol = {}));
56
70
  /**
57
71
  * A directory whose contents persist across runs.
58
72
  */
@@ -98,10 +112,11 @@ export class CacheVolume extends BaseClient {
98
112
  */
99
113
  export class Container extends BaseClient {
100
114
  /**
101
- * Initializes this container from a Dockerfile build, using the context, a dockerfile file path and some additional buildArgs.
115
+ * Initializes this container from a Dockerfile build.
102
116
  * @param context Directory context used by the Dockerfile.
103
117
  * @param opts.dockerfile Path to the Dockerfile to use.
104
- Defaults to './Dockerfile'.
118
+ *
119
+ * Default: './Dockerfile'.
105
120
  * @param opts.buildArgs Additional build arguments.
106
121
  * @param opts.target Target build stage to build.
107
122
  */
@@ -133,7 +148,10 @@ export class Container extends BaseClient {
133
148
  });
134
149
  }
135
150
  /**
136
- * Retrieves a directory at the given path. Mounts are included.
151
+ * Retrieves a directory at the given path.
152
+ *
153
+ * Mounts are included.
154
+ * @param path The path of the directory to retrieve (e.g., "./src").
137
155
  */
138
156
  directory(path) {
139
157
  return new Directory({
@@ -148,6 +166,29 @@ export class Container extends BaseClient {
148
166
  sessionToken: this.sessionToken,
149
167
  });
150
168
  }
169
+ /**
170
+ * Retrieves an endpoint that clients can use to reach this container.
171
+ *
172
+ * If no port is specified, the first exposed port is used. If none exist an error is returned.
173
+ *
174
+ * If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
175
+ *
176
+ * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
177
+ * @param opts.port The exposed port number for the endpoint
178
+ * @param opts.scheme Return a URL with the given scheme, eg. http for http://
179
+ */
180
+ endpoint(opts) {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
+ const response = yield computeQuery([
183
+ ...this._queryTree,
184
+ {
185
+ operation: "endpoint",
186
+ args: Object.assign({}, opts),
187
+ },
188
+ ], this.client);
189
+ return response;
190
+ });
191
+ }
151
192
  /**
152
193
  * Retrieves entrypoint to be prepended to the arguments of all commands.
153
194
  */
@@ -164,6 +205,7 @@ export class Container extends BaseClient {
164
205
  }
165
206
  /**
166
207
  * Retrieves the value of the specified environment variable.
208
+ * @param name The name of the environment variable to retrieve (e.g., "PATH").
167
209
  */
168
210
  envVariable(name) {
169
211
  return __awaiter(this, void 0, void 0, function* () {
@@ -193,13 +235,13 @@ export class Container extends BaseClient {
193
235
  }
194
236
  /**
195
237
  * Retrieves this container after executing the specified command inside it.
196
- * @param opts.args Command to run instead of the container's default command.
197
- * @param opts.stdin Content to write to the command's standard input before closing.
198
- * @param opts.redirectStdout Redirect the command's standard output to a file in the container.
199
- * @param opts.redirectStderr Redirect the command's standard error to a file in the container.
238
+ * @param opts.args Command to run instead of the container's default command (e.g., ["run", "main.go"]).
239
+ * @param opts.stdin Content to write to the command's standard input before closing (e.g., "Hello world").
240
+ * @param opts.redirectStdout Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
241
+ * @param opts.redirectStderr Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
200
242
  * @param opts.experimentalPrivilegedNesting Provide dagger access to the executed command.
201
- Do not use this option unless you trust the command being executed.
202
- The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
243
+ * Do not use this option unless you trust the command being executed.
244
+ * The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
203
245
  * @deprecated Replaced by withExec.
204
246
  */
205
247
  exec(opts) {
@@ -217,7 +259,7 @@ export class Container extends BaseClient {
217
259
  }
218
260
  /**
219
261
  * Exit code of the last executed command. Zero means success.
220
- * Null if no command has been executed.
262
+ * Errors if no command has been executed.
221
263
  */
222
264
  exitCode() {
223
265
  return __awaiter(this, void 0, void 0, function* () {
@@ -231,12 +273,14 @@ export class Container extends BaseClient {
231
273
  });
232
274
  }
233
275
  /**
234
- * Writes the container as an OCI tarball to the destination file path on the host for the specified platformVariants.
276
+ * Writes the container as an OCI tarball to the destination file path on the host for the specified platform variants.
277
+ *
235
278
  * Return true on success.
236
- * @param path Host's destination path.
237
- Path can be relative to the engine's workdir or absolute.
279
+ * It can also publishes platform variants.
280
+ * @param path Host's destination path (e.g., "./tarball").
281
+ * Path can be relative to the engine's workdir or absolute.
238
282
  * @param opts.platformVariants Identifiers for other platform specific containers.
239
- Used for multi-platform image.
283
+ * Used for multi-platform image.
240
284
  */
241
285
  export(path, opts) {
242
286
  return __awaiter(this, void 0, void 0, function* () {
@@ -251,7 +295,26 @@ export class Container extends BaseClient {
251
295
  });
252
296
  }
253
297
  /**
254
- * Retrieves a file at the given path. Mounts are included.
298
+ * Retrieves the list of exposed ports.
299
+ *
300
+ * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
301
+ */
302
+ exposedPorts() {
303
+ return __awaiter(this, void 0, void 0, function* () {
304
+ const response = yield computeQuery([
305
+ ...this._queryTree,
306
+ {
307
+ operation: "exposedPorts",
308
+ },
309
+ ], this.client);
310
+ return response;
311
+ });
312
+ }
313
+ /**
314
+ * Retrieves a file at the given path.
315
+ *
316
+ * Mounts are included.
317
+ * @param path The path of the file to retrieve (e.g., "./README.md").
255
318
  */
256
319
  file(path) {
257
320
  return new File({
@@ -267,9 +330,10 @@ export class Container extends BaseClient {
267
330
  });
268
331
  }
269
332
  /**
270
- * Initializes this container from the base image published at the given address.
333
+ * Initializes this container from a pulled base image.
271
334
  * @param address Image's address from its registry.
272
- Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
335
+ *
336
+ * Formatted as [host]/[user]/[repo]:[tag] (e.g., "docker.io/dagger/dagger:main").
273
337
  */
274
338
  from(address) {
275
339
  return new Container({
@@ -300,6 +364,22 @@ export class Container extends BaseClient {
300
364
  sessionToken: this.sessionToken,
301
365
  });
302
366
  }
367
+ /**
368
+ * Retrieves a hostname which can be used by clients to reach this container.
369
+ *
370
+ * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
371
+ */
372
+ hostname() {
373
+ return __awaiter(this, void 0, void 0, function* () {
374
+ const response = yield computeQuery([
375
+ ...this._queryTree,
376
+ {
377
+ operation: "hostname",
378
+ },
379
+ ], this.client);
380
+ return response;
381
+ });
382
+ }
303
383
  /**
304
384
  * A unique identifier for this container.
305
385
  */
@@ -314,6 +394,20 @@ export class Container extends BaseClient {
314
394
  return response;
315
395
  });
316
396
  }
397
+ /**
398
+ * The unique image reference which can only be retrieved immediately after the 'Container.From' call.
399
+ */
400
+ imageRef() {
401
+ return __awaiter(this, void 0, void 0, function* () {
402
+ const response = yield computeQuery([
403
+ ...this._queryTree,
404
+ {
405
+ operation: "imageRef",
406
+ },
407
+ ], this.client);
408
+ return response;
409
+ });
410
+ }
317
411
  /**
318
412
  * Retrieves the value of the specified label.
319
413
  */
@@ -359,6 +453,9 @@ export class Container extends BaseClient {
359
453
  }
360
454
  /**
361
455
  * Creates a named sub-pipeline
456
+ * @param name Pipeline name.
457
+ * @param opts.description Pipeline description.
458
+ * @param opts.labels Pipeline labels.
362
459
  */
363
460
  pipeline(name, opts) {
364
461
  return new Container({
@@ -388,11 +485,15 @@ export class Container extends BaseClient {
388
485
  });
389
486
  }
390
487
  /**
391
- * Publishes this container as a new image to the specified address, for the platformVariants, returning a fully qualified ref.
488
+ * Publishes this container as a new image to the specified address.
489
+ *
490
+ * Publish returns a fully qualified ref.
491
+ * It can also publish platform variants.
392
492
  * @param address Registry's address to publish the image to.
393
- Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
493
+ *
494
+ * Formatted as [host]/[user]/[repo]:[tag] (e.g. "docker.io/dagger/dagger:main").
394
495
  * @param opts.platformVariants Identifiers for other platform specific containers.
395
- Used for multi-platform image.
496
+ * Used for multi-platform image.
396
497
  */
397
498
  publish(address, opts) {
398
499
  return __awaiter(this, void 0, void 0, function* () {
@@ -423,7 +524,7 @@ export class Container extends BaseClient {
423
524
  }
424
525
  /**
425
526
  * The error stream of the last executed command.
426
- * Null if no command has been executed.
527
+ * Errors if no command has been executed.
427
528
  */
428
529
  stderr() {
429
530
  return __awaiter(this, void 0, void 0, function* () {
@@ -438,7 +539,7 @@ export class Container extends BaseClient {
438
539
  }
439
540
  /**
440
541
  * The output stream of the last executed command.
441
- * Null if no command has been executed.
542
+ * Errors if no command has been executed.
442
543
  */
443
544
  stdout() {
444
545
  return __awaiter(this, void 0, void 0, function* () {
@@ -467,6 +568,7 @@ export class Container extends BaseClient {
467
568
  }
468
569
  /**
469
570
  * Configures default arguments for future commands.
571
+ * @param opts.args Arguments to prepend to future executions (e.g., ["-v", "--no-cache"]).
470
572
  */
471
573
  withDefaultArgs(opts) {
472
574
  return new Container({
@@ -483,6 +585,10 @@ export class Container extends BaseClient {
483
585
  }
484
586
  /**
485
587
  * Retrieves this container plus a directory written at the given path.
588
+ * @param path Location of the written directory (e.g., "/tmp/directory").
589
+ * @param directory Identifier of the directory to write
590
+ * @param opts.exclude Patterns to exclude in the written directory (e.g., ["node_modules/**", ".gitignore", ".git/"]).
591
+ * @param opts.include Patterns to include in the written directory (e.g., ["*.go", "go.mod", "go.sum"]).
486
592
  */
487
593
  withDirectory(path, directory, opts) {
488
594
  return new Container({
@@ -499,6 +605,7 @@ export class Container extends BaseClient {
499
605
  }
500
606
  /**
501
607
  * Retrieves this container but with a different command entrypoint.
608
+ * @param args Entrypoint to use for future executions (e.g., ["go", "run"]).
502
609
  */
503
610
  withEntrypoint(args) {
504
611
  return new Container({
@@ -515,6 +622,8 @@ export class Container extends BaseClient {
515
622
  }
516
623
  /**
517
624
  * Retrieves this container plus the given environment variable.
625
+ * @param name The name of the environment variable (e.g., "HOST").
626
+ * @param value The value of the environment variable. (e.g., "localhost").
518
627
  */
519
628
  withEnvVariable(name, value) {
520
629
  return new Container({
@@ -531,13 +640,18 @@ export class Container extends BaseClient {
531
640
  }
532
641
  /**
533
642
  * Retrieves this container after executing the specified command inside it.
534
- * @param args Command to run instead of the container's default command.
535
- * @param opts.stdin Content to write to the command's standard input before closing.
536
- * @param opts.redirectStdout Redirect the command's standard output to a file in the container.
537
- * @param opts.redirectStderr Redirect the command's standard error to a file in the container.
538
- * @param opts.experimentalPrivilegedNesting Provide dagger access to the executed command.
539
- Do not use this option unless you trust the command being executed.
540
- The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
643
+ * @param args Command to run instead of the container's default command (e.g., ["run", "main.go"]).
644
+ * @param opts.stdin Content to write to the command's standard input before closing (e.g., "Hello world").
645
+ * @param opts.redirectStdout Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
646
+ * @param opts.redirectStderr Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
647
+ * @param opts.experimentalPrivilegedNesting Provides dagger access to the executed command.
648
+ *
649
+ * Do not use this option unless you trust the command being executed.
650
+ * The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
651
+ * @param opts.insecureRootCapabilities Execute the command with all root capabilities. This is similar to running a command
652
+ * with "sudo" or executing `docker run` with the `--privileged` flag. Containerization
653
+ * does not provide any security guarantees when using this option. It should only be used
654
+ * when absolutely necessary and only with trusted commands.
541
655
  */
542
656
  withExec(args, opts) {
543
657
  return new Container({
@@ -552,6 +666,31 @@ export class Container extends BaseClient {
552
666
  sessionToken: this.sessionToken,
553
667
  });
554
668
  }
669
+ /**
670
+ * Expose a network port.
671
+ *
672
+ * Exposed ports serve two purposes:
673
+ * - For health checks and introspection, when running services
674
+ * - For setting the EXPOSE OCI field when publishing the container
675
+ *
676
+ * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
677
+ * @param port Port number to expose
678
+ * @param opts.protocol Transport layer network protocol
679
+ * @param opts.description Optional port description
680
+ */
681
+ withExposedPort(port, opts) {
682
+ return new Container({
683
+ queryTree: [
684
+ ...this._queryTree,
685
+ {
686
+ operation: "withExposedPort",
687
+ args: Object.assign({ port }, opts),
688
+ },
689
+ ],
690
+ host: this.clientHost,
691
+ sessionToken: this.sessionToken,
692
+ });
693
+ }
555
694
  /**
556
695
  * Initializes this container from this DirectoryID.
557
696
  * @deprecated Replaced by withRootfs.
@@ -571,6 +710,11 @@ export class Container extends BaseClient {
571
710
  }
572
711
  /**
573
712
  * Retrieves this container plus the contents of the given file copied to the given path.
713
+ * @param path Location of the copied file (e.g., "/tmp/file.txt").
714
+ * @param source Identifier of the file to copy.
715
+ * @param opts.permissions Permission given to the copied file (e.g., 0600).
716
+ *
717
+ * Default: 0644.
574
718
  */
575
719
  withFile(path, source, opts) {
576
720
  return new Container({
@@ -587,6 +731,8 @@ export class Container extends BaseClient {
587
731
  }
588
732
  /**
589
733
  * Retrieves this container plus the given label.
734
+ * @param name The name of the label (e.g., "org.opencontainers.artifact.created").
735
+ * @param value The value of the label (e.g., "2023-01-01T00:00:00Z").
590
736
  */
591
737
  withLabel(name, value) {
592
738
  return new Container({
@@ -603,9 +749,9 @@ export class Container extends BaseClient {
603
749
  }
604
750
  /**
605
751
  * Retrieves this container plus a cache volume mounted at the given path.
606
- * @param path Path to mount the cache volume at.
607
- * @param cache ID of the cache to mount.
608
- * @param opts.source Directory to use as the cache volume's root.
752
+ * @param path Location of the cache directory (e.g., "/cache/node_modules").
753
+ * @param cache Identifier of the cache volume to mount.
754
+ * @param opts.source Identifier of the directory to use as the cache volume's root.
609
755
  * @param opts.sharing Sharing mode of the cache volume.
610
756
  */
611
757
  withMountedCache(path, cache, opts) {
@@ -623,6 +769,8 @@ export class Container extends BaseClient {
623
769
  }
624
770
  /**
625
771
  * Retrieves this container plus a directory mounted at the given path.
772
+ * @param path Location of the mounted directory (e.g., "/mnt/directory").
773
+ * @param source Identifier of the mounted directory.
626
774
  */
627
775
  withMountedDirectory(path, source) {
628
776
  return new Container({
@@ -639,6 +787,8 @@ export class Container extends BaseClient {
639
787
  }
640
788
  /**
641
789
  * Retrieves this container plus a file mounted at the given path.
790
+ * @param path Location of the mounted file (e.g., "/tmp/file.txt").
791
+ * @param source Identifier of the mounted file.
642
792
  */
643
793
  withMountedFile(path, source) {
644
794
  return new Container({
@@ -655,6 +805,8 @@ export class Container extends BaseClient {
655
805
  }
656
806
  /**
657
807
  * Retrieves this container plus a secret mounted into a file at the given path.
808
+ * @param path Location of the secret file (e.g., "/tmp/secret.txt").
809
+ * @param source Identifier of the secret to mount.
658
810
  */
659
811
  withMountedSecret(path, source) {
660
812
  return new Container({
@@ -671,6 +823,7 @@ export class Container extends BaseClient {
671
823
  }
672
824
  /**
673
825
  * Retrieves this container plus a temporary directory mounted at the given path.
826
+ * @param path Location of the temporary directory (e.g., "/tmp/temp_dir").
674
827
  */
675
828
  withMountedTemp(path) {
676
829
  return new Container({
@@ -687,6 +840,11 @@ export class Container extends BaseClient {
687
840
  }
688
841
  /**
689
842
  * Retrieves this container plus a new file written at the given path.
843
+ * @param path Location of the written file (e.g., "/tmp/file.txt").
844
+ * @param opts.contents Content of the file to write (e.g., "Hello world!").
845
+ * @param opts.permissions Permission given to the written file (e.g., 0600).
846
+ *
847
+ * Default: 0644.
690
848
  */
691
849
  withNewFile(path, opts) {
692
850
  return new Container({
@@ -704,7 +862,7 @@ export class Container extends BaseClient {
704
862
  /**
705
863
  * Retrieves this container with a registry authentication for a given address.
706
864
  * @param address Registry's address to bind the authentication to.
707
- Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
865
+ * Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
708
866
  * @param username The username of the registry's account (e.g., "Dagger").
709
867
  * @param secret The API key, password or token to authenticate to this registry.
710
868
  */
@@ -739,6 +897,8 @@ export class Container extends BaseClient {
739
897
  }
740
898
  /**
741
899
  * Retrieves this container plus an env variable containing the given secret.
900
+ * @param name The name of the secret variable (e.g., "API_SECRET").
901
+ * @param secret The identifier of the secret value.
742
902
  */
743
903
  withSecretVariable(name, secret) {
744
904
  return new Container({
@@ -753,8 +913,34 @@ export class Container extends BaseClient {
753
913
  sessionToken: this.sessionToken,
754
914
  });
755
915
  }
916
+ /**
917
+ * Establish a runtime dependency on a service. The service will be started automatically when needed and detached when it is no longer needed.
918
+ *
919
+ * The service will be reachable from the container via the provided hostname alias.
920
+ *
921
+ * The service dependency will also convey to any files or directories produced by the container.
922
+ *
923
+ * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
924
+ * @param alias A name that can be used to reach the service from the container
925
+ * @param service Identifier of the service container
926
+ */
927
+ withServiceBinding(alias, service) {
928
+ return new Container({
929
+ queryTree: [
930
+ ...this._queryTree,
931
+ {
932
+ operation: "withServiceBinding",
933
+ args: { alias, service },
934
+ },
935
+ ],
936
+ host: this.clientHost,
937
+ sessionToken: this.sessionToken,
938
+ });
939
+ }
756
940
  /**
757
941
  * Retrieves this container plus a socket forwarded to the given Unix socket path.
942
+ * @param path Location of the forwarded Unix socket (e.g., "/tmp/socket").
943
+ * @param source Identifier of the socket to forward.
758
944
  */
759
945
  withUnixSocket(path, source) {
760
946
  return new Container({
@@ -770,7 +956,8 @@ export class Container extends BaseClient {
770
956
  });
771
957
  }
772
958
  /**
773
- * Retrieves this containers with a different command user.
959
+ * Retrieves this container with a different command user.
960
+ * @param name The user to set (e.g., "root").
774
961
  */
775
962
  withUser(name) {
776
963
  return new Container({
@@ -787,6 +974,7 @@ export class Container extends BaseClient {
787
974
  }
788
975
  /**
789
976
  * Retrieves this container with a different working directory.
977
+ * @param path The path to set as the working directory (e.g., "/app").
790
978
  */
791
979
  withWorkdir(path) {
792
980
  return new Container({
@@ -803,6 +991,7 @@ export class Container extends BaseClient {
803
991
  }
804
992
  /**
805
993
  * Retrieves this container minus the given environment variable.
994
+ * @param name The name of the environment variable (e.g., "HOST").
806
995
  */
807
996
  withoutEnvVariable(name) {
808
997
  return new Container({
@@ -817,8 +1006,29 @@ export class Container extends BaseClient {
817
1006
  sessionToken: this.sessionToken,
818
1007
  });
819
1008
  }
1009
+ /**
1010
+ * Unexpose a previously exposed port.
1011
+ *
1012
+ * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
1013
+ * @param port Port number to unexpose
1014
+ * @param opts.protocol Port protocol to unexpose
1015
+ */
1016
+ withoutExposedPort(port, opts) {
1017
+ return new Container({
1018
+ queryTree: [
1019
+ ...this._queryTree,
1020
+ {
1021
+ operation: "withoutExposedPort",
1022
+ args: Object.assign({ port }, opts),
1023
+ },
1024
+ ],
1025
+ host: this.clientHost,
1026
+ sessionToken: this.sessionToken,
1027
+ });
1028
+ }
820
1029
  /**
821
1030
  * Retrieves this container minus the given environment label.
1031
+ * @param name The name of the label to remove (e.g., "org.opencontainers.artifact.created").
822
1032
  */
823
1033
  withoutLabel(name) {
824
1034
  return new Container({
@@ -835,6 +1045,7 @@ export class Container extends BaseClient {
835
1045
  }
836
1046
  /**
837
1047
  * Retrieves this container after unmounting everything at the given path.
1048
+ * @param path Location of the cache directory (e.g., "/cache/node_modules").
838
1049
  */
839
1050
  withoutMount(path) {
840
1051
  return new Container({
@@ -852,7 +1063,7 @@ export class Container extends BaseClient {
852
1063
  /**
853
1064
  * Retrieves this container without the registry authentication of a given address.
854
1065
  * @param address Registry's address to remove the authentication from.
855
- Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
1066
+ * Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
856
1067
  */
857
1068
  withoutRegistryAuth(address) {
858
1069
  return new Container({
@@ -869,6 +1080,7 @@ export class Container extends BaseClient {
869
1080
  }
870
1081
  /**
871
1082
  * Retrieves this container with a previously added Unix socket removed.
1083
+ * @param path Location of the socket to remove (e.g., "/tmp/socket").
872
1084
  */
873
1085
  withoutUnixSocket(path) {
874
1086
  return new Container({
@@ -928,6 +1140,7 @@ export class Container extends BaseClient {
928
1140
  export class Directory extends BaseClient {
929
1141
  /**
930
1142
  * Gets the difference between this directory and an another directory.
1143
+ * @param other Identifier of the directory to compare.
931
1144
  */
932
1145
  diff(other) {
933
1146
  return new Directory({
@@ -944,6 +1157,7 @@ export class Directory extends BaseClient {
944
1157
  }
945
1158
  /**
946
1159
  * Retrieves a directory at the given path.
1160
+ * @param path Location of the directory to retrieve (e.g., "/src").
947
1161
  */
948
1162
  directory(path) {
949
1163
  return new Directory({
@@ -960,10 +1174,11 @@ export class Directory extends BaseClient {
960
1174
  }
961
1175
  /**
962
1176
  * Builds a new Docker container from this directory.
963
- * @param opts.dockerfile Path to the Dockerfile to use.
964
- Defaults to './Dockerfile'.
1177
+ * @param opts.dockerfile Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
1178
+ *
1179
+ * Defaults: './Dockerfile'.
965
1180
  * @param opts.platform The platform to build.
966
- * @param opts.buildArgs Additional build arguments.
1181
+ * @param opts.buildArgs Build arguments to use in the build.
967
1182
  * @param opts.target Target build stage to build.
968
1183
  */
969
1184
  dockerBuild(opts) {
@@ -981,6 +1196,7 @@ export class Directory extends BaseClient {
981
1196
  }
982
1197
  /**
983
1198
  * Returns a list of files and directories at the given path.
1199
+ * @param opts.path Location of the directory to look at (e.g., "/src").
984
1200
  */
985
1201
  entries(opts) {
986
1202
  return __awaiter(this, void 0, void 0, function* () {
@@ -996,6 +1212,7 @@ export class Directory extends BaseClient {
996
1212
  }
997
1213
  /**
998
1214
  * Writes the contents of the directory to a path on the host.
1215
+ * @param path Location of the copied directory (e.g., "logs/").
999
1216
  */
1000
1217
  export(path) {
1001
1218
  return __awaiter(this, void 0, void 0, function* () {
@@ -1011,6 +1228,7 @@ export class Directory extends BaseClient {
1011
1228
  }
1012
1229
  /**
1013
1230
  * Retrieves a file at the given path.
1231
+ * @param path Location of the file to retrieve (e.g., "README.md").
1014
1232
  */
1015
1233
  file(path) {
1016
1234
  return new File({
@@ -1056,7 +1274,10 @@ export class Directory extends BaseClient {
1056
1274
  });
1057
1275
  }
1058
1276
  /**
1059
- * Creates a named sub-pipeline.
1277
+ * Creates a named sub-pipeline
1278
+ * @param name Pipeline name.
1279
+ * @param opts.description Pipeline description.
1280
+ * @param opts.labels Pipeline labels.
1060
1281
  */
1061
1282
  pipeline(name, opts) {
1062
1283
  return new Directory({
@@ -1073,10 +1294,10 @@ export class Directory extends BaseClient {
1073
1294
  }
1074
1295
  /**
1075
1296
  * Retrieves this directory plus a directory written at the given path.
1076
- * @param opts.exclude Exclude artifacts that match the given pattern.
1077
- (e.g. ["node_modules/", ".git*"]).
1078
- * @param opts.include Include only artifacts that match the given pattern.
1079
- (e.g. ["app/", "package.*"]).
1297
+ * @param path Location of the written directory (e.g., "/src/").
1298
+ * @param directory Identifier of the directory to copy.
1299
+ * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
1300
+ * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
1080
1301
  */
1081
1302
  withDirectory(path, directory, opts) {
1082
1303
  return new Directory({
@@ -1093,6 +1314,11 @@ export class Directory extends BaseClient {
1093
1314
  }
1094
1315
  /**
1095
1316
  * Retrieves this directory plus the contents of the given file copied to the given path.
1317
+ * @param path Location of the copied file (e.g., "/file.txt").
1318
+ * @param source Identifier of the file to copy.
1319
+ * @param opts.permissions Permission given to the copied file (e.g., 0600).
1320
+ *
1321
+ * Default: 0644.
1096
1322
  */
1097
1323
  withFile(path, source, opts) {
1098
1324
  return new Directory({
@@ -1109,6 +1335,10 @@ export class Directory extends BaseClient {
1109
1335
  }
1110
1336
  /**
1111
1337
  * Retrieves this directory plus a new directory created at the given path.
1338
+ * @param path Location of the directory created (e.g., "/logs").
1339
+ * @param opts.permissions Permission granted to the created directory (e.g., 0777).
1340
+ *
1341
+ * Default: 0755.
1112
1342
  */
1113
1343
  withNewDirectory(path, opts) {
1114
1344
  return new Directory({
@@ -1125,6 +1355,11 @@ export class Directory extends BaseClient {
1125
1355
  }
1126
1356
  /**
1127
1357
  * Retrieves this directory plus a new file written at the given path.
1358
+ * @param path Location of the written file (e.g., "/file.txt").
1359
+ * @param contents Content of the written file (e.g., "Hello world!").
1360
+ * @param opts.permissions Permission given to the copied file (e.g., 0600).
1361
+ *
1362
+ * Default: 0644.
1128
1363
  */
1129
1364
  withNewFile(path, contents, opts) {
1130
1365
  return new Directory({
@@ -1140,7 +1375,10 @@ export class Directory extends BaseClient {
1140
1375
  });
1141
1376
  }
1142
1377
  /**
1143
- * Retrieves this directory with all file/dir timestamps set to the given time, in seconds from the Unix epoch.
1378
+ * Retrieves this directory with all file/dir timestamps set to the given time.
1379
+ * @param timestamp Timestamp to set dir/files in.
1380
+ *
1381
+ * Formatted in seconds following Unix epoch (e.g., 1672531199).
1144
1382
  */
1145
1383
  withTimestamps(timestamp) {
1146
1384
  return new Directory({
@@ -1157,6 +1395,7 @@ export class Directory extends BaseClient {
1157
1395
  }
1158
1396
  /**
1159
1397
  * Retrieves this directory with the directory at the given path removed.
1398
+ * @param path Location of the directory to remove (e.g., ".github/").
1160
1399
  */
1161
1400
  withoutDirectory(path) {
1162
1401
  return new Directory({
@@ -1173,6 +1412,7 @@ export class Directory extends BaseClient {
1173
1412
  }
1174
1413
  /**
1175
1414
  * Retrieves this directory with the file at the given path removed.
1415
+ * @param path Location of the file to remove (e.g., "/file.txt").
1176
1416
  */
1177
1417
  withoutFile(path) {
1178
1418
  return new Directory({
@@ -1289,6 +1529,7 @@ export class File extends BaseClient {
1289
1529
  }
1290
1530
  /**
1291
1531
  * Writes the file to a file path on the host.
1532
+ * @param path Location of the written directory (e.g., "output.txt").
1292
1533
  */
1293
1534
  export(path) {
1294
1535
  return __awaiter(this, void 0, void 0, function* () {
@@ -1346,7 +1587,10 @@ export class File extends BaseClient {
1346
1587
  });
1347
1588
  }
1348
1589
  /**
1349
- * Retrieves this file with its created/modified timestamps set to the given time, in seconds from the Unix epoch.
1590
+ * Retrieves this file with its created/modified timestamps set to the given time.
1591
+ * @param timestamp Timestamp to set dir/files in.
1592
+ *
1593
+ * Formatted in seconds following Unix epoch (e.g., 1672531199).
1350
1594
  */
1351
1595
  withTimestamps(timestamp) {
1352
1596
  return new File({
@@ -1451,6 +1695,7 @@ export class GitRef extends BaseClient {
1451
1695
  export class GitRepository extends BaseClient {
1452
1696
  /**
1453
1697
  * Returns details on one branch.
1698
+ * @param name Branch's name (e.g., "main").
1454
1699
  */
1455
1700
  branch(name) {
1456
1701
  return new GitRef({
@@ -1481,6 +1726,7 @@ export class GitRepository extends BaseClient {
1481
1726
  }
1482
1727
  /**
1483
1728
  * Returns details on one commit.
1729
+ * @param id Identifier of the commit (e.g., "b6315d8f2810962c601af73f86831f6866ea798b").
1484
1730
  */
1485
1731
  commit(id) {
1486
1732
  return new GitRef({
@@ -1497,6 +1743,7 @@ export class GitRepository extends BaseClient {
1497
1743
  }
1498
1744
  /**
1499
1745
  * Returns details on one tag.
1746
+ * @param name Tag's name (e.g., "v0.3.9").
1500
1747
  */
1501
1748
  tag(name) {
1502
1749
  return new GitRef({
@@ -1556,6 +1803,9 @@ export class GitRepository extends BaseClient {
1556
1803
  export class Host extends BaseClient {
1557
1804
  /**
1558
1805
  * Accesses a directory on the host.
1806
+ * @param path Location of the directory to access (e.g., ".").
1807
+ * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
1808
+ * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
1559
1809
  */
1560
1810
  directory(path, opts) {
1561
1811
  return new Directory({
@@ -1572,6 +1822,7 @@ export class Host extends BaseClient {
1572
1822
  }
1573
1823
  /**
1574
1824
  * Accesses an environment variable on the host.
1825
+ * @param name Name of the environment variable (e.g., "PATH").
1575
1826
  */
1576
1827
  envVariable(name) {
1577
1828
  return new HostVariable({
@@ -1588,6 +1839,7 @@ export class Host extends BaseClient {
1588
1839
  }
1589
1840
  /**
1590
1841
  * Accesses a Unix socket on the host.
1842
+ * @param path Location of the Unix socket (e.g., "/var/run/docker.sock").
1591
1843
  */
1592
1844
  unixSocket(path) {
1593
1845
  return new Socket({
@@ -1604,6 +1856,8 @@ export class Host extends BaseClient {
1604
1856
  }
1605
1857
  /**
1606
1858
  * Retrieves the current working directory on the host.
1859
+ * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
1860
+ * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
1607
1861
  * @deprecated Use directory with path set to '.' instead.
1608
1862
  */
1609
1863
  workdir(opts) {
@@ -1759,6 +2013,77 @@ export class Label extends BaseClient {
1759
2013
  return arg(this);
1760
2014
  }
1761
2015
  }
2016
+ /**
2017
+ * A port exposed by a container.
2018
+ */
2019
+ export class Port extends BaseClient {
2020
+ /**
2021
+ * The port description.
2022
+ */
2023
+ description() {
2024
+ return __awaiter(this, void 0, void 0, function* () {
2025
+ const response = yield computeQuery([
2026
+ ...this._queryTree,
2027
+ {
2028
+ operation: "description",
2029
+ },
2030
+ ], this.client);
2031
+ return response;
2032
+ });
2033
+ }
2034
+ /**
2035
+ * The port number.
2036
+ */
2037
+ port() {
2038
+ return __awaiter(this, void 0, void 0, function* () {
2039
+ const response = yield computeQuery([
2040
+ ...this._queryTree,
2041
+ {
2042
+ operation: "port",
2043
+ },
2044
+ ], this.client);
2045
+ return response;
2046
+ });
2047
+ }
2048
+ /**
2049
+ * The transport layer network protocol.
2050
+ */
2051
+ protocol() {
2052
+ return __awaiter(this, void 0, void 0, function* () {
2053
+ const response = yield computeQuery([
2054
+ ...this._queryTree,
2055
+ {
2056
+ operation: "protocol",
2057
+ },
2058
+ ], this.client);
2059
+ return response;
2060
+ });
2061
+ }
2062
+ /**
2063
+ * Chain objects together
2064
+ * @example
2065
+ * ```ts
2066
+ * function AddAFewMounts(c) {
2067
+ * return c
2068
+ * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2069
+ * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2070
+ * }
2071
+ *
2072
+ * connect(async (client) => {
2073
+ * const tree = await client
2074
+ * .container()
2075
+ * .from("alpine")
2076
+ * .withWorkdir("/foo")
2077
+ * .with(AddAFewMounts)
2078
+ * .withExec(["ls", "-lh"])
2079
+ * .stdout()
2080
+ * })
2081
+ *```
2082
+ */
2083
+ with(arg) {
2084
+ return arg(this);
2085
+ }
2086
+ }
1762
2087
  /**
1763
2088
  * A set of scripts and/or extensions
1764
2089
  */
@@ -1876,7 +2201,7 @@ export class Project extends BaseClient {
1876
2201
  export default class Client extends BaseClient {
1877
2202
  /**
1878
2203
  * Constructs a cache volume for a given cache key.
1879
- * @param key A string identifier to target this cache volume (e.g. "myapp-cache").
2204
+ * @param key A string identifier to target this cache volume (e.g., "modules-cache").
1880
2205
  */
1881
2206
  cacheVolume(key) {
1882
2207
  return new CacheVolume({
@@ -1893,8 +2218,10 @@ export default class Client extends BaseClient {
1893
2218
  }
1894
2219
  /**
1895
2220
  * Loads a container from ID.
2221
+ *
1896
2222
  * Null ID returns an empty container (scratch).
1897
- * Optional platform argument initializes new containers to execute and publish as that platform. Platform defaults to that of the builder's host.
2223
+ * Optional platform argument initializes new containers to execute and publish as that platform.
2224
+ * Platform defaults to that of the builder's host.
1898
2225
  */
1899
2226
  container(opts) {
1900
2227
  return new Container({
@@ -1957,6 +2284,11 @@ export default class Client extends BaseClient {
1957
2284
  }
1958
2285
  /**
1959
2286
  * Queries a git repository.
2287
+ * @param url Url of the git repository.
2288
+ * Can be formatted as https://{host}/{owner}/{repo}, git@{host}/{owner}/{repo}
2289
+ * Suffix ".git" is optional.
2290
+ * @param opts.keepGitDir Set to true to keep .git directory.
2291
+ * @param opts.experimentalServiceHost A service which must be started before the repo is fetched.
1960
2292
  */
1961
2293
  git(url, opts) {
1962
2294
  return new GitRepository({
@@ -1988,14 +2320,16 @@ export default class Client extends BaseClient {
1988
2320
  }
1989
2321
  /**
1990
2322
  * Returns a file containing an http remote url content.
2323
+ * @param url HTTP url to get the content from (e.g., "https://docs.dagger.io").
2324
+ * @param opts.experimentalServiceHost A service which must be started before the URL is fetched.
1991
2325
  */
1992
- http(url) {
2326
+ http(url, opts) {
1993
2327
  return new File({
1994
2328
  queryTree: [
1995
2329
  ...this._queryTree,
1996
2330
  {
1997
2331
  operation: "http",
1998
- args: { url },
2332
+ args: Object.assign({ url }, opts),
1999
2333
  },
2000
2334
  ],
2001
2335
  host: this.clientHost,
@@ -2003,7 +2337,10 @@ export default class Client extends BaseClient {
2003
2337
  });
2004
2338
  }
2005
2339
  /**
2006
- * Creates a named sub-pipeline
2340
+ * Creates a named sub-pipeline.
2341
+ * @param name Pipeline name.
2342
+ * @param opts.description Pipeline description.
2343
+ * @param opts.labels Pipeline labels.
2007
2344
  */
2008
2345
  pipeline(name, opts) {
2009
2346
  return new Client({