@@ -32,10 +32,35 @@ type Machine struct {
32
32
reportHealthDone chan struct {}
33
33
}
34
34
35
+ type EngineKind int
36
+
37
+ const (
38
+ EngineKindBuildkit EngineKind = iota
39
+ EngineKindDagger
40
+ )
41
+
35
42
// Platform can be "amd64" or "arm64".
36
43
// This reports health continually to the Depot API and waits for the buildkit
37
- // machine to be ready. This can be canceled by canceling the context.
44
+ // machine and engine to be ready. This can be canceled by canceling the context.
38
45
func Acquire (ctx context.Context , buildID , token , platform string ) (* Machine , error ) {
46
+ return AcquireMachineEngine (ctx , buildID , token , platform , EngineKindBuildkit , "" )
47
+ }
48
+
49
+ // Platform can be "amd64" or "arm64".
50
+ // This reports health continually to the Depot API and waits for the buildkit
51
+ // machine and engine to be ready. This can be canceled by canceling the context.
52
+ func AcquireBuildkit (ctx context.Context , buildID , token , platform string ) (* Machine , error ) {
53
+ return AcquireMachineEngine (ctx , buildID , token , platform , EngineKindBuildkit , "" )
54
+ }
55
+
56
+ // Platform can be "amd64" or "arm64".
57
+ // This reports health continually to the Depot API and waits for the machine with the dagger version to be ready.
58
+ // This can be canceled by canceling the context.
59
+ func AcquireDagger (ctx context.Context , buildID , token , platform , engineVersion string ) (* Machine , error ) {
60
+ return AcquireMachineEngine (ctx , buildID , token , platform , EngineKindDagger , engineVersion )
61
+ }
62
+
63
+ func AcquireMachineEngine (ctx context.Context , buildID , token , platform string , engineKind EngineKind , engineVersion string ) (* Machine , error ) {
39
64
m := & Machine {
40
65
BuildID : buildID ,
41
66
Token : token ,
@@ -56,12 +81,26 @@ func Acquire(ctx context.Context, buildID, token, platform string) (*Machine, er
56
81
}
57
82
58
83
client := api .NewBuildClient ()
84
+ req := cliv1.GetBuildKitConnectionRequest {
85
+ BuildId : m .BuildID ,
86
+ Platform : builderPlatform ,
87
+ }
88
+ switch engineKind {
89
+ case EngineKindBuildkit :
90
+ req .RequiredEngine = & cliv1.GetBuildKitConnectionRequest_RequiredEngine {
91
+ Engine : & cliv1.GetBuildKitConnectionRequest_RequiredEngine_Buildkit {
92
+ Buildkit : & cliv1.GetBuildKitConnectionRequest_RequiredEngine_BuildKitEngine {},
93
+ },
94
+ }
95
+ case EngineKindDagger :
96
+ req .RequiredEngine = & cliv1.GetBuildKitConnectionRequest_RequiredEngine {
97
+ Engine : & cliv1.GetBuildKitConnectionRequest_RequiredEngine_Dagger {
98
+ Dagger : & cliv1.GetBuildKitConnectionRequest_RequiredEngine_DaggerEngine {Version : engineVersion },
99
+ },
100
+ }
101
+ }
59
102
60
103
for {
61
- req := cliv1.GetBuildKitConnectionRequest {
62
- BuildId : m .BuildID ,
63
- Platform : builderPlatform ,
64
- }
65
104
resp , err := client .GetBuildKitConnection (ctx , api .WithAuthentication (connect .NewRequest (& req ), m .Token ))
66
105
if err != nil {
67
106
return nil , err
0 commit comments