forked from jpadams/gcp-for-dagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dagger.gen.go
993 lines (807 loc) · 34.9 KB
/
dagger.gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
// Code generated by dagger. DO NOT EDIT.
package main
import (
"context"
"encoding/json"
"fmt"
"log/slog"
"os"
"main/internal/dagger"
"main/internal/telemetry"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/resource"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
"go.opentelemetry.io/otel/trace"
)
var dag = dagger.Connect()
func Tracer() trace.Tracer {
return otel.Tracer("dagger.io/sdk.go")
}
// used for local MarshalJSON implementations
var marshalCtx = context.Background()
// called by main()
func setMarshalContext(ctx context.Context) {
marshalCtx = ctx
dagger.SetMarshalContext(ctx)
}
type DaggerObject = dagger.DaggerObject
type ExecError = dagger.ExecError
// The `CacheVolumeID` scalar type represents an identifier for an object of type CacheVolume.
type CacheVolumeID = dagger.CacheVolumeID
// The `ContainerID` scalar type represents an identifier for an object of type Container.
type ContainerID = dagger.ContainerID
// The `CurrentModuleID` scalar type represents an identifier for an object of type CurrentModule.
type CurrentModuleID = dagger.CurrentModuleID
// The `DirectoryID` scalar type represents an identifier for an object of type Directory.
type DirectoryID = dagger.DirectoryID
// The `EnvVariableID` scalar type represents an identifier for an object of type EnvVariable.
type EnvVariableID = dagger.EnvVariableID
// The `FieldTypeDefID` scalar type represents an identifier for an object of type FieldTypeDef.
type FieldTypeDefID = dagger.FieldTypeDefID
// The `FileID` scalar type represents an identifier for an object of type File.
type FileID = dagger.FileID
// The `FunctionArgID` scalar type represents an identifier for an object of type FunctionArg.
type FunctionArgID = dagger.FunctionArgID
// The `FunctionCallArgValueID` scalar type represents an identifier for an object of type FunctionCallArgValue.
type FunctionCallArgValueID = dagger.FunctionCallArgValueID
// The `FunctionCallID` scalar type represents an identifier for an object of type FunctionCall.
type FunctionCallID = dagger.FunctionCallID
// The `FunctionID` scalar type represents an identifier for an object of type Function.
type FunctionID = dagger.FunctionID
// The `GeneratedCodeID` scalar type represents an identifier for an object of type GeneratedCode.
type GeneratedCodeID = dagger.GeneratedCodeID
// The `GitModuleSourceID` scalar type represents an identifier for an object of type GitModuleSource.
type GitModuleSourceID = dagger.GitModuleSourceID
// The `GitRefID` scalar type represents an identifier for an object of type GitRef.
type GitRefID = dagger.GitRefID
// The `GitRepositoryID` scalar type represents an identifier for an object of type GitRepository.
type GitRepositoryID = dagger.GitRepositoryID
// The `InputTypeDefID` scalar type represents an identifier for an object of type InputTypeDef.
type InputTypeDefID = dagger.InputTypeDefID
// The `InterfaceTypeDefID` scalar type represents an identifier for an object of type InterfaceTypeDef.
type InterfaceTypeDefID = dagger.InterfaceTypeDefID
// An arbitrary JSON-encoded value.
type JSON = dagger.JSON
// The `LabelID` scalar type represents an identifier for an object of type Label.
type LabelID = dagger.LabelID
// The `ListTypeDefID` scalar type represents an identifier for an object of type ListTypeDef.
type ListTypeDefID = dagger.ListTypeDefID
// The `LocalModuleSourceID` scalar type represents an identifier for an object of type LocalModuleSource.
type LocalModuleSourceID = dagger.LocalModuleSourceID
// The `ModuleDependencyID` scalar type represents an identifier for an object of type ModuleDependency.
type ModuleDependencyID = dagger.ModuleDependencyID
// The `ModuleID` scalar type represents an identifier for an object of type Module.
type ModuleID = dagger.ModuleID
// The `ModuleSourceID` scalar type represents an identifier for an object of type ModuleSource.
type ModuleSourceID = dagger.ModuleSourceID
// The `ModuleSourceViewID` scalar type represents an identifier for an object of type ModuleSourceView.
type ModuleSourceViewID = dagger.ModuleSourceViewID
// The `ObjectTypeDefID` scalar type represents an identifier for an object of type ObjectTypeDef.
type ObjectTypeDefID = dagger.ObjectTypeDefID
// The platform config OS and architecture in a Container.
//
// The format is [os]/[platform]/[version] (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
type Platform = dagger.Platform
// The `PortID` scalar type represents an identifier for an object of type Port.
type PortID = dagger.PortID
// The `ScalarTypeDefID` scalar type represents an identifier for an object of type ScalarTypeDef.
type ScalarTypeDefID = dagger.ScalarTypeDefID
// The `SecretID` scalar type represents an identifier for an object of type Secret.
type SecretID = dagger.SecretID
// The `ServiceID` scalar type represents an identifier for an object of type Service.
type ServiceID = dagger.ServiceID
// The `SocketID` scalar type represents an identifier for an object of type Socket.
type SocketID = dagger.SocketID
// The `TerminalID` scalar type represents an identifier for an object of type Terminal.
type TerminalID = dagger.TerminalID
// The `TypeDefID` scalar type represents an identifier for an object of type TypeDef.
type TypeDefID = dagger.TypeDefID
// The absence of a value.
//
// A Null Void is used as a placeholder for resolvers that do not return anything.
type Void = dagger.Void
// Key value object that represents a build argument.
type BuildArg = dagger.BuildArg
// Key value object that represents a pipeline label.
type PipelineLabel = dagger.PipelineLabel
// Port forwarding rules for tunneling network traffic.
type PortForward = dagger.PortForward
// A directory whose contents persist across runs.
type CacheVolume = dagger.CacheVolume
// An OCI-compatible container, also known as a Docker container.
type Container = dagger.Container
type WithContainerFunc = dagger.WithContainerFunc
// ContainerAsTarballOpts contains options for Container.AsTarball
type ContainerAsTarballOpts = dagger.ContainerAsTarballOpts
// ContainerBuildOpts contains options for Container.Build
type ContainerBuildOpts = dagger.ContainerBuildOpts
// ContainerExportOpts contains options for Container.Export
type ContainerExportOpts = dagger.ContainerExportOpts
// ContainerImportOpts contains options for Container.Import
type ContainerImportOpts = dagger.ContainerImportOpts
// ContainerPipelineOpts contains options for Container.Pipeline
type ContainerPipelineOpts = dagger.ContainerPipelineOpts
// ContainerPublishOpts contains options for Container.Publish
type ContainerPublishOpts = dagger.ContainerPublishOpts
// ContainerTerminalOpts contains options for Container.Terminal
type ContainerTerminalOpts = dagger.ContainerTerminalOpts
// ContainerWithDefaultTerminalCmdOpts contains options for Container.WithDefaultTerminalCmd
type ContainerWithDefaultTerminalCmdOpts = dagger.ContainerWithDefaultTerminalCmdOpts
// ContainerWithDirectoryOpts contains options for Container.WithDirectory
type ContainerWithDirectoryOpts = dagger.ContainerWithDirectoryOpts
// ContainerWithEntrypointOpts contains options for Container.WithEntrypoint
type ContainerWithEntrypointOpts = dagger.ContainerWithEntrypointOpts
// ContainerWithEnvVariableOpts contains options for Container.WithEnvVariable
type ContainerWithEnvVariableOpts = dagger.ContainerWithEnvVariableOpts
// ContainerWithExecOpts contains options for Container.WithExec
type ContainerWithExecOpts = dagger.ContainerWithExecOpts
// ContainerWithExposedPortOpts contains options for Container.WithExposedPort
type ContainerWithExposedPortOpts = dagger.ContainerWithExposedPortOpts
// ContainerWithFileOpts contains options for Container.WithFile
type ContainerWithFileOpts = dagger.ContainerWithFileOpts
// ContainerWithFilesOpts contains options for Container.WithFiles
type ContainerWithFilesOpts = dagger.ContainerWithFilesOpts
// ContainerWithMountedCacheOpts contains options for Container.WithMountedCache
type ContainerWithMountedCacheOpts = dagger.ContainerWithMountedCacheOpts
// ContainerWithMountedDirectoryOpts contains options for Container.WithMountedDirectory
type ContainerWithMountedDirectoryOpts = dagger.ContainerWithMountedDirectoryOpts
// ContainerWithMountedFileOpts contains options for Container.WithMountedFile
type ContainerWithMountedFileOpts = dagger.ContainerWithMountedFileOpts
// ContainerWithMountedSecretOpts contains options for Container.WithMountedSecret
type ContainerWithMountedSecretOpts = dagger.ContainerWithMountedSecretOpts
// ContainerWithNewFileOpts contains options for Container.WithNewFile
type ContainerWithNewFileOpts = dagger.ContainerWithNewFileOpts
// ContainerWithUnixSocketOpts contains options for Container.WithUnixSocket
type ContainerWithUnixSocketOpts = dagger.ContainerWithUnixSocketOpts
// ContainerWithoutEntrypointOpts contains options for Container.WithoutEntrypoint
type ContainerWithoutEntrypointOpts = dagger.ContainerWithoutEntrypointOpts
// ContainerWithoutExposedPortOpts contains options for Container.WithoutExposedPort
type ContainerWithoutExposedPortOpts = dagger.ContainerWithoutExposedPortOpts
// Reflective module API provided to functions at runtime.
type CurrentModule = dagger.CurrentModule
// CurrentModuleWorkdirOpts contains options for CurrentModule.Workdir
type CurrentModuleWorkdirOpts = dagger.CurrentModuleWorkdirOpts
// A directory.
type Directory = dagger.Directory
type WithDirectoryFunc = dagger.WithDirectoryFunc
// DirectoryAsModuleOpts contains options for Directory.AsModule
type DirectoryAsModuleOpts = dagger.DirectoryAsModuleOpts
// DirectoryDockerBuildOpts contains options for Directory.DockerBuild
type DirectoryDockerBuildOpts = dagger.DirectoryDockerBuildOpts
// DirectoryEntriesOpts contains options for Directory.Entries
type DirectoryEntriesOpts = dagger.DirectoryEntriesOpts
// DirectoryExportOpts contains options for Directory.Export
type DirectoryExportOpts = dagger.DirectoryExportOpts
// DirectoryPipelineOpts contains options for Directory.Pipeline
type DirectoryPipelineOpts = dagger.DirectoryPipelineOpts
// DirectoryWithDirectoryOpts contains options for Directory.WithDirectory
type DirectoryWithDirectoryOpts = dagger.DirectoryWithDirectoryOpts
// DirectoryWithFileOpts contains options for Directory.WithFile
type DirectoryWithFileOpts = dagger.DirectoryWithFileOpts
// DirectoryWithFilesOpts contains options for Directory.WithFiles
type DirectoryWithFilesOpts = dagger.DirectoryWithFilesOpts
// DirectoryWithNewDirectoryOpts contains options for Directory.WithNewDirectory
type DirectoryWithNewDirectoryOpts = dagger.DirectoryWithNewDirectoryOpts
// DirectoryWithNewFileOpts contains options for Directory.WithNewFile
type DirectoryWithNewFileOpts = dagger.DirectoryWithNewFileOpts
// An environment variable name and value.
type EnvVariable = dagger.EnvVariable
// A definition of a field on a custom object defined in a Module.
//
// A field on an object has a static value, as opposed to a function on an object whose value is computed by invoking code (and can accept arguments).
type FieldTypeDef = dagger.FieldTypeDef
// A file.
type File = dagger.File
type WithFileFunc = dagger.WithFileFunc
// FileExportOpts contains options for File.Export
type FileExportOpts = dagger.FileExportOpts
// Function represents a resolver provided by a Module.
//
// A function always evaluates against a parent object and is given a set of named arguments.
type Function = dagger.Function
type WithFunctionFunc = dagger.WithFunctionFunc
// FunctionWithArgOpts contains options for Function.WithArg
type FunctionWithArgOpts = dagger.FunctionWithArgOpts
// An argument accepted by a function.
//
// This is a specification for an argument at function definition time, not an argument passed at function call time.
type FunctionArg = dagger.FunctionArg
// An active function call.
type FunctionCall = dagger.FunctionCall
// A value passed as a named argument to a function call.
type FunctionCallArgValue = dagger.FunctionCallArgValue
// The result of running an SDK's codegen.
type GeneratedCode = dagger.GeneratedCode
type WithGeneratedCodeFunc = dagger.WithGeneratedCodeFunc
// Module source originating from a git repo.
type GitModuleSource = dagger.GitModuleSource
// A git ref (tag, branch, or commit).
type GitRef = dagger.GitRef
// GitRefTreeOpts contains options for GitRef.Tree
type GitRefTreeOpts = dagger.GitRefTreeOpts
// A git repository.
type GitRepository = dagger.GitRepository
type WithGitRepositoryFunc = dagger.WithGitRepositoryFunc
// A graphql input type, which is essentially just a group of named args.
// This is currently only used to represent pre-existing usage of graphql input types
// in the core API. It is not used by user modules and shouldn't ever be as user
// module accept input objects via their id rather than graphql input types.
type InputTypeDef = dagger.InputTypeDef
// A definition of a custom interface defined in a Module.
type InterfaceTypeDef = dagger.InterfaceTypeDef
// A simple key value object that represents a label.
type Label = dagger.Label
// A definition of a list type in a Module.
type ListTypeDef = dagger.ListTypeDef
// Module source that that originates from a path locally relative to an arbitrary directory.
type LocalModuleSource = dagger.LocalModuleSource
// A Dagger module.
type Module = dagger.Module
type WithModuleFunc = dagger.WithModuleFunc
// The configuration of dependency of a module.
type ModuleDependency = dagger.ModuleDependency
// The source needed to load and run a module, along with any metadata about the source such as versions/urls/etc.
type ModuleSource = dagger.ModuleSource
type WithModuleSourceFunc = dagger.WithModuleSourceFunc
// ModuleSourceResolveDirectoryFromCallerOpts contains options for ModuleSource.ResolveDirectoryFromCaller
type ModuleSourceResolveDirectoryFromCallerOpts = dagger.ModuleSourceResolveDirectoryFromCallerOpts
// A named set of path filters that can be applied to directory arguments provided to functions.
type ModuleSourceView = dagger.ModuleSourceView
// A definition of a custom object defined in a Module.
type ObjectTypeDef = dagger.ObjectTypeDef
// A port exposed by a container.
type Port = dagger.Port
// The root of the DAG.
type Client = dagger.Client
type WithClientFunc = dagger.WithClientFunc
// ContainerOpts contains options for Client.Container
type ContainerOpts = dagger.ContainerOpts
// DirectoryOpts contains options for Client.Directory
type DirectoryOpts = dagger.DirectoryOpts
// GitOpts contains options for Client.Git
type GitOpts = dagger.GitOpts
// HTTPOpts contains options for Client.HTTP
type HTTPOpts = dagger.HTTPOpts
// ModuleDependencyOpts contains options for Client.ModuleDependency
type ModuleDependencyOpts = dagger.ModuleDependencyOpts
// ModuleSourceOpts contains options for Client.ModuleSource
type ModuleSourceOpts = dagger.ModuleSourceOpts
// PipelineOpts contains options for Client.Pipeline
type PipelineOpts = dagger.PipelineOpts
// SecretOpts contains options for Client.Secret
type SecretOpts = dagger.SecretOpts
// A definition of a custom scalar defined in a Module.
type ScalarTypeDef = dagger.ScalarTypeDef
// A reference to a secret value, which can be handled more safely than the value itself.
type Secret = dagger.Secret
// A content-addressed service providing TCP connectivity.
type Service = dagger.Service
// ServiceEndpointOpts contains options for Service.Endpoint
type ServiceEndpointOpts = dagger.ServiceEndpointOpts
// ServiceStopOpts contains options for Service.Stop
type ServiceStopOpts = dagger.ServiceStopOpts
// ServiceUpOpts contains options for Service.Up
type ServiceUpOpts = dagger.ServiceUpOpts
// A Unix or TCP/IP socket that can be mounted into a container.
type Socket = dagger.Socket
// An interactive terminal that clients can connect to.
type Terminal = dagger.Terminal
// A definition of a parameter or return type in a Module.
type TypeDef = dagger.TypeDef
type WithTypeDefFunc = dagger.WithTypeDefFunc
// TypeDefWithFieldOpts contains options for TypeDef.WithField
type TypeDefWithFieldOpts = dagger.TypeDefWithFieldOpts
// TypeDefWithInterfaceOpts contains options for TypeDef.WithInterface
type TypeDefWithInterfaceOpts = dagger.TypeDefWithInterfaceOpts
// TypeDefWithObjectOpts contains options for TypeDef.WithObject
type TypeDefWithObjectOpts = dagger.TypeDefWithObjectOpts
// TypeDefWithScalarOpts contains options for TypeDef.WithScalar
type TypeDefWithScalarOpts = dagger.TypeDefWithScalarOpts
// Sharing mode of the cache volume.
type CacheSharingMode = dagger.CacheSharingMode
const (
// Shares the cache volume amongst many build pipelines, but will serialize the writes
Locked CacheSharingMode = dagger.Locked
// Keeps a cache volume for a single build pipeline
Private CacheSharingMode = dagger.Private
// Shares the cache volume amongst many build pipelines
Shared CacheSharingMode = dagger.Shared
)
// Compression algorithm to use for image layers.
type ImageLayerCompression = dagger.ImageLayerCompression
const (
Estargz ImageLayerCompression = dagger.Estargz
Gzip ImageLayerCompression = dagger.Gzip
Uncompressed ImageLayerCompression = dagger.Uncompressed
Zstd ImageLayerCompression = dagger.Zstd
)
// Mediatypes to use in published or exported image metadata.
type ImageMediaTypes = dagger.ImageMediaTypes
const (
Dockermediatypes ImageMediaTypes = dagger.Dockermediatypes
Ocimediatypes ImageMediaTypes = dagger.Ocimediatypes
)
// The kind of module source.
type ModuleSourceKind = dagger.ModuleSourceKind
const (
GitSource ModuleSourceKind = dagger.GitSource
LocalSource ModuleSourceKind = dagger.LocalSource
)
// Transport layer network protocol associated to a port.
type NetworkProtocol = dagger.NetworkProtocol
const (
Tcp NetworkProtocol = dagger.Tcp
Udp NetworkProtocol = dagger.Udp
)
// Distinguishes the different kinds of TypeDefs.
type TypeDefKind = dagger.TypeDefKind
const (
// A boolean value.
BooleanKind TypeDefKind = dagger.BooleanKind
// A graphql input type, used only when representing the core API via TypeDefs.
InputKind TypeDefKind = dagger.InputKind
// An integer value.
IntegerKind TypeDefKind = dagger.IntegerKind
// A named type of functions that can be matched+implemented by other objects+interfaces.
//
// Always paired with an InterfaceTypeDef.
InterfaceKind TypeDefKind = dagger.InterfaceKind
// A list of values all having the same type.
//
// Always paired with a ListTypeDef.
ListKind TypeDefKind = dagger.ListKind
// A named type defined in the GraphQL schema, with fields and functions.
//
// Always paired with an ObjectTypeDef.
ObjectKind TypeDefKind = dagger.ObjectKind
// A scalar value of any basic kind.
ScalarKind TypeDefKind = dagger.ScalarKind
// A string value.
StringKind TypeDefKind = dagger.StringKind
// A special kind used to signify that no value is returned.
//
// This is used for functions that have no return value. The outer TypeDef specifying this Kind is always Optional, as the Void is never actually represented.
VoidKind TypeDefKind = dagger.VoidKind
)
// ptr returns a pointer to the given value.
func ptr[T any](v T) *T {
return &v
}
// convertSlice converts a slice of one type to a slice of another type using a
// converter function
func convertSlice[I any, O any](in []I, f func(I) O) []O {
out := make([]O, len(in))
for i, v := range in {
out[i] = f(v)
}
return out
}
func (r Gcp) MarshalJSON() ([]byte, error) {
var concrete struct{}
return json.Marshal(&concrete)
}
func (r *Gcp) UnmarshalJSON(bs []byte) error {
var concrete struct{}
err := json.Unmarshal(bs, &concrete)
if err != nil {
return err
}
return nil
}
func main() {
ctx := context.Background()
// Direct slog to the new stderr. This is only for dev time debugging, and
// runtime errors/warnings.
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
Level: slog.LevelWarn,
})))
if err := dispatch(ctx); err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
}
func dispatch(ctx context.Context) error {
ctx = telemetry.InitEmbedded(ctx, resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String("dagger-go-sdk"),
// TODO version?
))
defer telemetry.Close()
ctx, span := Tracer().Start(ctx, "Go runtime",
trace.WithAttributes(
// In effect, the following two attributes hide the exec /runtime span.
//
// Replace the parent span,
attribute.Bool("dagger.io/ui.mask", true),
// and only show our children.
attribute.Bool("dagger.io/ui.passthrough", true),
))
defer span.End()
// A lot of the "work" actually happens when we're marshalling the return
// value, which entails getting object IDs, which happens in MarshalJSON,
// which has no ctx argument, so we use this lovely global variable.
setMarshalContext(ctx)
fnCall := dag.CurrentFunctionCall()
parentName, err := fnCall.ParentName(ctx)
if err != nil {
return fmt.Errorf("get parent name: %w", err)
}
fnName, err := fnCall.Name(ctx)
if err != nil {
return fmt.Errorf("get fn name: %w", err)
}
parentJson, err := fnCall.Parent(ctx)
if err != nil {
return fmt.Errorf("get fn parent: %w", err)
}
fnArgs, err := fnCall.InputArgs(ctx)
if err != nil {
return fmt.Errorf("get fn args: %w", err)
}
inputArgs := map[string][]byte{}
for _, fnArg := range fnArgs {
argName, err := fnArg.Name(ctx)
if err != nil {
return fmt.Errorf("get fn arg name: %w", err)
}
argValue, err := fnArg.Value(ctx)
if err != nil {
return fmt.Errorf("get fn arg value: %w", err)
}
inputArgs[argName] = []byte(argValue)
}
result, err := invoke(ctx, []byte(parentJson), parentName, fnName, inputArgs)
if err != nil {
return fmt.Errorf("invoke: %w", err)
}
resultBytes, err := json.Marshal(result)
if err != nil {
return fmt.Errorf("marshal: %w", err)
}
_, err = fnCall.ReturnValue(ctx, JSON(resultBytes))
if err != nil {
return fmt.Errorf("store return value: %w", err)
}
return nil
}
func invoke(ctx context.Context, parentJSON []byte, parentName string, fnName string, inputArgs map[string][]byte) (_ any, err error) {
switch parentName {
case "Gcp":
switch fnName {
case "GetSecret":
var parent Gcp
err = json.Unmarshal(parentJSON, &parent)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
}
var gcpCredentials *File
if inputArgs["gcpCredentials"] != nil {
err = json.Unmarshal([]byte(inputArgs["gcpCredentials"]), &gcpCredentials)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg gcpCredentials", err))
}
}
return (*Gcp).GetSecret(&parent, ctx, gcpCredentials)
case "WithGcpSecret":
var parent Gcp
err = json.Unmarshal(parentJSON, &parent)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
}
var ctr *Container
if inputArgs["ctr"] != nil {
err = json.Unmarshal([]byte(inputArgs["ctr"]), &ctr)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg ctr", err))
}
}
var gcpCredentials *File
if inputArgs["gcpCredentials"] != nil {
err = json.Unmarshal([]byte(inputArgs["gcpCredentials"]), &gcpCredentials)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg gcpCredentials", err))
}
}
return (*Gcp).WithGcpSecret(&parent, ctx, ctr, gcpCredentials)
case "GcloudCli":
var parent Gcp
err = json.Unmarshal(parentJSON, &parent)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
}
var project string
if inputArgs["project"] != nil {
err = json.Unmarshal([]byte(inputArgs["project"]), &project)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg project", err))
}
}
var gcpCredentials *File
if inputArgs["gcpCredentials"] != nil {
err = json.Unmarshal([]byte(inputArgs["gcpCredentials"]), &gcpCredentials)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg gcpCredentials", err))
}
}
return (*Gcp).GcloudCli(&parent, ctx, project, gcpCredentials)
case "List":
var parent Gcp
err = json.Unmarshal(parentJSON, &parent)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
}
var account string
if inputArgs["account"] != nil {
err = json.Unmarshal([]byte(inputArgs["account"]), &account)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg account", err))
}
}
var project string
if inputArgs["project"] != nil {
err = json.Unmarshal([]byte(inputArgs["project"]), &project)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg project", err))
}
}
var gcpCredentials *File
if inputArgs["gcpCredentials"] != nil {
err = json.Unmarshal([]byte(inputArgs["gcpCredentials"]), &gcpCredentials)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg gcpCredentials", err))
}
}
return (*Gcp).List(&parent, ctx, account, project, gcpCredentials)
case "GarEnsureServiceAccountKey":
var parent Gcp
err = json.Unmarshal(parentJSON, &parent)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
}
var account string
if inputArgs["account"] != nil {
err = json.Unmarshal([]byte(inputArgs["account"]), &account)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg account", err))
}
}
var region string
if inputArgs["region"] != nil {
err = json.Unmarshal([]byte(inputArgs["region"]), ®ion)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg region", err))
}
}
var project string
if inputArgs["project"] != nil {
err = json.Unmarshal([]byte(inputArgs["project"]), &project)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg project", err))
}
}
var gcpCredentials *File
if inputArgs["gcpCredentials"] != nil {
err = json.Unmarshal([]byte(inputArgs["gcpCredentials"]), &gcpCredentials)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg gcpCredentials", err))
}
}
return (*Gcp).GarEnsureServiceAccountKey(&parent, ctx, account, region, project, gcpCredentials)
case "GarPushExample":
var parent Gcp
err = json.Unmarshal(parentJSON, &parent)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
}
var account string
if inputArgs["account"] != nil {
err = json.Unmarshal([]byte(inputArgs["account"]), &account)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg account", err))
}
}
var region string
if inputArgs["region"] != nil {
err = json.Unmarshal([]byte(inputArgs["region"]), ®ion)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg region", err))
}
}
var project string
if inputArgs["project"] != nil {
err = json.Unmarshal([]byte(inputArgs["project"]), &project)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg project", err))
}
}
var repo string
if inputArgs["repo"] != nil {
err = json.Unmarshal([]byte(inputArgs["repo"]), &repo)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg repo", err))
}
}
var image string
if inputArgs["image"] != nil {
err = json.Unmarshal([]byte(inputArgs["image"]), &image)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg image", err))
}
}
var gcpCredentials *File
if inputArgs["gcpCredentials"] != nil {
err = json.Unmarshal([]byte(inputArgs["gcpCredentials"]), &gcpCredentials)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg gcpCredentials", err))
}
}
return (*Gcp).GarPushExample(&parent, ctx, account, region, project, repo, image, gcpCredentials)
case "CleanupServiceAccountKey":
var parent Gcp
err = json.Unmarshal(parentJSON, &parent)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
}
var account string
if inputArgs["account"] != nil {
err = json.Unmarshal([]byte(inputArgs["account"]), &account)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg account", err))
}
}
var region string
if inputArgs["region"] != nil {
err = json.Unmarshal([]byte(inputArgs["region"]), ®ion)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg region", err))
}
}
var project string
if inputArgs["project"] != nil {
err = json.Unmarshal([]byte(inputArgs["project"]), &project)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg project", err))
}
}
var gcpCredentials *File
if inputArgs["gcpCredentials"] != nil {
err = json.Unmarshal([]byte(inputArgs["gcpCredentials"]), &gcpCredentials)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg gcpCredentials", err))
}
}
var keyId string
if inputArgs["keyId"] != nil {
err = json.Unmarshal([]byte(inputArgs["keyId"]), &keyId)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg keyId", err))
}
}
return nil, (*Gcp).CleanupServiceAccountKey(&parent, ctx, account, region, project, gcpCredentials, keyId)
case "GarPush":
var parent Gcp
err = json.Unmarshal(parentJSON, &parent)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
}
var pushCtr *Container
if inputArgs["pushCtr"] != nil {
err = json.Unmarshal([]byte(inputArgs["pushCtr"]), &pushCtr)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg pushCtr", err))
}
}
var account string
if inputArgs["account"] != nil {
err = json.Unmarshal([]byte(inputArgs["account"]), &account)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg account", err))
}
}
var region string
if inputArgs["region"] != nil {
err = json.Unmarshal([]byte(inputArgs["region"]), ®ion)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg region", err))
}
}
var project string
if inputArgs["project"] != nil {
err = json.Unmarshal([]byte(inputArgs["project"]), &project)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg project", err))
}
}
var repo string
if inputArgs["repo"] != nil {
err = json.Unmarshal([]byte(inputArgs["repo"]), &repo)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg repo", err))
}
}
var image string
if inputArgs["image"] != nil {
err = json.Unmarshal([]byte(inputArgs["image"]), &image)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg image", err))
}
}
var gcpCredentials *File
if inputArgs["gcpCredentials"] != nil {
err = json.Unmarshal([]byte(inputArgs["gcpCredentials"]), &gcpCredentials)
if err != nil {
panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg gcpCredentials", err))
}
}
return (*Gcp).GarPush(&parent, ctx, pushCtr, account, region, project, repo, image, gcpCredentials)
default:
return nil, fmt.Errorf("unknown function %s", fnName)
}
case "":
return dag.Module().
WithDescription("Push a container image into Google Artifact Registry\n\nThis module lets you push a container into Google Artifact Registry, automating the tedious manual steps of setting up a service account for the docker credential\n\nFor more info and sample usage, check the readme: https://github.com/daggerverse/dagger-gcp\n").
WithObject(
dag.TypeDef().WithObject("Gcp").
WithFunction(
dag.Function("GetSecret",
dag.TypeDef().WithKind(StringKind)).
WithDescription("example usage: \"dagger call get-secret --gcp-credentials ~/.config/gcloud/credentials.db\"").
WithArg("gcpCredentials", dag.TypeDef().WithObject("File"))).
WithFunction(
dag.Function("WithGcpSecret",
dag.TypeDef().WithObject("Container")).
WithArg("ctr", dag.TypeDef().WithObject("Container")).
WithArg("gcpCredentials", dag.TypeDef().WithObject("File"))).
WithFunction(
dag.Function("GcloudCli",
dag.TypeDef().WithObject("Container")).
WithArg("project", dag.TypeDef().WithKind(StringKind)).
WithArg("gcpCredentials", dag.TypeDef().WithObject("File"))).
WithFunction(
dag.Function("List",
dag.TypeDef().WithKind(StringKind)).
WithDescription("example usage: \"dagger call list --account your@email.address --project gcp-project-id --gcp-credentials ~/.config/gcloud/credentials.db\"").
WithArg("account", dag.TypeDef().WithKind(StringKind)).
WithArg("project", dag.TypeDef().WithKind(StringKind)).
WithArg("gcpCredentials", dag.TypeDef().WithObject("File"))).
WithFunction(
dag.Function("GarEnsureServiceAccountKey",
dag.TypeDef().WithKind(StringKind)).
WithDescription("example usage: \"dagger call gar-ensure-service-account --region us-east-1 --project gcp-project-id --gcp-credentials ~/.config/gcloud/credentials.db\"").
WithArg("account", dag.TypeDef().WithKind(StringKind)).
WithArg("region", dag.TypeDef().WithKind(StringKind)).
WithArg("project", dag.TypeDef().WithKind(StringKind)).
WithArg("gcpCredentials", dag.TypeDef().WithObject("File"))).
WithFunction(
dag.Function("GarPushExample",
dag.TypeDef().WithKind(StringKind)).
WithDescription("Push ubuntu:latest to GAR under given repo 'test' (repo must be created first)\nexample usage: \"dagger call gar-push-example --region us-east-1 --gcp-credentials ~/.config/gcloud/credentials.db --gcp-account-id 12345 --repo test\"").
WithArg("account", dag.TypeDef().WithKind(StringKind)).
WithArg("region", dag.TypeDef().WithKind(StringKind)).
WithArg("project", dag.TypeDef().WithKind(StringKind)).
WithArg("repo", dag.TypeDef().WithKind(StringKind)).
WithArg("image", dag.TypeDef().WithKind(StringKind)).
WithArg("gcpCredentials", dag.TypeDef().WithObject("File"))).
WithFunction(
dag.Function("CleanupServiceAccountKey",
dag.TypeDef().WithKind(VoidKind).WithOptional(true)).
WithArg("account", dag.TypeDef().WithKind(StringKind)).
WithArg("region", dag.TypeDef().WithKind(StringKind)).
WithArg("project", dag.TypeDef().WithKind(StringKind)).
WithArg("gcpCredentials", dag.TypeDef().WithObject("File")).
WithArg("keyId", dag.TypeDef().WithKind(StringKind))).
WithFunction(
dag.Function("GarPush",
dag.TypeDef().WithKind(StringKind)).
WithArg("pushCtr", dag.TypeDef().WithObject("Container")).
WithArg("account", dag.TypeDef().WithKind(StringKind)).
WithArg("region", dag.TypeDef().WithKind(StringKind)).
WithArg("project", dag.TypeDef().WithKind(StringKind)).
WithArg("repo", dag.TypeDef().WithKind(StringKind)).
WithArg("image", dag.TypeDef().WithKind(StringKind)).
WithArg("gcpCredentials", dag.TypeDef().WithObject("File")))), nil
default:
return nil, fmt.Errorf("unknown object %s", parentName)
}
}